pdf.js 749 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. var pdfjsVersion = '2.3.200';
  123. var pdfjsBuild = '4ae3f9fc';
  124. var pdfjsSharedUtil = __w_pdfjs_require__(1);
  125. var pdfjsDisplayAPI = __w_pdfjs_require__(179);
  126. var pdfjsDisplayTextLayer = __w_pdfjs_require__(194);
  127. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(195);
  128. var pdfjsDisplayDisplayUtils = __w_pdfjs_require__(183);
  129. var pdfjsDisplaySVG = __w_pdfjs_require__(196);
  130. var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(188);
  131. var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(185);
  132. {
  133. var isNodeJS = __w_pdfjs_require__(4);
  134. if (isNodeJS()) {
  135. var PDFNodeStream = __w_pdfjs_require__(197).PDFNodeStream;
  136. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  137. return new PDFNodeStream(params);
  138. });
  139. } else {
  140. var PDFNetworkStream = __w_pdfjs_require__(200).PDFNetworkStream;
  141. var PDFFetchStream;
  142. if (pdfjsDisplayDisplayUtils.isFetchSupported()) {
  143. PDFFetchStream = __w_pdfjs_require__(201).PDFFetchStream;
  144. }
  145. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  146. if (PDFFetchStream && pdfjsDisplayDisplayUtils.isValidFetchUrl(params.url)) {
  147. return new PDFFetchStream(params);
  148. }
  149. return new PDFNetworkStream(params);
  150. });
  151. }
  152. }
  153. exports.build = pdfjsDisplayAPI.build;
  154. exports.version = pdfjsDisplayAPI.version;
  155. exports.getDocument = pdfjsDisplayAPI.getDocument;
  156. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  157. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  158. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  159. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  160. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  161. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  162. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  163. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  164. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  165. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  166. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  167. exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType;
  168. exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag;
  169. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  170. exports.OPS = pdfjsSharedUtil.OPS;
  171. exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel;
  172. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  173. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  174. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  175. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  176. exports.shadow = pdfjsSharedUtil.shadow;
  177. exports.Util = pdfjsSharedUtil.Util;
  178. exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
  179. exports.RenderingCancelledException = pdfjsDisplayDisplayUtils.RenderingCancelledException;
  180. exports.getFilenameFromUrl = pdfjsDisplayDisplayUtils.getFilenameFromUrl;
  181. exports.LinkTarget = pdfjsDisplayDisplayUtils.LinkTarget;
  182. exports.addLinkAttributes = pdfjsDisplayDisplayUtils.addLinkAttributes;
  183. exports.loadScript = pdfjsDisplayDisplayUtils.loadScript;
  184. exports.PDFDateString = pdfjsDisplayDisplayUtils.PDFDateString;
  185. exports.GlobalWorkerOptions = pdfjsDisplayWorkerOptions.GlobalWorkerOptions;
  186. exports.apiCompatibilityParams = pdfjsDisplayAPICompatibility.apiCompatibilityParams;
  187. /***/ }),
  188. /* 1 */
  189. /***/ (function(module, exports, __w_pdfjs_require__) {
  190. "use strict";
  191. Object.defineProperty(exports, "__esModule", {
  192. value: true
  193. });
  194. exports.arrayByteLength = arrayByteLength;
  195. exports.arraysToBytes = arraysToBytes;
  196. exports.assert = assert;
  197. exports.bytesToString = bytesToString;
  198. exports.createPromiseCapability = createPromiseCapability;
  199. exports.getVerbosityLevel = getVerbosityLevel;
  200. exports.info = info;
  201. exports.isArrayBuffer = isArrayBuffer;
  202. exports.isArrayEqual = isArrayEqual;
  203. exports.isBool = isBool;
  204. exports.isEmptyObj = isEmptyObj;
  205. exports.isNum = isNum;
  206. exports.isString = isString;
  207. exports.isSpace = isSpace;
  208. exports.isSameOrigin = isSameOrigin;
  209. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  210. exports.isLittleEndian = isLittleEndian;
  211. exports.isEvalSupported = isEvalSupported;
  212. exports.log2 = log2;
  213. exports.readInt8 = readInt8;
  214. exports.readUint16 = readUint16;
  215. exports.readUint32 = readUint32;
  216. exports.removeNullCharacters = removeNullCharacters;
  217. exports.setVerbosityLevel = setVerbosityLevel;
  218. exports.shadow = shadow;
  219. exports.string32 = string32;
  220. exports.stringToBytes = stringToBytes;
  221. exports.stringToPDFString = stringToPDFString;
  222. exports.stringToUTF8String = stringToUTF8String;
  223. exports.utf8StringToString = utf8StringToString;
  224. exports.warn = warn;
  225. exports.unreachable = unreachable;
  226. Object.defineProperty(exports, "ReadableStream", {
  227. enumerable: true,
  228. get: function () {
  229. return _streams_polyfill.ReadableStream;
  230. }
  231. });
  232. exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
  233. __w_pdfjs_require__(2);
  234. var _streams_polyfill = __w_pdfjs_require__(177);
  235. 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); } }
  236. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  237. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  238. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  239. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  240. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  241. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  242. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  243. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  244. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  245. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  246. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  247. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  248. var NativeImageDecoding = {
  249. NONE: 'none',
  250. DECODE: 'decode',
  251. DISPLAY: 'display'
  252. };
  253. exports.NativeImageDecoding = NativeImageDecoding;
  254. var PermissionFlag = {
  255. PRINT: 0x04,
  256. MODIFY_CONTENTS: 0x08,
  257. COPY: 0x10,
  258. MODIFY_ANNOTATIONS: 0x20,
  259. FILL_INTERACTIVE_FORMS: 0x100,
  260. COPY_FOR_ACCESSIBILITY: 0x200,
  261. ASSEMBLE: 0x400,
  262. PRINT_HIGH_QUALITY: 0x800
  263. };
  264. exports.PermissionFlag = PermissionFlag;
  265. var TextRenderingMode = {
  266. FILL: 0,
  267. STROKE: 1,
  268. FILL_STROKE: 2,
  269. INVISIBLE: 3,
  270. FILL_ADD_TO_PATH: 4,
  271. STROKE_ADD_TO_PATH: 5,
  272. FILL_STROKE_ADD_TO_PATH: 6,
  273. ADD_TO_PATH: 7,
  274. FILL_STROKE_MASK: 3,
  275. ADD_TO_PATH_FLAG: 4
  276. };
  277. exports.TextRenderingMode = TextRenderingMode;
  278. var ImageKind = {
  279. GRAYSCALE_1BPP: 1,
  280. RGB_24BPP: 2,
  281. RGBA_32BPP: 3
  282. };
  283. exports.ImageKind = ImageKind;
  284. var AnnotationType = {
  285. TEXT: 1,
  286. LINK: 2,
  287. FREETEXT: 3,
  288. LINE: 4,
  289. SQUARE: 5,
  290. CIRCLE: 6,
  291. POLYGON: 7,
  292. POLYLINE: 8,
  293. HIGHLIGHT: 9,
  294. UNDERLINE: 10,
  295. SQUIGGLY: 11,
  296. STRIKEOUT: 12,
  297. STAMP: 13,
  298. CARET: 14,
  299. INK: 15,
  300. POPUP: 16,
  301. FILEATTACHMENT: 17,
  302. SOUND: 18,
  303. MOVIE: 19,
  304. WIDGET: 20,
  305. SCREEN: 21,
  306. PRINTERMARK: 22,
  307. TRAPNET: 23,
  308. WATERMARK: 24,
  309. THREED: 25,
  310. REDACT: 26
  311. };
  312. exports.AnnotationType = AnnotationType;
  313. var AnnotationStateModelType = {
  314. MARKED: 'Marked',
  315. REVIEW: 'Review'
  316. };
  317. exports.AnnotationStateModelType = AnnotationStateModelType;
  318. var AnnotationMarkedState = {
  319. MARKED: 'Marked',
  320. UNMARKED: 'Unmarked'
  321. };
  322. exports.AnnotationMarkedState = AnnotationMarkedState;
  323. var AnnotationReviewState = {
  324. ACCEPTED: 'Accepted',
  325. REJECTED: 'Rejected',
  326. CANCELLED: 'Cancelled',
  327. COMPLETED: 'Completed',
  328. NONE: 'None'
  329. };
  330. exports.AnnotationReviewState = AnnotationReviewState;
  331. var AnnotationReplyType = {
  332. GROUP: 'Group',
  333. REPLY: 'R'
  334. };
  335. exports.AnnotationReplyType = AnnotationReplyType;
  336. var AnnotationFlag = {
  337. INVISIBLE: 0x01,
  338. HIDDEN: 0x02,
  339. PRINT: 0x04,
  340. NOZOOM: 0x08,
  341. NOROTATE: 0x10,
  342. NOVIEW: 0x20,
  343. READONLY: 0x40,
  344. LOCKED: 0x80,
  345. TOGGLENOVIEW: 0x100,
  346. LOCKEDCONTENTS: 0x200
  347. };
  348. exports.AnnotationFlag = AnnotationFlag;
  349. var AnnotationFieldFlag = {
  350. READONLY: 0x0000001,
  351. REQUIRED: 0x0000002,
  352. NOEXPORT: 0x0000004,
  353. MULTILINE: 0x0001000,
  354. PASSWORD: 0x0002000,
  355. NOTOGGLETOOFF: 0x0004000,
  356. RADIO: 0x0008000,
  357. PUSHBUTTON: 0x0010000,
  358. COMBO: 0x0020000,
  359. EDIT: 0x0040000,
  360. SORT: 0x0080000,
  361. FILESELECT: 0x0100000,
  362. MULTISELECT: 0x0200000,
  363. DONOTSPELLCHECK: 0x0400000,
  364. DONOTSCROLL: 0x0800000,
  365. COMB: 0x1000000,
  366. RICHTEXT: 0x2000000,
  367. RADIOSINUNISON: 0x2000000,
  368. COMMITONSELCHANGE: 0x4000000
  369. };
  370. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  371. var AnnotationBorderStyleType = {
  372. SOLID: 1,
  373. DASHED: 2,
  374. BEVELED: 3,
  375. INSET: 4,
  376. UNDERLINE: 5
  377. };
  378. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  379. var StreamType = {
  380. UNKNOWN: 'UNKNOWN',
  381. FLATE: 'FLATE',
  382. LZW: 'LZW',
  383. DCT: 'DCT',
  384. JPX: 'JPX',
  385. JBIG: 'JBIG',
  386. A85: 'A85',
  387. AHX: 'AHX',
  388. CCF: 'CCF',
  389. RLX: 'RLX'
  390. };
  391. exports.StreamType = StreamType;
  392. var FontType = {
  393. UNKNOWN: 'UNKNOWN',
  394. TYPE1: 'TYPE1',
  395. TYPE1C: 'TYPE1C',
  396. CIDFONTTYPE0: 'CIDFONTTYPE0',
  397. CIDFONTTYPE0C: 'CIDFONTTYPE0C',
  398. TRUETYPE: 'TRUETYPE',
  399. CIDFONTTYPE2: 'CIDFONTTYPE2',
  400. TYPE3: 'TYPE3',
  401. OPENTYPE: 'OPENTYPE',
  402. TYPE0: 'TYPE0',
  403. MMTYPE1: 'MMTYPE1'
  404. };
  405. exports.FontType = FontType;
  406. var VerbosityLevel = {
  407. ERRORS: 0,
  408. WARNINGS: 1,
  409. INFOS: 5
  410. };
  411. exports.VerbosityLevel = VerbosityLevel;
  412. var CMapCompressionType = {
  413. NONE: 0,
  414. BINARY: 1,
  415. STREAM: 2
  416. };
  417. exports.CMapCompressionType = CMapCompressionType;
  418. var OPS = {
  419. dependency: 1,
  420. setLineWidth: 2,
  421. setLineCap: 3,
  422. setLineJoin: 4,
  423. setMiterLimit: 5,
  424. setDash: 6,
  425. setRenderingIntent: 7,
  426. setFlatness: 8,
  427. setGState: 9,
  428. save: 10,
  429. restore: 11,
  430. transform: 12,
  431. moveTo: 13,
  432. lineTo: 14,
  433. curveTo: 15,
  434. curveTo2: 16,
  435. curveTo3: 17,
  436. closePath: 18,
  437. rectangle: 19,
  438. stroke: 20,
  439. closeStroke: 21,
  440. fill: 22,
  441. eoFill: 23,
  442. fillStroke: 24,
  443. eoFillStroke: 25,
  444. closeFillStroke: 26,
  445. closeEOFillStroke: 27,
  446. endPath: 28,
  447. clip: 29,
  448. eoClip: 30,
  449. beginText: 31,
  450. endText: 32,
  451. setCharSpacing: 33,
  452. setWordSpacing: 34,
  453. setHScale: 35,
  454. setLeading: 36,
  455. setFont: 37,
  456. setTextRenderingMode: 38,
  457. setTextRise: 39,
  458. moveText: 40,
  459. setLeadingMoveText: 41,
  460. setTextMatrix: 42,
  461. nextLine: 43,
  462. showText: 44,
  463. showSpacedText: 45,
  464. nextLineShowText: 46,
  465. nextLineSetSpacingShowText: 47,
  466. setCharWidth: 48,
  467. setCharWidthAndBounds: 49,
  468. setStrokeColorSpace: 50,
  469. setFillColorSpace: 51,
  470. setStrokeColor: 52,
  471. setStrokeColorN: 53,
  472. setFillColor: 54,
  473. setFillColorN: 55,
  474. setStrokeGray: 56,
  475. setFillGray: 57,
  476. setStrokeRGBColor: 58,
  477. setFillRGBColor: 59,
  478. setStrokeCMYKColor: 60,
  479. setFillCMYKColor: 61,
  480. shadingFill: 62,
  481. beginInlineImage: 63,
  482. beginImageData: 64,
  483. endInlineImage: 65,
  484. paintXObject: 66,
  485. markPoint: 67,
  486. markPointProps: 68,
  487. beginMarkedContent: 69,
  488. beginMarkedContentProps: 70,
  489. endMarkedContent: 71,
  490. beginCompat: 72,
  491. endCompat: 73,
  492. paintFormXObjectBegin: 74,
  493. paintFormXObjectEnd: 75,
  494. beginGroup: 76,
  495. endGroup: 77,
  496. beginAnnotations: 78,
  497. endAnnotations: 79,
  498. beginAnnotation: 80,
  499. endAnnotation: 81,
  500. paintJpegXObject: 82,
  501. paintImageMaskXObject: 83,
  502. paintImageMaskXObjectGroup: 84,
  503. paintImageXObject: 85,
  504. paintInlineImageXObject: 86,
  505. paintInlineImageXObjectGroup: 87,
  506. paintImageXObjectRepeat: 88,
  507. paintImageMaskXObjectRepeat: 89,
  508. paintSolidColorImageMask: 90,
  509. constructPath: 91
  510. };
  511. exports.OPS = OPS;
  512. var UNSUPPORTED_FEATURES = {
  513. unknown: 'unknown',
  514. forms: 'forms',
  515. javaScript: 'javaScript',
  516. smask: 'smask',
  517. shadingPattern: 'shadingPattern',
  518. font: 'font'
  519. };
  520. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  521. var PasswordResponses = {
  522. NEED_PASSWORD: 1,
  523. INCORRECT_PASSWORD: 2
  524. };
  525. exports.PasswordResponses = PasswordResponses;
  526. var verbosity = VerbosityLevel.WARNINGS;
  527. function setVerbosityLevel(level) {
  528. if (Number.isInteger(level)) {
  529. verbosity = level;
  530. }
  531. }
  532. function getVerbosityLevel() {
  533. return verbosity;
  534. }
  535. function info(msg) {
  536. if (verbosity >= VerbosityLevel.INFOS) {
  537. console.log("Info: ".concat(msg));
  538. }
  539. }
  540. function warn(msg) {
  541. if (verbosity >= VerbosityLevel.WARNINGS) {
  542. console.log("Warning: ".concat(msg));
  543. }
  544. }
  545. function unreachable(msg) {
  546. throw new Error(msg);
  547. }
  548. function assert(cond, msg) {
  549. if (!cond) {
  550. unreachable(msg);
  551. }
  552. }
  553. function isSameOrigin(baseUrl, otherUrl) {
  554. var base;
  555. try {
  556. base = new URL(baseUrl);
  557. if (!base.origin || base.origin === 'null') {
  558. return false;
  559. }
  560. } catch (e) {
  561. return false;
  562. }
  563. var other = new URL(otherUrl, base);
  564. return base.origin === other.origin;
  565. }
  566. function _isValidProtocol(url) {
  567. if (!url) {
  568. return false;
  569. }
  570. switch (url.protocol) {
  571. case 'http:':
  572. case 'https:':
  573. case 'ftp:':
  574. case 'mailto:':
  575. case 'tel:':
  576. return true;
  577. default:
  578. return false;
  579. }
  580. }
  581. function createValidAbsoluteUrl(url, baseUrl) {
  582. if (!url) {
  583. return null;
  584. }
  585. try {
  586. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  587. if (_isValidProtocol(absoluteUrl)) {
  588. return absoluteUrl;
  589. }
  590. } catch (ex) {}
  591. return null;
  592. }
  593. function shadow(obj, prop, value) {
  594. Object.defineProperty(obj, prop, {
  595. value: value,
  596. enumerable: true,
  597. configurable: true,
  598. writable: false
  599. });
  600. return value;
  601. }
  602. var BaseException = function BaseExceptionClosure() {
  603. function BaseException(message) {
  604. if (this.constructor === BaseException) {
  605. unreachable('Cannot initialize BaseException.');
  606. }
  607. this.message = message;
  608. this.name = this.constructor.name;
  609. }
  610. BaseException.prototype = new Error();
  611. BaseException.constructor = BaseException;
  612. return BaseException;
  613. }();
  614. exports.BaseException = BaseException;
  615. var PasswordException =
  616. /*#__PURE__*/
  617. function (_BaseException) {
  618. _inherits(PasswordException, _BaseException);
  619. function PasswordException(msg, code) {
  620. var _this;
  621. _classCallCheck(this, PasswordException);
  622. _this = _possibleConstructorReturn(this, _getPrototypeOf(PasswordException).call(this, msg));
  623. _this.code = code;
  624. return _this;
  625. }
  626. return PasswordException;
  627. }(BaseException);
  628. exports.PasswordException = PasswordException;
  629. var UnknownErrorException =
  630. /*#__PURE__*/
  631. function (_BaseException2) {
  632. _inherits(UnknownErrorException, _BaseException2);
  633. function UnknownErrorException(msg, details) {
  634. var _this2;
  635. _classCallCheck(this, UnknownErrorException);
  636. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(UnknownErrorException).call(this, msg));
  637. _this2.details = details;
  638. return _this2;
  639. }
  640. return UnknownErrorException;
  641. }(BaseException);
  642. exports.UnknownErrorException = UnknownErrorException;
  643. var InvalidPDFException =
  644. /*#__PURE__*/
  645. function (_BaseException3) {
  646. _inherits(InvalidPDFException, _BaseException3);
  647. function InvalidPDFException() {
  648. _classCallCheck(this, InvalidPDFException);
  649. return _possibleConstructorReturn(this, _getPrototypeOf(InvalidPDFException).apply(this, arguments));
  650. }
  651. return InvalidPDFException;
  652. }(BaseException);
  653. exports.InvalidPDFException = InvalidPDFException;
  654. var MissingPDFException =
  655. /*#__PURE__*/
  656. function (_BaseException4) {
  657. _inherits(MissingPDFException, _BaseException4);
  658. function MissingPDFException() {
  659. _classCallCheck(this, MissingPDFException);
  660. return _possibleConstructorReturn(this, _getPrototypeOf(MissingPDFException).apply(this, arguments));
  661. }
  662. return MissingPDFException;
  663. }(BaseException);
  664. exports.MissingPDFException = MissingPDFException;
  665. var UnexpectedResponseException =
  666. /*#__PURE__*/
  667. function (_BaseException5) {
  668. _inherits(UnexpectedResponseException, _BaseException5);
  669. function UnexpectedResponseException(msg, status) {
  670. var _this3;
  671. _classCallCheck(this, UnexpectedResponseException);
  672. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(UnexpectedResponseException).call(this, msg));
  673. _this3.status = status;
  674. return _this3;
  675. }
  676. return UnexpectedResponseException;
  677. }(BaseException);
  678. exports.UnexpectedResponseException = UnexpectedResponseException;
  679. var FormatError =
  680. /*#__PURE__*/
  681. function (_BaseException6) {
  682. _inherits(FormatError, _BaseException6);
  683. function FormatError() {
  684. _classCallCheck(this, FormatError);
  685. return _possibleConstructorReturn(this, _getPrototypeOf(FormatError).apply(this, arguments));
  686. }
  687. return FormatError;
  688. }(BaseException);
  689. exports.FormatError = FormatError;
  690. var AbortException =
  691. /*#__PURE__*/
  692. function (_BaseException7) {
  693. _inherits(AbortException, _BaseException7);
  694. function AbortException() {
  695. _classCallCheck(this, AbortException);
  696. return _possibleConstructorReturn(this, _getPrototypeOf(AbortException).apply(this, arguments));
  697. }
  698. return AbortException;
  699. }(BaseException);
  700. exports.AbortException = AbortException;
  701. var NullCharactersRegExp = /\x00/g;
  702. function removeNullCharacters(str) {
  703. if (typeof str !== 'string') {
  704. warn('The argument for removeNullCharacters must be a string.');
  705. return str;
  706. }
  707. return str.replace(NullCharactersRegExp, '');
  708. }
  709. function bytesToString(bytes) {
  710. assert(bytes !== null && _typeof(bytes) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  711. var length = bytes.length;
  712. var MAX_ARGUMENT_COUNT = 8192;
  713. if (length < MAX_ARGUMENT_COUNT) {
  714. return String.fromCharCode.apply(null, bytes);
  715. }
  716. var strBuf = [];
  717. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  718. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  719. var chunk = bytes.subarray(i, chunkEnd);
  720. strBuf.push(String.fromCharCode.apply(null, chunk));
  721. }
  722. return strBuf.join('');
  723. }
  724. function stringToBytes(str) {
  725. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  726. var length = str.length;
  727. var bytes = new Uint8Array(length);
  728. for (var i = 0; i < length; ++i) {
  729. bytes[i] = str.charCodeAt(i) & 0xFF;
  730. }
  731. return bytes;
  732. }
  733. function arrayByteLength(arr) {
  734. if (arr.length !== undefined) {
  735. return arr.length;
  736. }
  737. assert(arr.byteLength !== undefined);
  738. return arr.byteLength;
  739. }
  740. function arraysToBytes(arr) {
  741. var length = arr.length;
  742. if (length === 1 && arr[0] instanceof Uint8Array) {
  743. return arr[0];
  744. }
  745. var resultLength = 0;
  746. for (var i = 0; i < length; i++) {
  747. resultLength += arrayByteLength(arr[i]);
  748. }
  749. var pos = 0;
  750. var data = new Uint8Array(resultLength);
  751. for (var _i = 0; _i < length; _i++) {
  752. var item = arr[_i];
  753. if (!(item instanceof Uint8Array)) {
  754. if (typeof item === 'string') {
  755. item = stringToBytes(item);
  756. } else {
  757. item = new Uint8Array(item);
  758. }
  759. }
  760. var itemLength = item.byteLength;
  761. data.set(item, pos);
  762. pos += itemLength;
  763. }
  764. return data;
  765. }
  766. function string32(value) {
  767. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  768. }
  769. function log2(x) {
  770. if (x <= 0) {
  771. return 0;
  772. }
  773. return Math.ceil(Math.log2(x));
  774. }
  775. function readInt8(data, start) {
  776. return data[start] << 24 >> 24;
  777. }
  778. function readUint16(data, offset) {
  779. return data[offset] << 8 | data[offset + 1];
  780. }
  781. function readUint32(data, offset) {
  782. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  783. }
  784. function isLittleEndian() {
  785. var buffer8 = new Uint8Array(4);
  786. buffer8[0] = 1;
  787. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  788. return view32[0] === 1;
  789. }
  790. function isEvalSupported() {
  791. try {
  792. new Function('');
  793. return true;
  794. } catch (e) {
  795. return false;
  796. }
  797. }
  798. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  799. var Util =
  800. /*#__PURE__*/
  801. function () {
  802. function Util() {
  803. _classCallCheck(this, Util);
  804. }
  805. _createClass(Util, null, [{
  806. key: "makeCssRgb",
  807. value: function makeCssRgb(r, g, b) {
  808. rgbBuf[1] = r;
  809. rgbBuf[3] = g;
  810. rgbBuf[5] = b;
  811. return rgbBuf.join('');
  812. }
  813. }, {
  814. key: "transform",
  815. value: function transform(m1, m2) {
  816. 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]];
  817. }
  818. }, {
  819. key: "applyTransform",
  820. value: function applyTransform(p, m) {
  821. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  822. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  823. return [xt, yt];
  824. }
  825. }, {
  826. key: "applyInverseTransform",
  827. value: function applyInverseTransform(p, m) {
  828. var d = m[0] * m[3] - m[1] * m[2];
  829. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  830. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  831. return [xt, yt];
  832. }
  833. }, {
  834. key: "getAxialAlignedBoundingBox",
  835. value: function getAxialAlignedBoundingBox(r, m) {
  836. var p1 = Util.applyTransform(r, m);
  837. var p2 = Util.applyTransform(r.slice(2, 4), m);
  838. var p3 = Util.applyTransform([r[0], r[3]], m);
  839. var p4 = Util.applyTransform([r[2], r[1]], m);
  840. 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])];
  841. }
  842. }, {
  843. key: "inverseTransform",
  844. value: function inverseTransform(m) {
  845. var d = m[0] * m[3] - m[1] * m[2];
  846. 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];
  847. }
  848. }, {
  849. key: "apply3dTransform",
  850. value: function apply3dTransform(m, v) {
  851. 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]];
  852. }
  853. }, {
  854. key: "singularValueDecompose2dScale",
  855. value: function singularValueDecompose2dScale(m) {
  856. var transpose = [m[0], m[2], m[1], m[3]];
  857. var a = m[0] * transpose[0] + m[1] * transpose[2];
  858. var b = m[0] * transpose[1] + m[1] * transpose[3];
  859. var c = m[2] * transpose[0] + m[3] * transpose[2];
  860. var d = m[2] * transpose[1] + m[3] * transpose[3];
  861. var first = (a + d) / 2;
  862. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  863. var sx = first + second || 1;
  864. var sy = first - second || 1;
  865. return [Math.sqrt(sx), Math.sqrt(sy)];
  866. }
  867. }, {
  868. key: "normalizeRect",
  869. value: function normalizeRect(rect) {
  870. var r = rect.slice(0);
  871. if (rect[0] > rect[2]) {
  872. r[0] = rect[2];
  873. r[2] = rect[0];
  874. }
  875. if (rect[1] > rect[3]) {
  876. r[1] = rect[3];
  877. r[3] = rect[1];
  878. }
  879. return r;
  880. }
  881. }, {
  882. key: "intersect",
  883. value: function intersect(rect1, rect2) {
  884. function compare(a, b) {
  885. return a - b;
  886. }
  887. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
  888. var orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
  889. var result = [];
  890. rect1 = Util.normalizeRect(rect1);
  891. rect2 = Util.normalizeRect(rect2);
  892. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  893. result[0] = orderedX[1];
  894. result[2] = orderedX[2];
  895. } else {
  896. return null;
  897. }
  898. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  899. result[1] = orderedY[1];
  900. result[3] = orderedY[2];
  901. } else {
  902. return null;
  903. }
  904. return result;
  905. }
  906. }]);
  907. return Util;
  908. }();
  909. exports.Util = Util;
  910. 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];
  911. function stringToPDFString(str) {
  912. var length = str.length,
  913. strBuf = [];
  914. if (str[0] === '\xFE' && str[1] === '\xFF') {
  915. for (var i = 2; i < length; i += 2) {
  916. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  917. }
  918. } else {
  919. for (var _i2 = 0; _i2 < length; ++_i2) {
  920. var code = PDFStringTranslateTable[str.charCodeAt(_i2)];
  921. strBuf.push(code ? String.fromCharCode(code) : str.charAt(_i2));
  922. }
  923. }
  924. return strBuf.join('');
  925. }
  926. function stringToUTF8String(str) {
  927. return decodeURIComponent(escape(str));
  928. }
  929. function utf8StringToString(str) {
  930. return unescape(encodeURIComponent(str));
  931. }
  932. function isEmptyObj(obj) {
  933. for (var key in obj) {
  934. return false;
  935. }
  936. return true;
  937. }
  938. function isBool(v) {
  939. return typeof v === 'boolean';
  940. }
  941. function isNum(v) {
  942. return typeof v === 'number';
  943. }
  944. function isString(v) {
  945. return typeof v === 'string';
  946. }
  947. function isArrayBuffer(v) {
  948. return _typeof(v) === 'object' && v !== null && v.byteLength !== undefined;
  949. }
  950. function isArrayEqual(arr1, arr2) {
  951. if (arr1.length !== arr2.length) {
  952. return false;
  953. }
  954. return arr1.every(function (element, index) {
  955. return element === arr2[index];
  956. });
  957. }
  958. function isSpace(ch) {
  959. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  960. }
  961. function createPromiseCapability() {
  962. var capability = Object.create(null);
  963. var isSettled = false;
  964. Object.defineProperty(capability, 'settled', {
  965. get: function get() {
  966. return isSettled;
  967. }
  968. });
  969. capability.promise = new Promise(function (resolve, reject) {
  970. capability.resolve = function (data) {
  971. isSettled = true;
  972. resolve(data);
  973. };
  974. capability.reject = function (reason) {
  975. isSettled = true;
  976. reject(reason);
  977. };
  978. });
  979. return capability;
  980. }
  981. var createObjectURL = function createObjectURLClosure() {
  982. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  983. return function createObjectURL(data, contentType) {
  984. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  985. if (!forceDataSchema && URL.createObjectURL) {
  986. var blob = new Blob([data], {
  987. type: contentType
  988. });
  989. return URL.createObjectURL(blob);
  990. }
  991. var buffer = "data:".concat(contentType, ";base64,");
  992. for (var i = 0, ii = data.length; i < ii; i += 3) {
  993. var b1 = data[i] & 0xFF;
  994. var b2 = data[i + 1] & 0xFF;
  995. var b3 = data[i + 2] & 0xFF;
  996. var d1 = b1 >> 2,
  997. d2 = (b1 & 3) << 4 | b2 >> 4;
  998. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  999. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1000. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1001. }
  1002. return buffer;
  1003. };
  1004. }();
  1005. exports.createObjectURL = createObjectURL;
  1006. /***/ }),
  1007. /* 2 */
  1008. /***/ (function(module, exports, __w_pdfjs_require__) {
  1009. "use strict";
  1010. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1011. var globalScope = __w_pdfjs_require__(3);
  1012. if (!globalScope._pdfjsCompatibilityChecked) {
  1013. globalScope._pdfjsCompatibilityChecked = true;
  1014. var isNodeJS = __w_pdfjs_require__(4);
  1015. var hasDOM = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object';
  1016. (function checkNodeBtoa() {
  1017. if (globalScope.btoa || !isNodeJS()) {
  1018. return;
  1019. }
  1020. globalScope.btoa = function (chars) {
  1021. return Buffer.from(chars, 'binary').toString('base64');
  1022. };
  1023. })();
  1024. (function checkNodeAtob() {
  1025. if (globalScope.atob || !isNodeJS()) {
  1026. return;
  1027. }
  1028. globalScope.atob = function (input) {
  1029. return Buffer.from(input, 'base64').toString('binary');
  1030. };
  1031. })();
  1032. (function checkChildNodeRemove() {
  1033. if (!hasDOM) {
  1034. return;
  1035. }
  1036. if (typeof Element.prototype.remove !== 'undefined') {
  1037. return;
  1038. }
  1039. Element.prototype.remove = function () {
  1040. if (this.parentNode) {
  1041. this.parentNode.removeChild(this);
  1042. }
  1043. };
  1044. })();
  1045. (function checkDOMTokenListAddRemove() {
  1046. if (!hasDOM || isNodeJS()) {
  1047. return;
  1048. }
  1049. var div = document.createElement('div');
  1050. div.classList.add('testOne', 'testTwo');
  1051. if (div.classList.contains('testOne') === true && div.classList.contains('testTwo') === true) {
  1052. return;
  1053. }
  1054. var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
  1055. var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
  1056. DOMTokenList.prototype.add = function () {
  1057. for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
  1058. tokens[_key] = arguments[_key];
  1059. }
  1060. for (var _i = 0, _tokens = tokens; _i < _tokens.length; _i++) {
  1061. var token = _tokens[_i];
  1062. OriginalDOMTokenListAdd.call(this, token);
  1063. }
  1064. };
  1065. DOMTokenList.prototype.remove = function () {
  1066. for (var _len2 = arguments.length, tokens = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1067. tokens[_key2] = arguments[_key2];
  1068. }
  1069. for (var _i2 = 0, _tokens2 = tokens; _i2 < _tokens2.length; _i2++) {
  1070. var token = _tokens2[_i2];
  1071. OriginalDOMTokenListRemove.call(this, token);
  1072. }
  1073. };
  1074. })();
  1075. (function checkDOMTokenListToggle() {
  1076. if (!hasDOM || isNodeJS()) {
  1077. return;
  1078. }
  1079. var div = document.createElement('div');
  1080. if (div.classList.toggle('test', 0) === false) {
  1081. return;
  1082. }
  1083. DOMTokenList.prototype.toggle = function (token) {
  1084. var force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
  1085. return this[force ? 'add' : 'remove'](token), force;
  1086. };
  1087. })();
  1088. (function checkStringStartsWith() {
  1089. if (String.prototype.startsWith) {
  1090. return;
  1091. }
  1092. __w_pdfjs_require__(5);
  1093. })();
  1094. (function checkStringEndsWith() {
  1095. if (String.prototype.endsWith) {
  1096. return;
  1097. }
  1098. __w_pdfjs_require__(57);
  1099. })();
  1100. (function checkStringIncludes() {
  1101. if (String.prototype.includes) {
  1102. return;
  1103. }
  1104. __w_pdfjs_require__(59);
  1105. })();
  1106. (function checkArrayIncludes() {
  1107. if (Array.prototype.includes) {
  1108. return;
  1109. }
  1110. __w_pdfjs_require__(61);
  1111. })();
  1112. (function checkArrayFrom() {
  1113. if (Array.from) {
  1114. return;
  1115. }
  1116. __w_pdfjs_require__(68);
  1117. })();
  1118. (function checkObjectAssign() {
  1119. if (Object.assign) {
  1120. return;
  1121. }
  1122. __w_pdfjs_require__(89);
  1123. })();
  1124. (function checkMathLog2() {
  1125. if (Math.log2) {
  1126. return;
  1127. }
  1128. Math.log2 = __w_pdfjs_require__(92);
  1129. })();
  1130. (function checkNumberIsNaN() {
  1131. if (Number.isNaN) {
  1132. return;
  1133. }
  1134. Number.isNaN = __w_pdfjs_require__(94);
  1135. })();
  1136. (function checkNumberIsInteger() {
  1137. if (Number.isInteger) {
  1138. return;
  1139. }
  1140. Number.isInteger = __w_pdfjs_require__(96);
  1141. })();
  1142. (function checkPromise() {
  1143. if (globalScope.Promise && globalScope.Promise.prototype && globalScope.Promise.prototype["finally"]) {
  1144. return;
  1145. }
  1146. globalScope.Promise = __w_pdfjs_require__(99);
  1147. })();
  1148. (function checkURL() {
  1149. globalScope.URL = __w_pdfjs_require__(121);
  1150. })();
  1151. (function checkWeakMap() {
  1152. if (globalScope.WeakMap) {
  1153. return;
  1154. }
  1155. globalScope.WeakMap = __w_pdfjs_require__(128);
  1156. })();
  1157. (function checkWeakSet() {
  1158. if (globalScope.WeakSet) {
  1159. return;
  1160. }
  1161. globalScope.WeakSet = __w_pdfjs_require__(138);
  1162. })();
  1163. (function checkStringCodePointAt() {
  1164. if (String.prototype.codePointAt) {
  1165. return;
  1166. }
  1167. __w_pdfjs_require__(140);
  1168. })();
  1169. (function checkStringFromCodePoint() {
  1170. if (String.fromCodePoint) {
  1171. return;
  1172. }
  1173. String.fromCodePoint = __w_pdfjs_require__(142);
  1174. })();
  1175. (function checkSymbol() {
  1176. if (globalScope.Symbol) {
  1177. return;
  1178. }
  1179. __w_pdfjs_require__(144);
  1180. })();
  1181. (function checkStringPadStart() {
  1182. if (String.prototype.padStart) {
  1183. return;
  1184. }
  1185. __w_pdfjs_require__(167);
  1186. })();
  1187. (function checkStringPadEnd() {
  1188. if (String.prototype.padEnd) {
  1189. return;
  1190. }
  1191. __w_pdfjs_require__(172);
  1192. })();
  1193. (function checkObjectValues() {
  1194. if (Object.values) {
  1195. return;
  1196. }
  1197. Object.values = __w_pdfjs_require__(174);
  1198. })();
  1199. }
  1200. /***/ }),
  1201. /* 3 */
  1202. /***/ (function(module, exports, __w_pdfjs_require__) {
  1203. "use strict";
  1204. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1205. /***/ }),
  1206. /* 4 */
  1207. /***/ (function(module, exports, __w_pdfjs_require__) {
  1208. "use strict";
  1209. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1210. module.exports = function isNodeJS() {
  1211. return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
  1212. };
  1213. /***/ }),
  1214. /* 5 */
  1215. /***/ (function(module, exports, __w_pdfjs_require__) {
  1216. __w_pdfjs_require__(6);
  1217. var entryUnbind = __w_pdfjs_require__(54);
  1218. module.exports = entryUnbind('String', 'startsWith');
  1219. /***/ }),
  1220. /* 6 */
  1221. /***/ (function(module, exports, __w_pdfjs_require__) {
  1222. "use strict";
  1223. var $ = __w_pdfjs_require__(7);
  1224. var toLength = __w_pdfjs_require__(43);
  1225. var notARegExp = __w_pdfjs_require__(49);
  1226. var requireObjectCoercible = __w_pdfjs_require__(17);
  1227. var correctIsRegExpLogic = __w_pdfjs_require__(53);
  1228. var nativeStartsWith = ''.startsWith;
  1229. var min = Math.min;
  1230. $({
  1231. target: 'String',
  1232. proto: true,
  1233. forced: !correctIsRegExpLogic('startsWith')
  1234. }, {
  1235. startsWith: function startsWith(searchString) {
  1236. var that = String(requireObjectCoercible(this));
  1237. notARegExp(searchString);
  1238. var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  1239. var search = String(searchString);
  1240. return nativeStartsWith ? nativeStartsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
  1241. }
  1242. });
  1243. /***/ }),
  1244. /* 7 */
  1245. /***/ (function(module, exports, __w_pdfjs_require__) {
  1246. var global = __w_pdfjs_require__(8);
  1247. var getOwnPropertyDescriptor = __w_pdfjs_require__(9).f;
  1248. var hide = __w_pdfjs_require__(23);
  1249. var redefine = __w_pdfjs_require__(26);
  1250. var setGlobal = __w_pdfjs_require__(28);
  1251. var copyConstructorProperties = __w_pdfjs_require__(36);
  1252. var isForced = __w_pdfjs_require__(48);
  1253. module.exports = function (options, source) {
  1254. var TARGET = options.target;
  1255. var GLOBAL = options.global;
  1256. var STATIC = options.stat;
  1257. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  1258. if (GLOBAL) {
  1259. target = global;
  1260. } else if (STATIC) {
  1261. target = global[TARGET] || setGlobal(TARGET, {});
  1262. } else {
  1263. target = (global[TARGET] || {}).prototype;
  1264. }
  1265. if (target)
  1266. for (key in source) {
  1267. sourceProperty = source[key];
  1268. if (options.noTargetGet) {
  1269. descriptor = getOwnPropertyDescriptor(target, key);
  1270. targetProperty = descriptor && descriptor.value;
  1271. } else
  1272. targetProperty = target[key];
  1273. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  1274. if (!FORCED && targetProperty !== undefined) {
  1275. if (typeof sourceProperty === typeof targetProperty)
  1276. continue;
  1277. copyConstructorProperties(sourceProperty, targetProperty);
  1278. }
  1279. if (options.sham || targetProperty && targetProperty.sham) {
  1280. hide(sourceProperty, 'sham', true);
  1281. }
  1282. redefine(target, key, sourceProperty, options);
  1283. }
  1284. };
  1285. /***/ }),
  1286. /* 8 */
  1287. /***/ (function(module, exports) {
  1288. var O = 'object';
  1289. var check = function (it) {
  1290. return it && it.Math == Math && it;
  1291. };
  1292. module.exports = check(typeof globalThis == O && globalThis) || check(typeof window == O && window) || check(typeof self == O && self) || check(typeof global == O && global) || Function('return this')();
  1293. /***/ }),
  1294. /* 9 */
  1295. /***/ (function(module, exports, __w_pdfjs_require__) {
  1296. var DESCRIPTORS = __w_pdfjs_require__(10);
  1297. var propertyIsEnumerableModule = __w_pdfjs_require__(12);
  1298. var createPropertyDescriptor = __w_pdfjs_require__(13);
  1299. var toIndexedObject = __w_pdfjs_require__(14);
  1300. var toPrimitive = __w_pdfjs_require__(18);
  1301. var has = __w_pdfjs_require__(20);
  1302. var IE8_DOM_DEFINE = __w_pdfjs_require__(21);
  1303. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1304. exports.f = DESCRIPTORS ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  1305. O = toIndexedObject(O);
  1306. P = toPrimitive(P, true);
  1307. if (IE8_DOM_DEFINE)
  1308. try {
  1309. return nativeGetOwnPropertyDescriptor(O, P);
  1310. } catch (error) {
  1311. }
  1312. if (has(O, P))
  1313. return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  1314. };
  1315. /***/ }),
  1316. /* 10 */
  1317. /***/ (function(module, exports, __w_pdfjs_require__) {
  1318. var fails = __w_pdfjs_require__(11);
  1319. module.exports = !fails(function () {
  1320. return Object.defineProperty({}, 'a', {
  1321. get: function () {
  1322. return 7;
  1323. }
  1324. }).a != 7;
  1325. });
  1326. /***/ }),
  1327. /* 11 */
  1328. /***/ (function(module, exports) {
  1329. module.exports = function (exec) {
  1330. try {
  1331. return !!exec();
  1332. } catch (error) {
  1333. return true;
  1334. }
  1335. };
  1336. /***/ }),
  1337. /* 12 */
  1338. /***/ (function(module, exports, __w_pdfjs_require__) {
  1339. "use strict";
  1340. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  1341. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1342. var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  1343. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  1344. var descriptor = getOwnPropertyDescriptor(this, V);
  1345. return !!descriptor && descriptor.enumerable;
  1346. } : nativePropertyIsEnumerable;
  1347. /***/ }),
  1348. /* 13 */
  1349. /***/ (function(module, exports) {
  1350. module.exports = function (bitmap, value) {
  1351. return {
  1352. enumerable: !(bitmap & 1),
  1353. configurable: !(bitmap & 2),
  1354. writable: !(bitmap & 4),
  1355. value: value
  1356. };
  1357. };
  1358. /***/ }),
  1359. /* 14 */
  1360. /***/ (function(module, exports, __w_pdfjs_require__) {
  1361. var IndexedObject = __w_pdfjs_require__(15);
  1362. var requireObjectCoercible = __w_pdfjs_require__(17);
  1363. module.exports = function (it) {
  1364. return IndexedObject(requireObjectCoercible(it));
  1365. };
  1366. /***/ }),
  1367. /* 15 */
  1368. /***/ (function(module, exports, __w_pdfjs_require__) {
  1369. var fails = __w_pdfjs_require__(11);
  1370. var classof = __w_pdfjs_require__(16);
  1371. var split = ''.split;
  1372. module.exports = fails(function () {
  1373. return !Object('z').propertyIsEnumerable(0);
  1374. }) ? function (it) {
  1375. return classof(it) == 'String' ? split.call(it, '') : Object(it);
  1376. } : Object;
  1377. /***/ }),
  1378. /* 16 */
  1379. /***/ (function(module, exports) {
  1380. var toString = {}.toString;
  1381. module.exports = function (it) {
  1382. return toString.call(it).slice(8, -1);
  1383. };
  1384. /***/ }),
  1385. /* 17 */
  1386. /***/ (function(module, exports) {
  1387. module.exports = function (it) {
  1388. if (it == undefined)
  1389. throw TypeError("Can't call method on " + it);
  1390. return it;
  1391. };
  1392. /***/ }),
  1393. /* 18 */
  1394. /***/ (function(module, exports, __w_pdfjs_require__) {
  1395. var isObject = __w_pdfjs_require__(19);
  1396. module.exports = function (input, PREFERRED_STRING) {
  1397. if (!isObject(input))
  1398. return input;
  1399. var fn, val;
  1400. if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  1401. return val;
  1402. if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input)))
  1403. return val;
  1404. if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input)))
  1405. return val;
  1406. throw TypeError("Can't convert object to primitive value");
  1407. };
  1408. /***/ }),
  1409. /* 19 */
  1410. /***/ (function(module, exports) {
  1411. module.exports = function (it) {
  1412. return typeof it === 'object' ? it !== null : typeof it === 'function';
  1413. };
  1414. /***/ }),
  1415. /* 20 */
  1416. /***/ (function(module, exports) {
  1417. var hasOwnProperty = {}.hasOwnProperty;
  1418. module.exports = function (it, key) {
  1419. return hasOwnProperty.call(it, key);
  1420. };
  1421. /***/ }),
  1422. /* 21 */
  1423. /***/ (function(module, exports, __w_pdfjs_require__) {
  1424. var DESCRIPTORS = __w_pdfjs_require__(10);
  1425. var fails = __w_pdfjs_require__(11);
  1426. var createElement = __w_pdfjs_require__(22);
  1427. module.exports = !DESCRIPTORS && !fails(function () {
  1428. return Object.defineProperty(createElement('div'), 'a', {
  1429. get: function () {
  1430. return 7;
  1431. }
  1432. }).a != 7;
  1433. });
  1434. /***/ }),
  1435. /* 22 */
  1436. /***/ (function(module, exports, __w_pdfjs_require__) {
  1437. var global = __w_pdfjs_require__(8);
  1438. var isObject = __w_pdfjs_require__(19);
  1439. var document = global.document;
  1440. var EXISTS = isObject(document) && isObject(document.createElement);
  1441. module.exports = function (it) {
  1442. return EXISTS ? document.createElement(it) : {};
  1443. };
  1444. /***/ }),
  1445. /* 23 */
  1446. /***/ (function(module, exports, __w_pdfjs_require__) {
  1447. var DESCRIPTORS = __w_pdfjs_require__(10);
  1448. var definePropertyModule = __w_pdfjs_require__(24);
  1449. var createPropertyDescriptor = __w_pdfjs_require__(13);
  1450. module.exports = DESCRIPTORS ? function (object, key, value) {
  1451. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  1452. } : function (object, key, value) {
  1453. object[key] = value;
  1454. return object;
  1455. };
  1456. /***/ }),
  1457. /* 24 */
  1458. /***/ (function(module, exports, __w_pdfjs_require__) {
  1459. var DESCRIPTORS = __w_pdfjs_require__(10);
  1460. var IE8_DOM_DEFINE = __w_pdfjs_require__(21);
  1461. var anObject = __w_pdfjs_require__(25);
  1462. var toPrimitive = __w_pdfjs_require__(18);
  1463. var nativeDefineProperty = Object.defineProperty;
  1464. exports.f = DESCRIPTORS ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  1465. anObject(O);
  1466. P = toPrimitive(P, true);
  1467. anObject(Attributes);
  1468. if (IE8_DOM_DEFINE)
  1469. try {
  1470. return nativeDefineProperty(O, P, Attributes);
  1471. } catch (error) {
  1472. }
  1473. if ('get' in Attributes || 'set' in Attributes)
  1474. throw TypeError('Accessors not supported');
  1475. if ('value' in Attributes)
  1476. O[P] = Attributes.value;
  1477. return O;
  1478. };
  1479. /***/ }),
  1480. /* 25 */
  1481. /***/ (function(module, exports, __w_pdfjs_require__) {
  1482. var isObject = __w_pdfjs_require__(19);
  1483. module.exports = function (it) {
  1484. if (!isObject(it)) {
  1485. throw TypeError(String(it) + ' is not an object');
  1486. }
  1487. return it;
  1488. };
  1489. /***/ }),
  1490. /* 26 */
  1491. /***/ (function(module, exports, __w_pdfjs_require__) {
  1492. var global = __w_pdfjs_require__(8);
  1493. var shared = __w_pdfjs_require__(27);
  1494. var hide = __w_pdfjs_require__(23);
  1495. var has = __w_pdfjs_require__(20);
  1496. var setGlobal = __w_pdfjs_require__(28);
  1497. var nativeFunctionToString = __w_pdfjs_require__(30);
  1498. var InternalStateModule = __w_pdfjs_require__(31);
  1499. var getInternalState = InternalStateModule.get;
  1500. var enforceInternalState = InternalStateModule.enforce;
  1501. var TEMPLATE = String(nativeFunctionToString).split('toString');
  1502. shared('inspectSource', function (it) {
  1503. return nativeFunctionToString.call(it);
  1504. });
  1505. (module.exports = function (O, key, value, options) {
  1506. var unsafe = options ? !!options.unsafe : false;
  1507. var simple = options ? !!options.enumerable : false;
  1508. var noTargetGet = options ? !!options.noTargetGet : false;
  1509. if (typeof value == 'function') {
  1510. if (typeof key == 'string' && !has(value, 'name'))
  1511. hide(value, 'name', key);
  1512. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  1513. }
  1514. if (O === global) {
  1515. if (simple)
  1516. O[key] = value;
  1517. else
  1518. setGlobal(key, value);
  1519. return;
  1520. } else if (!unsafe) {
  1521. delete O[key];
  1522. } else if (!noTargetGet && O[key]) {
  1523. simple = true;
  1524. }
  1525. if (simple)
  1526. O[key] = value;
  1527. else
  1528. hide(O, key, value);
  1529. })(Function.prototype, 'toString', function toString() {
  1530. return typeof this == 'function' && getInternalState(this).source || nativeFunctionToString.call(this);
  1531. });
  1532. /***/ }),
  1533. /* 27 */
  1534. /***/ (function(module, exports, __w_pdfjs_require__) {
  1535. var global = __w_pdfjs_require__(8);
  1536. var setGlobal = __w_pdfjs_require__(28);
  1537. var IS_PURE = __w_pdfjs_require__(29);
  1538. var SHARED = '__core-js_shared__';
  1539. var store = global[SHARED] || setGlobal(SHARED, {});
  1540. (module.exports = function (key, value) {
  1541. return store[key] || (store[key] = value !== undefined ? value : {});
  1542. })('versions', []).push({
  1543. version: '3.2.1',
  1544. mode: IS_PURE ? 'pure' : 'global',
  1545. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  1546. });
  1547. /***/ }),
  1548. /* 28 */
  1549. /***/ (function(module, exports, __w_pdfjs_require__) {
  1550. var global = __w_pdfjs_require__(8);
  1551. var hide = __w_pdfjs_require__(23);
  1552. module.exports = function (key, value) {
  1553. try {
  1554. hide(global, key, value);
  1555. } catch (error) {
  1556. global[key] = value;
  1557. }
  1558. return value;
  1559. };
  1560. /***/ }),
  1561. /* 29 */
  1562. /***/ (function(module, exports) {
  1563. module.exports = false;
  1564. /***/ }),
  1565. /* 30 */
  1566. /***/ (function(module, exports, __w_pdfjs_require__) {
  1567. var shared = __w_pdfjs_require__(27);
  1568. module.exports = shared('native-function-to-string', Function.toString);
  1569. /***/ }),
  1570. /* 31 */
  1571. /***/ (function(module, exports, __w_pdfjs_require__) {
  1572. var NATIVE_WEAK_MAP = __w_pdfjs_require__(32);
  1573. var global = __w_pdfjs_require__(8);
  1574. var isObject = __w_pdfjs_require__(19);
  1575. var hide = __w_pdfjs_require__(23);
  1576. var objectHas = __w_pdfjs_require__(20);
  1577. var sharedKey = __w_pdfjs_require__(33);
  1578. var hiddenKeys = __w_pdfjs_require__(35);
  1579. var WeakMap = global.WeakMap;
  1580. var set, get, has;
  1581. var enforce = function (it) {
  1582. return has(it) ? get(it) : set(it, {});
  1583. };
  1584. var getterFor = function (TYPE) {
  1585. return function (it) {
  1586. var state;
  1587. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1588. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1589. }
  1590. return state;
  1591. };
  1592. };
  1593. if (NATIVE_WEAK_MAP) {
  1594. var store = new WeakMap();
  1595. var wmget = store.get;
  1596. var wmhas = store.has;
  1597. var wmset = store.set;
  1598. set = function (it, metadata) {
  1599. wmset.call(store, it, metadata);
  1600. return metadata;
  1601. };
  1602. get = function (it) {
  1603. return wmget.call(store, it) || {};
  1604. };
  1605. has = function (it) {
  1606. return wmhas.call(store, it);
  1607. };
  1608. } else {
  1609. var STATE = sharedKey('state');
  1610. hiddenKeys[STATE] = true;
  1611. set = function (it, metadata) {
  1612. hide(it, STATE, metadata);
  1613. return metadata;
  1614. };
  1615. get = function (it) {
  1616. return objectHas(it, STATE) ? it[STATE] : {};
  1617. };
  1618. has = function (it) {
  1619. return objectHas(it, STATE);
  1620. };
  1621. }
  1622. module.exports = {
  1623. set: set,
  1624. get: get,
  1625. has: has,
  1626. enforce: enforce,
  1627. getterFor: getterFor
  1628. };
  1629. /***/ }),
  1630. /* 32 */
  1631. /***/ (function(module, exports, __w_pdfjs_require__) {
  1632. var global = __w_pdfjs_require__(8);
  1633. var nativeFunctionToString = __w_pdfjs_require__(30);
  1634. var WeakMap = global.WeakMap;
  1635. module.exports = typeof WeakMap === 'function' && /native code/.test(nativeFunctionToString.call(WeakMap));
  1636. /***/ }),
  1637. /* 33 */
  1638. /***/ (function(module, exports, __w_pdfjs_require__) {
  1639. var shared = __w_pdfjs_require__(27);
  1640. var uid = __w_pdfjs_require__(34);
  1641. var keys = shared('keys');
  1642. module.exports = function (key) {
  1643. return keys[key] || (keys[key] = uid(key));
  1644. };
  1645. /***/ }),
  1646. /* 34 */
  1647. /***/ (function(module, exports) {
  1648. var id = 0;
  1649. var postfix = Math.random();
  1650. module.exports = function (key) {
  1651. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  1652. };
  1653. /***/ }),
  1654. /* 35 */
  1655. /***/ (function(module, exports) {
  1656. module.exports = {};
  1657. /***/ }),
  1658. /* 36 */
  1659. /***/ (function(module, exports, __w_pdfjs_require__) {
  1660. var has = __w_pdfjs_require__(20);
  1661. var ownKeys = __w_pdfjs_require__(37);
  1662. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(9);
  1663. var definePropertyModule = __w_pdfjs_require__(24);
  1664. module.exports = function (target, source) {
  1665. var keys = ownKeys(source);
  1666. var defineProperty = definePropertyModule.f;
  1667. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1668. for (var i = 0; i < keys.length; i++) {
  1669. var key = keys[i];
  1670. if (!has(target, key))
  1671. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1672. }
  1673. };
  1674. /***/ }),
  1675. /* 37 */
  1676. /***/ (function(module, exports, __w_pdfjs_require__) {
  1677. var getBuiltIn = __w_pdfjs_require__(38);
  1678. var getOwnPropertyNamesModule = __w_pdfjs_require__(40);
  1679. var getOwnPropertySymbolsModule = __w_pdfjs_require__(47);
  1680. var anObject = __w_pdfjs_require__(25);
  1681. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1682. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1683. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1684. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  1685. };
  1686. /***/ }),
  1687. /* 38 */
  1688. /***/ (function(module, exports, __w_pdfjs_require__) {
  1689. var path = __w_pdfjs_require__(39);
  1690. var global = __w_pdfjs_require__(8);
  1691. var aFunction = function (variable) {
  1692. return typeof variable == 'function' ? variable : undefined;
  1693. };
  1694. module.exports = function (namespace, method) {
  1695. return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global[namespace]) : path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
  1696. };
  1697. /***/ }),
  1698. /* 39 */
  1699. /***/ (function(module, exports, __w_pdfjs_require__) {
  1700. module.exports = __w_pdfjs_require__(8);
  1701. /***/ }),
  1702. /* 40 */
  1703. /***/ (function(module, exports, __w_pdfjs_require__) {
  1704. var internalObjectKeys = __w_pdfjs_require__(41);
  1705. var enumBugKeys = __w_pdfjs_require__(46);
  1706. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1707. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1708. return internalObjectKeys(O, hiddenKeys);
  1709. };
  1710. /***/ }),
  1711. /* 41 */
  1712. /***/ (function(module, exports, __w_pdfjs_require__) {
  1713. var has = __w_pdfjs_require__(20);
  1714. var toIndexedObject = __w_pdfjs_require__(14);
  1715. var indexOf = __w_pdfjs_require__(42).indexOf;
  1716. var hiddenKeys = __w_pdfjs_require__(35);
  1717. module.exports = function (object, names) {
  1718. var O = toIndexedObject(object);
  1719. var i = 0;
  1720. var result = [];
  1721. var key;
  1722. for (key in O)
  1723. !has(hiddenKeys, key) && has(O, key) && result.push(key);
  1724. while (names.length > i)
  1725. if (has(O, key = names[i++])) {
  1726. ~indexOf(result, key) || result.push(key);
  1727. }
  1728. return result;
  1729. };
  1730. /***/ }),
  1731. /* 42 */
  1732. /***/ (function(module, exports, __w_pdfjs_require__) {
  1733. var toIndexedObject = __w_pdfjs_require__(14);
  1734. var toLength = __w_pdfjs_require__(43);
  1735. var toAbsoluteIndex = __w_pdfjs_require__(45);
  1736. var createMethod = function (IS_INCLUDES) {
  1737. return function ($this, el, fromIndex) {
  1738. var O = toIndexedObject($this);
  1739. var length = toLength(O.length);
  1740. var index = toAbsoluteIndex(fromIndex, length);
  1741. var value;
  1742. if (IS_INCLUDES && el != el)
  1743. while (length > index) {
  1744. value = O[index++];
  1745. if (value != value)
  1746. return true;
  1747. }
  1748. else
  1749. for (; length > index; index++) {
  1750. if ((IS_INCLUDES || index in O) && O[index] === el)
  1751. return IS_INCLUDES || index || 0;
  1752. }
  1753. return !IS_INCLUDES && -1;
  1754. };
  1755. };
  1756. module.exports = {
  1757. includes: createMethod(true),
  1758. indexOf: createMethod(false)
  1759. };
  1760. /***/ }),
  1761. /* 43 */
  1762. /***/ (function(module, exports, __w_pdfjs_require__) {
  1763. var toInteger = __w_pdfjs_require__(44);
  1764. var min = Math.min;
  1765. module.exports = function (argument) {
  1766. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0;
  1767. };
  1768. /***/ }),
  1769. /* 44 */
  1770. /***/ (function(module, exports) {
  1771. var ceil = Math.ceil;
  1772. var floor = Math.floor;
  1773. module.exports = function (argument) {
  1774. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  1775. };
  1776. /***/ }),
  1777. /* 45 */
  1778. /***/ (function(module, exports, __w_pdfjs_require__) {
  1779. var toInteger = __w_pdfjs_require__(44);
  1780. var max = Math.max;
  1781. var min = Math.min;
  1782. module.exports = function (index, length) {
  1783. var integer = toInteger(index);
  1784. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1785. };
  1786. /***/ }),
  1787. /* 46 */
  1788. /***/ (function(module, exports) {
  1789. module.exports = [
  1790. 'constructor',
  1791. 'hasOwnProperty',
  1792. 'isPrototypeOf',
  1793. 'propertyIsEnumerable',
  1794. 'toLocaleString',
  1795. 'toString',
  1796. 'valueOf'
  1797. ];
  1798. /***/ }),
  1799. /* 47 */
  1800. /***/ (function(module, exports) {
  1801. exports.f = Object.getOwnPropertySymbols;
  1802. /***/ }),
  1803. /* 48 */
  1804. /***/ (function(module, exports, __w_pdfjs_require__) {
  1805. var fails = __w_pdfjs_require__(11);
  1806. var replacement = /#|\.prototype\./;
  1807. var isForced = function (feature, detection) {
  1808. var value = data[normalize(feature)];
  1809. return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
  1810. };
  1811. var normalize = isForced.normalize = function (string) {
  1812. return String(string).replace(replacement, '.').toLowerCase();
  1813. };
  1814. var data = isForced.data = {};
  1815. var NATIVE = isForced.NATIVE = 'N';
  1816. var POLYFILL = isForced.POLYFILL = 'P';
  1817. module.exports = isForced;
  1818. /***/ }),
  1819. /* 49 */
  1820. /***/ (function(module, exports, __w_pdfjs_require__) {
  1821. var isRegExp = __w_pdfjs_require__(50);
  1822. module.exports = function (it) {
  1823. if (isRegExp(it)) {
  1824. throw TypeError("The method doesn't accept regular expressions");
  1825. }
  1826. return it;
  1827. };
  1828. /***/ }),
  1829. /* 50 */
  1830. /***/ (function(module, exports, __w_pdfjs_require__) {
  1831. var isObject = __w_pdfjs_require__(19);
  1832. var classof = __w_pdfjs_require__(16);
  1833. var wellKnownSymbol = __w_pdfjs_require__(51);
  1834. var MATCH = wellKnownSymbol('match');
  1835. module.exports = function (it) {
  1836. var isRegExp;
  1837. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
  1838. };
  1839. /***/ }),
  1840. /* 51 */
  1841. /***/ (function(module, exports, __w_pdfjs_require__) {
  1842. var global = __w_pdfjs_require__(8);
  1843. var shared = __w_pdfjs_require__(27);
  1844. var uid = __w_pdfjs_require__(34);
  1845. var NATIVE_SYMBOL = __w_pdfjs_require__(52);
  1846. var Symbol = global.Symbol;
  1847. var store = shared('wks');
  1848. module.exports = function (name) {
  1849. return store[name] || (store[name] = NATIVE_SYMBOL && Symbol[name] || (NATIVE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  1850. };
  1851. /***/ }),
  1852. /* 52 */
  1853. /***/ (function(module, exports, __w_pdfjs_require__) {
  1854. var fails = __w_pdfjs_require__(11);
  1855. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1856. return !String(Symbol());
  1857. });
  1858. /***/ }),
  1859. /* 53 */
  1860. /***/ (function(module, exports, __w_pdfjs_require__) {
  1861. var wellKnownSymbol = __w_pdfjs_require__(51);
  1862. var MATCH = wellKnownSymbol('match');
  1863. module.exports = function (METHOD_NAME) {
  1864. var regexp = /./;
  1865. try {
  1866. '/./'[METHOD_NAME](regexp);
  1867. } catch (e) {
  1868. try {
  1869. regexp[MATCH] = false;
  1870. return '/./'[METHOD_NAME](regexp);
  1871. } catch (f) {
  1872. }
  1873. }
  1874. return false;
  1875. };
  1876. /***/ }),
  1877. /* 54 */
  1878. /***/ (function(module, exports, __w_pdfjs_require__) {
  1879. var global = __w_pdfjs_require__(8);
  1880. var bind = __w_pdfjs_require__(55);
  1881. var call = Function.call;
  1882. module.exports = function (CONSTRUCTOR, METHOD, length) {
  1883. return bind(call, global[CONSTRUCTOR].prototype[METHOD], length);
  1884. };
  1885. /***/ }),
  1886. /* 55 */
  1887. /***/ (function(module, exports, __w_pdfjs_require__) {
  1888. var aFunction = __w_pdfjs_require__(56);
  1889. module.exports = function (fn, that, length) {
  1890. aFunction(fn);
  1891. if (that === undefined)
  1892. return fn;
  1893. switch (length) {
  1894. case 0:
  1895. return function () {
  1896. return fn.call(that);
  1897. };
  1898. case 1:
  1899. return function (a) {
  1900. return fn.call(that, a);
  1901. };
  1902. case 2:
  1903. return function (a, b) {
  1904. return fn.call(that, a, b);
  1905. };
  1906. case 3:
  1907. return function (a, b, c) {
  1908. return fn.call(that, a, b, c);
  1909. };
  1910. }
  1911. return function () {
  1912. return fn.apply(that, arguments);
  1913. };
  1914. };
  1915. /***/ }),
  1916. /* 56 */
  1917. /***/ (function(module, exports) {
  1918. module.exports = function (it) {
  1919. if (typeof it != 'function') {
  1920. throw TypeError(String(it) + ' is not a function');
  1921. }
  1922. return it;
  1923. };
  1924. /***/ }),
  1925. /* 57 */
  1926. /***/ (function(module, exports, __w_pdfjs_require__) {
  1927. __w_pdfjs_require__(58);
  1928. var entryUnbind = __w_pdfjs_require__(54);
  1929. module.exports = entryUnbind('String', 'endsWith');
  1930. /***/ }),
  1931. /* 58 */
  1932. /***/ (function(module, exports, __w_pdfjs_require__) {
  1933. "use strict";
  1934. var $ = __w_pdfjs_require__(7);
  1935. var toLength = __w_pdfjs_require__(43);
  1936. var notARegExp = __w_pdfjs_require__(49);
  1937. var requireObjectCoercible = __w_pdfjs_require__(17);
  1938. var correctIsRegExpLogic = __w_pdfjs_require__(53);
  1939. var nativeEndsWith = ''.endsWith;
  1940. var min = Math.min;
  1941. $({
  1942. target: 'String',
  1943. proto: true,
  1944. forced: !correctIsRegExpLogic('endsWith')
  1945. }, {
  1946. endsWith: function endsWith(searchString) {
  1947. var that = String(requireObjectCoercible(this));
  1948. notARegExp(searchString);
  1949. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  1950. var len = toLength(that.length);
  1951. var end = endPosition === undefined ? len : min(toLength(endPosition), len);
  1952. var search = String(searchString);
  1953. return nativeEndsWith ? nativeEndsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
  1954. }
  1955. });
  1956. /***/ }),
  1957. /* 59 */
  1958. /***/ (function(module, exports, __w_pdfjs_require__) {
  1959. __w_pdfjs_require__(60);
  1960. var entryUnbind = __w_pdfjs_require__(54);
  1961. module.exports = entryUnbind('String', 'includes');
  1962. /***/ }),
  1963. /* 60 */
  1964. /***/ (function(module, exports, __w_pdfjs_require__) {
  1965. "use strict";
  1966. var $ = __w_pdfjs_require__(7);
  1967. var notARegExp = __w_pdfjs_require__(49);
  1968. var requireObjectCoercible = __w_pdfjs_require__(17);
  1969. var correctIsRegExpLogic = __w_pdfjs_require__(53);
  1970. $({
  1971. target: 'String',
  1972. proto: true,
  1973. forced: !correctIsRegExpLogic('includes')
  1974. }, {
  1975. includes: function includes(searchString) {
  1976. return !!~String(requireObjectCoercible(this)).indexOf(notARegExp(searchString), arguments.length > 1 ? arguments[1] : undefined);
  1977. }
  1978. });
  1979. /***/ }),
  1980. /* 61 */
  1981. /***/ (function(module, exports, __w_pdfjs_require__) {
  1982. __w_pdfjs_require__(62);
  1983. var entryUnbind = __w_pdfjs_require__(54);
  1984. module.exports = entryUnbind('Array', 'includes');
  1985. /***/ }),
  1986. /* 62 */
  1987. /***/ (function(module, exports, __w_pdfjs_require__) {
  1988. "use strict";
  1989. var $ = __w_pdfjs_require__(7);
  1990. var $includes = __w_pdfjs_require__(42).includes;
  1991. var addToUnscopables = __w_pdfjs_require__(63);
  1992. $({
  1993. target: 'Array',
  1994. proto: true
  1995. }, {
  1996. includes: function includes(el) {
  1997. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  1998. }
  1999. });
  2000. addToUnscopables('includes');
  2001. /***/ }),
  2002. /* 63 */
  2003. /***/ (function(module, exports, __w_pdfjs_require__) {
  2004. var wellKnownSymbol = __w_pdfjs_require__(51);
  2005. var create = __w_pdfjs_require__(64);
  2006. var hide = __w_pdfjs_require__(23);
  2007. var UNSCOPABLES = wellKnownSymbol('unscopables');
  2008. var ArrayPrototype = Array.prototype;
  2009. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  2010. hide(ArrayPrototype, UNSCOPABLES, create(null));
  2011. }
  2012. module.exports = function (key) {
  2013. ArrayPrototype[UNSCOPABLES][key] = true;
  2014. };
  2015. /***/ }),
  2016. /* 64 */
  2017. /***/ (function(module, exports, __w_pdfjs_require__) {
  2018. var anObject = __w_pdfjs_require__(25);
  2019. var defineProperties = __w_pdfjs_require__(65);
  2020. var enumBugKeys = __w_pdfjs_require__(46);
  2021. var hiddenKeys = __w_pdfjs_require__(35);
  2022. var html = __w_pdfjs_require__(67);
  2023. var documentCreateElement = __w_pdfjs_require__(22);
  2024. var sharedKey = __w_pdfjs_require__(33);
  2025. var IE_PROTO = sharedKey('IE_PROTO');
  2026. var PROTOTYPE = 'prototype';
  2027. var Empty = function () {
  2028. };
  2029. var createDict = function () {
  2030. var iframe = documentCreateElement('iframe');
  2031. var length = enumBugKeys.length;
  2032. var lt = '<';
  2033. var script = 'script';
  2034. var gt = '>';
  2035. var js = 'java' + script + ':';
  2036. var iframeDocument;
  2037. iframe.style.display = 'none';
  2038. html.appendChild(iframe);
  2039. iframe.src = String(js);
  2040. iframeDocument = iframe.contentWindow.document;
  2041. iframeDocument.open();
  2042. iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  2043. iframeDocument.close();
  2044. createDict = iframeDocument.F;
  2045. while (length--)
  2046. delete createDict[PROTOTYPE][enumBugKeys[length]];
  2047. return createDict();
  2048. };
  2049. module.exports = Object.create || function create(O, Properties) {
  2050. var result;
  2051. if (O !== null) {
  2052. Empty[PROTOTYPE] = anObject(O);
  2053. result = new Empty();
  2054. Empty[PROTOTYPE] = null;
  2055. result[IE_PROTO] = O;
  2056. } else
  2057. result = createDict();
  2058. return Properties === undefined ? result : defineProperties(result, Properties);
  2059. };
  2060. hiddenKeys[IE_PROTO] = true;
  2061. /***/ }),
  2062. /* 65 */
  2063. /***/ (function(module, exports, __w_pdfjs_require__) {
  2064. var DESCRIPTORS = __w_pdfjs_require__(10);
  2065. var definePropertyModule = __w_pdfjs_require__(24);
  2066. var anObject = __w_pdfjs_require__(25);
  2067. var objectKeys = __w_pdfjs_require__(66);
  2068. module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  2069. anObject(O);
  2070. var keys = objectKeys(Properties);
  2071. var length = keys.length;
  2072. var index = 0;
  2073. var key;
  2074. while (length > index)
  2075. definePropertyModule.f(O, key = keys[index++], Properties[key]);
  2076. return O;
  2077. };
  2078. /***/ }),
  2079. /* 66 */
  2080. /***/ (function(module, exports, __w_pdfjs_require__) {
  2081. var internalObjectKeys = __w_pdfjs_require__(41);
  2082. var enumBugKeys = __w_pdfjs_require__(46);
  2083. module.exports = Object.keys || function keys(O) {
  2084. return internalObjectKeys(O, enumBugKeys);
  2085. };
  2086. /***/ }),
  2087. /* 67 */
  2088. /***/ (function(module, exports, __w_pdfjs_require__) {
  2089. var getBuiltIn = __w_pdfjs_require__(38);
  2090. module.exports = getBuiltIn('document', 'documentElement');
  2091. /***/ }),
  2092. /* 68 */
  2093. /***/ (function(module, exports, __w_pdfjs_require__) {
  2094. __w_pdfjs_require__(69);
  2095. __w_pdfjs_require__(81);
  2096. var path = __w_pdfjs_require__(39);
  2097. module.exports = path.Array.from;
  2098. /***/ }),
  2099. /* 69 */
  2100. /***/ (function(module, exports, __w_pdfjs_require__) {
  2101. "use strict";
  2102. var charAt = __w_pdfjs_require__(70).charAt;
  2103. var InternalStateModule = __w_pdfjs_require__(31);
  2104. var defineIterator = __w_pdfjs_require__(71);
  2105. var STRING_ITERATOR = 'String Iterator';
  2106. var setInternalState = InternalStateModule.set;
  2107. var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
  2108. defineIterator(String, 'String', function (iterated) {
  2109. setInternalState(this, {
  2110. type: STRING_ITERATOR,
  2111. string: String(iterated),
  2112. index: 0
  2113. });
  2114. }, function next() {
  2115. var state = getInternalState(this);
  2116. var string = state.string;
  2117. var index = state.index;
  2118. var point;
  2119. if (index >= string.length)
  2120. return {
  2121. value: undefined,
  2122. done: true
  2123. };
  2124. point = charAt(string, index);
  2125. state.index += point.length;
  2126. return {
  2127. value: point,
  2128. done: false
  2129. };
  2130. });
  2131. /***/ }),
  2132. /* 70 */
  2133. /***/ (function(module, exports, __w_pdfjs_require__) {
  2134. var toInteger = __w_pdfjs_require__(44);
  2135. var requireObjectCoercible = __w_pdfjs_require__(17);
  2136. var createMethod = function (CONVERT_TO_STRING) {
  2137. return function ($this, pos) {
  2138. var S = String(requireObjectCoercible($this));
  2139. var position = toInteger(pos);
  2140. var size = S.length;
  2141. var first, second;
  2142. if (position < 0 || position >= size)
  2143. return CONVERT_TO_STRING ? '' : undefined;
  2144. first = S.charCodeAt(position);
  2145. return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  2146. };
  2147. };
  2148. module.exports = {
  2149. codeAt: createMethod(false),
  2150. charAt: createMethod(true)
  2151. };
  2152. /***/ }),
  2153. /* 71 */
  2154. /***/ (function(module, exports, __w_pdfjs_require__) {
  2155. "use strict";
  2156. var $ = __w_pdfjs_require__(7);
  2157. var createIteratorConstructor = __w_pdfjs_require__(72);
  2158. var getPrototypeOf = __w_pdfjs_require__(74);
  2159. var setPrototypeOf = __w_pdfjs_require__(79);
  2160. var setToStringTag = __w_pdfjs_require__(77);
  2161. var hide = __w_pdfjs_require__(23);
  2162. var redefine = __w_pdfjs_require__(26);
  2163. var wellKnownSymbol = __w_pdfjs_require__(51);
  2164. var IS_PURE = __w_pdfjs_require__(29);
  2165. var Iterators = __w_pdfjs_require__(78);
  2166. var IteratorsCore = __w_pdfjs_require__(73);
  2167. var IteratorPrototype = IteratorsCore.IteratorPrototype;
  2168. var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
  2169. var ITERATOR = wellKnownSymbol('iterator');
  2170. var KEYS = 'keys';
  2171. var VALUES = 'values';
  2172. var ENTRIES = 'entries';
  2173. var returnThis = function () {
  2174. return this;
  2175. };
  2176. module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
  2177. createIteratorConstructor(IteratorConstructor, NAME, next);
  2178. var getIterationMethod = function (KIND) {
  2179. if (KIND === DEFAULT && defaultIterator)
  2180. return defaultIterator;
  2181. if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype)
  2182. return IterablePrototype[KIND];
  2183. switch (KIND) {
  2184. case KEYS:
  2185. return function keys() {
  2186. return new IteratorConstructor(this, KIND);
  2187. };
  2188. case VALUES:
  2189. return function values() {
  2190. return new IteratorConstructor(this, KIND);
  2191. };
  2192. case ENTRIES:
  2193. return function entries() {
  2194. return new IteratorConstructor(this, KIND);
  2195. };
  2196. }
  2197. return function () {
  2198. return new IteratorConstructor(this);
  2199. };
  2200. };
  2201. var TO_STRING_TAG = NAME + ' Iterator';
  2202. var INCORRECT_VALUES_NAME = false;
  2203. var IterablePrototype = Iterable.prototype;
  2204. var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
  2205. var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
  2206. var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
  2207. var CurrentIteratorPrototype, methods, KEY;
  2208. if (anyNativeIterator) {
  2209. CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
  2210. if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
  2211. if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
  2212. if (setPrototypeOf) {
  2213. setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
  2214. } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') {
  2215. hide(CurrentIteratorPrototype, ITERATOR, returnThis);
  2216. }
  2217. }
  2218. setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
  2219. if (IS_PURE)
  2220. Iterators[TO_STRING_TAG] = returnThis;
  2221. }
  2222. }
  2223. if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
  2224. INCORRECT_VALUES_NAME = true;
  2225. defaultIterator = function values() {
  2226. return nativeIterator.call(this);
  2227. };
  2228. }
  2229. if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
  2230. hide(IterablePrototype, ITERATOR, defaultIterator);
  2231. }
  2232. Iterators[NAME] = defaultIterator;
  2233. if (DEFAULT) {
  2234. methods = {
  2235. values: getIterationMethod(VALUES),
  2236. keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
  2237. entries: getIterationMethod(ENTRIES)
  2238. };
  2239. if (FORCED)
  2240. for (KEY in methods) {
  2241. if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
  2242. redefine(IterablePrototype, KEY, methods[KEY]);
  2243. }
  2244. }
  2245. else
  2246. $({
  2247. target: NAME,
  2248. proto: true,
  2249. forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
  2250. }, methods);
  2251. }
  2252. return methods;
  2253. };
  2254. /***/ }),
  2255. /* 72 */
  2256. /***/ (function(module, exports, __w_pdfjs_require__) {
  2257. "use strict";
  2258. var IteratorPrototype = __w_pdfjs_require__(73).IteratorPrototype;
  2259. var create = __w_pdfjs_require__(64);
  2260. var createPropertyDescriptor = __w_pdfjs_require__(13);
  2261. var setToStringTag = __w_pdfjs_require__(77);
  2262. var Iterators = __w_pdfjs_require__(78);
  2263. var returnThis = function () {
  2264. return this;
  2265. };
  2266. module.exports = function (IteratorConstructor, NAME, next) {
  2267. var TO_STRING_TAG = NAME + ' Iterator';
  2268. IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) });
  2269. setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
  2270. Iterators[TO_STRING_TAG] = returnThis;
  2271. return IteratorConstructor;
  2272. };
  2273. /***/ }),
  2274. /* 73 */
  2275. /***/ (function(module, exports, __w_pdfjs_require__) {
  2276. "use strict";
  2277. var getPrototypeOf = __w_pdfjs_require__(74);
  2278. var hide = __w_pdfjs_require__(23);
  2279. var has = __w_pdfjs_require__(20);
  2280. var wellKnownSymbol = __w_pdfjs_require__(51);
  2281. var IS_PURE = __w_pdfjs_require__(29);
  2282. var ITERATOR = wellKnownSymbol('iterator');
  2283. var BUGGY_SAFARI_ITERATORS = false;
  2284. var returnThis = function () {
  2285. return this;
  2286. };
  2287. var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
  2288. if ([].keys) {
  2289. arrayIterator = [].keys();
  2290. if (!('next' in arrayIterator))
  2291. BUGGY_SAFARI_ITERATORS = true;
  2292. else {
  2293. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  2294. if (PrototypeOfArrayIteratorPrototype !== Object.prototype)
  2295. IteratorPrototype = PrototypeOfArrayIteratorPrototype;
  2296. }
  2297. }
  2298. if (IteratorPrototype == undefined)
  2299. IteratorPrototype = {};
  2300. if (!IS_PURE && !has(IteratorPrototype, ITERATOR))
  2301. hide(IteratorPrototype, ITERATOR, returnThis);
  2302. module.exports = {
  2303. IteratorPrototype: IteratorPrototype,
  2304. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  2305. };
  2306. /***/ }),
  2307. /* 74 */
  2308. /***/ (function(module, exports, __w_pdfjs_require__) {
  2309. var has = __w_pdfjs_require__(20);
  2310. var toObject = __w_pdfjs_require__(75);
  2311. var sharedKey = __w_pdfjs_require__(33);
  2312. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(76);
  2313. var IE_PROTO = sharedKey('IE_PROTO');
  2314. var ObjectPrototype = Object.prototype;
  2315. module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  2316. O = toObject(O);
  2317. if (has(O, IE_PROTO))
  2318. return O[IE_PROTO];
  2319. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  2320. return O.constructor.prototype;
  2321. }
  2322. return O instanceof Object ? ObjectPrototype : null;
  2323. };
  2324. /***/ }),
  2325. /* 75 */
  2326. /***/ (function(module, exports, __w_pdfjs_require__) {
  2327. var requireObjectCoercible = __w_pdfjs_require__(17);
  2328. module.exports = function (argument) {
  2329. return Object(requireObjectCoercible(argument));
  2330. };
  2331. /***/ }),
  2332. /* 76 */
  2333. /***/ (function(module, exports, __w_pdfjs_require__) {
  2334. var fails = __w_pdfjs_require__(11);
  2335. module.exports = !fails(function () {
  2336. function F() {
  2337. }
  2338. F.prototype.constructor = null;
  2339. return Object.getPrototypeOf(new F()) !== F.prototype;
  2340. });
  2341. /***/ }),
  2342. /* 77 */
  2343. /***/ (function(module, exports, __w_pdfjs_require__) {
  2344. var defineProperty = __w_pdfjs_require__(24).f;
  2345. var has = __w_pdfjs_require__(20);
  2346. var wellKnownSymbol = __w_pdfjs_require__(51);
  2347. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2348. module.exports = function (it, TAG, STATIC) {
  2349. if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
  2350. defineProperty(it, TO_STRING_TAG, {
  2351. configurable: true,
  2352. value: TAG
  2353. });
  2354. }
  2355. };
  2356. /***/ }),
  2357. /* 78 */
  2358. /***/ (function(module, exports) {
  2359. module.exports = {};
  2360. /***/ }),
  2361. /* 79 */
  2362. /***/ (function(module, exports, __w_pdfjs_require__) {
  2363. var anObject = __w_pdfjs_require__(25);
  2364. var aPossiblePrototype = __w_pdfjs_require__(80);
  2365. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
  2366. var CORRECT_SETTER = false;
  2367. var test = {};
  2368. var setter;
  2369. try {
  2370. setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
  2371. setter.call(test, []);
  2372. CORRECT_SETTER = test instanceof Array;
  2373. } catch (error) {
  2374. }
  2375. return function setPrototypeOf(O, proto) {
  2376. anObject(O);
  2377. aPossiblePrototype(proto);
  2378. if (CORRECT_SETTER)
  2379. setter.call(O, proto);
  2380. else
  2381. O.__proto__ = proto;
  2382. return O;
  2383. };
  2384. }() : undefined);
  2385. /***/ }),
  2386. /* 80 */
  2387. /***/ (function(module, exports, __w_pdfjs_require__) {
  2388. var isObject = __w_pdfjs_require__(19);
  2389. module.exports = function (it) {
  2390. if (!isObject(it) && it !== null) {
  2391. throw TypeError("Can't set " + String(it) + ' as a prototype');
  2392. }
  2393. return it;
  2394. };
  2395. /***/ }),
  2396. /* 81 */
  2397. /***/ (function(module, exports, __w_pdfjs_require__) {
  2398. var $ = __w_pdfjs_require__(7);
  2399. var from = __w_pdfjs_require__(82);
  2400. var checkCorrectnessOfIteration = __w_pdfjs_require__(88);
  2401. var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
  2402. Array.from(iterable);
  2403. });
  2404. $({
  2405. target: 'Array',
  2406. stat: true,
  2407. forced: INCORRECT_ITERATION
  2408. }, { from: from });
  2409. /***/ }),
  2410. /* 82 */
  2411. /***/ (function(module, exports, __w_pdfjs_require__) {
  2412. "use strict";
  2413. var bind = __w_pdfjs_require__(55);
  2414. var toObject = __w_pdfjs_require__(75);
  2415. var callWithSafeIterationClosing = __w_pdfjs_require__(83);
  2416. var isArrayIteratorMethod = __w_pdfjs_require__(84);
  2417. var toLength = __w_pdfjs_require__(43);
  2418. var createProperty = __w_pdfjs_require__(85);
  2419. var getIteratorMethod = __w_pdfjs_require__(86);
  2420. module.exports = function from(arrayLike) {
  2421. var O = toObject(arrayLike);
  2422. var C = typeof this == 'function' ? this : Array;
  2423. var argumentsLength = arguments.length;
  2424. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  2425. var mapping = mapfn !== undefined;
  2426. var index = 0;
  2427. var iteratorMethod = getIteratorMethod(O);
  2428. var length, result, step, iterator;
  2429. if (mapping)
  2430. mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  2431. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  2432. iterator = iteratorMethod.call(O);
  2433. result = new C();
  2434. for (; !(step = iterator.next()).done; index++) {
  2435. createProperty(result, index, mapping ? callWithSafeIterationClosing(iterator, mapfn, [
  2436. step.value,
  2437. index
  2438. ], true) : step.value);
  2439. }
  2440. } else {
  2441. length = toLength(O.length);
  2442. result = new C(length);
  2443. for (; length > index; index++) {
  2444. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  2445. }
  2446. }
  2447. result.length = index;
  2448. return result;
  2449. };
  2450. /***/ }),
  2451. /* 83 */
  2452. /***/ (function(module, exports, __w_pdfjs_require__) {
  2453. var anObject = __w_pdfjs_require__(25);
  2454. module.exports = function (iterator, fn, value, ENTRIES) {
  2455. try {
  2456. return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
  2457. } catch (error) {
  2458. var returnMethod = iterator['return'];
  2459. if (returnMethod !== undefined)
  2460. anObject(returnMethod.call(iterator));
  2461. throw error;
  2462. }
  2463. };
  2464. /***/ }),
  2465. /* 84 */
  2466. /***/ (function(module, exports, __w_pdfjs_require__) {
  2467. var wellKnownSymbol = __w_pdfjs_require__(51);
  2468. var Iterators = __w_pdfjs_require__(78);
  2469. var ITERATOR = wellKnownSymbol('iterator');
  2470. var ArrayPrototype = Array.prototype;
  2471. module.exports = function (it) {
  2472. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  2473. };
  2474. /***/ }),
  2475. /* 85 */
  2476. /***/ (function(module, exports, __w_pdfjs_require__) {
  2477. "use strict";
  2478. var toPrimitive = __w_pdfjs_require__(18);
  2479. var definePropertyModule = __w_pdfjs_require__(24);
  2480. var createPropertyDescriptor = __w_pdfjs_require__(13);
  2481. module.exports = function (object, key, value) {
  2482. var propertyKey = toPrimitive(key);
  2483. if (propertyKey in object)
  2484. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  2485. else
  2486. object[propertyKey] = value;
  2487. };
  2488. /***/ }),
  2489. /* 86 */
  2490. /***/ (function(module, exports, __w_pdfjs_require__) {
  2491. var classof = __w_pdfjs_require__(87);
  2492. var Iterators = __w_pdfjs_require__(78);
  2493. var wellKnownSymbol = __w_pdfjs_require__(51);
  2494. var ITERATOR = wellKnownSymbol('iterator');
  2495. module.exports = function (it) {
  2496. if (it != undefined)
  2497. return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2498. };
  2499. /***/ }),
  2500. /* 87 */
  2501. /***/ (function(module, exports, __w_pdfjs_require__) {
  2502. var classofRaw = __w_pdfjs_require__(16);
  2503. var wellKnownSymbol = __w_pdfjs_require__(51);
  2504. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2505. var CORRECT_ARGUMENTS = classofRaw(function () {
  2506. return arguments;
  2507. }()) == 'Arguments';
  2508. var tryGet = function (it, key) {
  2509. try {
  2510. return it[key];
  2511. } catch (error) {
  2512. }
  2513. };
  2514. module.exports = function (it) {
  2515. var O, tag, result;
  2516. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  2517. };
  2518. /***/ }),
  2519. /* 88 */
  2520. /***/ (function(module, exports, __w_pdfjs_require__) {
  2521. var wellKnownSymbol = __w_pdfjs_require__(51);
  2522. var ITERATOR = wellKnownSymbol('iterator');
  2523. var SAFE_CLOSING = false;
  2524. try {
  2525. var called = 0;
  2526. var iteratorWithReturn = {
  2527. next: function () {
  2528. return { done: !!called++ };
  2529. },
  2530. 'return': function () {
  2531. SAFE_CLOSING = true;
  2532. }
  2533. };
  2534. iteratorWithReturn[ITERATOR] = function () {
  2535. return this;
  2536. };
  2537. Array.from(iteratorWithReturn, function () {
  2538. throw 2;
  2539. });
  2540. } catch (error) {
  2541. }
  2542. module.exports = function (exec, SKIP_CLOSING) {
  2543. if (!SKIP_CLOSING && !SAFE_CLOSING)
  2544. return false;
  2545. var ITERATION_SUPPORT = false;
  2546. try {
  2547. var object = {};
  2548. object[ITERATOR] = function () {
  2549. return {
  2550. next: function () {
  2551. return { done: ITERATION_SUPPORT = true };
  2552. }
  2553. };
  2554. };
  2555. exec(object);
  2556. } catch (error) {
  2557. }
  2558. return ITERATION_SUPPORT;
  2559. };
  2560. /***/ }),
  2561. /* 89 */
  2562. /***/ (function(module, exports, __w_pdfjs_require__) {
  2563. __w_pdfjs_require__(90);
  2564. var path = __w_pdfjs_require__(39);
  2565. module.exports = path.Object.assign;
  2566. /***/ }),
  2567. /* 90 */
  2568. /***/ (function(module, exports, __w_pdfjs_require__) {
  2569. var $ = __w_pdfjs_require__(7);
  2570. var assign = __w_pdfjs_require__(91);
  2571. $({
  2572. target: 'Object',
  2573. stat: true,
  2574. forced: Object.assign !== assign
  2575. }, { assign: assign });
  2576. /***/ }),
  2577. /* 91 */
  2578. /***/ (function(module, exports, __w_pdfjs_require__) {
  2579. "use strict";
  2580. var DESCRIPTORS = __w_pdfjs_require__(10);
  2581. var fails = __w_pdfjs_require__(11);
  2582. var objectKeys = __w_pdfjs_require__(66);
  2583. var getOwnPropertySymbolsModule = __w_pdfjs_require__(47);
  2584. var propertyIsEnumerableModule = __w_pdfjs_require__(12);
  2585. var toObject = __w_pdfjs_require__(75);
  2586. var IndexedObject = __w_pdfjs_require__(15);
  2587. var nativeAssign = Object.assign;
  2588. module.exports = !nativeAssign || fails(function () {
  2589. var A = {};
  2590. var B = {};
  2591. var symbol = Symbol();
  2592. var alphabet = 'abcdefghijklmnopqrst';
  2593. A[symbol] = 7;
  2594. alphabet.split('').forEach(function (chr) {
  2595. B[chr] = chr;
  2596. });
  2597. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  2598. }) ? function assign(target, source) {
  2599. var T = toObject(target);
  2600. var argumentsLength = arguments.length;
  2601. var index = 1;
  2602. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  2603. var propertyIsEnumerable = propertyIsEnumerableModule.f;
  2604. while (argumentsLength > index) {
  2605. var S = IndexedObject(arguments[index++]);
  2606. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  2607. var length = keys.length;
  2608. var j = 0;
  2609. var key;
  2610. while (length > j) {
  2611. key = keys[j++];
  2612. if (!DESCRIPTORS || propertyIsEnumerable.call(S, key))
  2613. T[key] = S[key];
  2614. }
  2615. }
  2616. return T;
  2617. } : nativeAssign;
  2618. /***/ }),
  2619. /* 92 */
  2620. /***/ (function(module, exports, __w_pdfjs_require__) {
  2621. __w_pdfjs_require__(93);
  2622. var path = __w_pdfjs_require__(39);
  2623. module.exports = path.Math.log2;
  2624. /***/ }),
  2625. /* 93 */
  2626. /***/ (function(module, exports, __w_pdfjs_require__) {
  2627. var $ = __w_pdfjs_require__(7);
  2628. var log = Math.log;
  2629. var LN2 = Math.LN2;
  2630. $({
  2631. target: 'Math',
  2632. stat: true
  2633. }, {
  2634. log2: function log2(x) {
  2635. return log(x) / LN2;
  2636. }
  2637. });
  2638. /***/ }),
  2639. /* 94 */
  2640. /***/ (function(module, exports, __w_pdfjs_require__) {
  2641. __w_pdfjs_require__(95);
  2642. var path = __w_pdfjs_require__(39);
  2643. module.exports = path.Number.isNaN;
  2644. /***/ }),
  2645. /* 95 */
  2646. /***/ (function(module, exports, __w_pdfjs_require__) {
  2647. var $ = __w_pdfjs_require__(7);
  2648. $({
  2649. target: 'Number',
  2650. stat: true
  2651. }, {
  2652. isNaN: function isNaN(number) {
  2653. return number != number;
  2654. }
  2655. });
  2656. /***/ }),
  2657. /* 96 */
  2658. /***/ (function(module, exports, __w_pdfjs_require__) {
  2659. __w_pdfjs_require__(97);
  2660. var path = __w_pdfjs_require__(39);
  2661. module.exports = path.Number.isInteger;
  2662. /***/ }),
  2663. /* 97 */
  2664. /***/ (function(module, exports, __w_pdfjs_require__) {
  2665. var $ = __w_pdfjs_require__(7);
  2666. var isInteger = __w_pdfjs_require__(98);
  2667. $({
  2668. target: 'Number',
  2669. stat: true
  2670. }, { isInteger: isInteger });
  2671. /***/ }),
  2672. /* 98 */
  2673. /***/ (function(module, exports, __w_pdfjs_require__) {
  2674. var isObject = __w_pdfjs_require__(19);
  2675. var floor = Math.floor;
  2676. module.exports = function isInteger(it) {
  2677. return !isObject(it) && isFinite(it) && floor(it) === it;
  2678. };
  2679. /***/ }),
  2680. /* 99 */
  2681. /***/ (function(module, exports, __w_pdfjs_require__) {
  2682. __w_pdfjs_require__(100);
  2683. __w_pdfjs_require__(69);
  2684. __w_pdfjs_require__(102);
  2685. __w_pdfjs_require__(105);
  2686. __w_pdfjs_require__(119);
  2687. __w_pdfjs_require__(120);
  2688. var path = __w_pdfjs_require__(39);
  2689. module.exports = path.Promise;
  2690. /***/ }),
  2691. /* 100 */
  2692. /***/ (function(module, exports, __w_pdfjs_require__) {
  2693. var redefine = __w_pdfjs_require__(26);
  2694. var toString = __w_pdfjs_require__(101);
  2695. var ObjectPrototype = Object.prototype;
  2696. if (toString !== ObjectPrototype.toString) {
  2697. redefine(ObjectPrototype, 'toString', toString, { unsafe: true });
  2698. }
  2699. /***/ }),
  2700. /* 101 */
  2701. /***/ (function(module, exports, __w_pdfjs_require__) {
  2702. "use strict";
  2703. var classof = __w_pdfjs_require__(87);
  2704. var wellKnownSymbol = __w_pdfjs_require__(51);
  2705. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2706. var test = {};
  2707. test[TO_STRING_TAG] = 'z';
  2708. module.exports = String(test) !== '[object z]' ? function toString() {
  2709. return '[object ' + classof(this) + ']';
  2710. } : test.toString;
  2711. /***/ }),
  2712. /* 102 */
  2713. /***/ (function(module, exports, __w_pdfjs_require__) {
  2714. var global = __w_pdfjs_require__(8);
  2715. var DOMIterables = __w_pdfjs_require__(103);
  2716. var ArrayIteratorMethods = __w_pdfjs_require__(104);
  2717. var hide = __w_pdfjs_require__(23);
  2718. var wellKnownSymbol = __w_pdfjs_require__(51);
  2719. var ITERATOR = wellKnownSymbol('iterator');
  2720. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2721. var ArrayValues = ArrayIteratorMethods.values;
  2722. for (var COLLECTION_NAME in DOMIterables) {
  2723. var Collection = global[COLLECTION_NAME];
  2724. var CollectionPrototype = Collection && Collection.prototype;
  2725. if (CollectionPrototype) {
  2726. if (CollectionPrototype[ITERATOR] !== ArrayValues)
  2727. try {
  2728. hide(CollectionPrototype, ITERATOR, ArrayValues);
  2729. } catch (error) {
  2730. CollectionPrototype[ITERATOR] = ArrayValues;
  2731. }
  2732. if (!CollectionPrototype[TO_STRING_TAG])
  2733. hide(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
  2734. if (DOMIterables[COLLECTION_NAME])
  2735. for (var METHOD_NAME in ArrayIteratorMethods) {
  2736. if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME])
  2737. try {
  2738. hide(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
  2739. } catch (error) {
  2740. CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
  2741. }
  2742. }
  2743. }
  2744. }
  2745. /***/ }),
  2746. /* 103 */
  2747. /***/ (function(module, exports) {
  2748. module.exports = {
  2749. CSSRuleList: 0,
  2750. CSSStyleDeclaration: 0,
  2751. CSSValueList: 0,
  2752. ClientRectList: 0,
  2753. DOMRectList: 0,
  2754. DOMStringList: 0,
  2755. DOMTokenList: 1,
  2756. DataTransferItemList: 0,
  2757. FileList: 0,
  2758. HTMLAllCollection: 0,
  2759. HTMLCollection: 0,
  2760. HTMLFormElement: 0,
  2761. HTMLSelectElement: 0,
  2762. MediaList: 0,
  2763. MimeTypeArray: 0,
  2764. NamedNodeMap: 0,
  2765. NodeList: 1,
  2766. PaintRequestList: 0,
  2767. Plugin: 0,
  2768. PluginArray: 0,
  2769. SVGLengthList: 0,
  2770. SVGNumberList: 0,
  2771. SVGPathSegList: 0,
  2772. SVGPointList: 0,
  2773. SVGStringList: 0,
  2774. SVGTransformList: 0,
  2775. SourceBufferList: 0,
  2776. StyleSheetList: 0,
  2777. TextTrackCueList: 0,
  2778. TextTrackList: 0,
  2779. TouchList: 0
  2780. };
  2781. /***/ }),
  2782. /* 104 */
  2783. /***/ (function(module, exports, __w_pdfjs_require__) {
  2784. "use strict";
  2785. var toIndexedObject = __w_pdfjs_require__(14);
  2786. var addToUnscopables = __w_pdfjs_require__(63);
  2787. var Iterators = __w_pdfjs_require__(78);
  2788. var InternalStateModule = __w_pdfjs_require__(31);
  2789. var defineIterator = __w_pdfjs_require__(71);
  2790. var ARRAY_ITERATOR = 'Array Iterator';
  2791. var setInternalState = InternalStateModule.set;
  2792. var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
  2793. module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
  2794. setInternalState(this, {
  2795. type: ARRAY_ITERATOR,
  2796. target: toIndexedObject(iterated),
  2797. index: 0,
  2798. kind: kind
  2799. });
  2800. }, function () {
  2801. var state = getInternalState(this);
  2802. var target = state.target;
  2803. var kind = state.kind;
  2804. var index = state.index++;
  2805. if (!target || index >= target.length) {
  2806. state.target = undefined;
  2807. return {
  2808. value: undefined,
  2809. done: true
  2810. };
  2811. }
  2812. if (kind == 'keys')
  2813. return {
  2814. value: index,
  2815. done: false
  2816. };
  2817. if (kind == 'values')
  2818. return {
  2819. value: target[index],
  2820. done: false
  2821. };
  2822. return {
  2823. value: [
  2824. index,
  2825. target[index]
  2826. ],
  2827. done: false
  2828. };
  2829. }, 'values');
  2830. Iterators.Arguments = Iterators.Array;
  2831. addToUnscopables('keys');
  2832. addToUnscopables('values');
  2833. addToUnscopables('entries');
  2834. /***/ }),
  2835. /* 105 */
  2836. /***/ (function(module, exports, __w_pdfjs_require__) {
  2837. "use strict";
  2838. var $ = __w_pdfjs_require__(7);
  2839. var IS_PURE = __w_pdfjs_require__(29);
  2840. var global = __w_pdfjs_require__(8);
  2841. var path = __w_pdfjs_require__(39);
  2842. var NativePromise = __w_pdfjs_require__(106);
  2843. var redefine = __w_pdfjs_require__(26);
  2844. var redefineAll = __w_pdfjs_require__(107);
  2845. var setToStringTag = __w_pdfjs_require__(77);
  2846. var setSpecies = __w_pdfjs_require__(108);
  2847. var isObject = __w_pdfjs_require__(19);
  2848. var aFunction = __w_pdfjs_require__(56);
  2849. var anInstance = __w_pdfjs_require__(109);
  2850. var classof = __w_pdfjs_require__(16);
  2851. var iterate = __w_pdfjs_require__(110);
  2852. var checkCorrectnessOfIteration = __w_pdfjs_require__(88);
  2853. var speciesConstructor = __w_pdfjs_require__(111);
  2854. var task = __w_pdfjs_require__(112).set;
  2855. var microtask = __w_pdfjs_require__(113);
  2856. var promiseResolve = __w_pdfjs_require__(115);
  2857. var hostReportErrors = __w_pdfjs_require__(117);
  2858. var newPromiseCapabilityModule = __w_pdfjs_require__(116);
  2859. var perform = __w_pdfjs_require__(118);
  2860. var userAgent = __w_pdfjs_require__(114);
  2861. var InternalStateModule = __w_pdfjs_require__(31);
  2862. var isForced = __w_pdfjs_require__(48);
  2863. var wellKnownSymbol = __w_pdfjs_require__(51);
  2864. var SPECIES = wellKnownSymbol('species');
  2865. var PROMISE = 'Promise';
  2866. var getInternalState = InternalStateModule.get;
  2867. var setInternalState = InternalStateModule.set;
  2868. var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
  2869. var PromiseConstructor = NativePromise;
  2870. var TypeError = global.TypeError;
  2871. var document = global.document;
  2872. var process = global.process;
  2873. var $fetch = global.fetch;
  2874. var versions = process && process.versions;
  2875. var v8 = versions && versions.v8 || '';
  2876. var newPromiseCapability = newPromiseCapabilityModule.f;
  2877. var newGenericPromiseCapability = newPromiseCapability;
  2878. var IS_NODE = classof(process) == 'process';
  2879. var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
  2880. var UNHANDLED_REJECTION = 'unhandledrejection';
  2881. var REJECTION_HANDLED = 'rejectionhandled';
  2882. var PENDING = 0;
  2883. var FULFILLED = 1;
  2884. var REJECTED = 2;
  2885. var HANDLED = 1;
  2886. var UNHANDLED = 2;
  2887. var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
  2888. var FORCED = isForced(PROMISE, function () {
  2889. var promise = PromiseConstructor.resolve(1);
  2890. var empty = function () {
  2891. };
  2892. var FakePromise = (promise.constructor = {})[SPECIES] = function (exec) {
  2893. exec(empty, empty);
  2894. };
  2895. return !((IS_NODE || typeof PromiseRejectionEvent == 'function') && (!IS_PURE || promise['finally']) && promise.then(empty) instanceof FakePromise && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1);
  2896. });
  2897. var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
  2898. PromiseConstructor.all(iterable)['catch'](function () {
  2899. });
  2900. });
  2901. var isThenable = function (it) {
  2902. var then;
  2903. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  2904. };
  2905. var notify = function (promise, state, isReject) {
  2906. if (state.notified)
  2907. return;
  2908. state.notified = true;
  2909. var chain = state.reactions;
  2910. microtask(function () {
  2911. var value = state.value;
  2912. var ok = state.state == FULFILLED;
  2913. var index = 0;
  2914. while (chain.length > index) {
  2915. var reaction = chain[index++];
  2916. var handler = ok ? reaction.ok : reaction.fail;
  2917. var resolve = reaction.resolve;
  2918. var reject = reaction.reject;
  2919. var domain = reaction.domain;
  2920. var result, then, exited;
  2921. try {
  2922. if (handler) {
  2923. if (!ok) {
  2924. if (state.rejection === UNHANDLED)
  2925. onHandleUnhandled(promise, state);
  2926. state.rejection = HANDLED;
  2927. }
  2928. if (handler === true)
  2929. result = value;
  2930. else {
  2931. if (domain)
  2932. domain.enter();
  2933. result = handler(value);
  2934. if (domain) {
  2935. domain.exit();
  2936. exited = true;
  2937. }
  2938. }
  2939. if (result === reaction.promise) {
  2940. reject(TypeError('Promise-chain cycle'));
  2941. } else if (then = isThenable(result)) {
  2942. then.call(result, resolve, reject);
  2943. } else
  2944. resolve(result);
  2945. } else
  2946. reject(value);
  2947. } catch (error) {
  2948. if (domain && !exited)
  2949. domain.exit();
  2950. reject(error);
  2951. }
  2952. }
  2953. state.reactions = [];
  2954. state.notified = false;
  2955. if (isReject && !state.rejection)
  2956. onUnhandled(promise, state);
  2957. });
  2958. };
  2959. var dispatchEvent = function (name, promise, reason) {
  2960. var event, handler;
  2961. if (DISPATCH_EVENT) {
  2962. event = document.createEvent('Event');
  2963. event.promise = promise;
  2964. event.reason = reason;
  2965. event.initEvent(name, false, true);
  2966. global.dispatchEvent(event);
  2967. } else
  2968. event = {
  2969. promise: promise,
  2970. reason: reason
  2971. };
  2972. if (handler = global['on' + name])
  2973. handler(event);
  2974. else if (name === UNHANDLED_REJECTION)
  2975. hostReportErrors('Unhandled promise rejection', reason);
  2976. };
  2977. var onUnhandled = function (promise, state) {
  2978. task.call(global, function () {
  2979. var value = state.value;
  2980. var IS_UNHANDLED = isUnhandled(state);
  2981. var result;
  2982. if (IS_UNHANDLED) {
  2983. result = perform(function () {
  2984. if (IS_NODE) {
  2985. process.emit('unhandledRejection', value, promise);
  2986. } else
  2987. dispatchEvent(UNHANDLED_REJECTION, promise, value);
  2988. });
  2989. state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
  2990. if (result.error)
  2991. throw result.value;
  2992. }
  2993. });
  2994. };
  2995. var isUnhandled = function (state) {
  2996. return state.rejection !== HANDLED && !state.parent;
  2997. };
  2998. var onHandleUnhandled = function (promise, state) {
  2999. task.call(global, function () {
  3000. if (IS_NODE) {
  3001. process.emit('rejectionHandled', promise);
  3002. } else
  3003. dispatchEvent(REJECTION_HANDLED, promise, state.value);
  3004. });
  3005. };
  3006. var bind = function (fn, promise, state, unwrap) {
  3007. return function (value) {
  3008. fn(promise, state, value, unwrap);
  3009. };
  3010. };
  3011. var internalReject = function (promise, state, value, unwrap) {
  3012. if (state.done)
  3013. return;
  3014. state.done = true;
  3015. if (unwrap)
  3016. state = unwrap;
  3017. state.value = value;
  3018. state.state = REJECTED;
  3019. notify(promise, state, true);
  3020. };
  3021. var internalResolve = function (promise, state, value, unwrap) {
  3022. if (state.done)
  3023. return;
  3024. state.done = true;
  3025. if (unwrap)
  3026. state = unwrap;
  3027. try {
  3028. if (promise === value)
  3029. throw TypeError("Promise can't be resolved itself");
  3030. var then = isThenable(value);
  3031. if (then) {
  3032. microtask(function () {
  3033. var wrapper = { done: false };
  3034. try {
  3035. then.call(value, bind(internalResolve, promise, wrapper, state), bind(internalReject, promise, wrapper, state));
  3036. } catch (error) {
  3037. internalReject(promise, wrapper, error, state);
  3038. }
  3039. });
  3040. } else {
  3041. state.value = value;
  3042. state.state = FULFILLED;
  3043. notify(promise, state, false);
  3044. }
  3045. } catch (error) {
  3046. internalReject(promise, { done: false }, error, state);
  3047. }
  3048. };
  3049. if (FORCED) {
  3050. PromiseConstructor = function Promise(executor) {
  3051. anInstance(this, PromiseConstructor, PROMISE);
  3052. aFunction(executor);
  3053. Internal.call(this);
  3054. var state = getInternalState(this);
  3055. try {
  3056. executor(bind(internalResolve, this, state), bind(internalReject, this, state));
  3057. } catch (error) {
  3058. internalReject(this, state, error);
  3059. }
  3060. };
  3061. Internal = function Promise(executor) {
  3062. setInternalState(this, {
  3063. type: PROMISE,
  3064. done: false,
  3065. notified: false,
  3066. parent: false,
  3067. reactions: [],
  3068. rejection: false,
  3069. state: PENDING,
  3070. value: undefined
  3071. });
  3072. };
  3073. Internal.prototype = redefineAll(PromiseConstructor.prototype, {
  3074. then: function then(onFulfilled, onRejected) {
  3075. var state = getInternalPromiseState(this);
  3076. var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
  3077. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  3078. reaction.fail = typeof onRejected == 'function' && onRejected;
  3079. reaction.domain = IS_NODE ? process.domain : undefined;
  3080. state.parent = true;
  3081. state.reactions.push(reaction);
  3082. if (state.state != PENDING)
  3083. notify(this, state, false);
  3084. return reaction.promise;
  3085. },
  3086. 'catch': function (onRejected) {
  3087. return this.then(undefined, onRejected);
  3088. }
  3089. });
  3090. OwnPromiseCapability = function () {
  3091. var promise = new Internal();
  3092. var state = getInternalState(promise);
  3093. this.promise = promise;
  3094. this.resolve = bind(internalResolve, promise, state);
  3095. this.reject = bind(internalReject, promise, state);
  3096. };
  3097. newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
  3098. return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  3099. };
  3100. if (!IS_PURE && typeof NativePromise == 'function') {
  3101. nativeThen = NativePromise.prototype.then;
  3102. redefine(NativePromise.prototype, 'then', function then(onFulfilled, onRejected) {
  3103. var that = this;
  3104. return new PromiseConstructor(function (resolve, reject) {
  3105. nativeThen.call(that, resolve, reject);
  3106. }).then(onFulfilled, onRejected);
  3107. });
  3108. if (typeof $fetch == 'function')
  3109. $({
  3110. global: true,
  3111. enumerable: true,
  3112. forced: true
  3113. }, {
  3114. fetch: function fetch(input) {
  3115. return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
  3116. }
  3117. });
  3118. }
  3119. }
  3120. $({
  3121. global: true,
  3122. wrap: true,
  3123. forced: FORCED
  3124. }, { Promise: PromiseConstructor });
  3125. setToStringTag(PromiseConstructor, PROMISE, false, true);
  3126. setSpecies(PROMISE);
  3127. PromiseWrapper = path[PROMISE];
  3128. $({
  3129. target: PROMISE,
  3130. stat: true,
  3131. forced: FORCED
  3132. }, {
  3133. reject: function reject(r) {
  3134. var capability = newPromiseCapability(this);
  3135. capability.reject.call(undefined, r);
  3136. return capability.promise;
  3137. }
  3138. });
  3139. $({
  3140. target: PROMISE,
  3141. stat: true,
  3142. forced: IS_PURE || FORCED
  3143. }, {
  3144. resolve: function resolve(x) {
  3145. return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
  3146. }
  3147. });
  3148. $({
  3149. target: PROMISE,
  3150. stat: true,
  3151. forced: INCORRECT_ITERATION
  3152. }, {
  3153. all: function all(iterable) {
  3154. var C = this;
  3155. var capability = newPromiseCapability(C);
  3156. var resolve = capability.resolve;
  3157. var reject = capability.reject;
  3158. var result = perform(function () {
  3159. var $promiseResolve = aFunction(C.resolve);
  3160. var values = [];
  3161. var counter = 0;
  3162. var remaining = 1;
  3163. iterate(iterable, function (promise) {
  3164. var index = counter++;
  3165. var alreadyCalled = false;
  3166. values.push(undefined);
  3167. remaining++;
  3168. $promiseResolve.call(C, promise).then(function (value) {
  3169. if (alreadyCalled)
  3170. return;
  3171. alreadyCalled = true;
  3172. values[index] = value;
  3173. --remaining || resolve(values);
  3174. }, reject);
  3175. });
  3176. --remaining || resolve(values);
  3177. });
  3178. if (result.error)
  3179. reject(result.value);
  3180. return capability.promise;
  3181. },
  3182. race: function race(iterable) {
  3183. var C = this;
  3184. var capability = newPromiseCapability(C);
  3185. var reject = capability.reject;
  3186. var result = perform(function () {
  3187. var $promiseResolve = aFunction(C.resolve);
  3188. iterate(iterable, function (promise) {
  3189. $promiseResolve.call(C, promise).then(capability.resolve, reject);
  3190. });
  3191. });
  3192. if (result.error)
  3193. reject(result.value);
  3194. return capability.promise;
  3195. }
  3196. });
  3197. /***/ }),
  3198. /* 106 */
  3199. /***/ (function(module, exports, __w_pdfjs_require__) {
  3200. var global = __w_pdfjs_require__(8);
  3201. module.exports = global.Promise;
  3202. /***/ }),
  3203. /* 107 */
  3204. /***/ (function(module, exports, __w_pdfjs_require__) {
  3205. var redefine = __w_pdfjs_require__(26);
  3206. module.exports = function (target, src, options) {
  3207. for (var key in src)
  3208. redefine(target, key, src[key], options);
  3209. return target;
  3210. };
  3211. /***/ }),
  3212. /* 108 */
  3213. /***/ (function(module, exports, __w_pdfjs_require__) {
  3214. "use strict";
  3215. var getBuiltIn = __w_pdfjs_require__(38);
  3216. var definePropertyModule = __w_pdfjs_require__(24);
  3217. var wellKnownSymbol = __w_pdfjs_require__(51);
  3218. var DESCRIPTORS = __w_pdfjs_require__(10);
  3219. var SPECIES = wellKnownSymbol('species');
  3220. module.exports = function (CONSTRUCTOR_NAME) {
  3221. var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
  3222. var defineProperty = definePropertyModule.f;
  3223. if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
  3224. defineProperty(Constructor, SPECIES, {
  3225. configurable: true,
  3226. get: function () {
  3227. return this;
  3228. }
  3229. });
  3230. }
  3231. };
  3232. /***/ }),
  3233. /* 109 */
  3234. /***/ (function(module, exports) {
  3235. module.exports = function (it, Constructor, name) {
  3236. if (!(it instanceof Constructor)) {
  3237. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  3238. }
  3239. return it;
  3240. };
  3241. /***/ }),
  3242. /* 110 */
  3243. /***/ (function(module, exports, __w_pdfjs_require__) {
  3244. var anObject = __w_pdfjs_require__(25);
  3245. var isArrayIteratorMethod = __w_pdfjs_require__(84);
  3246. var toLength = __w_pdfjs_require__(43);
  3247. var bind = __w_pdfjs_require__(55);
  3248. var getIteratorMethod = __w_pdfjs_require__(86);
  3249. var callWithSafeIterationClosing = __w_pdfjs_require__(83);
  3250. var Result = function (stopped, result) {
  3251. this.stopped = stopped;
  3252. this.result = result;
  3253. };
  3254. var iterate = module.exports = function (iterable, fn, that, AS_ENTRIES, IS_ITERATOR) {
  3255. var boundFunction = bind(fn, that, AS_ENTRIES ? 2 : 1);
  3256. var iterator, iterFn, index, length, result, step;
  3257. if (IS_ITERATOR) {
  3258. iterator = iterable;
  3259. } else {
  3260. iterFn = getIteratorMethod(iterable);
  3261. if (typeof iterFn != 'function')
  3262. throw TypeError('Target is not iterable');
  3263. if (isArrayIteratorMethod(iterFn)) {
  3264. for (index = 0, length = toLength(iterable.length); length > index; index++) {
  3265. result = AS_ENTRIES ? boundFunction(anObject(step = iterable[index])[0], step[1]) : boundFunction(iterable[index]);
  3266. if (result && result instanceof Result)
  3267. return result;
  3268. }
  3269. return new Result(false);
  3270. }
  3271. iterator = iterFn.call(iterable);
  3272. }
  3273. while (!(step = iterator.next()).done) {
  3274. result = callWithSafeIterationClosing(iterator, boundFunction, step.value, AS_ENTRIES);
  3275. if (result && result instanceof Result)
  3276. return result;
  3277. }
  3278. return new Result(false);
  3279. };
  3280. iterate.stop = function (result) {
  3281. return new Result(true, result);
  3282. };
  3283. /***/ }),
  3284. /* 111 */
  3285. /***/ (function(module, exports, __w_pdfjs_require__) {
  3286. var anObject = __w_pdfjs_require__(25);
  3287. var aFunction = __w_pdfjs_require__(56);
  3288. var wellKnownSymbol = __w_pdfjs_require__(51);
  3289. var SPECIES = wellKnownSymbol('species');
  3290. module.exports = function (O, defaultConstructor) {
  3291. var C = anObject(O).constructor;
  3292. var S;
  3293. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S);
  3294. };
  3295. /***/ }),
  3296. /* 112 */
  3297. /***/ (function(module, exports, __w_pdfjs_require__) {
  3298. var global = __w_pdfjs_require__(8);
  3299. var fails = __w_pdfjs_require__(11);
  3300. var classof = __w_pdfjs_require__(16);
  3301. var bind = __w_pdfjs_require__(55);
  3302. var html = __w_pdfjs_require__(67);
  3303. var createElement = __w_pdfjs_require__(22);
  3304. var location = global.location;
  3305. var set = global.setImmediate;
  3306. var clear = global.clearImmediate;
  3307. var process = global.process;
  3308. var MessageChannel = global.MessageChannel;
  3309. var Dispatch = global.Dispatch;
  3310. var counter = 0;
  3311. var queue = {};
  3312. var ONREADYSTATECHANGE = 'onreadystatechange';
  3313. var defer, channel, port;
  3314. var run = function (id) {
  3315. if (queue.hasOwnProperty(id)) {
  3316. var fn = queue[id];
  3317. delete queue[id];
  3318. fn();
  3319. }
  3320. };
  3321. var runner = function (id) {
  3322. return function () {
  3323. run(id);
  3324. };
  3325. };
  3326. var listener = function (event) {
  3327. run(event.data);
  3328. };
  3329. var post = function (id) {
  3330. global.postMessage(id + '', location.protocol + '//' + location.host);
  3331. };
  3332. if (!set || !clear) {
  3333. set = function setImmediate(fn) {
  3334. var args = [];
  3335. var i = 1;
  3336. while (arguments.length > i)
  3337. args.push(arguments[i++]);
  3338. queue[++counter] = function () {
  3339. (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args);
  3340. };
  3341. defer(counter);
  3342. return counter;
  3343. };
  3344. clear = function clearImmediate(id) {
  3345. delete queue[id];
  3346. };
  3347. if (classof(process) == 'process') {
  3348. defer = function (id) {
  3349. process.nextTick(runner(id));
  3350. };
  3351. } else if (Dispatch && Dispatch.now) {
  3352. defer = function (id) {
  3353. Dispatch.now(runner(id));
  3354. };
  3355. } else if (MessageChannel) {
  3356. channel = new MessageChannel();
  3357. port = channel.port2;
  3358. channel.port1.onmessage = listener;
  3359. defer = bind(port.postMessage, port, 1);
  3360. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts && !fails(post)) {
  3361. defer = post;
  3362. global.addEventListener('message', listener, false);
  3363. } else if (ONREADYSTATECHANGE in createElement('script')) {
  3364. defer = function (id) {
  3365. html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
  3366. html.removeChild(this);
  3367. run(id);
  3368. };
  3369. };
  3370. } else {
  3371. defer = function (id) {
  3372. setTimeout(runner(id), 0);
  3373. };
  3374. }
  3375. }
  3376. module.exports = {
  3377. set: set,
  3378. clear: clear
  3379. };
  3380. /***/ }),
  3381. /* 113 */
  3382. /***/ (function(module, exports, __w_pdfjs_require__) {
  3383. var global = __w_pdfjs_require__(8);
  3384. var getOwnPropertyDescriptor = __w_pdfjs_require__(9).f;
  3385. var classof = __w_pdfjs_require__(16);
  3386. var macrotask = __w_pdfjs_require__(112).set;
  3387. var userAgent = __w_pdfjs_require__(114);
  3388. var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
  3389. var process = global.process;
  3390. var Promise = global.Promise;
  3391. var IS_NODE = classof(process) == 'process';
  3392. var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
  3393. var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
  3394. var flush, head, last, notify, toggle, node, promise, then;
  3395. if (!queueMicrotask) {
  3396. flush = function () {
  3397. var parent, fn;
  3398. if (IS_NODE && (parent = process.domain))
  3399. parent.exit();
  3400. while (head) {
  3401. fn = head.fn;
  3402. head = head.next;
  3403. try {
  3404. fn();
  3405. } catch (error) {
  3406. if (head)
  3407. notify();
  3408. else
  3409. last = undefined;
  3410. throw error;
  3411. }
  3412. }
  3413. last = undefined;
  3414. if (parent)
  3415. parent.enter();
  3416. };
  3417. if (IS_NODE) {
  3418. notify = function () {
  3419. process.nextTick(flush);
  3420. };
  3421. } else if (MutationObserver && !/(iphone|ipod|ipad).*applewebkit/i.test(userAgent)) {
  3422. toggle = true;
  3423. node = document.createTextNode('');
  3424. new MutationObserver(flush).observe(node, { characterData: true });
  3425. notify = function () {
  3426. node.data = toggle = !toggle;
  3427. };
  3428. } else if (Promise && Promise.resolve) {
  3429. promise = Promise.resolve(undefined);
  3430. then = promise.then;
  3431. notify = function () {
  3432. then.call(promise, flush);
  3433. };
  3434. } else {
  3435. notify = function () {
  3436. macrotask.call(global, flush);
  3437. };
  3438. }
  3439. }
  3440. module.exports = queueMicrotask || function (fn) {
  3441. var task = {
  3442. fn: fn,
  3443. next: undefined
  3444. };
  3445. if (last)
  3446. last.next = task;
  3447. if (!head) {
  3448. head = task;
  3449. notify();
  3450. }
  3451. last = task;
  3452. };
  3453. /***/ }),
  3454. /* 114 */
  3455. /***/ (function(module, exports, __w_pdfjs_require__) {
  3456. var getBuiltIn = __w_pdfjs_require__(38);
  3457. module.exports = getBuiltIn('navigator', 'userAgent') || '';
  3458. /***/ }),
  3459. /* 115 */
  3460. /***/ (function(module, exports, __w_pdfjs_require__) {
  3461. var anObject = __w_pdfjs_require__(25);
  3462. var isObject = __w_pdfjs_require__(19);
  3463. var newPromiseCapability = __w_pdfjs_require__(116);
  3464. module.exports = function (C, x) {
  3465. anObject(C);
  3466. if (isObject(x) && x.constructor === C)
  3467. return x;
  3468. var promiseCapability = newPromiseCapability.f(C);
  3469. var resolve = promiseCapability.resolve;
  3470. resolve(x);
  3471. return promiseCapability.promise;
  3472. };
  3473. /***/ }),
  3474. /* 116 */
  3475. /***/ (function(module, exports, __w_pdfjs_require__) {
  3476. "use strict";
  3477. var aFunction = __w_pdfjs_require__(56);
  3478. var PromiseCapability = function (C) {
  3479. var resolve, reject;
  3480. this.promise = new C(function ($$resolve, $$reject) {
  3481. if (resolve !== undefined || reject !== undefined)
  3482. throw TypeError('Bad Promise constructor');
  3483. resolve = $$resolve;
  3484. reject = $$reject;
  3485. });
  3486. this.resolve = aFunction(resolve);
  3487. this.reject = aFunction(reject);
  3488. };
  3489. module.exports.f = function (C) {
  3490. return new PromiseCapability(C);
  3491. };
  3492. /***/ }),
  3493. /* 117 */
  3494. /***/ (function(module, exports, __w_pdfjs_require__) {
  3495. var global = __w_pdfjs_require__(8);
  3496. module.exports = function (a, b) {
  3497. var console = global.console;
  3498. if (console && console.error) {
  3499. arguments.length === 1 ? console.error(a) : console.error(a, b);
  3500. }
  3501. };
  3502. /***/ }),
  3503. /* 118 */
  3504. /***/ (function(module, exports) {
  3505. module.exports = function (exec) {
  3506. try {
  3507. return {
  3508. error: false,
  3509. value: exec()
  3510. };
  3511. } catch (error) {
  3512. return {
  3513. error: true,
  3514. value: error
  3515. };
  3516. }
  3517. };
  3518. /***/ }),
  3519. /* 119 */
  3520. /***/ (function(module, exports, __w_pdfjs_require__) {
  3521. "use strict";
  3522. var $ = __w_pdfjs_require__(7);
  3523. var aFunction = __w_pdfjs_require__(56);
  3524. var newPromiseCapabilityModule = __w_pdfjs_require__(116);
  3525. var perform = __w_pdfjs_require__(118);
  3526. var iterate = __w_pdfjs_require__(110);
  3527. $({
  3528. target: 'Promise',
  3529. stat: true
  3530. }, {
  3531. allSettled: function allSettled(iterable) {
  3532. var C = this;
  3533. var capability = newPromiseCapabilityModule.f(C);
  3534. var resolve = capability.resolve;
  3535. var reject = capability.reject;
  3536. var result = perform(function () {
  3537. var promiseResolve = aFunction(C.resolve);
  3538. var values = [];
  3539. var counter = 0;
  3540. var remaining = 1;
  3541. iterate(iterable, function (promise) {
  3542. var index = counter++;
  3543. var alreadyCalled = false;
  3544. values.push(undefined);
  3545. remaining++;
  3546. promiseResolve.call(C, promise).then(function (value) {
  3547. if (alreadyCalled)
  3548. return;
  3549. alreadyCalled = true;
  3550. values[index] = {
  3551. status: 'fulfilled',
  3552. value: value
  3553. };
  3554. --remaining || resolve(values);
  3555. }, function (e) {
  3556. if (alreadyCalled)
  3557. return;
  3558. alreadyCalled = true;
  3559. values[index] = {
  3560. status: 'rejected',
  3561. reason: e
  3562. };
  3563. --remaining || resolve(values);
  3564. });
  3565. });
  3566. --remaining || resolve(values);
  3567. });
  3568. if (result.error)
  3569. reject(result.value);
  3570. return capability.promise;
  3571. }
  3572. });
  3573. /***/ }),
  3574. /* 120 */
  3575. /***/ (function(module, exports, __w_pdfjs_require__) {
  3576. "use strict";
  3577. var $ = __w_pdfjs_require__(7);
  3578. var IS_PURE = __w_pdfjs_require__(29);
  3579. var NativePromise = __w_pdfjs_require__(106);
  3580. var getBuiltIn = __w_pdfjs_require__(38);
  3581. var speciesConstructor = __w_pdfjs_require__(111);
  3582. var promiseResolve = __w_pdfjs_require__(115);
  3583. var redefine = __w_pdfjs_require__(26);
  3584. $({
  3585. target: 'Promise',
  3586. proto: true,
  3587. real: true
  3588. }, {
  3589. 'finally': function (onFinally) {
  3590. var C = speciesConstructor(this, getBuiltIn('Promise'));
  3591. var isFunction = typeof onFinally == 'function';
  3592. return this.then(isFunction ? function (x) {
  3593. return promiseResolve(C, onFinally()).then(function () {
  3594. return x;
  3595. });
  3596. } : onFinally, isFunction ? function (e) {
  3597. return promiseResolve(C, onFinally()).then(function () {
  3598. throw e;
  3599. });
  3600. } : onFinally);
  3601. }
  3602. });
  3603. if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
  3604. redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
  3605. }
  3606. /***/ }),
  3607. /* 121 */
  3608. /***/ (function(module, exports, __w_pdfjs_require__) {
  3609. __w_pdfjs_require__(122);
  3610. __w_pdfjs_require__(127);
  3611. __w_pdfjs_require__(125);
  3612. var path = __w_pdfjs_require__(39);
  3613. module.exports = path.URL;
  3614. /***/ }),
  3615. /* 122 */
  3616. /***/ (function(module, exports, __w_pdfjs_require__) {
  3617. "use strict";
  3618. __w_pdfjs_require__(69);
  3619. var $ = __w_pdfjs_require__(7);
  3620. var DESCRIPTORS = __w_pdfjs_require__(10);
  3621. var USE_NATIVE_URL = __w_pdfjs_require__(123);
  3622. var global = __w_pdfjs_require__(8);
  3623. var defineProperties = __w_pdfjs_require__(65);
  3624. var redefine = __w_pdfjs_require__(26);
  3625. var anInstance = __w_pdfjs_require__(109);
  3626. var has = __w_pdfjs_require__(20);
  3627. var assign = __w_pdfjs_require__(91);
  3628. var arrayFrom = __w_pdfjs_require__(82);
  3629. var codeAt = __w_pdfjs_require__(70).codeAt;
  3630. var toASCII = __w_pdfjs_require__(124);
  3631. var setToStringTag = __w_pdfjs_require__(77);
  3632. var URLSearchParamsModule = __w_pdfjs_require__(125);
  3633. var InternalStateModule = __w_pdfjs_require__(31);
  3634. var NativeURL = global.URL;
  3635. var URLSearchParams = URLSearchParamsModule.URLSearchParams;
  3636. var getInternalSearchParamsState = URLSearchParamsModule.getState;
  3637. var setInternalState = InternalStateModule.set;
  3638. var getInternalURLState = InternalStateModule.getterFor('URL');
  3639. var floor = Math.floor;
  3640. var pow = Math.pow;
  3641. var INVALID_AUTHORITY = 'Invalid authority';
  3642. var INVALID_SCHEME = 'Invalid scheme';
  3643. var INVALID_HOST = 'Invalid host';
  3644. var INVALID_PORT = 'Invalid port';
  3645. var ALPHA = /[A-Za-z]/;
  3646. var ALPHANUMERIC = /[\d+\-.A-Za-z]/;
  3647. var DIGIT = /\d/;
  3648. var HEX_START = /^(0x|0X)/;
  3649. var OCT = /^[0-7]+$/;
  3650. var DEC = /^\d+$/;
  3651. var HEX = /^[\dA-Fa-f]+$/;
  3652. var FORBIDDEN_HOST_CODE_POINT = /[\u0000\u0009\u000A\u000D #%/:?@[\\]]/;
  3653. var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\u0000\u0009\u000A\u000D #/:?@[\\]]/;
  3654. var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g;
  3655. var TAB_AND_NEW_LINE = /[\u0009\u000A\u000D]/g;
  3656. var EOF;
  3657. var parseHost = function (url, input) {
  3658. var result, codePoints, index;
  3659. if (input.charAt(0) == '[') {
  3660. if (input.charAt(input.length - 1) != ']')
  3661. return INVALID_HOST;
  3662. result = parseIPv6(input.slice(1, -1));
  3663. if (!result)
  3664. return INVALID_HOST;
  3665. url.host = result;
  3666. } else if (!isSpecial(url)) {
  3667. if (FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT.test(input))
  3668. return INVALID_HOST;
  3669. result = '';
  3670. codePoints = arrayFrom(input);
  3671. for (index = 0; index < codePoints.length; index++) {
  3672. result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
  3673. }
  3674. url.host = result;
  3675. } else {
  3676. input = toASCII(input);
  3677. if (FORBIDDEN_HOST_CODE_POINT.test(input))
  3678. return INVALID_HOST;
  3679. result = parseIPv4(input);
  3680. if (result === null)
  3681. return INVALID_HOST;
  3682. url.host = result;
  3683. }
  3684. };
  3685. var parseIPv4 = function (input) {
  3686. var parts = input.split('.');
  3687. var partsLength, numbers, index, part, radix, number, ipv4;
  3688. if (parts.length && parts[parts.length - 1] == '') {
  3689. parts.pop();
  3690. }
  3691. partsLength = parts.length;
  3692. if (partsLength > 4)
  3693. return input;
  3694. numbers = [];
  3695. for (index = 0; index < partsLength; index++) {
  3696. part = parts[index];
  3697. if (part == '')
  3698. return input;
  3699. radix = 10;
  3700. if (part.length > 1 && part.charAt(0) == '0') {
  3701. radix = HEX_START.test(part) ? 16 : 8;
  3702. part = part.slice(radix == 8 ? 1 : 2);
  3703. }
  3704. if (part === '') {
  3705. number = 0;
  3706. } else {
  3707. if (!(radix == 10 ? DEC : radix == 8 ? OCT : HEX).test(part))
  3708. return input;
  3709. number = parseInt(part, radix);
  3710. }
  3711. numbers.push(number);
  3712. }
  3713. for (index = 0; index < partsLength; index++) {
  3714. number = numbers[index];
  3715. if (index == partsLength - 1) {
  3716. if (number >= pow(256, 5 - partsLength))
  3717. return null;
  3718. } else if (number > 255)
  3719. return null;
  3720. }
  3721. ipv4 = numbers.pop();
  3722. for (index = 0; index < numbers.length; index++) {
  3723. ipv4 += numbers[index] * pow(256, 3 - index);
  3724. }
  3725. return ipv4;
  3726. };
  3727. var parseIPv6 = function (input) {
  3728. var address = [
  3729. 0,
  3730. 0,
  3731. 0,
  3732. 0,
  3733. 0,
  3734. 0,
  3735. 0,
  3736. 0
  3737. ];
  3738. var pieceIndex = 0;
  3739. var compress = null;
  3740. var pointer = 0;
  3741. var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
  3742. var char = function () {
  3743. return input.charAt(pointer);
  3744. };
  3745. if (char() == ':') {
  3746. if (input.charAt(1) != ':')
  3747. return;
  3748. pointer += 2;
  3749. pieceIndex++;
  3750. compress = pieceIndex;
  3751. }
  3752. while (char()) {
  3753. if (pieceIndex == 8)
  3754. return;
  3755. if (char() == ':') {
  3756. if (compress !== null)
  3757. return;
  3758. pointer++;
  3759. pieceIndex++;
  3760. compress = pieceIndex;
  3761. continue;
  3762. }
  3763. value = length = 0;
  3764. while (length < 4 && HEX.test(char())) {
  3765. value = value * 16 + parseInt(char(), 16);
  3766. pointer++;
  3767. length++;
  3768. }
  3769. if (char() == '.') {
  3770. if (length == 0)
  3771. return;
  3772. pointer -= length;
  3773. if (pieceIndex > 6)
  3774. return;
  3775. numbersSeen = 0;
  3776. while (char()) {
  3777. ipv4Piece = null;
  3778. if (numbersSeen > 0) {
  3779. if (char() == '.' && numbersSeen < 4)
  3780. pointer++;
  3781. else
  3782. return;
  3783. }
  3784. if (!DIGIT.test(char()))
  3785. return;
  3786. while (DIGIT.test(char())) {
  3787. number = parseInt(char(), 10);
  3788. if (ipv4Piece === null)
  3789. ipv4Piece = number;
  3790. else if (ipv4Piece == 0)
  3791. return;
  3792. else
  3793. ipv4Piece = ipv4Piece * 10 + number;
  3794. if (ipv4Piece > 255)
  3795. return;
  3796. pointer++;
  3797. }
  3798. address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
  3799. numbersSeen++;
  3800. if (numbersSeen == 2 || numbersSeen == 4)
  3801. pieceIndex++;
  3802. }
  3803. if (numbersSeen != 4)
  3804. return;
  3805. break;
  3806. } else if (char() == ':') {
  3807. pointer++;
  3808. if (!char())
  3809. return;
  3810. } else if (char())
  3811. return;
  3812. address[pieceIndex++] = value;
  3813. }
  3814. if (compress !== null) {
  3815. swaps = pieceIndex - compress;
  3816. pieceIndex = 7;
  3817. while (pieceIndex != 0 && swaps > 0) {
  3818. swap = address[pieceIndex];
  3819. address[pieceIndex--] = address[compress + swaps - 1];
  3820. address[compress + --swaps] = swap;
  3821. }
  3822. } else if (pieceIndex != 8)
  3823. return;
  3824. return address;
  3825. };
  3826. var findLongestZeroSequence = function (ipv6) {
  3827. var maxIndex = null;
  3828. var maxLength = 1;
  3829. var currStart = null;
  3830. var currLength = 0;
  3831. var index = 0;
  3832. for (; index < 8; index++) {
  3833. if (ipv6[index] !== 0) {
  3834. if (currLength > maxLength) {
  3835. maxIndex = currStart;
  3836. maxLength = currLength;
  3837. }
  3838. currStart = null;
  3839. currLength = 0;
  3840. } else {
  3841. if (currStart === null)
  3842. currStart = index;
  3843. ++currLength;
  3844. }
  3845. }
  3846. if (currLength > maxLength) {
  3847. maxIndex = currStart;
  3848. maxLength = currLength;
  3849. }
  3850. return maxIndex;
  3851. };
  3852. var serializeHost = function (host) {
  3853. var result, index, compress, ignore0;
  3854. if (typeof host == 'number') {
  3855. result = [];
  3856. for (index = 0; index < 4; index++) {
  3857. result.unshift(host % 256);
  3858. host = floor(host / 256);
  3859. }
  3860. return result.join('.');
  3861. } else if (typeof host == 'object') {
  3862. result = '';
  3863. compress = findLongestZeroSequence(host);
  3864. for (index = 0; index < 8; index++) {
  3865. if (ignore0 && host[index] === 0)
  3866. continue;
  3867. if (ignore0)
  3868. ignore0 = false;
  3869. if (compress === index) {
  3870. result += index ? ':' : '::';
  3871. ignore0 = true;
  3872. } else {
  3873. result += host[index].toString(16);
  3874. if (index < 7)
  3875. result += ':';
  3876. }
  3877. }
  3878. return '[' + result + ']';
  3879. }
  3880. return host;
  3881. };
  3882. var C0ControlPercentEncodeSet = {};
  3883. var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
  3884. ' ': 1,
  3885. '"': 1,
  3886. '<': 1,
  3887. '>': 1,
  3888. '`': 1
  3889. });
  3890. var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
  3891. '#': 1,
  3892. '?': 1,
  3893. '{': 1,
  3894. '}': 1
  3895. });
  3896. var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
  3897. '/': 1,
  3898. ':': 1,
  3899. ';': 1,
  3900. '=': 1,
  3901. '@': 1,
  3902. '[': 1,
  3903. '\\': 1,
  3904. ']': 1,
  3905. '^': 1,
  3906. '|': 1
  3907. });
  3908. var percentEncode = function (char, set) {
  3909. var code = codeAt(char, 0);
  3910. return code > 0x20 && code < 0x7F && !has(set, char) ? char : encodeURIComponent(char);
  3911. };
  3912. var specialSchemes = {
  3913. ftp: 21,
  3914. file: null,
  3915. gopher: 70,
  3916. http: 80,
  3917. https: 443,
  3918. ws: 80,
  3919. wss: 443
  3920. };
  3921. var isSpecial = function (url) {
  3922. return has(specialSchemes, url.scheme);
  3923. };
  3924. var includesCredentials = function (url) {
  3925. return url.username != '' || url.password != '';
  3926. };
  3927. var cannotHaveUsernamePasswordPort = function (url) {
  3928. return !url.host || url.cannotBeABaseURL || url.scheme == 'file';
  3929. };
  3930. var isWindowsDriveLetter = function (string, normalized) {
  3931. var second;
  3932. return string.length == 2 && ALPHA.test(string.charAt(0)) && ((second = string.charAt(1)) == ':' || !normalized && second == '|');
  3933. };
  3934. var startsWithWindowsDriveLetter = function (string) {
  3935. var third;
  3936. return string.length > 1 && isWindowsDriveLetter(string.slice(0, 2)) && (string.length == 2 || ((third = string.charAt(2)) === '/' || third === '\\' || third === '?' || third === '#'));
  3937. };
  3938. var shortenURLsPath = function (url) {
  3939. var path = url.path;
  3940. var pathSize = path.length;
  3941. if (pathSize && (url.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
  3942. path.pop();
  3943. }
  3944. };
  3945. var isSingleDot = function (segment) {
  3946. return segment === '.' || segment.toLowerCase() === '%2e';
  3947. };
  3948. var isDoubleDot = function (segment) {
  3949. segment = segment.toLowerCase();
  3950. return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
  3951. };
  3952. var SCHEME_START = {};
  3953. var SCHEME = {};
  3954. var NO_SCHEME = {};
  3955. var SPECIAL_RELATIVE_OR_AUTHORITY = {};
  3956. var PATH_OR_AUTHORITY = {};
  3957. var RELATIVE = {};
  3958. var RELATIVE_SLASH = {};
  3959. var SPECIAL_AUTHORITY_SLASHES = {};
  3960. var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
  3961. var AUTHORITY = {};
  3962. var HOST = {};
  3963. var HOSTNAME = {};
  3964. var PORT = {};
  3965. var FILE = {};
  3966. var FILE_SLASH = {};
  3967. var FILE_HOST = {};
  3968. var PATH_START = {};
  3969. var PATH = {};
  3970. var CANNOT_BE_A_BASE_URL_PATH = {};
  3971. var QUERY = {};
  3972. var FRAGMENT = {};
  3973. var parseURL = function (url, input, stateOverride, base) {
  3974. var state = stateOverride || SCHEME_START;
  3975. var pointer = 0;
  3976. var buffer = '';
  3977. var seenAt = false;
  3978. var seenBracket = false;
  3979. var seenPasswordToken = false;
  3980. var codePoints, char, bufferCodePoints, failure;
  3981. if (!stateOverride) {
  3982. url.scheme = '';
  3983. url.username = '';
  3984. url.password = '';
  3985. url.host = null;
  3986. url.port = null;
  3987. url.path = [];
  3988. url.query = null;
  3989. url.fragment = null;
  3990. url.cannotBeABaseURL = false;
  3991. input = input.replace(LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
  3992. }
  3993. input = input.replace(TAB_AND_NEW_LINE, '');
  3994. codePoints = arrayFrom(input);
  3995. while (pointer <= codePoints.length) {
  3996. char = codePoints[pointer];
  3997. switch (state) {
  3998. case SCHEME_START:
  3999. if (char && ALPHA.test(char)) {
  4000. buffer += char.toLowerCase();
  4001. state = SCHEME;
  4002. } else if (!stateOverride) {
  4003. state = NO_SCHEME;
  4004. continue;
  4005. } else
  4006. return INVALID_SCHEME;
  4007. break;
  4008. case SCHEME:
  4009. if (char && (ALPHANUMERIC.test(char) || char == '+' || char == '-' || char == '.')) {
  4010. buffer += char.toLowerCase();
  4011. } else if (char == ':') {
  4012. if (stateOverride && (isSpecial(url) != has(specialSchemes, buffer) || buffer == 'file' && (includesCredentials(url) || url.port !== null) || url.scheme == 'file' && !url.host))
  4013. return;
  4014. url.scheme = buffer;
  4015. if (stateOverride) {
  4016. if (isSpecial(url) && specialSchemes[url.scheme] == url.port)
  4017. url.port = null;
  4018. return;
  4019. }
  4020. buffer = '';
  4021. if (url.scheme == 'file') {
  4022. state = FILE;
  4023. } else if (isSpecial(url) && base && base.scheme == url.scheme) {
  4024. state = SPECIAL_RELATIVE_OR_AUTHORITY;
  4025. } else if (isSpecial(url)) {
  4026. state = SPECIAL_AUTHORITY_SLASHES;
  4027. } else if (codePoints[pointer + 1] == '/') {
  4028. state = PATH_OR_AUTHORITY;
  4029. pointer++;
  4030. } else {
  4031. url.cannotBeABaseURL = true;
  4032. url.path.push('');
  4033. state = CANNOT_BE_A_BASE_URL_PATH;
  4034. }
  4035. } else if (!stateOverride) {
  4036. buffer = '';
  4037. state = NO_SCHEME;
  4038. pointer = 0;
  4039. continue;
  4040. } else
  4041. return INVALID_SCHEME;
  4042. break;
  4043. case NO_SCHEME:
  4044. if (!base || base.cannotBeABaseURL && char != '#')
  4045. return INVALID_SCHEME;
  4046. if (base.cannotBeABaseURL && char == '#') {
  4047. url.scheme = base.scheme;
  4048. url.path = base.path.slice();
  4049. url.query = base.query;
  4050. url.fragment = '';
  4051. url.cannotBeABaseURL = true;
  4052. state = FRAGMENT;
  4053. break;
  4054. }
  4055. state = base.scheme == 'file' ? FILE : RELATIVE;
  4056. continue;
  4057. case SPECIAL_RELATIVE_OR_AUTHORITY:
  4058. if (char == '/' && codePoints[pointer + 1] == '/') {
  4059. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  4060. pointer++;
  4061. } else {
  4062. state = RELATIVE;
  4063. continue;
  4064. }
  4065. break;
  4066. case PATH_OR_AUTHORITY:
  4067. if (char == '/') {
  4068. state = AUTHORITY;
  4069. break;
  4070. } else {
  4071. state = PATH;
  4072. continue;
  4073. }
  4074. case RELATIVE:
  4075. url.scheme = base.scheme;
  4076. if (char == EOF) {
  4077. url.username = base.username;
  4078. url.password = base.password;
  4079. url.host = base.host;
  4080. url.port = base.port;
  4081. url.path = base.path.slice();
  4082. url.query = base.query;
  4083. } else if (char == '/' || char == '\\' && isSpecial(url)) {
  4084. state = RELATIVE_SLASH;
  4085. } else if (char == '?') {
  4086. url.username = base.username;
  4087. url.password = base.password;
  4088. url.host = base.host;
  4089. url.port = base.port;
  4090. url.path = base.path.slice();
  4091. url.query = '';
  4092. state = QUERY;
  4093. } else if (char == '#') {
  4094. url.username = base.username;
  4095. url.password = base.password;
  4096. url.host = base.host;
  4097. url.port = base.port;
  4098. url.path = base.path.slice();
  4099. url.query = base.query;
  4100. url.fragment = '';
  4101. state = FRAGMENT;
  4102. } else {
  4103. url.username = base.username;
  4104. url.password = base.password;
  4105. url.host = base.host;
  4106. url.port = base.port;
  4107. url.path = base.path.slice();
  4108. url.path.pop();
  4109. state = PATH;
  4110. continue;
  4111. }
  4112. break;
  4113. case RELATIVE_SLASH:
  4114. if (isSpecial(url) && (char == '/' || char == '\\')) {
  4115. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  4116. } else if (char == '/') {
  4117. state = AUTHORITY;
  4118. } else {
  4119. url.username = base.username;
  4120. url.password = base.password;
  4121. url.host = base.host;
  4122. url.port = base.port;
  4123. state = PATH;
  4124. continue;
  4125. }
  4126. break;
  4127. case SPECIAL_AUTHORITY_SLASHES:
  4128. state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
  4129. if (char != '/' || buffer.charAt(pointer + 1) != '/')
  4130. continue;
  4131. pointer++;
  4132. break;
  4133. case SPECIAL_AUTHORITY_IGNORE_SLASHES:
  4134. if (char != '/' && char != '\\') {
  4135. state = AUTHORITY;
  4136. continue;
  4137. }
  4138. break;
  4139. case AUTHORITY:
  4140. if (char == '@') {
  4141. if (seenAt)
  4142. buffer = '%40' + buffer;
  4143. seenAt = true;
  4144. bufferCodePoints = arrayFrom(buffer);
  4145. for (var i = 0; i < bufferCodePoints.length; i++) {
  4146. var codePoint = bufferCodePoints[i];
  4147. if (codePoint == ':' && !seenPasswordToken) {
  4148. seenPasswordToken = true;
  4149. continue;
  4150. }
  4151. var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
  4152. if (seenPasswordToken)
  4153. url.password += encodedCodePoints;
  4154. else
  4155. url.username += encodedCodePoints;
  4156. }
  4157. buffer = '';
  4158. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  4159. if (seenAt && buffer == '')
  4160. return INVALID_AUTHORITY;
  4161. pointer -= arrayFrom(buffer).length + 1;
  4162. buffer = '';
  4163. state = HOST;
  4164. } else
  4165. buffer += char;
  4166. break;
  4167. case HOST:
  4168. case HOSTNAME:
  4169. if (stateOverride && url.scheme == 'file') {
  4170. state = FILE_HOST;
  4171. continue;
  4172. } else if (char == ':' && !seenBracket) {
  4173. if (buffer == '')
  4174. return INVALID_HOST;
  4175. failure = parseHost(url, buffer);
  4176. if (failure)
  4177. return failure;
  4178. buffer = '';
  4179. state = PORT;
  4180. if (stateOverride == HOSTNAME)
  4181. return;
  4182. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url)) {
  4183. if (isSpecial(url) && buffer == '')
  4184. return INVALID_HOST;
  4185. if (stateOverride && buffer == '' && (includesCredentials(url) || url.port !== null))
  4186. return;
  4187. failure = parseHost(url, buffer);
  4188. if (failure)
  4189. return failure;
  4190. buffer = '';
  4191. state = PATH_START;
  4192. if (stateOverride)
  4193. return;
  4194. continue;
  4195. } else {
  4196. if (char == '[')
  4197. seenBracket = true;
  4198. else if (char == ']')
  4199. seenBracket = false;
  4200. buffer += char;
  4201. }
  4202. break;
  4203. case PORT:
  4204. if (DIGIT.test(char)) {
  4205. buffer += char;
  4206. } else if (char == EOF || char == '/' || char == '?' || char == '#' || char == '\\' && isSpecial(url) || stateOverride) {
  4207. if (buffer != '') {
  4208. var port = parseInt(buffer, 10);
  4209. if (port > 0xFFFF)
  4210. return INVALID_PORT;
  4211. url.port = isSpecial(url) && port === specialSchemes[url.scheme] ? null : port;
  4212. buffer = '';
  4213. }
  4214. if (stateOverride)
  4215. return;
  4216. state = PATH_START;
  4217. continue;
  4218. } else
  4219. return INVALID_PORT;
  4220. break;
  4221. case FILE:
  4222. url.scheme = 'file';
  4223. if (char == '/' || char == '\\')
  4224. state = FILE_SLASH;
  4225. else if (base && base.scheme == 'file') {
  4226. if (char == EOF) {
  4227. url.host = base.host;
  4228. url.path = base.path.slice();
  4229. url.query = base.query;
  4230. } else if (char == '?') {
  4231. url.host = base.host;
  4232. url.path = base.path.slice();
  4233. url.query = '';
  4234. state = QUERY;
  4235. } else if (char == '#') {
  4236. url.host = base.host;
  4237. url.path = base.path.slice();
  4238. url.query = base.query;
  4239. url.fragment = '';
  4240. state = FRAGMENT;
  4241. } else {
  4242. if (!startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  4243. url.host = base.host;
  4244. url.path = base.path.slice();
  4245. shortenURLsPath(url);
  4246. }
  4247. state = PATH;
  4248. continue;
  4249. }
  4250. } else {
  4251. state = PATH;
  4252. continue;
  4253. }
  4254. break;
  4255. case FILE_SLASH:
  4256. if (char == '/' || char == '\\') {
  4257. state = FILE_HOST;
  4258. break;
  4259. }
  4260. if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(codePoints.slice(pointer).join(''))) {
  4261. if (isWindowsDriveLetter(base.path[0], true))
  4262. url.path.push(base.path[0]);
  4263. else
  4264. url.host = base.host;
  4265. }
  4266. state = PATH;
  4267. continue;
  4268. case FILE_HOST:
  4269. if (char == EOF || char == '/' || char == '\\' || char == '?' || char == '#') {
  4270. if (!stateOverride && isWindowsDriveLetter(buffer)) {
  4271. state = PATH;
  4272. } else if (buffer == '') {
  4273. url.host = '';
  4274. if (stateOverride)
  4275. return;
  4276. state = PATH_START;
  4277. } else {
  4278. failure = parseHost(url, buffer);
  4279. if (failure)
  4280. return failure;
  4281. if (url.host == 'localhost')
  4282. url.host = '';
  4283. if (stateOverride)
  4284. return;
  4285. buffer = '';
  4286. state = PATH_START;
  4287. }
  4288. continue;
  4289. } else
  4290. buffer += char;
  4291. break;
  4292. case PATH_START:
  4293. if (isSpecial(url)) {
  4294. state = PATH;
  4295. if (char != '/' && char != '\\')
  4296. continue;
  4297. } else if (!stateOverride && char == '?') {
  4298. url.query = '';
  4299. state = QUERY;
  4300. } else if (!stateOverride && char == '#') {
  4301. url.fragment = '';
  4302. state = FRAGMENT;
  4303. } else if (char != EOF) {
  4304. state = PATH;
  4305. if (char != '/')
  4306. continue;
  4307. }
  4308. break;
  4309. case PATH:
  4310. if (char == EOF || char == '/' || char == '\\' && isSpecial(url) || !stateOverride && (char == '?' || char == '#')) {
  4311. if (isDoubleDot(buffer)) {
  4312. shortenURLsPath(url);
  4313. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  4314. url.path.push('');
  4315. }
  4316. } else if (isSingleDot(buffer)) {
  4317. if (char != '/' && !(char == '\\' && isSpecial(url))) {
  4318. url.path.push('');
  4319. }
  4320. } else {
  4321. if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
  4322. if (url.host)
  4323. url.host = '';
  4324. buffer = buffer.charAt(0) + ':';
  4325. }
  4326. url.path.push(buffer);
  4327. }
  4328. buffer = '';
  4329. if (url.scheme == 'file' && (char == EOF || char == '?' || char == '#')) {
  4330. while (url.path.length > 1 && url.path[0] === '') {
  4331. url.path.shift();
  4332. }
  4333. }
  4334. if (char == '?') {
  4335. url.query = '';
  4336. state = QUERY;
  4337. } else if (char == '#') {
  4338. url.fragment = '';
  4339. state = FRAGMENT;
  4340. }
  4341. } else {
  4342. buffer += percentEncode(char, pathPercentEncodeSet);
  4343. }
  4344. break;
  4345. case CANNOT_BE_A_BASE_URL_PATH:
  4346. if (char == '?') {
  4347. url.query = '';
  4348. state = QUERY;
  4349. } else if (char == '#') {
  4350. url.fragment = '';
  4351. state = FRAGMENT;
  4352. } else if (char != EOF) {
  4353. url.path[0] += percentEncode(char, C0ControlPercentEncodeSet);
  4354. }
  4355. break;
  4356. case QUERY:
  4357. if (!stateOverride && char == '#') {
  4358. url.fragment = '';
  4359. state = FRAGMENT;
  4360. } else if (char != EOF) {
  4361. if (char == "'" && isSpecial(url))
  4362. url.query += '%27';
  4363. else if (char == '#')
  4364. url.query += '%23';
  4365. else
  4366. url.query += percentEncode(char, C0ControlPercentEncodeSet);
  4367. }
  4368. break;
  4369. case FRAGMENT:
  4370. if (char != EOF)
  4371. url.fragment += percentEncode(char, fragmentPercentEncodeSet);
  4372. break;
  4373. }
  4374. pointer++;
  4375. }
  4376. };
  4377. var URLConstructor = function URL(url) {
  4378. var that = anInstance(this, URLConstructor, 'URL');
  4379. var base = arguments.length > 1 ? arguments[1] : undefined;
  4380. var urlString = String(url);
  4381. var state = setInternalState(that, { type: 'URL' });
  4382. var baseState, failure;
  4383. if (base !== undefined) {
  4384. if (base instanceof URLConstructor)
  4385. baseState = getInternalURLState(base);
  4386. else {
  4387. failure = parseURL(baseState = {}, String(base));
  4388. if (failure)
  4389. throw TypeError(failure);
  4390. }
  4391. }
  4392. failure = parseURL(state, urlString, null, baseState);
  4393. if (failure)
  4394. throw TypeError(failure);
  4395. var searchParams = state.searchParams = new URLSearchParams();
  4396. var searchParamsState = getInternalSearchParamsState(searchParams);
  4397. searchParamsState.updateSearchParams(state.query);
  4398. searchParamsState.updateURL = function () {
  4399. state.query = String(searchParams) || null;
  4400. };
  4401. if (!DESCRIPTORS) {
  4402. that.href = serializeURL.call(that);
  4403. that.origin = getOrigin.call(that);
  4404. that.protocol = getProtocol.call(that);
  4405. that.username = getUsername.call(that);
  4406. that.password = getPassword.call(that);
  4407. that.host = getHost.call(that);
  4408. that.hostname = getHostname.call(that);
  4409. that.port = getPort.call(that);
  4410. that.pathname = getPathname.call(that);
  4411. that.search = getSearch.call(that);
  4412. that.searchParams = getSearchParams.call(that);
  4413. that.hash = getHash.call(that);
  4414. }
  4415. };
  4416. var URLPrototype = URLConstructor.prototype;
  4417. var serializeURL = function () {
  4418. var url = getInternalURLState(this);
  4419. var scheme = url.scheme;
  4420. var username = url.username;
  4421. var password = url.password;
  4422. var host = url.host;
  4423. var port = url.port;
  4424. var path = url.path;
  4425. var query = url.query;
  4426. var fragment = url.fragment;
  4427. var output = scheme + ':';
  4428. if (host !== null) {
  4429. output += '//';
  4430. if (includesCredentials(url)) {
  4431. output += username + (password ? ':' + password : '') + '@';
  4432. }
  4433. output += serializeHost(host);
  4434. if (port !== null)
  4435. output += ':' + port;
  4436. } else if (scheme == 'file')
  4437. output += '//';
  4438. output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  4439. if (query !== null)
  4440. output += '?' + query;
  4441. if (fragment !== null)
  4442. output += '#' + fragment;
  4443. return output;
  4444. };
  4445. var getOrigin = function () {
  4446. var url = getInternalURLState(this);
  4447. var scheme = url.scheme;
  4448. var port = url.port;
  4449. if (scheme == 'blob')
  4450. try {
  4451. return new URL(scheme.path[0]).origin;
  4452. } catch (error) {
  4453. return 'null';
  4454. }
  4455. if (scheme == 'file' || !isSpecial(url))
  4456. return 'null';
  4457. return scheme + '://' + serializeHost(url.host) + (port !== null ? ':' + port : '');
  4458. };
  4459. var getProtocol = function () {
  4460. return getInternalURLState(this).scheme + ':';
  4461. };
  4462. var getUsername = function () {
  4463. return getInternalURLState(this).username;
  4464. };
  4465. var getPassword = function () {
  4466. return getInternalURLState(this).password;
  4467. };
  4468. var getHost = function () {
  4469. var url = getInternalURLState(this);
  4470. var host = url.host;
  4471. var port = url.port;
  4472. return host === null ? '' : port === null ? serializeHost(host) : serializeHost(host) + ':' + port;
  4473. };
  4474. var getHostname = function () {
  4475. var host = getInternalURLState(this).host;
  4476. return host === null ? '' : serializeHost(host);
  4477. };
  4478. var getPort = function () {
  4479. var port = getInternalURLState(this).port;
  4480. return port === null ? '' : String(port);
  4481. };
  4482. var getPathname = function () {
  4483. var url = getInternalURLState(this);
  4484. var path = url.path;
  4485. return url.cannotBeABaseURL ? path[0] : path.length ? '/' + path.join('/') : '';
  4486. };
  4487. var getSearch = function () {
  4488. var query = getInternalURLState(this).query;
  4489. return query ? '?' + query : '';
  4490. };
  4491. var getSearchParams = function () {
  4492. return getInternalURLState(this).searchParams;
  4493. };
  4494. var getHash = function () {
  4495. var fragment = getInternalURLState(this).fragment;
  4496. return fragment ? '#' + fragment : '';
  4497. };
  4498. var accessorDescriptor = function (getter, setter) {
  4499. return {
  4500. get: getter,
  4501. set: setter,
  4502. configurable: true,
  4503. enumerable: true
  4504. };
  4505. };
  4506. if (DESCRIPTORS) {
  4507. defineProperties(URLPrototype, {
  4508. href: accessorDescriptor(serializeURL, function (href) {
  4509. var url = getInternalURLState(this);
  4510. var urlString = String(href);
  4511. var failure = parseURL(url, urlString);
  4512. if (failure)
  4513. throw TypeError(failure);
  4514. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  4515. }),
  4516. origin: accessorDescriptor(getOrigin),
  4517. protocol: accessorDescriptor(getProtocol, function (protocol) {
  4518. var url = getInternalURLState(this);
  4519. parseURL(url, String(protocol) + ':', SCHEME_START);
  4520. }),
  4521. username: accessorDescriptor(getUsername, function (username) {
  4522. var url = getInternalURLState(this);
  4523. var codePoints = arrayFrom(String(username));
  4524. if (cannotHaveUsernamePasswordPort(url))
  4525. return;
  4526. url.username = '';
  4527. for (var i = 0; i < codePoints.length; i++) {
  4528. url.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  4529. }
  4530. }),
  4531. password: accessorDescriptor(getPassword, function (password) {
  4532. var url = getInternalURLState(this);
  4533. var codePoints = arrayFrom(String(password));
  4534. if (cannotHaveUsernamePasswordPort(url))
  4535. return;
  4536. url.password = '';
  4537. for (var i = 0; i < codePoints.length; i++) {
  4538. url.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
  4539. }
  4540. }),
  4541. host: accessorDescriptor(getHost, function (host) {
  4542. var url = getInternalURLState(this);
  4543. if (url.cannotBeABaseURL)
  4544. return;
  4545. parseURL(url, String(host), HOST);
  4546. }),
  4547. hostname: accessorDescriptor(getHostname, function (hostname) {
  4548. var url = getInternalURLState(this);
  4549. if (url.cannotBeABaseURL)
  4550. return;
  4551. parseURL(url, String(hostname), HOSTNAME);
  4552. }),
  4553. port: accessorDescriptor(getPort, function (port) {
  4554. var url = getInternalURLState(this);
  4555. if (cannotHaveUsernamePasswordPort(url))
  4556. return;
  4557. port = String(port);
  4558. if (port == '')
  4559. url.port = null;
  4560. else
  4561. parseURL(url, port, PORT);
  4562. }),
  4563. pathname: accessorDescriptor(getPathname, function (pathname) {
  4564. var url = getInternalURLState(this);
  4565. if (url.cannotBeABaseURL)
  4566. return;
  4567. url.path = [];
  4568. parseURL(url, pathname + '', PATH_START);
  4569. }),
  4570. search: accessorDescriptor(getSearch, function (search) {
  4571. var url = getInternalURLState(this);
  4572. search = String(search);
  4573. if (search == '') {
  4574. url.query = null;
  4575. } else {
  4576. if ('?' == search.charAt(0))
  4577. search = search.slice(1);
  4578. url.query = '';
  4579. parseURL(url, search, QUERY);
  4580. }
  4581. getInternalSearchParamsState(url.searchParams).updateSearchParams(url.query);
  4582. }),
  4583. searchParams: accessorDescriptor(getSearchParams),
  4584. hash: accessorDescriptor(getHash, function (hash) {
  4585. var url = getInternalURLState(this);
  4586. hash = String(hash);
  4587. if (hash == '') {
  4588. url.fragment = null;
  4589. return;
  4590. }
  4591. if ('#' == hash.charAt(0))
  4592. hash = hash.slice(1);
  4593. url.fragment = '';
  4594. parseURL(url, hash, FRAGMENT);
  4595. })
  4596. });
  4597. }
  4598. redefine(URLPrototype, 'toJSON', function toJSON() {
  4599. return serializeURL.call(this);
  4600. }, { enumerable: true });
  4601. redefine(URLPrototype, 'toString', function toString() {
  4602. return serializeURL.call(this);
  4603. }, { enumerable: true });
  4604. if (NativeURL) {
  4605. var nativeCreateObjectURL = NativeURL.createObjectURL;
  4606. var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
  4607. if (nativeCreateObjectURL)
  4608. redefine(URLConstructor, 'createObjectURL', function createObjectURL(blob) {
  4609. return nativeCreateObjectURL.apply(NativeURL, arguments);
  4610. });
  4611. if (nativeRevokeObjectURL)
  4612. redefine(URLConstructor, 'revokeObjectURL', function revokeObjectURL(url) {
  4613. return nativeRevokeObjectURL.apply(NativeURL, arguments);
  4614. });
  4615. }
  4616. setToStringTag(URLConstructor, 'URL');
  4617. $({
  4618. global: true,
  4619. forced: !USE_NATIVE_URL,
  4620. sham: !DESCRIPTORS
  4621. }, { URL: URLConstructor });
  4622. /***/ }),
  4623. /* 123 */
  4624. /***/ (function(module, exports, __w_pdfjs_require__) {
  4625. var fails = __w_pdfjs_require__(11);
  4626. var wellKnownSymbol = __w_pdfjs_require__(51);
  4627. var IS_PURE = __w_pdfjs_require__(29);
  4628. var ITERATOR = wellKnownSymbol('iterator');
  4629. module.exports = !fails(function () {
  4630. var url = new URL('b?e=1', 'http://a');
  4631. var searchParams = url.searchParams;
  4632. url.pathname = 'c%20d';
  4633. return IS_PURE && !url.toJSON || !searchParams.sort || url.href !== 'http://a/c%20d?e=1' || searchParams.get('e') !== '1' || String(new URLSearchParams('?a=1')) !== 'a=1' || !searchParams[ITERATOR] || new URL('https://a@b').username !== 'a' || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' || new URL('http://тест').host !== 'xn--e1aybc' || new URL('http://a#б').hash !== '#%D0%B1';
  4634. });
  4635. /***/ }),
  4636. /* 124 */
  4637. /***/ (function(module, exports, __w_pdfjs_require__) {
  4638. "use strict";
  4639. var maxInt = 2147483647;
  4640. var base = 36;
  4641. var tMin = 1;
  4642. var tMax = 26;
  4643. var skew = 38;
  4644. var damp = 700;
  4645. var initialBias = 72;
  4646. var initialN = 128;
  4647. var delimiter = '-';
  4648. var regexNonASCII = /[^\0-\u007E]/;
  4649. var regexSeparators = /[.\u3002\uFF0E\uFF61]/g;
  4650. var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
  4651. var baseMinusTMin = base - tMin;
  4652. var floor = Math.floor;
  4653. var stringFromCharCode = String.fromCharCode;
  4654. var ucs2decode = function (string) {
  4655. var output = [];
  4656. var counter = 0;
  4657. var length = string.length;
  4658. while (counter < length) {
  4659. var value = string.charCodeAt(counter++);
  4660. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  4661. var extra = string.charCodeAt(counter++);
  4662. if ((extra & 0xFC00) == 0xDC00) {
  4663. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  4664. } else {
  4665. output.push(value);
  4666. counter--;
  4667. }
  4668. } else {
  4669. output.push(value);
  4670. }
  4671. }
  4672. return output;
  4673. };
  4674. var digitToBasic = function (digit) {
  4675. return digit + 22 + 75 * (digit < 26);
  4676. };
  4677. var adapt = function (delta, numPoints, firstTime) {
  4678. var k = 0;
  4679. delta = firstTime ? floor(delta / damp) : delta >> 1;
  4680. delta += floor(delta / numPoints);
  4681. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  4682. delta = floor(delta / baseMinusTMin);
  4683. }
  4684. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  4685. };
  4686. var encode = function (input) {
  4687. var output = [];
  4688. input = ucs2decode(input);
  4689. var inputLength = input.length;
  4690. var n = initialN;
  4691. var delta = 0;
  4692. var bias = initialBias;
  4693. var i, currentValue;
  4694. for (i = 0; i < input.length; i++) {
  4695. currentValue = input[i];
  4696. if (currentValue < 0x80) {
  4697. output.push(stringFromCharCode(currentValue));
  4698. }
  4699. }
  4700. var basicLength = output.length;
  4701. var handledCPCount = basicLength;
  4702. if (basicLength) {
  4703. output.push(delimiter);
  4704. }
  4705. while (handledCPCount < inputLength) {
  4706. var m = maxInt;
  4707. for (i = 0; i < input.length; i++) {
  4708. currentValue = input[i];
  4709. if (currentValue >= n && currentValue < m) {
  4710. m = currentValue;
  4711. }
  4712. }
  4713. var handledCPCountPlusOne = handledCPCount + 1;
  4714. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  4715. throw RangeError(OVERFLOW_ERROR);
  4716. }
  4717. delta += (m - n) * handledCPCountPlusOne;
  4718. n = m;
  4719. for (i = 0; i < input.length; i++) {
  4720. currentValue = input[i];
  4721. if (currentValue < n && ++delta > maxInt) {
  4722. throw RangeError(OVERFLOW_ERROR);
  4723. }
  4724. if (currentValue == n) {
  4725. var q = delta;
  4726. for (var k = base;; k += base) {
  4727. var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  4728. if (q < t)
  4729. break;
  4730. var qMinusT = q - t;
  4731. var baseMinusT = base - t;
  4732. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
  4733. q = floor(qMinusT / baseMinusT);
  4734. }
  4735. output.push(stringFromCharCode(digitToBasic(q)));
  4736. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  4737. delta = 0;
  4738. ++handledCPCount;
  4739. }
  4740. }
  4741. ++delta;
  4742. ++n;
  4743. }
  4744. return output.join('');
  4745. };
  4746. module.exports = function (input) {
  4747. var encoded = [];
  4748. var labels = input.toLowerCase().replace(regexSeparators, '\u002E').split('.');
  4749. var i, label;
  4750. for (i = 0; i < labels.length; i++) {
  4751. label = labels[i];
  4752. encoded.push(regexNonASCII.test(label) ? 'xn--' + encode(label) : label);
  4753. }
  4754. return encoded.join('.');
  4755. };
  4756. /***/ }),
  4757. /* 125 */
  4758. /***/ (function(module, exports, __w_pdfjs_require__) {
  4759. "use strict";
  4760. __w_pdfjs_require__(104);
  4761. var $ = __w_pdfjs_require__(7);
  4762. var USE_NATIVE_URL = __w_pdfjs_require__(123);
  4763. var redefine = __w_pdfjs_require__(26);
  4764. var redefineAll = __w_pdfjs_require__(107);
  4765. var setToStringTag = __w_pdfjs_require__(77);
  4766. var createIteratorConstructor = __w_pdfjs_require__(72);
  4767. var InternalStateModule = __w_pdfjs_require__(31);
  4768. var anInstance = __w_pdfjs_require__(109);
  4769. var hasOwn = __w_pdfjs_require__(20);
  4770. var bind = __w_pdfjs_require__(55);
  4771. var anObject = __w_pdfjs_require__(25);
  4772. var isObject = __w_pdfjs_require__(19);
  4773. var getIterator = __w_pdfjs_require__(126);
  4774. var getIteratorMethod = __w_pdfjs_require__(86);
  4775. var wellKnownSymbol = __w_pdfjs_require__(51);
  4776. var ITERATOR = wellKnownSymbol('iterator');
  4777. var URL_SEARCH_PARAMS = 'URLSearchParams';
  4778. var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
  4779. var setInternalState = InternalStateModule.set;
  4780. var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
  4781. var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
  4782. var plus = /\+/g;
  4783. var sequences = Array(4);
  4784. var percentSequence = function (bytes) {
  4785. return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
  4786. };
  4787. var percentDecode = function (sequence) {
  4788. try {
  4789. return decodeURIComponent(sequence);
  4790. } catch (error) {
  4791. return sequence;
  4792. }
  4793. };
  4794. var deserialize = function (it) {
  4795. var result = it.replace(plus, ' ');
  4796. var bytes = 4;
  4797. try {
  4798. return decodeURIComponent(result);
  4799. } catch (error) {
  4800. while (bytes) {
  4801. result = result.replace(percentSequence(bytes--), percentDecode);
  4802. }
  4803. return result;
  4804. }
  4805. };
  4806. var find = /[!'()~]|%20/g;
  4807. var replace = {
  4808. '!': '%21',
  4809. "'": '%27',
  4810. '(': '%28',
  4811. ')': '%29',
  4812. '~': '%7E',
  4813. '%20': '+'
  4814. };
  4815. var replacer = function (match) {
  4816. return replace[match];
  4817. };
  4818. var serialize = function (it) {
  4819. return encodeURIComponent(it).replace(find, replacer);
  4820. };
  4821. var parseSearchParams = function (result, query) {
  4822. if (query) {
  4823. var attributes = query.split('&');
  4824. var index = 0;
  4825. var attribute, entry;
  4826. while (index < attributes.length) {
  4827. attribute = attributes[index++];
  4828. if (attribute.length) {
  4829. entry = attribute.split('=');
  4830. result.push({
  4831. key: deserialize(entry.shift()),
  4832. value: deserialize(entry.join('='))
  4833. });
  4834. }
  4835. }
  4836. }
  4837. };
  4838. var updateSearchParams = function (query) {
  4839. this.entries.length = 0;
  4840. parseSearchParams(this.entries, query);
  4841. };
  4842. var validateArgumentsLength = function (passed, required) {
  4843. if (passed < required)
  4844. throw TypeError('Not enough arguments');
  4845. };
  4846. var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
  4847. setInternalState(this, {
  4848. type: URL_SEARCH_PARAMS_ITERATOR,
  4849. iterator: getIterator(getInternalParamsState(params).entries),
  4850. kind: kind
  4851. });
  4852. }, 'Iterator', function next() {
  4853. var state = getInternalIteratorState(this);
  4854. var kind = state.kind;
  4855. var step = state.iterator.next();
  4856. var entry = step.value;
  4857. if (!step.done) {
  4858. step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [
  4859. entry.key,
  4860. entry.value
  4861. ];
  4862. }
  4863. return step;
  4864. });
  4865. var URLSearchParamsConstructor = function URLSearchParams() {
  4866. anInstance(this, URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  4867. var init = arguments.length > 0 ? arguments[0] : undefined;
  4868. var that = this;
  4869. var entries = [];
  4870. var iteratorMethod, iterator, step, entryIterator, first, second, key;
  4871. setInternalState(that, {
  4872. type: URL_SEARCH_PARAMS,
  4873. entries: entries,
  4874. updateURL: function () {
  4875. },
  4876. updateSearchParams: updateSearchParams
  4877. });
  4878. if (init !== undefined) {
  4879. if (isObject(init)) {
  4880. iteratorMethod = getIteratorMethod(init);
  4881. if (typeof iteratorMethod === 'function') {
  4882. iterator = iteratorMethod.call(init);
  4883. while (!(step = iterator.next()).done) {
  4884. entryIterator = getIterator(anObject(step.value));
  4885. if ((first = entryIterator.next()).done || (second = entryIterator.next()).done || !entryIterator.next().done)
  4886. throw TypeError('Expected sequence with length 2');
  4887. entries.push({
  4888. key: first.value + '',
  4889. value: second.value + ''
  4890. });
  4891. }
  4892. } else
  4893. for (key in init)
  4894. if (hasOwn(init, key))
  4895. entries.push({
  4896. key: key,
  4897. value: init[key] + ''
  4898. });
  4899. } else {
  4900. parseSearchParams(entries, typeof init === 'string' ? init.charAt(0) === '?' ? init.slice(1) : init : init + '');
  4901. }
  4902. }
  4903. };
  4904. var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
  4905. redefineAll(URLSearchParamsPrototype, {
  4906. append: function append(name, value) {
  4907. validateArgumentsLength(arguments.length, 2);
  4908. var state = getInternalParamsState(this);
  4909. state.entries.push({
  4910. key: name + '',
  4911. value: value + ''
  4912. });
  4913. state.updateURL();
  4914. },
  4915. 'delete': function (name) {
  4916. validateArgumentsLength(arguments.length, 1);
  4917. var state = getInternalParamsState(this);
  4918. var entries = state.entries;
  4919. var key = name + '';
  4920. var index = 0;
  4921. while (index < entries.length) {
  4922. if (entries[index].key === key)
  4923. entries.splice(index, 1);
  4924. else
  4925. index++;
  4926. }
  4927. state.updateURL();
  4928. },
  4929. get: function get(name) {
  4930. validateArgumentsLength(arguments.length, 1);
  4931. var entries = getInternalParamsState(this).entries;
  4932. var key = name + '';
  4933. var index = 0;
  4934. for (; index < entries.length; index++) {
  4935. if (entries[index].key === key)
  4936. return entries[index].value;
  4937. }
  4938. return null;
  4939. },
  4940. getAll: function getAll(name) {
  4941. validateArgumentsLength(arguments.length, 1);
  4942. var entries = getInternalParamsState(this).entries;
  4943. var key = name + '';
  4944. var result = [];
  4945. var index = 0;
  4946. for (; index < entries.length; index++) {
  4947. if (entries[index].key === key)
  4948. result.push(entries[index].value);
  4949. }
  4950. return result;
  4951. },
  4952. has: function has(name) {
  4953. validateArgumentsLength(arguments.length, 1);
  4954. var entries = getInternalParamsState(this).entries;
  4955. var key = name + '';
  4956. var index = 0;
  4957. while (index < entries.length) {
  4958. if (entries[index++].key === key)
  4959. return true;
  4960. }
  4961. return false;
  4962. },
  4963. set: function set(name, value) {
  4964. validateArgumentsLength(arguments.length, 1);
  4965. var state = getInternalParamsState(this);
  4966. var entries = state.entries;
  4967. var found = false;
  4968. var key = name + '';
  4969. var val = value + '';
  4970. var index = 0;
  4971. var entry;
  4972. for (; index < entries.length; index++) {
  4973. entry = entries[index];
  4974. if (entry.key === key) {
  4975. if (found)
  4976. entries.splice(index--, 1);
  4977. else {
  4978. found = true;
  4979. entry.value = val;
  4980. }
  4981. }
  4982. }
  4983. if (!found)
  4984. entries.push({
  4985. key: key,
  4986. value: val
  4987. });
  4988. state.updateURL();
  4989. },
  4990. sort: function sort() {
  4991. var state = getInternalParamsState(this);
  4992. var entries = state.entries;
  4993. var slice = entries.slice();
  4994. var entry, entriesIndex, sliceIndex;
  4995. entries.length = 0;
  4996. for (sliceIndex = 0; sliceIndex < slice.length; sliceIndex++) {
  4997. entry = slice[sliceIndex];
  4998. for (entriesIndex = 0; entriesIndex < sliceIndex; entriesIndex++) {
  4999. if (entries[entriesIndex].key > entry.key) {
  5000. entries.splice(entriesIndex, 0, entry);
  5001. break;
  5002. }
  5003. }
  5004. if (entriesIndex === sliceIndex)
  5005. entries.push(entry);
  5006. }
  5007. state.updateURL();
  5008. },
  5009. forEach: function forEach(callback) {
  5010. var entries = getInternalParamsState(this).entries;
  5011. var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined, 3);
  5012. var index = 0;
  5013. var entry;
  5014. while (index < entries.length) {
  5015. entry = entries[index++];
  5016. boundFunction(entry.value, entry.key, this);
  5017. }
  5018. },
  5019. keys: function keys() {
  5020. return new URLSearchParamsIterator(this, 'keys');
  5021. },
  5022. values: function values() {
  5023. return new URLSearchParamsIterator(this, 'values');
  5024. },
  5025. entries: function entries() {
  5026. return new URLSearchParamsIterator(this, 'entries');
  5027. }
  5028. }, { enumerable: true });
  5029. redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries);
  5030. redefine(URLSearchParamsPrototype, 'toString', function toString() {
  5031. var entries = getInternalParamsState(this).entries;
  5032. var result = [];
  5033. var index = 0;
  5034. var entry;
  5035. while (index < entries.length) {
  5036. entry = entries[index++];
  5037. result.push(serialize(entry.key) + '=' + serialize(entry.value));
  5038. }
  5039. return result.join('&');
  5040. }, { enumerable: true });
  5041. setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
  5042. $({
  5043. global: true,
  5044. forced: !USE_NATIVE_URL
  5045. }, { URLSearchParams: URLSearchParamsConstructor });
  5046. module.exports = {
  5047. URLSearchParams: URLSearchParamsConstructor,
  5048. getState: getInternalParamsState
  5049. };
  5050. /***/ }),
  5051. /* 126 */
  5052. /***/ (function(module, exports, __w_pdfjs_require__) {
  5053. var anObject = __w_pdfjs_require__(25);
  5054. var getIteratorMethod = __w_pdfjs_require__(86);
  5055. module.exports = function (it) {
  5056. var iteratorMethod = getIteratorMethod(it);
  5057. if (typeof iteratorMethod != 'function') {
  5058. throw TypeError(String(it) + ' is not iterable');
  5059. }
  5060. return anObject(iteratorMethod.call(it));
  5061. };
  5062. /***/ }),
  5063. /* 127 */
  5064. /***/ (function(module, exports, __w_pdfjs_require__) {
  5065. "use strict";
  5066. var $ = __w_pdfjs_require__(7);
  5067. $({
  5068. target: 'URL',
  5069. proto: true,
  5070. enumerable: true
  5071. }, {
  5072. toJSON: function toJSON() {
  5073. return URL.prototype.toString.call(this);
  5074. }
  5075. });
  5076. /***/ }),
  5077. /* 128 */
  5078. /***/ (function(module, exports, __w_pdfjs_require__) {
  5079. __w_pdfjs_require__(100);
  5080. __w_pdfjs_require__(129);
  5081. __w_pdfjs_require__(102);
  5082. var path = __w_pdfjs_require__(39);
  5083. module.exports = path.WeakMap;
  5084. /***/ }),
  5085. /* 129 */
  5086. /***/ (function(module, exports, __w_pdfjs_require__) {
  5087. "use strict";
  5088. var global = __w_pdfjs_require__(8);
  5089. var redefineAll = __w_pdfjs_require__(107);
  5090. var InternalMetadataModule = __w_pdfjs_require__(130);
  5091. var collection = __w_pdfjs_require__(132);
  5092. var collectionWeak = __w_pdfjs_require__(134);
  5093. var isObject = __w_pdfjs_require__(19);
  5094. var enforceIternalState = __w_pdfjs_require__(31).enforce;
  5095. var NATIVE_WEAK_MAP = __w_pdfjs_require__(32);
  5096. var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
  5097. var isExtensible = Object.isExtensible;
  5098. var InternalWeakMap;
  5099. var wrapper = function (get) {
  5100. return function WeakMap() {
  5101. return get(this, arguments.length ? arguments[0] : undefined);
  5102. };
  5103. };
  5104. var $WeakMap = module.exports = collection('WeakMap', wrapper, collectionWeak, true, true);
  5105. if (NATIVE_WEAK_MAP && IS_IE11) {
  5106. InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
  5107. InternalMetadataModule.REQUIRED = true;
  5108. var WeakMapPrototype = $WeakMap.prototype;
  5109. var nativeDelete = WeakMapPrototype['delete'];
  5110. var nativeHas = WeakMapPrototype.has;
  5111. var nativeGet = WeakMapPrototype.get;
  5112. var nativeSet = WeakMapPrototype.set;
  5113. redefineAll(WeakMapPrototype, {
  5114. 'delete': function (key) {
  5115. if (isObject(key) && !isExtensible(key)) {
  5116. var state = enforceIternalState(this);
  5117. if (!state.frozen)
  5118. state.frozen = new InternalWeakMap();
  5119. return nativeDelete.call(this, key) || state.frozen['delete'](key);
  5120. }
  5121. return nativeDelete.call(this, key);
  5122. },
  5123. has: function has(key) {
  5124. if (isObject(key) && !isExtensible(key)) {
  5125. var state = enforceIternalState(this);
  5126. if (!state.frozen)
  5127. state.frozen = new InternalWeakMap();
  5128. return nativeHas.call(this, key) || state.frozen.has(key);
  5129. }
  5130. return nativeHas.call(this, key);
  5131. },
  5132. get: function get(key) {
  5133. if (isObject(key) && !isExtensible(key)) {
  5134. var state = enforceIternalState(this);
  5135. if (!state.frozen)
  5136. state.frozen = new InternalWeakMap();
  5137. return nativeHas.call(this, key) ? nativeGet.call(this, key) : state.frozen.get(key);
  5138. }
  5139. return nativeGet.call(this, key);
  5140. },
  5141. set: function set(key, value) {
  5142. if (isObject(key) && !isExtensible(key)) {
  5143. var state = enforceIternalState(this);
  5144. if (!state.frozen)
  5145. state.frozen = new InternalWeakMap();
  5146. nativeHas.call(this, key) ? nativeSet.call(this, key, value) : state.frozen.set(key, value);
  5147. } else
  5148. nativeSet.call(this, key, value);
  5149. return this;
  5150. }
  5151. });
  5152. }
  5153. /***/ }),
  5154. /* 130 */
  5155. /***/ (function(module, exports, __w_pdfjs_require__) {
  5156. var hiddenKeys = __w_pdfjs_require__(35);
  5157. var isObject = __w_pdfjs_require__(19);
  5158. var has = __w_pdfjs_require__(20);
  5159. var defineProperty = __w_pdfjs_require__(24).f;
  5160. var uid = __w_pdfjs_require__(34);
  5161. var FREEZING = __w_pdfjs_require__(131);
  5162. var METADATA = uid('meta');
  5163. var id = 0;
  5164. var isExtensible = Object.isExtensible || function () {
  5165. return true;
  5166. };
  5167. var setMetadata = function (it) {
  5168. defineProperty(it, METADATA, {
  5169. value: {
  5170. objectID: 'O' + ++id,
  5171. weakData: {}
  5172. }
  5173. });
  5174. };
  5175. var fastKey = function (it, create) {
  5176. if (!isObject(it))
  5177. return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  5178. if (!has(it, METADATA)) {
  5179. if (!isExtensible(it))
  5180. return 'F';
  5181. if (!create)
  5182. return 'E';
  5183. setMetadata(it);
  5184. }
  5185. return it[METADATA].objectID;
  5186. };
  5187. var getWeakData = function (it, create) {
  5188. if (!has(it, METADATA)) {
  5189. if (!isExtensible(it))
  5190. return true;
  5191. if (!create)
  5192. return false;
  5193. setMetadata(it);
  5194. }
  5195. return it[METADATA].weakData;
  5196. };
  5197. var onFreeze = function (it) {
  5198. if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA))
  5199. setMetadata(it);
  5200. return it;
  5201. };
  5202. var meta = module.exports = {
  5203. REQUIRED: false,
  5204. fastKey: fastKey,
  5205. getWeakData: getWeakData,
  5206. onFreeze: onFreeze
  5207. };
  5208. hiddenKeys[METADATA] = true;
  5209. /***/ }),
  5210. /* 131 */
  5211. /***/ (function(module, exports, __w_pdfjs_require__) {
  5212. var fails = __w_pdfjs_require__(11);
  5213. module.exports = !fails(function () {
  5214. return Object.isExtensible(Object.preventExtensions({}));
  5215. });
  5216. /***/ }),
  5217. /* 132 */
  5218. /***/ (function(module, exports, __w_pdfjs_require__) {
  5219. "use strict";
  5220. var $ = __w_pdfjs_require__(7);
  5221. var global = __w_pdfjs_require__(8);
  5222. var isForced = __w_pdfjs_require__(48);
  5223. var redefine = __w_pdfjs_require__(26);
  5224. var InternalMetadataModule = __w_pdfjs_require__(130);
  5225. var iterate = __w_pdfjs_require__(110);
  5226. var anInstance = __w_pdfjs_require__(109);
  5227. var isObject = __w_pdfjs_require__(19);
  5228. var fails = __w_pdfjs_require__(11);
  5229. var checkCorrectnessOfIteration = __w_pdfjs_require__(88);
  5230. var setToStringTag = __w_pdfjs_require__(77);
  5231. var inheritIfRequired = __w_pdfjs_require__(133);
  5232. module.exports = function (CONSTRUCTOR_NAME, wrapper, common, IS_MAP, IS_WEAK) {
  5233. var NativeConstructor = global[CONSTRUCTOR_NAME];
  5234. var NativePrototype = NativeConstructor && NativeConstructor.prototype;
  5235. var Constructor = NativeConstructor;
  5236. var ADDER = IS_MAP ? 'set' : 'add';
  5237. var exported = {};
  5238. var fixMethod = function (KEY) {
  5239. var nativeMethod = NativePrototype[KEY];
  5240. redefine(NativePrototype, KEY, KEY == 'add' ? function add(value) {
  5241. nativeMethod.call(this, value === 0 ? 0 : value);
  5242. return this;
  5243. } : KEY == 'delete' ? function (key) {
  5244. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  5245. } : KEY == 'get' ? function get(key) {
  5246. return IS_WEAK && !isObject(key) ? undefined : nativeMethod.call(this, key === 0 ? 0 : key);
  5247. } : KEY == 'has' ? function has(key) {
  5248. return IS_WEAK && !isObject(key) ? false : nativeMethod.call(this, key === 0 ? 0 : key);
  5249. } : function set(key, value) {
  5250. nativeMethod.call(this, key === 0 ? 0 : key, value);
  5251. return this;
  5252. });
  5253. };
  5254. if (isForced(CONSTRUCTOR_NAME, typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
  5255. new NativeConstructor().entries().next();
  5256. })))) {
  5257. Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
  5258. InternalMetadataModule.REQUIRED = true;
  5259. } else if (isForced(CONSTRUCTOR_NAME, true)) {
  5260. var instance = new Constructor();
  5261. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  5262. var THROWS_ON_PRIMITIVES = fails(function () {
  5263. instance.has(1);
  5264. });
  5265. var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) {
  5266. new NativeConstructor(iterable);
  5267. });
  5268. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  5269. var $instance = new NativeConstructor();
  5270. var index = 5;
  5271. while (index--)
  5272. $instance[ADDER](index, index);
  5273. return !$instance.has(-0);
  5274. });
  5275. if (!ACCEPT_ITERABLES) {
  5276. Constructor = wrapper(function (dummy, iterable) {
  5277. anInstance(dummy, Constructor, CONSTRUCTOR_NAME);
  5278. var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
  5279. if (iterable != undefined)
  5280. iterate(iterable, that[ADDER], that, IS_MAP);
  5281. return that;
  5282. });
  5283. Constructor.prototype = NativePrototype;
  5284. NativePrototype.constructor = Constructor;
  5285. }
  5286. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  5287. fixMethod('delete');
  5288. fixMethod('has');
  5289. IS_MAP && fixMethod('get');
  5290. }
  5291. if (BUGGY_ZERO || HASNT_CHAINING)
  5292. fixMethod(ADDER);
  5293. if (IS_WEAK && NativePrototype.clear)
  5294. delete NativePrototype.clear;
  5295. }
  5296. exported[CONSTRUCTOR_NAME] = Constructor;
  5297. $({
  5298. global: true,
  5299. forced: Constructor != NativeConstructor
  5300. }, exported);
  5301. setToStringTag(Constructor, CONSTRUCTOR_NAME);
  5302. if (!IS_WEAK)
  5303. common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
  5304. return Constructor;
  5305. };
  5306. /***/ }),
  5307. /* 133 */
  5308. /***/ (function(module, exports, __w_pdfjs_require__) {
  5309. var isObject = __w_pdfjs_require__(19);
  5310. var setPrototypeOf = __w_pdfjs_require__(79);
  5311. module.exports = function ($this, dummy, Wrapper) {
  5312. var NewTarget, NewTargetPrototype;
  5313. if (setPrototypeOf && typeof (NewTarget = dummy.constructor) == 'function' && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  5314. setPrototypeOf($this, NewTargetPrototype);
  5315. return $this;
  5316. };
  5317. /***/ }),
  5318. /* 134 */
  5319. /***/ (function(module, exports, __w_pdfjs_require__) {
  5320. "use strict";
  5321. var redefineAll = __w_pdfjs_require__(107);
  5322. var getWeakData = __w_pdfjs_require__(130).getWeakData;
  5323. var anObject = __w_pdfjs_require__(25);
  5324. var isObject = __w_pdfjs_require__(19);
  5325. var anInstance = __w_pdfjs_require__(109);
  5326. var iterate = __w_pdfjs_require__(110);
  5327. var ArrayIterationModule = __w_pdfjs_require__(135);
  5328. var $has = __w_pdfjs_require__(20);
  5329. var InternalStateModule = __w_pdfjs_require__(31);
  5330. var setInternalState = InternalStateModule.set;
  5331. var internalStateGetterFor = InternalStateModule.getterFor;
  5332. var find = ArrayIterationModule.find;
  5333. var findIndex = ArrayIterationModule.findIndex;
  5334. var id = 0;
  5335. var uncaughtFrozenStore = function (store) {
  5336. return store.frozen || (store.frozen = new UncaughtFrozenStore());
  5337. };
  5338. var UncaughtFrozenStore = function () {
  5339. this.entries = [];
  5340. };
  5341. var findUncaughtFrozen = function (store, key) {
  5342. return find(store.entries, function (it) {
  5343. return it[0] === key;
  5344. });
  5345. };
  5346. UncaughtFrozenStore.prototype = {
  5347. get: function (key) {
  5348. var entry = findUncaughtFrozen(this, key);
  5349. if (entry)
  5350. return entry[1];
  5351. },
  5352. has: function (key) {
  5353. return !!findUncaughtFrozen(this, key);
  5354. },
  5355. set: function (key, value) {
  5356. var entry = findUncaughtFrozen(this, key);
  5357. if (entry)
  5358. entry[1] = value;
  5359. else
  5360. this.entries.push([
  5361. key,
  5362. value
  5363. ]);
  5364. },
  5365. 'delete': function (key) {
  5366. var index = findIndex(this.entries, function (it) {
  5367. return it[0] === key;
  5368. });
  5369. if (~index)
  5370. this.entries.splice(index, 1);
  5371. return !!~index;
  5372. }
  5373. };
  5374. module.exports = {
  5375. getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
  5376. var C = wrapper(function (that, iterable) {
  5377. anInstance(that, C, CONSTRUCTOR_NAME);
  5378. setInternalState(that, {
  5379. type: CONSTRUCTOR_NAME,
  5380. id: id++,
  5381. frozen: undefined
  5382. });
  5383. if (iterable != undefined)
  5384. iterate(iterable, that[ADDER], that, IS_MAP);
  5385. });
  5386. var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
  5387. var define = function (that, key, value) {
  5388. var state = getInternalState(that);
  5389. var data = getWeakData(anObject(key), true);
  5390. if (data === true)
  5391. uncaughtFrozenStore(state).set(key, value);
  5392. else
  5393. data[state.id] = value;
  5394. return that;
  5395. };
  5396. redefineAll(C.prototype, {
  5397. 'delete': function (key) {
  5398. var state = getInternalState(this);
  5399. if (!isObject(key))
  5400. return false;
  5401. var data = getWeakData(key);
  5402. if (data === true)
  5403. return uncaughtFrozenStore(state)['delete'](key);
  5404. return data && $has(data, state.id) && delete data[state.id];
  5405. },
  5406. has: function has(key) {
  5407. var state = getInternalState(this);
  5408. if (!isObject(key))
  5409. return false;
  5410. var data = getWeakData(key);
  5411. if (data === true)
  5412. return uncaughtFrozenStore(state).has(key);
  5413. return data && $has(data, state.id);
  5414. }
  5415. });
  5416. redefineAll(C.prototype, IS_MAP ? {
  5417. get: function get(key) {
  5418. var state = getInternalState(this);
  5419. if (isObject(key)) {
  5420. var data = getWeakData(key);
  5421. if (data === true)
  5422. return uncaughtFrozenStore(state).get(key);
  5423. return data ? data[state.id] : undefined;
  5424. }
  5425. },
  5426. set: function set(key, value) {
  5427. return define(this, key, value);
  5428. }
  5429. } : {
  5430. add: function add(value) {
  5431. return define(this, value, true);
  5432. }
  5433. });
  5434. return C;
  5435. }
  5436. };
  5437. /***/ }),
  5438. /* 135 */
  5439. /***/ (function(module, exports, __w_pdfjs_require__) {
  5440. var bind = __w_pdfjs_require__(55);
  5441. var IndexedObject = __w_pdfjs_require__(15);
  5442. var toObject = __w_pdfjs_require__(75);
  5443. var toLength = __w_pdfjs_require__(43);
  5444. var arraySpeciesCreate = __w_pdfjs_require__(136);
  5445. var push = [].push;
  5446. var createMethod = function (TYPE) {
  5447. var IS_MAP = TYPE == 1;
  5448. var IS_FILTER = TYPE == 2;
  5449. var IS_SOME = TYPE == 3;
  5450. var IS_EVERY = TYPE == 4;
  5451. var IS_FIND_INDEX = TYPE == 6;
  5452. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  5453. return function ($this, callbackfn, that, specificCreate) {
  5454. var O = toObject($this);
  5455. var self = IndexedObject(O);
  5456. var boundFunction = bind(callbackfn, that, 3);
  5457. var length = toLength(self.length);
  5458. var index = 0;
  5459. var create = specificCreate || arraySpeciesCreate;
  5460. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  5461. var value, result;
  5462. for (; length > index; index++)
  5463. if (NO_HOLES || index in self) {
  5464. value = self[index];
  5465. result = boundFunction(value, index, O);
  5466. if (TYPE) {
  5467. if (IS_MAP)
  5468. target[index] = result;
  5469. else if (result)
  5470. switch (TYPE) {
  5471. case 3:
  5472. return true;
  5473. case 5:
  5474. return value;
  5475. case 6:
  5476. return index;
  5477. case 2:
  5478. push.call(target, value);
  5479. }
  5480. else if (IS_EVERY)
  5481. return false;
  5482. }
  5483. }
  5484. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  5485. };
  5486. };
  5487. module.exports = {
  5488. forEach: createMethod(0),
  5489. map: createMethod(1),
  5490. filter: createMethod(2),
  5491. some: createMethod(3),
  5492. every: createMethod(4),
  5493. find: createMethod(5),
  5494. findIndex: createMethod(6)
  5495. };
  5496. /***/ }),
  5497. /* 136 */
  5498. /***/ (function(module, exports, __w_pdfjs_require__) {
  5499. var isObject = __w_pdfjs_require__(19);
  5500. var isArray = __w_pdfjs_require__(137);
  5501. var wellKnownSymbol = __w_pdfjs_require__(51);
  5502. var SPECIES = wellKnownSymbol('species');
  5503. module.exports = function (originalArray, length) {
  5504. var C;
  5505. if (isArray(originalArray)) {
  5506. C = originalArray.constructor;
  5507. if (typeof C == 'function' && (C === Array || isArray(C.prototype)))
  5508. C = undefined;
  5509. else if (isObject(C)) {
  5510. C = C[SPECIES];
  5511. if (C === null)
  5512. C = undefined;
  5513. }
  5514. }
  5515. return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  5516. };
  5517. /***/ }),
  5518. /* 137 */
  5519. /***/ (function(module, exports, __w_pdfjs_require__) {
  5520. var classof = __w_pdfjs_require__(16);
  5521. module.exports = Array.isArray || function isArray(arg) {
  5522. return classof(arg) == 'Array';
  5523. };
  5524. /***/ }),
  5525. /* 138 */
  5526. /***/ (function(module, exports, __w_pdfjs_require__) {
  5527. __w_pdfjs_require__(100);
  5528. __w_pdfjs_require__(139);
  5529. __w_pdfjs_require__(102);
  5530. var path = __w_pdfjs_require__(39);
  5531. module.exports = path.WeakSet;
  5532. /***/ }),
  5533. /* 139 */
  5534. /***/ (function(module, exports, __w_pdfjs_require__) {
  5535. "use strict";
  5536. var collection = __w_pdfjs_require__(132);
  5537. var collectionWeak = __w_pdfjs_require__(134);
  5538. collection('WeakSet', function (get) {
  5539. return function WeakSet() {
  5540. return get(this, arguments.length ? arguments[0] : undefined);
  5541. };
  5542. }, collectionWeak, false, true);
  5543. /***/ }),
  5544. /* 140 */
  5545. /***/ (function(module, exports, __w_pdfjs_require__) {
  5546. __w_pdfjs_require__(141);
  5547. var entryUnbind = __w_pdfjs_require__(54);
  5548. module.exports = entryUnbind('String', 'codePointAt');
  5549. /***/ }),
  5550. /* 141 */
  5551. /***/ (function(module, exports, __w_pdfjs_require__) {
  5552. "use strict";
  5553. var $ = __w_pdfjs_require__(7);
  5554. var codeAt = __w_pdfjs_require__(70).codeAt;
  5555. $({
  5556. target: 'String',
  5557. proto: true
  5558. }, {
  5559. codePointAt: function codePointAt(pos) {
  5560. return codeAt(this, pos);
  5561. }
  5562. });
  5563. /***/ }),
  5564. /* 142 */
  5565. /***/ (function(module, exports, __w_pdfjs_require__) {
  5566. __w_pdfjs_require__(143);
  5567. var path = __w_pdfjs_require__(39);
  5568. module.exports = path.String.fromCodePoint;
  5569. /***/ }),
  5570. /* 143 */
  5571. /***/ (function(module, exports, __w_pdfjs_require__) {
  5572. var $ = __w_pdfjs_require__(7);
  5573. var toAbsoluteIndex = __w_pdfjs_require__(45);
  5574. var fromCharCode = String.fromCharCode;
  5575. var nativeFromCodePoint = String.fromCodePoint;
  5576. var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;
  5577. $({
  5578. target: 'String',
  5579. stat: true,
  5580. forced: INCORRECT_LENGTH
  5581. }, {
  5582. fromCodePoint: function fromCodePoint(x) {
  5583. var elements = [];
  5584. var length = arguments.length;
  5585. var i = 0;
  5586. var code;
  5587. while (length > i) {
  5588. code = +arguments[i++];
  5589. if (toAbsoluteIndex(code, 0x10FFFF) !== code)
  5590. throw RangeError(code + ' is not a valid code point');
  5591. elements.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00));
  5592. }
  5593. return elements.join('');
  5594. }
  5595. });
  5596. /***/ }),
  5597. /* 144 */
  5598. /***/ (function(module, exports, __w_pdfjs_require__) {
  5599. __w_pdfjs_require__(145);
  5600. __w_pdfjs_require__(100);
  5601. __w_pdfjs_require__(147);
  5602. __w_pdfjs_require__(151);
  5603. __w_pdfjs_require__(152);
  5604. __w_pdfjs_require__(153);
  5605. __w_pdfjs_require__(154);
  5606. __w_pdfjs_require__(155);
  5607. __w_pdfjs_require__(156);
  5608. __w_pdfjs_require__(157);
  5609. __w_pdfjs_require__(158);
  5610. __w_pdfjs_require__(159);
  5611. __w_pdfjs_require__(160);
  5612. __w_pdfjs_require__(161);
  5613. __w_pdfjs_require__(162);
  5614. __w_pdfjs_require__(163);
  5615. __w_pdfjs_require__(164);
  5616. __w_pdfjs_require__(165);
  5617. __w_pdfjs_require__(166);
  5618. var path = __w_pdfjs_require__(39);
  5619. module.exports = path.Symbol;
  5620. /***/ }),
  5621. /* 145 */
  5622. /***/ (function(module, exports, __w_pdfjs_require__) {
  5623. "use strict";
  5624. var $ = __w_pdfjs_require__(7);
  5625. var fails = __w_pdfjs_require__(11);
  5626. var isArray = __w_pdfjs_require__(137);
  5627. var isObject = __w_pdfjs_require__(19);
  5628. var toObject = __w_pdfjs_require__(75);
  5629. var toLength = __w_pdfjs_require__(43);
  5630. var createProperty = __w_pdfjs_require__(85);
  5631. var arraySpeciesCreate = __w_pdfjs_require__(136);
  5632. var arrayMethodHasSpeciesSupport = __w_pdfjs_require__(146);
  5633. var wellKnownSymbol = __w_pdfjs_require__(51);
  5634. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  5635. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  5636. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  5637. var IS_CONCAT_SPREADABLE_SUPPORT = !fails(function () {
  5638. var array = [];
  5639. array[IS_CONCAT_SPREADABLE] = false;
  5640. return array.concat()[0] !== array;
  5641. });
  5642. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  5643. var isConcatSpreadable = function (O) {
  5644. if (!isObject(O))
  5645. return false;
  5646. var spreadable = O[IS_CONCAT_SPREADABLE];
  5647. return spreadable !== undefined ? !!spreadable : isArray(O);
  5648. };
  5649. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  5650. $({
  5651. target: 'Array',
  5652. proto: true,
  5653. forced: FORCED
  5654. }, {
  5655. concat: function concat(arg) {
  5656. var O = toObject(this);
  5657. var A = arraySpeciesCreate(O, 0);
  5658. var n = 0;
  5659. var i, k, length, len, E;
  5660. for (i = -1, length = arguments.length; i < length; i++) {
  5661. E = i === -1 ? O : arguments[i];
  5662. if (isConcatSpreadable(E)) {
  5663. len = toLength(E.length);
  5664. if (n + len > MAX_SAFE_INTEGER)
  5665. throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  5666. for (k = 0; k < len; k++, n++)
  5667. if (k in E)
  5668. createProperty(A, n, E[k]);
  5669. } else {
  5670. if (n >= MAX_SAFE_INTEGER)
  5671. throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  5672. createProperty(A, n++, E);
  5673. }
  5674. }
  5675. A.length = n;
  5676. return A;
  5677. }
  5678. });
  5679. /***/ }),
  5680. /* 146 */
  5681. /***/ (function(module, exports, __w_pdfjs_require__) {
  5682. var fails = __w_pdfjs_require__(11);
  5683. var wellKnownSymbol = __w_pdfjs_require__(51);
  5684. var SPECIES = wellKnownSymbol('species');
  5685. module.exports = function (METHOD_NAME) {
  5686. return !fails(function () {
  5687. var array = [];
  5688. var constructor = array.constructor = {};
  5689. constructor[SPECIES] = function () {
  5690. return { foo: 1 };
  5691. };
  5692. return array[METHOD_NAME](Boolean).foo !== 1;
  5693. });
  5694. };
  5695. /***/ }),
  5696. /* 147 */
  5697. /***/ (function(module, exports, __w_pdfjs_require__) {
  5698. "use strict";
  5699. var $ = __w_pdfjs_require__(7);
  5700. var global = __w_pdfjs_require__(8);
  5701. var IS_PURE = __w_pdfjs_require__(29);
  5702. var DESCRIPTORS = __w_pdfjs_require__(10);
  5703. var NATIVE_SYMBOL = __w_pdfjs_require__(52);
  5704. var fails = __w_pdfjs_require__(11);
  5705. var has = __w_pdfjs_require__(20);
  5706. var isArray = __w_pdfjs_require__(137);
  5707. var isObject = __w_pdfjs_require__(19);
  5708. var anObject = __w_pdfjs_require__(25);
  5709. var toObject = __w_pdfjs_require__(75);
  5710. var toIndexedObject = __w_pdfjs_require__(14);
  5711. var toPrimitive = __w_pdfjs_require__(18);
  5712. var createPropertyDescriptor = __w_pdfjs_require__(13);
  5713. var nativeObjectCreate = __w_pdfjs_require__(64);
  5714. var objectKeys = __w_pdfjs_require__(66);
  5715. var getOwnPropertyNamesModule = __w_pdfjs_require__(40);
  5716. var getOwnPropertyNamesExternal = __w_pdfjs_require__(148);
  5717. var getOwnPropertySymbolsModule = __w_pdfjs_require__(47);
  5718. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(9);
  5719. var definePropertyModule = __w_pdfjs_require__(24);
  5720. var propertyIsEnumerableModule = __w_pdfjs_require__(12);
  5721. var hide = __w_pdfjs_require__(23);
  5722. var redefine = __w_pdfjs_require__(26);
  5723. var shared = __w_pdfjs_require__(27);
  5724. var sharedKey = __w_pdfjs_require__(33);
  5725. var hiddenKeys = __w_pdfjs_require__(35);
  5726. var uid = __w_pdfjs_require__(34);
  5727. var wellKnownSymbol = __w_pdfjs_require__(51);
  5728. var wrappedWellKnownSymbolModule = __w_pdfjs_require__(149);
  5729. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  5730. var setToStringTag = __w_pdfjs_require__(77);
  5731. var InternalStateModule = __w_pdfjs_require__(31);
  5732. var $forEach = __w_pdfjs_require__(135).forEach;
  5733. var HIDDEN = sharedKey('hidden');
  5734. var SYMBOL = 'Symbol';
  5735. var PROTOTYPE = 'prototype';
  5736. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  5737. var setInternalState = InternalStateModule.set;
  5738. var getInternalState = InternalStateModule.getterFor(SYMBOL);
  5739. var ObjectPrototype = Object[PROTOTYPE];
  5740. var $Symbol = global.Symbol;
  5741. var JSON = global.JSON;
  5742. var nativeJSONStringify = JSON && JSON.stringify;
  5743. var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  5744. var nativeDefineProperty = definePropertyModule.f;
  5745. var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
  5746. var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
  5747. var AllSymbols = shared('symbols');
  5748. var ObjectPrototypeSymbols = shared('op-symbols');
  5749. var StringToSymbolRegistry = shared('string-to-symbol-registry');
  5750. var SymbolToStringRegistry = shared('symbol-to-string-registry');
  5751. var WellKnownSymbolsStore = shared('wks');
  5752. var QObject = global.QObject;
  5753. var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  5754. var setSymbolDescriptor = DESCRIPTORS && fails(function () {
  5755. return nativeObjectCreate(nativeDefineProperty({}, 'a', {
  5756. get: function () {
  5757. return nativeDefineProperty(this, 'a', { value: 7 }).a;
  5758. }
  5759. })).a != 7;
  5760. }) ? function (O, P, Attributes) {
  5761. var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
  5762. if (ObjectPrototypeDescriptor)
  5763. delete ObjectPrototype[P];
  5764. nativeDefineProperty(O, P, Attributes);
  5765. if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
  5766. nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
  5767. }
  5768. } : nativeDefineProperty;
  5769. var wrap = function (tag, description) {
  5770. var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
  5771. setInternalState(symbol, {
  5772. type: SYMBOL,
  5773. tag: tag,
  5774. description: description
  5775. });
  5776. if (!DESCRIPTORS)
  5777. symbol.description = description;
  5778. return symbol;
  5779. };
  5780. var isSymbol = NATIVE_SYMBOL && typeof $Symbol.iterator == 'symbol' ? function (it) {
  5781. return typeof it == 'symbol';
  5782. } : function (it) {
  5783. return Object(it) instanceof $Symbol;
  5784. };
  5785. var $defineProperty = function defineProperty(O, P, Attributes) {
  5786. if (O === ObjectPrototype)
  5787. $defineProperty(ObjectPrototypeSymbols, P, Attributes);
  5788. anObject(O);
  5789. var key = toPrimitive(P, true);
  5790. anObject(Attributes);
  5791. if (has(AllSymbols, key)) {
  5792. if (!Attributes.enumerable) {
  5793. if (!has(O, HIDDEN))
  5794. nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
  5795. O[HIDDEN][key] = true;
  5796. } else {
  5797. if (has(O, HIDDEN) && O[HIDDEN][key])
  5798. O[HIDDEN][key] = false;
  5799. Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) });
  5800. }
  5801. return setSymbolDescriptor(O, key, Attributes);
  5802. }
  5803. return nativeDefineProperty(O, key, Attributes);
  5804. };
  5805. var $defineProperties = function defineProperties(O, Properties) {
  5806. anObject(O);
  5807. var properties = toIndexedObject(Properties);
  5808. var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
  5809. $forEach(keys, function (key) {
  5810. if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key))
  5811. $defineProperty(O, key, properties[key]);
  5812. });
  5813. return O;
  5814. };
  5815. var $create = function create(O, Properties) {
  5816. return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
  5817. };
  5818. var $propertyIsEnumerable = function propertyIsEnumerable(V) {
  5819. var P = toPrimitive(V, true);
  5820. var enumerable = nativePropertyIsEnumerable.call(this, P);
  5821. if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P))
  5822. return false;
  5823. return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
  5824. };
  5825. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
  5826. var it = toIndexedObject(O);
  5827. var key = toPrimitive(P, true);
  5828. if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key))
  5829. return;
  5830. var descriptor = nativeGetOwnPropertyDescriptor(it, key);
  5831. if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) {
  5832. descriptor.enumerable = true;
  5833. }
  5834. return descriptor;
  5835. };
  5836. var $getOwnPropertyNames = function getOwnPropertyNames(O) {
  5837. var names = nativeGetOwnPropertyNames(toIndexedObject(O));
  5838. var result = [];
  5839. $forEach(names, function (key) {
  5840. if (!has(AllSymbols, key) && !has(hiddenKeys, key))
  5841. result.push(key);
  5842. });
  5843. return result;
  5844. };
  5845. var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
  5846. var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
  5847. var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
  5848. var result = [];
  5849. $forEach(names, function (key) {
  5850. if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) {
  5851. result.push(AllSymbols[key]);
  5852. }
  5853. });
  5854. return result;
  5855. };
  5856. if (!NATIVE_SYMBOL) {
  5857. $Symbol = function Symbol() {
  5858. if (this instanceof $Symbol)
  5859. throw TypeError('Symbol is not a constructor');
  5860. var description = !arguments.length || arguments[0] === undefined ? undefined : String(arguments[0]);
  5861. var tag = uid(description);
  5862. var setter = function (value) {
  5863. if (this === ObjectPrototype)
  5864. setter.call(ObjectPrototypeSymbols, value);
  5865. if (has(this, HIDDEN) && has(this[HIDDEN], tag))
  5866. this[HIDDEN][tag] = false;
  5867. setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
  5868. };
  5869. if (DESCRIPTORS && USE_SETTER)
  5870. setSymbolDescriptor(ObjectPrototype, tag, {
  5871. configurable: true,
  5872. set: setter
  5873. });
  5874. return wrap(tag, description);
  5875. };
  5876. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  5877. return getInternalState(this).tag;
  5878. });
  5879. propertyIsEnumerableModule.f = $propertyIsEnumerable;
  5880. definePropertyModule.f = $defineProperty;
  5881. getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
  5882. getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
  5883. getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
  5884. if (DESCRIPTORS) {
  5885. nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
  5886. configurable: true,
  5887. get: function description() {
  5888. return getInternalState(this).description;
  5889. }
  5890. });
  5891. if (!IS_PURE) {
  5892. redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true });
  5893. }
  5894. }
  5895. wrappedWellKnownSymbolModule.f = function (name) {
  5896. return wrap(wellKnownSymbol(name), name);
  5897. };
  5898. }
  5899. $({
  5900. global: true,
  5901. wrap: true,
  5902. forced: !NATIVE_SYMBOL,
  5903. sham: !NATIVE_SYMBOL
  5904. }, { Symbol: $Symbol });
  5905. $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
  5906. defineWellKnownSymbol(name);
  5907. });
  5908. $({
  5909. target: SYMBOL,
  5910. stat: true,
  5911. forced: !NATIVE_SYMBOL
  5912. }, {
  5913. 'for': function (key) {
  5914. var string = String(key);
  5915. if (has(StringToSymbolRegistry, string))
  5916. return StringToSymbolRegistry[string];
  5917. var symbol = $Symbol(string);
  5918. StringToSymbolRegistry[string] = symbol;
  5919. SymbolToStringRegistry[symbol] = string;
  5920. return symbol;
  5921. },
  5922. keyFor: function keyFor(sym) {
  5923. if (!isSymbol(sym))
  5924. throw TypeError(sym + ' is not a symbol');
  5925. if (has(SymbolToStringRegistry, sym))
  5926. return SymbolToStringRegistry[sym];
  5927. },
  5928. useSetter: function () {
  5929. USE_SETTER = true;
  5930. },
  5931. useSimple: function () {
  5932. USE_SETTER = false;
  5933. }
  5934. });
  5935. $({
  5936. target: 'Object',
  5937. stat: true,
  5938. forced: !NATIVE_SYMBOL,
  5939. sham: !DESCRIPTORS
  5940. }, {
  5941. create: $create,
  5942. defineProperty: $defineProperty,
  5943. defineProperties: $defineProperties,
  5944. getOwnPropertyDescriptor: $getOwnPropertyDescriptor
  5945. });
  5946. $({
  5947. target: 'Object',
  5948. stat: true,
  5949. forced: !NATIVE_SYMBOL
  5950. }, {
  5951. getOwnPropertyNames: $getOwnPropertyNames,
  5952. getOwnPropertySymbols: $getOwnPropertySymbols
  5953. });
  5954. $({
  5955. target: 'Object',
  5956. stat: true,
  5957. forced: fails(function () {
  5958. getOwnPropertySymbolsModule.f(1);
  5959. })
  5960. }, {
  5961. getOwnPropertySymbols: function getOwnPropertySymbols(it) {
  5962. return getOwnPropertySymbolsModule.f(toObject(it));
  5963. }
  5964. });
  5965. JSON && $({
  5966. target: 'JSON',
  5967. stat: true,
  5968. forced: !NATIVE_SYMBOL || fails(function () {
  5969. var symbol = $Symbol();
  5970. return nativeJSONStringify([symbol]) != '[null]' || nativeJSONStringify({ a: symbol }) != '{}' || nativeJSONStringify(Object(symbol)) != '{}';
  5971. })
  5972. }, {
  5973. stringify: function stringify(it) {
  5974. var args = [it];
  5975. var index = 1;
  5976. var replacer, $replacer;
  5977. while (arguments.length > index)
  5978. args.push(arguments[index++]);
  5979. $replacer = replacer = args[1];
  5980. if (!isObject(replacer) && it === undefined || isSymbol(it))
  5981. return;
  5982. if (!isArray(replacer))
  5983. replacer = function (key, value) {
  5984. if (typeof $replacer == 'function')
  5985. value = $replacer.call(this, key, value);
  5986. if (!isSymbol(value))
  5987. return value;
  5988. };
  5989. args[1] = replacer;
  5990. return nativeJSONStringify.apply(JSON, args);
  5991. }
  5992. });
  5993. if (!$Symbol[PROTOTYPE][TO_PRIMITIVE])
  5994. hide($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  5995. setToStringTag($Symbol, SYMBOL);
  5996. hiddenKeys[HIDDEN] = true;
  5997. /***/ }),
  5998. /* 148 */
  5999. /***/ (function(module, exports, __w_pdfjs_require__) {
  6000. var toIndexedObject = __w_pdfjs_require__(14);
  6001. var nativeGetOwnPropertyNames = __w_pdfjs_require__(40).f;
  6002. var toString = {}.toString;
  6003. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  6004. var getWindowNames = function (it) {
  6005. try {
  6006. return nativeGetOwnPropertyNames(it);
  6007. } catch (error) {
  6008. return windowNames.slice();
  6009. }
  6010. };
  6011. module.exports.f = function getOwnPropertyNames(it) {
  6012. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : nativeGetOwnPropertyNames(toIndexedObject(it));
  6013. };
  6014. /***/ }),
  6015. /* 149 */
  6016. /***/ (function(module, exports, __w_pdfjs_require__) {
  6017. exports.f = __w_pdfjs_require__(51);
  6018. /***/ }),
  6019. /* 150 */
  6020. /***/ (function(module, exports, __w_pdfjs_require__) {
  6021. var path = __w_pdfjs_require__(39);
  6022. var has = __w_pdfjs_require__(20);
  6023. var wrappedWellKnownSymbolModule = __w_pdfjs_require__(149);
  6024. var defineProperty = __w_pdfjs_require__(24).f;
  6025. module.exports = function (NAME) {
  6026. var Symbol = path.Symbol || (path.Symbol = {});
  6027. if (!has(Symbol, NAME))
  6028. defineProperty(Symbol, NAME, { value: wrappedWellKnownSymbolModule.f(NAME) });
  6029. };
  6030. /***/ }),
  6031. /* 151 */
  6032. /***/ (function(module, exports, __w_pdfjs_require__) {
  6033. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6034. defineWellKnownSymbol('asyncIterator');
  6035. /***/ }),
  6036. /* 152 */
  6037. /***/ (function(module, exports, __w_pdfjs_require__) {
  6038. "use strict";
  6039. var $ = __w_pdfjs_require__(7);
  6040. var DESCRIPTORS = __w_pdfjs_require__(10);
  6041. var global = __w_pdfjs_require__(8);
  6042. var has = __w_pdfjs_require__(20);
  6043. var isObject = __w_pdfjs_require__(19);
  6044. var defineProperty = __w_pdfjs_require__(24).f;
  6045. var copyConstructorProperties = __w_pdfjs_require__(36);
  6046. var NativeSymbol = global.Symbol;
  6047. if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || NativeSymbol().description !== undefined)) {
  6048. var EmptyStringDescriptionStore = {};
  6049. var SymbolWrapper = function Symbol() {
  6050. var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]);
  6051. var result = this instanceof SymbolWrapper ? new NativeSymbol(description) : description === undefined ? NativeSymbol() : NativeSymbol(description);
  6052. if (description === '')
  6053. EmptyStringDescriptionStore[result] = true;
  6054. return result;
  6055. };
  6056. copyConstructorProperties(SymbolWrapper, NativeSymbol);
  6057. var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype;
  6058. symbolPrototype.constructor = SymbolWrapper;
  6059. var symbolToString = symbolPrototype.toString;
  6060. var native = String(NativeSymbol('test')) == 'Symbol(test)';
  6061. var regexp = /^Symbol\((.*)\)[^)]+$/;
  6062. defineProperty(symbolPrototype, 'description', {
  6063. configurable: true,
  6064. get: function description() {
  6065. var symbol = isObject(this) ? this.valueOf() : this;
  6066. var string = symbolToString.call(symbol);
  6067. if (has(EmptyStringDescriptionStore, symbol))
  6068. return '';
  6069. var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
  6070. return desc === '' ? undefined : desc;
  6071. }
  6072. });
  6073. $({
  6074. global: true,
  6075. forced: true
  6076. }, { Symbol: SymbolWrapper });
  6077. }
  6078. /***/ }),
  6079. /* 153 */
  6080. /***/ (function(module, exports, __w_pdfjs_require__) {
  6081. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6082. defineWellKnownSymbol('hasInstance');
  6083. /***/ }),
  6084. /* 154 */
  6085. /***/ (function(module, exports, __w_pdfjs_require__) {
  6086. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6087. defineWellKnownSymbol('isConcatSpreadable');
  6088. /***/ }),
  6089. /* 155 */
  6090. /***/ (function(module, exports, __w_pdfjs_require__) {
  6091. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6092. defineWellKnownSymbol('iterator');
  6093. /***/ }),
  6094. /* 156 */
  6095. /***/ (function(module, exports, __w_pdfjs_require__) {
  6096. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6097. defineWellKnownSymbol('match');
  6098. /***/ }),
  6099. /* 157 */
  6100. /***/ (function(module, exports, __w_pdfjs_require__) {
  6101. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6102. defineWellKnownSymbol('matchAll');
  6103. /***/ }),
  6104. /* 158 */
  6105. /***/ (function(module, exports, __w_pdfjs_require__) {
  6106. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6107. defineWellKnownSymbol('replace');
  6108. /***/ }),
  6109. /* 159 */
  6110. /***/ (function(module, exports, __w_pdfjs_require__) {
  6111. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6112. defineWellKnownSymbol('search');
  6113. /***/ }),
  6114. /* 160 */
  6115. /***/ (function(module, exports, __w_pdfjs_require__) {
  6116. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6117. defineWellKnownSymbol('species');
  6118. /***/ }),
  6119. /* 161 */
  6120. /***/ (function(module, exports, __w_pdfjs_require__) {
  6121. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6122. defineWellKnownSymbol('split');
  6123. /***/ }),
  6124. /* 162 */
  6125. /***/ (function(module, exports, __w_pdfjs_require__) {
  6126. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6127. defineWellKnownSymbol('toPrimitive');
  6128. /***/ }),
  6129. /* 163 */
  6130. /***/ (function(module, exports, __w_pdfjs_require__) {
  6131. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6132. defineWellKnownSymbol('toStringTag');
  6133. /***/ }),
  6134. /* 164 */
  6135. /***/ (function(module, exports, __w_pdfjs_require__) {
  6136. var defineWellKnownSymbol = __w_pdfjs_require__(150);
  6137. defineWellKnownSymbol('unscopables');
  6138. /***/ }),
  6139. /* 165 */
  6140. /***/ (function(module, exports, __w_pdfjs_require__) {
  6141. var setToStringTag = __w_pdfjs_require__(77);
  6142. setToStringTag(Math, 'Math', true);
  6143. /***/ }),
  6144. /* 166 */
  6145. /***/ (function(module, exports, __w_pdfjs_require__) {
  6146. var global = __w_pdfjs_require__(8);
  6147. var setToStringTag = __w_pdfjs_require__(77);
  6148. setToStringTag(global.JSON, 'JSON', true);
  6149. /***/ }),
  6150. /* 167 */
  6151. /***/ (function(module, exports, __w_pdfjs_require__) {
  6152. __w_pdfjs_require__(168);
  6153. var entryUnbind = __w_pdfjs_require__(54);
  6154. module.exports = entryUnbind('String', 'padStart');
  6155. /***/ }),
  6156. /* 168 */
  6157. /***/ (function(module, exports, __w_pdfjs_require__) {
  6158. "use strict";
  6159. var $ = __w_pdfjs_require__(7);
  6160. var $padStart = __w_pdfjs_require__(169).start;
  6161. var WEBKIT_BUG = __w_pdfjs_require__(171);
  6162. $({
  6163. target: 'String',
  6164. proto: true,
  6165. forced: WEBKIT_BUG
  6166. }, {
  6167. padStart: function padStart(maxLength) {
  6168. return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  6169. }
  6170. });
  6171. /***/ }),
  6172. /* 169 */
  6173. /***/ (function(module, exports, __w_pdfjs_require__) {
  6174. var toLength = __w_pdfjs_require__(43);
  6175. var repeat = __w_pdfjs_require__(170);
  6176. var requireObjectCoercible = __w_pdfjs_require__(17);
  6177. var ceil = Math.ceil;
  6178. var createMethod = function (IS_END) {
  6179. return function ($this, maxLength, fillString) {
  6180. var S = String(requireObjectCoercible($this));
  6181. var stringLength = S.length;
  6182. var fillStr = fillString === undefined ? ' ' : String(fillString);
  6183. var intMaxLength = toLength(maxLength);
  6184. var fillLen, stringFiller;
  6185. if (intMaxLength <= stringLength || fillStr == '')
  6186. return S;
  6187. fillLen = intMaxLength - stringLength;
  6188. stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));
  6189. if (stringFiller.length > fillLen)
  6190. stringFiller = stringFiller.slice(0, fillLen);
  6191. return IS_END ? S + stringFiller : stringFiller + S;
  6192. };
  6193. };
  6194. module.exports = {
  6195. start: createMethod(false),
  6196. end: createMethod(true)
  6197. };
  6198. /***/ }),
  6199. /* 170 */
  6200. /***/ (function(module, exports, __w_pdfjs_require__) {
  6201. "use strict";
  6202. var toInteger = __w_pdfjs_require__(44);
  6203. var requireObjectCoercible = __w_pdfjs_require__(17);
  6204. module.exports = ''.repeat || function repeat(count) {
  6205. var str = String(requireObjectCoercible(this));
  6206. var result = '';
  6207. var n = toInteger(count);
  6208. if (n < 0 || n == Infinity)
  6209. throw RangeError('Wrong number of repetitions');
  6210. for (; n > 0; (n >>>= 1) && (str += str))
  6211. if (n & 1)
  6212. result += str;
  6213. return result;
  6214. };
  6215. /***/ }),
  6216. /* 171 */
  6217. /***/ (function(module, exports, __w_pdfjs_require__) {
  6218. var userAgent = __w_pdfjs_require__(114);
  6219. module.exports = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
  6220. /***/ }),
  6221. /* 172 */
  6222. /***/ (function(module, exports, __w_pdfjs_require__) {
  6223. __w_pdfjs_require__(173);
  6224. var entryUnbind = __w_pdfjs_require__(54);
  6225. module.exports = entryUnbind('String', 'padEnd');
  6226. /***/ }),
  6227. /* 173 */
  6228. /***/ (function(module, exports, __w_pdfjs_require__) {
  6229. "use strict";
  6230. var $ = __w_pdfjs_require__(7);
  6231. var $padEnd = __w_pdfjs_require__(169).end;
  6232. var WEBKIT_BUG = __w_pdfjs_require__(171);
  6233. $({
  6234. target: 'String',
  6235. proto: true,
  6236. forced: WEBKIT_BUG
  6237. }, {
  6238. padEnd: function padEnd(maxLength) {
  6239. return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
  6240. }
  6241. });
  6242. /***/ }),
  6243. /* 174 */
  6244. /***/ (function(module, exports, __w_pdfjs_require__) {
  6245. __w_pdfjs_require__(175);
  6246. var path = __w_pdfjs_require__(39);
  6247. module.exports = path.Object.values;
  6248. /***/ }),
  6249. /* 175 */
  6250. /***/ (function(module, exports, __w_pdfjs_require__) {
  6251. var $ = __w_pdfjs_require__(7);
  6252. var $values = __w_pdfjs_require__(176).values;
  6253. $({
  6254. target: 'Object',
  6255. stat: true
  6256. }, {
  6257. values: function values(O) {
  6258. return $values(O);
  6259. }
  6260. });
  6261. /***/ }),
  6262. /* 176 */
  6263. /***/ (function(module, exports, __w_pdfjs_require__) {
  6264. var DESCRIPTORS = __w_pdfjs_require__(10);
  6265. var objectKeys = __w_pdfjs_require__(66);
  6266. var toIndexedObject = __w_pdfjs_require__(14);
  6267. var propertyIsEnumerable = __w_pdfjs_require__(12).f;
  6268. var createMethod = function (TO_ENTRIES) {
  6269. return function (it) {
  6270. var O = toIndexedObject(it);
  6271. var keys = objectKeys(O);
  6272. var length = keys.length;
  6273. var i = 0;
  6274. var result = [];
  6275. var key;
  6276. while (length > i) {
  6277. key = keys[i++];
  6278. if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) {
  6279. result.push(TO_ENTRIES ? [
  6280. key,
  6281. O[key]
  6282. ] : O[key]);
  6283. }
  6284. }
  6285. return result;
  6286. };
  6287. };
  6288. module.exports = {
  6289. entries: createMethod(true),
  6290. values: createMethod(false)
  6291. };
  6292. /***/ }),
  6293. /* 177 */
  6294. /***/ (function(module, exports, __w_pdfjs_require__) {
  6295. "use strict";
  6296. {
  6297. var isReadableStreamSupported = false;
  6298. if (typeof ReadableStream !== 'undefined') {
  6299. try {
  6300. new ReadableStream({
  6301. start: function start(controller) {
  6302. controller.close();
  6303. }
  6304. });
  6305. isReadableStreamSupported = true;
  6306. } catch (e) {}
  6307. }
  6308. if (isReadableStreamSupported) {
  6309. exports.ReadableStream = ReadableStream;
  6310. } else {
  6311. exports.ReadableStream = __w_pdfjs_require__(178).ReadableStream;
  6312. }
  6313. }
  6314. /***/ }),
  6315. /* 178 */
  6316. /***/ (function(__webpack_module__, __webpack_exports__, __w_pdfjs_require__) {
  6317. "use strict";
  6318. __w_pdfjs_require__.r(__webpack_exports__);
  6319. /* harmony export (binding) */ __w_pdfjs_require__.d(__webpack_exports__, "ByteLengthQueuingStrategy", function() { return ByteLengthQueuingStrategy; });
  6320. /* harmony export (binding) */ __w_pdfjs_require__.d(__webpack_exports__, "CountQueuingStrategy", function() { return CountQueuingStrategy; });
  6321. /* harmony export (binding) */ __w_pdfjs_require__.d(__webpack_exports__, "ReadableStream", function() { return ReadableStream; });
  6322. /* harmony export (binding) */ __w_pdfjs_require__.d(__webpack_exports__, "TransformStream", function() { return TransformStream; });
  6323. /* harmony export (binding) */ __w_pdfjs_require__.d(__webpack_exports__, "WritableStream", function() { return WritableStream; });
  6324. var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol : function (description) {
  6325. return "Symbol(" + description + ")";
  6326. };
  6327. function noop() {
  6328. }
  6329. var NumberIsNaN = Number.isNaN || function (x) {
  6330. return x !== x;
  6331. };
  6332. function typeIsObject(x) {
  6333. return typeof x === 'object' && x !== null || typeof x === 'function';
  6334. }
  6335. function createArrayFromList(elements) {
  6336. return elements.slice();
  6337. }
  6338. function ArrayBufferCopy(dest, destOffset, src, srcOffset, n) {
  6339. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  6340. }
  6341. function IsFiniteNonNegativeNumber(v) {
  6342. if (IsNonNegativeNumber(v) === false) {
  6343. return false;
  6344. }
  6345. if (v === Infinity) {
  6346. return false;
  6347. }
  6348. return true;
  6349. }
  6350. function IsNonNegativeNumber(v) {
  6351. if (typeof v !== 'number') {
  6352. return false;
  6353. }
  6354. if (NumberIsNaN(v)) {
  6355. return false;
  6356. }
  6357. if (v < 0) {
  6358. return false;
  6359. }
  6360. return true;
  6361. }
  6362. function Call(F, V, args) {
  6363. if (typeof F !== 'function') {
  6364. throw new TypeError('Argument is not a function');
  6365. }
  6366. return Function.prototype.apply.call(F, V, args);
  6367. }
  6368. function CreateAlgorithmFromUnderlyingMethod(underlyingObject, methodName, algoArgCount, extraArgs) {
  6369. var method = underlyingObject[methodName];
  6370. if (method !== undefined) {
  6371. if (typeof method !== 'function') {
  6372. throw new TypeError(method + " is not a method");
  6373. }
  6374. switch (algoArgCount) {
  6375. case 0: {
  6376. return function () {
  6377. return PromiseCall(method, underlyingObject, extraArgs);
  6378. };
  6379. }
  6380. case 1: {
  6381. return function (arg) {
  6382. var fullArgs = [arg].concat(extraArgs);
  6383. return PromiseCall(method, underlyingObject, fullArgs);
  6384. };
  6385. }
  6386. }
  6387. }
  6388. return function () {
  6389. return Promise.resolve();
  6390. };
  6391. }
  6392. function InvokeOrNoop(O, P, args) {
  6393. var method = O[P];
  6394. if (method === undefined) {
  6395. return undefined;
  6396. }
  6397. return Call(method, O, args);
  6398. }
  6399. function PromiseCall(F, V, args) {
  6400. try {
  6401. return Promise.resolve(Call(F, V, args));
  6402. } catch (value) {
  6403. return Promise.reject(value);
  6404. }
  6405. }
  6406. function TransferArrayBuffer(O) {
  6407. return O;
  6408. }
  6409. function IsDetachedBuffer(O) {
  6410. return false;
  6411. }
  6412. function ValidateAndNormalizeHighWaterMark(highWaterMark) {
  6413. highWaterMark = Number(highWaterMark);
  6414. if (NumberIsNaN(highWaterMark) || highWaterMark < 0) {
  6415. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  6416. }
  6417. return highWaterMark;
  6418. }
  6419. function MakeSizeAlgorithmFromSizeFunction(size) {
  6420. if (size === undefined) {
  6421. return function () {
  6422. return 1;
  6423. };
  6424. }
  6425. if (typeof size !== 'function') {
  6426. throw new TypeError('size property of a queuing strategy must be a function');
  6427. }
  6428. return function (chunk) {
  6429. return size(chunk);
  6430. };
  6431. }
  6432. var QUEUE_MAX_ARRAY_SIZE = 16384;
  6433. var SimpleQueue = function () {
  6434. function SimpleQueue() {
  6435. this._cursor = 0;
  6436. this._size = 0;
  6437. this._front = {
  6438. _elements: [],
  6439. _next: undefined
  6440. };
  6441. this._back = this._front;
  6442. this._cursor = 0;
  6443. this._size = 0;
  6444. }
  6445. Object.defineProperty(SimpleQueue.prototype, "length", {
  6446. get: function () {
  6447. return this._size;
  6448. },
  6449. enumerable: true,
  6450. configurable: true
  6451. });
  6452. SimpleQueue.prototype.push = function (element) {
  6453. var oldBack = this._back;
  6454. var newBack = oldBack;
  6455. if (oldBack._elements.length === QUEUE_MAX_ARRAY_SIZE - 1) {
  6456. newBack = {
  6457. _elements: [],
  6458. _next: undefined
  6459. };
  6460. }
  6461. oldBack._elements.push(element);
  6462. if (newBack !== oldBack) {
  6463. this._back = newBack;
  6464. oldBack._next = newBack;
  6465. }
  6466. ++this._size;
  6467. };
  6468. SimpleQueue.prototype.shift = function () {
  6469. var oldFront = this._front;
  6470. var newFront = oldFront;
  6471. var oldCursor = this._cursor;
  6472. var newCursor = oldCursor + 1;
  6473. var elements = oldFront._elements;
  6474. var element = elements[oldCursor];
  6475. if (newCursor === QUEUE_MAX_ARRAY_SIZE) {
  6476. newFront = oldFront._next;
  6477. newCursor = 0;
  6478. }
  6479. --this._size;
  6480. this._cursor = newCursor;
  6481. if (oldFront !== newFront) {
  6482. this._front = newFront;
  6483. }
  6484. elements[oldCursor] = undefined;
  6485. return element;
  6486. };
  6487. SimpleQueue.prototype.forEach = function (callback) {
  6488. var i = this._cursor;
  6489. var node = this._front;
  6490. var elements = node._elements;
  6491. while (i !== elements.length || node._next !== undefined) {
  6492. if (i === elements.length) {
  6493. node = node._next;
  6494. elements = node._elements;
  6495. i = 0;
  6496. if (elements.length === 0) {
  6497. break;
  6498. }
  6499. }
  6500. callback(elements[i]);
  6501. ++i;
  6502. }
  6503. };
  6504. SimpleQueue.prototype.peek = function () {
  6505. var front = this._front;
  6506. var cursor = this._cursor;
  6507. return front._elements[cursor];
  6508. };
  6509. return SimpleQueue;
  6510. }();
  6511. function ReadableStreamCreateReadResult(value, done, forAuthorCode) {
  6512. var prototype = null;
  6513. if (forAuthorCode === true) {
  6514. prototype = Object.prototype;
  6515. }
  6516. var obj = Object.create(prototype);
  6517. obj.value = value;
  6518. obj.done = done;
  6519. return obj;
  6520. }
  6521. function ReadableStreamReaderGenericInitialize(reader, stream) {
  6522. reader._forAuthorCode = true;
  6523. reader._ownerReadableStream = stream;
  6524. stream._reader = reader;
  6525. if (stream._state === 'readable') {
  6526. defaultReaderClosedPromiseInitialize(reader);
  6527. } else if (stream._state === 'closed') {
  6528. defaultReaderClosedPromiseInitializeAsResolved(reader);
  6529. } else {
  6530. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  6531. }
  6532. }
  6533. function ReadableStreamReaderGenericCancel(reader, reason) {
  6534. var stream = reader._ownerReadableStream;
  6535. return ReadableStreamCancel(stream, reason);
  6536. }
  6537. function ReadableStreamReaderGenericRelease(reader) {
  6538. if (reader._ownerReadableStream._state === 'readable') {
  6539. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  6540. } else {
  6541. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  6542. }
  6543. reader._ownerReadableStream._reader = undefined;
  6544. reader._ownerReadableStream = undefined;
  6545. }
  6546. function readerLockException(name) {
  6547. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  6548. }
  6549. function defaultReaderClosedPromiseInitialize(reader) {
  6550. reader._closedPromise = new Promise(function (resolve, reject) {
  6551. reader._closedPromise_resolve = resolve;
  6552. reader._closedPromise_reject = reject;
  6553. });
  6554. }
  6555. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  6556. defaultReaderClosedPromiseInitialize(reader);
  6557. defaultReaderClosedPromiseReject(reader, reason);
  6558. }
  6559. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  6560. defaultReaderClosedPromiseInitialize(reader);
  6561. defaultReaderClosedPromiseResolve(reader);
  6562. }
  6563. function defaultReaderClosedPromiseReject(reader, reason) {
  6564. reader._closedPromise.catch(noop);
  6565. reader._closedPromise_reject(reason);
  6566. reader._closedPromise_resolve = undefined;
  6567. reader._closedPromise_reject = undefined;
  6568. }
  6569. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  6570. defaultReaderClosedPromiseInitializeAsRejected(reader, reason);
  6571. }
  6572. function defaultReaderClosedPromiseResolve(reader) {
  6573. reader._closedPromise_resolve(undefined);
  6574. reader._closedPromise_resolve = undefined;
  6575. reader._closedPromise_reject = undefined;
  6576. }
  6577. var CancelSteps = SymbolPolyfill('[[CancelSteps]]');
  6578. var PullSteps = SymbolPolyfill('[[PullSteps]]');
  6579. function AcquireReadableStreamDefaultReader(stream, forAuthorCode) {
  6580. if (forAuthorCode === void 0) {
  6581. forAuthorCode = false;
  6582. }
  6583. var reader = new ReadableStreamDefaultReader(stream);
  6584. reader._forAuthorCode = forAuthorCode;
  6585. return reader;
  6586. }
  6587. function ReadableStreamAddReadRequest(stream) {
  6588. var promise = new Promise(function (resolve, reject) {
  6589. var readRequest = {
  6590. _resolve: resolve,
  6591. _reject: reject
  6592. };
  6593. stream._reader._readRequests.push(readRequest);
  6594. });
  6595. return promise;
  6596. }
  6597. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  6598. var reader = stream._reader;
  6599. var readRequest = reader._readRequests.shift();
  6600. readRequest._resolve(ReadableStreamCreateReadResult(chunk, done, reader._forAuthorCode));
  6601. }
  6602. function ReadableStreamGetNumReadRequests(stream) {
  6603. return stream._reader._readRequests.length;
  6604. }
  6605. function ReadableStreamHasDefaultReader(stream) {
  6606. var reader = stream._reader;
  6607. if (reader === undefined) {
  6608. return false;
  6609. }
  6610. if (!IsReadableStreamDefaultReader(reader)) {
  6611. return false;
  6612. }
  6613. return true;
  6614. }
  6615. var ReadableStreamDefaultReader = function () {
  6616. function ReadableStreamDefaultReader(stream) {
  6617. if (IsReadableStream(stream) === false) {
  6618. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  6619. }
  6620. if (IsReadableStreamLocked(stream) === true) {
  6621. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  6622. }
  6623. ReadableStreamReaderGenericInitialize(this, stream);
  6624. this._readRequests = new SimpleQueue();
  6625. }
  6626. Object.defineProperty(ReadableStreamDefaultReader.prototype, "closed", {
  6627. get: function () {
  6628. if (!IsReadableStreamDefaultReader(this)) {
  6629. return Promise.reject(defaultReaderBrandCheckException('closed'));
  6630. }
  6631. return this._closedPromise;
  6632. },
  6633. enumerable: true,
  6634. configurable: true
  6635. });
  6636. ReadableStreamDefaultReader.prototype.cancel = function (reason) {
  6637. if (!IsReadableStreamDefaultReader(this)) {
  6638. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  6639. }
  6640. if (this._ownerReadableStream === undefined) {
  6641. return Promise.reject(readerLockException('cancel'));
  6642. }
  6643. return ReadableStreamReaderGenericCancel(this, reason);
  6644. };
  6645. ReadableStreamDefaultReader.prototype.read = function () {
  6646. if (!IsReadableStreamDefaultReader(this)) {
  6647. return Promise.reject(defaultReaderBrandCheckException('read'));
  6648. }
  6649. if (this._ownerReadableStream === undefined) {
  6650. return Promise.reject(readerLockException('read from'));
  6651. }
  6652. return ReadableStreamDefaultReaderRead(this);
  6653. };
  6654. ReadableStreamDefaultReader.prototype.releaseLock = function () {
  6655. if (!IsReadableStreamDefaultReader(this)) {
  6656. throw defaultReaderBrandCheckException('releaseLock');
  6657. }
  6658. if (this._ownerReadableStream === undefined) {
  6659. return;
  6660. }
  6661. if (this._readRequests.length > 0) {
  6662. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  6663. }
  6664. ReadableStreamReaderGenericRelease(this);
  6665. };
  6666. return ReadableStreamDefaultReader;
  6667. }();
  6668. function IsReadableStreamDefaultReader(x) {
  6669. if (!typeIsObject(x)) {
  6670. return false;
  6671. }
  6672. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  6673. return false;
  6674. }
  6675. return true;
  6676. }
  6677. function ReadableStreamDefaultReaderRead(reader) {
  6678. var stream = reader._ownerReadableStream;
  6679. stream._disturbed = true;
  6680. if (stream._state === 'closed') {
  6681. return Promise.resolve(ReadableStreamCreateReadResult(undefined, true, reader._forAuthorCode));
  6682. }
  6683. if (stream._state === 'errored') {
  6684. return Promise.reject(stream._storedError);
  6685. }
  6686. return stream._readableStreamController[PullSteps]();
  6687. }
  6688. function defaultReaderBrandCheckException(name) {
  6689. return new TypeError("ReadableStreamDefaultReader.prototype." + name + " can only be used on a ReadableStreamDefaultReader");
  6690. }
  6691. var _a;
  6692. var AsyncIteratorPrototype;
  6693. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  6694. AsyncIteratorPrototype = (_a = {}, _a[SymbolPolyfill.asyncIterator] = function () {
  6695. return this;
  6696. }, _a);
  6697. Object.defineProperty(AsyncIteratorPrototype, SymbolPolyfill.asyncIterator, { enumerable: false });
  6698. }
  6699. var ReadableStreamAsyncIteratorPrototype = {
  6700. next: function () {
  6701. if (IsReadableStreamAsyncIterator(this) === false) {
  6702. return Promise.reject(streamAsyncIteratorBrandCheckException('next'));
  6703. }
  6704. var reader = this._asyncIteratorReader;
  6705. if (reader._ownerReadableStream === undefined) {
  6706. return Promise.reject(readerLockException('iterate'));
  6707. }
  6708. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  6709. var done = result.done;
  6710. if (done) {
  6711. ReadableStreamReaderGenericRelease(reader);
  6712. }
  6713. var value = result.value;
  6714. return ReadableStreamCreateReadResult(value, done, true);
  6715. });
  6716. },
  6717. return: function (value) {
  6718. if (IsReadableStreamAsyncIterator(this) === false) {
  6719. return Promise.reject(streamAsyncIteratorBrandCheckException('next'));
  6720. }
  6721. var reader = this._asyncIteratorReader;
  6722. if (reader._ownerReadableStream === undefined) {
  6723. return Promise.reject(readerLockException('finish iterating'));
  6724. }
  6725. if (reader._readRequests.length > 0) {
  6726. return Promise.reject(new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'));
  6727. }
  6728. if (this._preventCancel === false) {
  6729. var result = ReadableStreamReaderGenericCancel(reader, value);
  6730. ReadableStreamReaderGenericRelease(reader);
  6731. return result.then(function () {
  6732. return ReadableStreamCreateReadResult(value, true, true);
  6733. });
  6734. }
  6735. ReadableStreamReaderGenericRelease(reader);
  6736. return Promise.resolve(ReadableStreamCreateReadResult(value, true, true));
  6737. }
  6738. };
  6739. if (AsyncIteratorPrototype !== undefined) {
  6740. Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
  6741. }
  6742. Object.defineProperty(ReadableStreamAsyncIteratorPrototype, 'next', { enumerable: false });
  6743. Object.defineProperty(ReadableStreamAsyncIteratorPrototype, 'return', { enumerable: false });
  6744. function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
  6745. if (preventCancel === void 0) {
  6746. preventCancel = false;
  6747. }
  6748. var reader = AcquireReadableStreamDefaultReader(stream);
  6749. var iterator = Object.create(ReadableStreamAsyncIteratorPrototype);
  6750. iterator._asyncIteratorReader = reader;
  6751. iterator._preventCancel = Boolean(preventCancel);
  6752. return iterator;
  6753. }
  6754. function IsReadableStreamAsyncIterator(x) {
  6755. if (!typeIsObject(x)) {
  6756. return false;
  6757. }
  6758. if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorReader')) {
  6759. return false;
  6760. }
  6761. return true;
  6762. }
  6763. function streamAsyncIteratorBrandCheckException(name) {
  6764. return new TypeError("ReadableStreamAsyncIterator." + name + " can only be used on a ReadableSteamAsyncIterator");
  6765. }
  6766. var rethrowAssertionErrorRejection = noop;
  6767. function DequeueValue(container) {
  6768. var pair = container._queue.shift();
  6769. container._queueTotalSize -= pair.size;
  6770. if (container._queueTotalSize < 0) {
  6771. container._queueTotalSize = 0;
  6772. }
  6773. return pair.value;
  6774. }
  6775. function EnqueueValueWithSize(container, value, size) {
  6776. size = Number(size);
  6777. if (!IsFiniteNonNegativeNumber(size)) {
  6778. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  6779. }
  6780. container._queue.push({
  6781. value: value,
  6782. size: size
  6783. });
  6784. container._queueTotalSize += size;
  6785. }
  6786. function PeekQueueValue(container) {
  6787. var pair = container._queue.peek();
  6788. return pair.value;
  6789. }
  6790. function ResetQueue(container) {
  6791. container._queue = new SimpleQueue();
  6792. container._queueTotalSize = 0;
  6793. }
  6794. var AbortSteps = SymbolPolyfill('[[AbortSteps]]');
  6795. var ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
  6796. var WritableStream = function () {
  6797. function WritableStream(underlyingSink, strategy) {
  6798. if (underlyingSink === void 0) {
  6799. underlyingSink = {};
  6800. }
  6801. if (strategy === void 0) {
  6802. strategy = {};
  6803. }
  6804. InitializeWritableStream(this);
  6805. var size = strategy.size;
  6806. var highWaterMark = strategy.highWaterMark;
  6807. var type = underlyingSink.type;
  6808. if (type !== undefined) {
  6809. throw new RangeError('Invalid type is specified');
  6810. }
  6811. var sizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(size);
  6812. if (highWaterMark === undefined) {
  6813. highWaterMark = 1;
  6814. }
  6815. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  6816. SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, highWaterMark, sizeAlgorithm);
  6817. }
  6818. Object.defineProperty(WritableStream.prototype, "locked", {
  6819. get: function () {
  6820. if (IsWritableStream(this) === false) {
  6821. throw streamBrandCheckException('locked');
  6822. }
  6823. return IsWritableStreamLocked(this);
  6824. },
  6825. enumerable: true,
  6826. configurable: true
  6827. });
  6828. WritableStream.prototype.abort = function (reason) {
  6829. if (IsWritableStream(this) === false) {
  6830. return Promise.reject(streamBrandCheckException('abort'));
  6831. }
  6832. if (IsWritableStreamLocked(this) === true) {
  6833. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  6834. }
  6835. return WritableStreamAbort(this, reason);
  6836. };
  6837. WritableStream.prototype.getWriter = function () {
  6838. if (IsWritableStream(this) === false) {
  6839. throw streamBrandCheckException('getWriter');
  6840. }
  6841. return AcquireWritableStreamDefaultWriter(this);
  6842. };
  6843. return WritableStream;
  6844. }();
  6845. function AcquireWritableStreamDefaultWriter(stream) {
  6846. return new WritableStreamDefaultWriter(stream);
  6847. }
  6848. function CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  6849. if (highWaterMark === void 0) {
  6850. highWaterMark = 1;
  6851. }
  6852. if (sizeAlgorithm === void 0) {
  6853. sizeAlgorithm = function () {
  6854. return 1;
  6855. };
  6856. }
  6857. var stream = Object.create(WritableStream.prototype);
  6858. InitializeWritableStream(stream);
  6859. var controller = Object.create(WritableStreamDefaultController.prototype);
  6860. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  6861. return stream;
  6862. }
  6863. function InitializeWritableStream(stream) {
  6864. stream._state = 'writable';
  6865. stream._storedError = undefined;
  6866. stream._writer = undefined;
  6867. stream._writableStreamController = undefined;
  6868. stream._writeRequests = new SimpleQueue();
  6869. stream._inFlightWriteRequest = undefined;
  6870. stream._closeRequest = undefined;
  6871. stream._inFlightCloseRequest = undefined;
  6872. stream._pendingAbortRequest = undefined;
  6873. stream._backpressure = false;
  6874. }
  6875. function IsWritableStream(x) {
  6876. if (!typeIsObject(x)) {
  6877. return false;
  6878. }
  6879. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  6880. return false;
  6881. }
  6882. return true;
  6883. }
  6884. function IsWritableStreamLocked(stream) {
  6885. if (stream._writer === undefined) {
  6886. return false;
  6887. }
  6888. return true;
  6889. }
  6890. function WritableStreamAbort(stream, reason) {
  6891. var state = stream._state;
  6892. if (state === 'closed' || state === 'errored') {
  6893. return Promise.resolve(undefined);
  6894. }
  6895. if (stream._pendingAbortRequest !== undefined) {
  6896. return stream._pendingAbortRequest._promise;
  6897. }
  6898. var wasAlreadyErroring = false;
  6899. if (state === 'erroring') {
  6900. wasAlreadyErroring = true;
  6901. reason = undefined;
  6902. }
  6903. var promise = new Promise(function (resolve, reject) {
  6904. stream._pendingAbortRequest = {
  6905. _promise: undefined,
  6906. _resolve: resolve,
  6907. _reject: reject,
  6908. _reason: reason,
  6909. _wasAlreadyErroring: wasAlreadyErroring
  6910. };
  6911. });
  6912. stream._pendingAbortRequest._promise = promise;
  6913. if (wasAlreadyErroring === false) {
  6914. WritableStreamStartErroring(stream, reason);
  6915. }
  6916. return promise;
  6917. }
  6918. function WritableStreamAddWriteRequest(stream) {
  6919. var promise = new Promise(function (resolve, reject) {
  6920. var writeRequest = {
  6921. _resolve: resolve,
  6922. _reject: reject
  6923. };
  6924. stream._writeRequests.push(writeRequest);
  6925. });
  6926. return promise;
  6927. }
  6928. function WritableStreamDealWithRejection(stream, error) {
  6929. var state = stream._state;
  6930. if (state === 'writable') {
  6931. WritableStreamStartErroring(stream, error);
  6932. return;
  6933. }
  6934. WritableStreamFinishErroring(stream);
  6935. }
  6936. function WritableStreamStartErroring(stream, reason) {
  6937. var controller = stream._writableStreamController;
  6938. stream._state = 'erroring';
  6939. stream._storedError = reason;
  6940. var writer = stream._writer;
  6941. if (writer !== undefined) {
  6942. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  6943. }
  6944. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  6945. WritableStreamFinishErroring(stream);
  6946. }
  6947. }
  6948. function WritableStreamFinishErroring(stream) {
  6949. stream._state = 'errored';
  6950. stream._writableStreamController[ErrorSteps]();
  6951. var storedError = stream._storedError;
  6952. stream._writeRequests.forEach(function (writeRequest) {
  6953. writeRequest._reject(storedError);
  6954. });
  6955. stream._writeRequests = new SimpleQueue();
  6956. if (stream._pendingAbortRequest === undefined) {
  6957. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  6958. return;
  6959. }
  6960. var abortRequest = stream._pendingAbortRequest;
  6961. stream._pendingAbortRequest = undefined;
  6962. if (abortRequest._wasAlreadyErroring === true) {
  6963. abortRequest._reject(storedError);
  6964. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  6965. return;
  6966. }
  6967. var promise = stream._writableStreamController[AbortSteps](abortRequest._reason);
  6968. promise.then(function () {
  6969. abortRequest._resolve();
  6970. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  6971. }, function (reason) {
  6972. abortRequest._reject(reason);
  6973. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  6974. });
  6975. }
  6976. function WritableStreamFinishInFlightWrite(stream) {
  6977. stream._inFlightWriteRequest._resolve(undefined);
  6978. stream._inFlightWriteRequest = undefined;
  6979. }
  6980. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  6981. stream._inFlightWriteRequest._reject(error);
  6982. stream._inFlightWriteRequest = undefined;
  6983. WritableStreamDealWithRejection(stream, error);
  6984. }
  6985. function WritableStreamFinishInFlightClose(stream) {
  6986. stream._inFlightCloseRequest._resolve(undefined);
  6987. stream._inFlightCloseRequest = undefined;
  6988. var state = stream._state;
  6989. if (state === 'erroring') {
  6990. stream._storedError = undefined;
  6991. if (stream._pendingAbortRequest !== undefined) {
  6992. stream._pendingAbortRequest._resolve();
  6993. stream._pendingAbortRequest = undefined;
  6994. }
  6995. }
  6996. stream._state = 'closed';
  6997. var writer = stream._writer;
  6998. if (writer !== undefined) {
  6999. defaultWriterClosedPromiseResolve(writer);
  7000. }
  7001. }
  7002. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  7003. stream._inFlightCloseRequest._reject(error);
  7004. stream._inFlightCloseRequest = undefined;
  7005. if (stream._pendingAbortRequest !== undefined) {
  7006. stream._pendingAbortRequest._reject(error);
  7007. stream._pendingAbortRequest = undefined;
  7008. }
  7009. WritableStreamDealWithRejection(stream, error);
  7010. }
  7011. function WritableStreamCloseQueuedOrInFlight(stream) {
  7012. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7013. return false;
  7014. }
  7015. return true;
  7016. }
  7017. function WritableStreamHasOperationMarkedInFlight(stream) {
  7018. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  7019. return false;
  7020. }
  7021. return true;
  7022. }
  7023. function WritableStreamMarkCloseRequestInFlight(stream) {
  7024. stream._inFlightCloseRequest = stream._closeRequest;
  7025. stream._closeRequest = undefined;
  7026. }
  7027. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  7028. stream._inFlightWriteRequest = stream._writeRequests.shift();
  7029. }
  7030. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  7031. if (stream._closeRequest !== undefined) {
  7032. stream._closeRequest._reject(stream._storedError);
  7033. stream._closeRequest = undefined;
  7034. }
  7035. var writer = stream._writer;
  7036. if (writer !== undefined) {
  7037. defaultWriterClosedPromiseReject(writer, stream._storedError);
  7038. }
  7039. }
  7040. function WritableStreamUpdateBackpressure(stream, backpressure) {
  7041. var writer = stream._writer;
  7042. if (writer !== undefined && backpressure !== stream._backpressure) {
  7043. if (backpressure === true) {
  7044. defaultWriterReadyPromiseReset(writer);
  7045. } else {
  7046. defaultWriterReadyPromiseResolve(writer);
  7047. }
  7048. }
  7049. stream._backpressure = backpressure;
  7050. }
  7051. var WritableStreamDefaultWriter = function () {
  7052. function WritableStreamDefaultWriter(stream) {
  7053. if (IsWritableStream(stream) === false) {
  7054. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  7055. }
  7056. if (IsWritableStreamLocked(stream) === true) {
  7057. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  7058. }
  7059. this._ownerWritableStream = stream;
  7060. stream._writer = this;
  7061. var state = stream._state;
  7062. if (state === 'writable') {
  7063. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  7064. defaultWriterReadyPromiseInitialize(this);
  7065. } else {
  7066. defaultWriterReadyPromiseInitializeAsResolved(this);
  7067. }
  7068. defaultWriterClosedPromiseInitialize(this);
  7069. } else if (state === 'erroring') {
  7070. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  7071. defaultWriterClosedPromiseInitialize(this);
  7072. } else if (state === 'closed') {
  7073. defaultWriterReadyPromiseInitializeAsResolved(this);
  7074. defaultWriterClosedPromiseInitializeAsResolved(this);
  7075. } else {
  7076. var storedError = stream._storedError;
  7077. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  7078. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  7079. }
  7080. }
  7081. Object.defineProperty(WritableStreamDefaultWriter.prototype, "closed", {
  7082. get: function () {
  7083. if (IsWritableStreamDefaultWriter(this) === false) {
  7084. return Promise.reject(defaultWriterBrandCheckException('closed'));
  7085. }
  7086. return this._closedPromise;
  7087. },
  7088. enumerable: true,
  7089. configurable: true
  7090. });
  7091. Object.defineProperty(WritableStreamDefaultWriter.prototype, "desiredSize", {
  7092. get: function () {
  7093. if (IsWritableStreamDefaultWriter(this) === false) {
  7094. throw defaultWriterBrandCheckException('desiredSize');
  7095. }
  7096. if (this._ownerWritableStream === undefined) {
  7097. throw defaultWriterLockException('desiredSize');
  7098. }
  7099. return WritableStreamDefaultWriterGetDesiredSize(this);
  7100. },
  7101. enumerable: true,
  7102. configurable: true
  7103. });
  7104. Object.defineProperty(WritableStreamDefaultWriter.prototype, "ready", {
  7105. get: function () {
  7106. if (IsWritableStreamDefaultWriter(this) === false) {
  7107. return Promise.reject(defaultWriterBrandCheckException('ready'));
  7108. }
  7109. return this._readyPromise;
  7110. },
  7111. enumerable: true,
  7112. configurable: true
  7113. });
  7114. WritableStreamDefaultWriter.prototype.abort = function (reason) {
  7115. if (IsWritableStreamDefaultWriter(this) === false) {
  7116. return Promise.reject(defaultWriterBrandCheckException('abort'));
  7117. }
  7118. if (this._ownerWritableStream === undefined) {
  7119. return Promise.reject(defaultWriterLockException('abort'));
  7120. }
  7121. return WritableStreamDefaultWriterAbort(this, reason);
  7122. };
  7123. WritableStreamDefaultWriter.prototype.close = function () {
  7124. if (IsWritableStreamDefaultWriter(this) === false) {
  7125. return Promise.reject(defaultWriterBrandCheckException('close'));
  7126. }
  7127. var stream = this._ownerWritableStream;
  7128. if (stream === undefined) {
  7129. return Promise.reject(defaultWriterLockException('close'));
  7130. }
  7131. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  7132. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  7133. }
  7134. return WritableStreamDefaultWriterClose(this);
  7135. };
  7136. WritableStreamDefaultWriter.prototype.releaseLock = function () {
  7137. if (IsWritableStreamDefaultWriter(this) === false) {
  7138. throw defaultWriterBrandCheckException('releaseLock');
  7139. }
  7140. var stream = this._ownerWritableStream;
  7141. if (stream === undefined) {
  7142. return;
  7143. }
  7144. WritableStreamDefaultWriterRelease(this);
  7145. };
  7146. WritableStreamDefaultWriter.prototype.write = function (chunk) {
  7147. if (IsWritableStreamDefaultWriter(this) === false) {
  7148. return Promise.reject(defaultWriterBrandCheckException('write'));
  7149. }
  7150. if (this._ownerWritableStream === undefined) {
  7151. return Promise.reject(defaultWriterLockException('write to'));
  7152. }
  7153. return WritableStreamDefaultWriterWrite(this, chunk);
  7154. };
  7155. return WritableStreamDefaultWriter;
  7156. }();
  7157. function IsWritableStreamDefaultWriter(x) {
  7158. if (!typeIsObject(x)) {
  7159. return false;
  7160. }
  7161. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  7162. return false;
  7163. }
  7164. return true;
  7165. }
  7166. function WritableStreamDefaultWriterAbort(writer, reason) {
  7167. var stream = writer._ownerWritableStream;
  7168. return WritableStreamAbort(stream, reason);
  7169. }
  7170. function WritableStreamDefaultWriterClose(writer) {
  7171. var stream = writer._ownerWritableStream;
  7172. var state = stream._state;
  7173. if (state === 'closed' || state === 'errored') {
  7174. return Promise.reject(new TypeError("The stream (in " + state + " state) is not in the writable state and cannot be closed"));
  7175. }
  7176. var promise = new Promise(function (resolve, reject) {
  7177. var closeRequest = {
  7178. _resolve: resolve,
  7179. _reject: reject
  7180. };
  7181. stream._closeRequest = closeRequest;
  7182. });
  7183. if (stream._backpressure === true && state === 'writable') {
  7184. defaultWriterReadyPromiseResolve(writer);
  7185. }
  7186. WritableStreamDefaultControllerClose(stream._writableStreamController);
  7187. return promise;
  7188. }
  7189. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  7190. var stream = writer._ownerWritableStream;
  7191. var state = stream._state;
  7192. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  7193. return Promise.resolve();
  7194. }
  7195. if (state === 'errored') {
  7196. return Promise.reject(stream._storedError);
  7197. }
  7198. return WritableStreamDefaultWriterClose(writer);
  7199. }
  7200. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  7201. if (writer._closedPromiseState === 'pending') {
  7202. defaultWriterClosedPromiseReject(writer, error);
  7203. } else {
  7204. defaultWriterClosedPromiseResetToRejected(writer, error);
  7205. }
  7206. }
  7207. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  7208. if (writer._readyPromiseState === 'pending') {
  7209. defaultWriterReadyPromiseReject(writer, error);
  7210. } else {
  7211. defaultWriterReadyPromiseResetToRejected(writer, error);
  7212. }
  7213. }
  7214. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  7215. var stream = writer._ownerWritableStream;
  7216. var state = stream._state;
  7217. if (state === 'errored' || state === 'erroring') {
  7218. return null;
  7219. }
  7220. if (state === 'closed') {
  7221. return 0;
  7222. }
  7223. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  7224. }
  7225. function WritableStreamDefaultWriterRelease(writer) {
  7226. var stream = writer._ownerWritableStream;
  7227. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  7228. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  7229. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  7230. stream._writer = undefined;
  7231. writer._ownerWritableStream = undefined;
  7232. }
  7233. function WritableStreamDefaultWriterWrite(writer, chunk) {
  7234. var stream = writer._ownerWritableStream;
  7235. var controller = stream._writableStreamController;
  7236. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  7237. if (stream !== writer._ownerWritableStream) {
  7238. return Promise.reject(defaultWriterLockException('write to'));
  7239. }
  7240. var state = stream._state;
  7241. if (state === 'errored') {
  7242. return Promise.reject(stream._storedError);
  7243. }
  7244. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  7245. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  7246. }
  7247. if (state === 'erroring') {
  7248. return Promise.reject(stream._storedError);
  7249. }
  7250. var promise = WritableStreamAddWriteRequest(stream);
  7251. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  7252. return promise;
  7253. }
  7254. var WritableStreamDefaultController = function () {
  7255. function WritableStreamDefaultController() {
  7256. throw new TypeError('WritableStreamDefaultController cannot be constructed explicitly');
  7257. }
  7258. WritableStreamDefaultController.prototype.error = function (e) {
  7259. if (IsWritableStreamDefaultController(this) === false) {
  7260. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  7261. }
  7262. var state = this._controlledWritableStream._state;
  7263. if (state !== 'writable') {
  7264. return;
  7265. }
  7266. WritableStreamDefaultControllerError(this, e);
  7267. };
  7268. WritableStreamDefaultController.prototype[AbortSteps] = function (reason) {
  7269. var result = this._abortAlgorithm(reason);
  7270. WritableStreamDefaultControllerClearAlgorithms(this);
  7271. return result;
  7272. };
  7273. WritableStreamDefaultController.prototype[ErrorSteps] = function () {
  7274. ResetQueue(this);
  7275. };
  7276. return WritableStreamDefaultController;
  7277. }();
  7278. function IsWritableStreamDefaultController(x) {
  7279. if (!typeIsObject(x)) {
  7280. return false;
  7281. }
  7282. if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) {
  7283. return false;
  7284. }
  7285. return true;
  7286. }
  7287. function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
  7288. controller._controlledWritableStream = stream;
  7289. stream._writableStreamController = controller;
  7290. controller._queue = undefined;
  7291. controller._queueTotalSize = undefined;
  7292. ResetQueue(controller);
  7293. controller._started = false;
  7294. controller._strategySizeAlgorithm = sizeAlgorithm;
  7295. controller._strategyHWM = highWaterMark;
  7296. controller._writeAlgorithm = writeAlgorithm;
  7297. controller._closeAlgorithm = closeAlgorithm;
  7298. controller._abortAlgorithm = abortAlgorithm;
  7299. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7300. WritableStreamUpdateBackpressure(stream, backpressure);
  7301. var startResult = startAlgorithm();
  7302. var startPromise = Promise.resolve(startResult);
  7303. startPromise.then(function () {
  7304. controller._started = true;
  7305. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7306. }, function (r) {
  7307. controller._started = true;
  7308. WritableStreamDealWithRejection(stream, r);
  7309. }).catch(rethrowAssertionErrorRejection);
  7310. }
  7311. function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
  7312. var controller = Object.create(WritableStreamDefaultController.prototype);
  7313. function startAlgorithm() {
  7314. return InvokeOrNoop(underlyingSink, 'start', [controller]);
  7315. }
  7316. var writeAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'write', 1, [controller]);
  7317. var closeAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'close', 0, []);
  7318. var abortAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSink, 'abort', 1, []);
  7319. SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
  7320. }
  7321. function WritableStreamDefaultControllerClearAlgorithms(controller) {
  7322. controller._writeAlgorithm = undefined;
  7323. controller._closeAlgorithm = undefined;
  7324. controller._abortAlgorithm = undefined;
  7325. controller._strategySizeAlgorithm = undefined;
  7326. }
  7327. function WritableStreamDefaultControllerClose(controller) {
  7328. EnqueueValueWithSize(controller, 'close', 0);
  7329. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7330. }
  7331. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  7332. try {
  7333. return controller._strategySizeAlgorithm(chunk);
  7334. } catch (chunkSizeE) {
  7335. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  7336. return 1;
  7337. }
  7338. }
  7339. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  7340. return controller._strategyHWM - controller._queueTotalSize;
  7341. }
  7342. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  7343. var writeRecord = { chunk: chunk };
  7344. try {
  7345. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  7346. } catch (enqueueE) {
  7347. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  7348. return;
  7349. }
  7350. var stream = controller._controlledWritableStream;
  7351. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  7352. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7353. WritableStreamUpdateBackpressure(stream, backpressure);
  7354. }
  7355. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7356. }
  7357. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  7358. var stream = controller._controlledWritableStream;
  7359. if (controller._started === false) {
  7360. return;
  7361. }
  7362. if (stream._inFlightWriteRequest !== undefined) {
  7363. return;
  7364. }
  7365. var state = stream._state;
  7366. if (state === 'erroring') {
  7367. WritableStreamFinishErroring(stream);
  7368. return;
  7369. }
  7370. if (controller._queue.length === 0) {
  7371. return;
  7372. }
  7373. var writeRecord = PeekQueueValue(controller);
  7374. if (writeRecord === 'close') {
  7375. WritableStreamDefaultControllerProcessClose(controller);
  7376. } else {
  7377. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  7378. }
  7379. }
  7380. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  7381. if (controller._controlledWritableStream._state === 'writable') {
  7382. WritableStreamDefaultControllerError(controller, error);
  7383. }
  7384. }
  7385. function WritableStreamDefaultControllerProcessClose(controller) {
  7386. var stream = controller._controlledWritableStream;
  7387. WritableStreamMarkCloseRequestInFlight(stream);
  7388. DequeueValue(controller);
  7389. var sinkClosePromise = controller._closeAlgorithm();
  7390. WritableStreamDefaultControllerClearAlgorithms(controller);
  7391. sinkClosePromise.then(function () {
  7392. WritableStreamFinishInFlightClose(stream);
  7393. }, function (reason) {
  7394. WritableStreamFinishInFlightCloseWithError(stream, reason);
  7395. }).catch(rethrowAssertionErrorRejection);
  7396. }
  7397. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  7398. var stream = controller._controlledWritableStream;
  7399. WritableStreamMarkFirstWriteRequestInFlight(stream);
  7400. var sinkWritePromise = controller._writeAlgorithm(chunk);
  7401. sinkWritePromise.then(function () {
  7402. WritableStreamFinishInFlightWrite(stream);
  7403. var state = stream._state;
  7404. DequeueValue(controller);
  7405. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  7406. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  7407. WritableStreamUpdateBackpressure(stream, backpressure);
  7408. }
  7409. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  7410. }, function (reason) {
  7411. if (stream._state === 'writable') {
  7412. WritableStreamDefaultControllerClearAlgorithms(controller);
  7413. }
  7414. WritableStreamFinishInFlightWriteWithError(stream, reason);
  7415. }).catch(rethrowAssertionErrorRejection);
  7416. }
  7417. function WritableStreamDefaultControllerGetBackpressure(controller) {
  7418. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  7419. return desiredSize <= 0;
  7420. }
  7421. function WritableStreamDefaultControllerError(controller, error) {
  7422. var stream = controller._controlledWritableStream;
  7423. WritableStreamDefaultControllerClearAlgorithms(controller);
  7424. WritableStreamStartErroring(stream, error);
  7425. }
  7426. function streamBrandCheckException(name) {
  7427. return new TypeError("WritableStream.prototype." + name + " can only be used on a WritableStream");
  7428. }
  7429. function defaultWriterBrandCheckException(name) {
  7430. return new TypeError("WritableStreamDefaultWriter.prototype." + name + " can only be used on a WritableStreamDefaultWriter");
  7431. }
  7432. function defaultWriterLockException(name) {
  7433. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  7434. }
  7435. function defaultWriterClosedPromiseInitialize(writer) {
  7436. writer._closedPromise = new Promise(function (resolve, reject) {
  7437. writer._closedPromise_resolve = resolve;
  7438. writer._closedPromise_reject = reject;
  7439. writer._closedPromiseState = 'pending';
  7440. });
  7441. }
  7442. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  7443. defaultWriterClosedPromiseInitialize(writer);
  7444. defaultWriterClosedPromiseReject(writer, reason);
  7445. }
  7446. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  7447. defaultWriterClosedPromiseInitialize(writer);
  7448. defaultWriterClosedPromiseResolve(writer);
  7449. }
  7450. function defaultWriterClosedPromiseReject(writer, reason) {
  7451. writer._closedPromise.catch(noop);
  7452. writer._closedPromise_reject(reason);
  7453. writer._closedPromise_resolve = undefined;
  7454. writer._closedPromise_reject = undefined;
  7455. writer._closedPromiseState = 'rejected';
  7456. }
  7457. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  7458. defaultWriterClosedPromiseInitializeAsRejected(writer, reason);
  7459. }
  7460. function defaultWriterClosedPromiseResolve(writer) {
  7461. writer._closedPromise_resolve(undefined);
  7462. writer._closedPromise_resolve = undefined;
  7463. writer._closedPromise_reject = undefined;
  7464. writer._closedPromiseState = 'resolved';
  7465. }
  7466. function defaultWriterReadyPromiseInitialize(writer) {
  7467. writer._readyPromise = new Promise(function (resolve, reject) {
  7468. writer._readyPromise_resolve = resolve;
  7469. writer._readyPromise_reject = reject;
  7470. });
  7471. writer._readyPromiseState = 'pending';
  7472. }
  7473. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  7474. defaultWriterReadyPromiseInitialize(writer);
  7475. defaultWriterReadyPromiseReject(writer, reason);
  7476. }
  7477. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  7478. defaultWriterReadyPromiseInitialize(writer);
  7479. defaultWriterReadyPromiseResolve(writer);
  7480. }
  7481. function defaultWriterReadyPromiseReject(writer, reason) {
  7482. writer._readyPromise.catch(noop);
  7483. writer._readyPromise_reject(reason);
  7484. writer._readyPromise_resolve = undefined;
  7485. writer._readyPromise_reject = undefined;
  7486. writer._readyPromiseState = 'rejected';
  7487. }
  7488. function defaultWriterReadyPromiseReset(writer) {
  7489. defaultWriterReadyPromiseInitialize(writer);
  7490. }
  7491. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  7492. defaultWriterReadyPromiseInitializeAsRejected(writer, reason);
  7493. }
  7494. function defaultWriterReadyPromiseResolve(writer) {
  7495. writer._readyPromise_resolve(undefined);
  7496. writer._readyPromise_resolve = undefined;
  7497. writer._readyPromise_reject = undefined;
  7498. writer._readyPromiseState = 'fulfilled';
  7499. }
  7500. function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
  7501. var reader = AcquireReadableStreamDefaultReader(source);
  7502. var writer = AcquireWritableStreamDefaultWriter(dest);
  7503. var shuttingDown = false;
  7504. var currentWrite = Promise.resolve();
  7505. return new Promise(function (resolve, reject) {
  7506. var abortAlgorithm;
  7507. if (signal !== undefined) {
  7508. abortAlgorithm = function () {
  7509. var error = new DOMException('Aborted', 'AbortError');
  7510. var actions = [];
  7511. if (preventAbort === false) {
  7512. actions.push(function () {
  7513. if (dest._state === 'writable') {
  7514. return WritableStreamAbort(dest, error);
  7515. }
  7516. return Promise.resolve();
  7517. });
  7518. }
  7519. if (preventCancel === false) {
  7520. actions.push(function () {
  7521. if (source._state === 'readable') {
  7522. return ReadableStreamCancel(source, error);
  7523. }
  7524. return Promise.resolve();
  7525. });
  7526. }
  7527. shutdownWithAction(function () {
  7528. return Promise.all(actions.map(function (action) {
  7529. return action();
  7530. }));
  7531. }, true, error);
  7532. };
  7533. if (signal.aborted === true) {
  7534. abortAlgorithm();
  7535. return;
  7536. }
  7537. signal.addEventListener('abort', abortAlgorithm);
  7538. }
  7539. function pipeLoop() {
  7540. return new Promise(function (resolveLoop, rejectLoop) {
  7541. function next(done) {
  7542. if (done) {
  7543. resolveLoop();
  7544. } else {
  7545. pipeStep().then(next, rejectLoop);
  7546. }
  7547. }
  7548. next(false);
  7549. });
  7550. }
  7551. function pipeStep() {
  7552. if (shuttingDown === true) {
  7553. return Promise.resolve(true);
  7554. }
  7555. return writer._readyPromise.then(function () {
  7556. return ReadableStreamDefaultReaderRead(reader).then(function (_a) {
  7557. var value = _a.value, done = _a.done;
  7558. if (done === true) {
  7559. return true;
  7560. }
  7561. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(noop);
  7562. return false;
  7563. });
  7564. });
  7565. }
  7566. isOrBecomesErrored(source, reader._closedPromise, function (storedError) {
  7567. if (preventAbort === false) {
  7568. shutdownWithAction(function () {
  7569. return WritableStreamAbort(dest, storedError);
  7570. }, true, storedError);
  7571. } else {
  7572. shutdown(true, storedError);
  7573. }
  7574. });
  7575. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  7576. if (preventCancel === false) {
  7577. shutdownWithAction(function () {
  7578. return ReadableStreamCancel(source, storedError);
  7579. }, true, storedError);
  7580. } else {
  7581. shutdown(true, storedError);
  7582. }
  7583. });
  7584. isOrBecomesClosed(source, reader._closedPromise, function () {
  7585. if (preventClose === false) {
  7586. shutdownWithAction(function () {
  7587. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  7588. });
  7589. } else {
  7590. shutdown();
  7591. }
  7592. });
  7593. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  7594. var destClosed_1 = new TypeError('the destination writable stream closed before all data could be piped to it');
  7595. if (preventCancel === false) {
  7596. shutdownWithAction(function () {
  7597. return ReadableStreamCancel(source, destClosed_1);
  7598. }, true, destClosed_1);
  7599. } else {
  7600. shutdown(true, destClosed_1);
  7601. }
  7602. }
  7603. pipeLoop().catch(rethrowAssertionErrorRejection);
  7604. function waitForWritesToFinish() {
  7605. var oldCurrentWrite = currentWrite;
  7606. return currentWrite.then(function () {
  7607. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  7608. });
  7609. }
  7610. function isOrBecomesErrored(stream, promise, action) {
  7611. if (stream._state === 'errored') {
  7612. action(stream._storedError);
  7613. } else {
  7614. promise.catch(action).catch(rethrowAssertionErrorRejection);
  7615. }
  7616. }
  7617. function isOrBecomesClosed(stream, promise, action) {
  7618. if (stream._state === 'closed') {
  7619. action();
  7620. } else {
  7621. promise.then(action).catch(rethrowAssertionErrorRejection);
  7622. }
  7623. }
  7624. function shutdownWithAction(action, originalIsError, originalError) {
  7625. if (shuttingDown === true) {
  7626. return;
  7627. }
  7628. shuttingDown = true;
  7629. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  7630. waitForWritesToFinish().then(doTheRest);
  7631. } else {
  7632. doTheRest();
  7633. }
  7634. function doTheRest() {
  7635. action().then(function () {
  7636. return finalize(originalIsError, originalError);
  7637. }, function (newError) {
  7638. return finalize(true, newError);
  7639. }).catch(rethrowAssertionErrorRejection);
  7640. }
  7641. }
  7642. function shutdown(isError, error) {
  7643. if (shuttingDown === true) {
  7644. return;
  7645. }
  7646. shuttingDown = true;
  7647. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  7648. waitForWritesToFinish().then(function () {
  7649. return finalize(isError, error);
  7650. }).catch(rethrowAssertionErrorRejection);
  7651. } else {
  7652. finalize(isError, error);
  7653. }
  7654. }
  7655. function finalize(isError, error) {
  7656. WritableStreamDefaultWriterRelease(writer);
  7657. ReadableStreamReaderGenericRelease(reader);
  7658. if (signal !== undefined) {
  7659. signal.removeEventListener('abort', abortAlgorithm);
  7660. }
  7661. if (isError) {
  7662. reject(error);
  7663. } else {
  7664. resolve(undefined);
  7665. }
  7666. }
  7667. });
  7668. }
  7669. var ReadableStreamDefaultController = function () {
  7670. function ReadableStreamDefaultController() {
  7671. throw new TypeError();
  7672. }
  7673. Object.defineProperty(ReadableStreamDefaultController.prototype, "desiredSize", {
  7674. get: function () {
  7675. if (IsReadableStreamDefaultController(this) === false) {
  7676. throw defaultControllerBrandCheckException('desiredSize');
  7677. }
  7678. return ReadableStreamDefaultControllerGetDesiredSize(this);
  7679. },
  7680. enumerable: true,
  7681. configurable: true
  7682. });
  7683. ReadableStreamDefaultController.prototype.close = function () {
  7684. if (IsReadableStreamDefaultController(this) === false) {
  7685. throw defaultControllerBrandCheckException('close');
  7686. }
  7687. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
  7688. throw new TypeError('The stream is not in a state that permits close');
  7689. }
  7690. ReadableStreamDefaultControllerClose(this);
  7691. };
  7692. ReadableStreamDefaultController.prototype.enqueue = function (chunk) {
  7693. if (IsReadableStreamDefaultController(this) === false) {
  7694. throw defaultControllerBrandCheckException('enqueue');
  7695. }
  7696. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
  7697. throw new TypeError('The stream is not in a state that permits enqueue');
  7698. }
  7699. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  7700. };
  7701. ReadableStreamDefaultController.prototype.error = function (e) {
  7702. if (IsReadableStreamDefaultController(this) === false) {
  7703. throw defaultControllerBrandCheckException('error');
  7704. }
  7705. ReadableStreamDefaultControllerError(this, e);
  7706. };
  7707. ReadableStreamDefaultController.prototype[CancelSteps] = function (reason) {
  7708. ResetQueue(this);
  7709. var result = this._cancelAlgorithm(reason);
  7710. ReadableStreamDefaultControllerClearAlgorithms(this);
  7711. return result;
  7712. };
  7713. ReadableStreamDefaultController.prototype[PullSteps] = function () {
  7714. var stream = this._controlledReadableStream;
  7715. if (this._queue.length > 0) {
  7716. var chunk = DequeueValue(this);
  7717. if (this._closeRequested === true && this._queue.length === 0) {
  7718. ReadableStreamDefaultControllerClearAlgorithms(this);
  7719. ReadableStreamClose(stream);
  7720. } else {
  7721. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  7722. }
  7723. return Promise.resolve(ReadableStreamCreateReadResult(chunk, false, stream._reader._forAuthorCode));
  7724. }
  7725. var pendingPromise = ReadableStreamAddReadRequest(stream);
  7726. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  7727. return pendingPromise;
  7728. };
  7729. return ReadableStreamDefaultController;
  7730. }();
  7731. function IsReadableStreamDefaultController(x) {
  7732. if (!typeIsObject(x)) {
  7733. return false;
  7734. }
  7735. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) {
  7736. return false;
  7737. }
  7738. return true;
  7739. }
  7740. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  7741. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  7742. if (shouldPull === false) {
  7743. return;
  7744. }
  7745. if (controller._pulling === true) {
  7746. controller._pullAgain = true;
  7747. return;
  7748. }
  7749. controller._pulling = true;
  7750. var pullPromise = controller._pullAlgorithm();
  7751. pullPromise.then(function () {
  7752. controller._pulling = false;
  7753. if (controller._pullAgain === true) {
  7754. controller._pullAgain = false;
  7755. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  7756. }
  7757. }, function (e) {
  7758. ReadableStreamDefaultControllerError(controller, e);
  7759. }).catch(rethrowAssertionErrorRejection);
  7760. }
  7761. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  7762. var stream = controller._controlledReadableStream;
  7763. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) === false) {
  7764. return false;
  7765. }
  7766. if (controller._started === false) {
  7767. return false;
  7768. }
  7769. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  7770. return true;
  7771. }
  7772. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  7773. if (desiredSize > 0) {
  7774. return true;
  7775. }
  7776. return false;
  7777. }
  7778. function ReadableStreamDefaultControllerClearAlgorithms(controller) {
  7779. controller._pullAlgorithm = undefined;
  7780. controller._cancelAlgorithm = undefined;
  7781. controller._strategySizeAlgorithm = undefined;
  7782. }
  7783. function ReadableStreamDefaultControllerClose(controller) {
  7784. var stream = controller._controlledReadableStream;
  7785. controller._closeRequested = true;
  7786. if (controller._queue.length === 0) {
  7787. ReadableStreamDefaultControllerClearAlgorithms(controller);
  7788. ReadableStreamClose(stream);
  7789. }
  7790. }
  7791. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  7792. var stream = controller._controlledReadableStream;
  7793. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  7794. ReadableStreamFulfillReadRequest(stream, chunk, false);
  7795. } else {
  7796. var chunkSize = void 0;
  7797. try {
  7798. chunkSize = controller._strategySizeAlgorithm(chunk);
  7799. } catch (chunkSizeE) {
  7800. ReadableStreamDefaultControllerError(controller, chunkSizeE);
  7801. throw chunkSizeE;
  7802. }
  7803. try {
  7804. EnqueueValueWithSize(controller, chunk, chunkSize);
  7805. } catch (enqueueE) {
  7806. ReadableStreamDefaultControllerError(controller, enqueueE);
  7807. throw enqueueE;
  7808. }
  7809. }
  7810. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  7811. }
  7812. function ReadableStreamDefaultControllerError(controller, e) {
  7813. var stream = controller._controlledReadableStream;
  7814. if (stream._state !== 'readable') {
  7815. return;
  7816. }
  7817. ResetQueue(controller);
  7818. ReadableStreamDefaultControllerClearAlgorithms(controller);
  7819. ReadableStreamError(stream, e);
  7820. }
  7821. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  7822. var stream = controller._controlledReadableStream;
  7823. var state = stream._state;
  7824. if (state === 'errored') {
  7825. return null;
  7826. }
  7827. if (state === 'closed') {
  7828. return 0;
  7829. }
  7830. return controller._strategyHWM - controller._queueTotalSize;
  7831. }
  7832. function ReadableStreamDefaultControllerHasBackpressure(controller) {
  7833. if (ReadableStreamDefaultControllerShouldCallPull(controller) === true) {
  7834. return false;
  7835. }
  7836. return true;
  7837. }
  7838. function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
  7839. var state = controller._controlledReadableStream._state;
  7840. if (controller._closeRequested === false && state === 'readable') {
  7841. return true;
  7842. }
  7843. return false;
  7844. }
  7845. function SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  7846. controller._controlledReadableStream = stream;
  7847. controller._queue = undefined;
  7848. controller._queueTotalSize = undefined;
  7849. ResetQueue(controller);
  7850. controller._started = false;
  7851. controller._closeRequested = false;
  7852. controller._pullAgain = false;
  7853. controller._pulling = false;
  7854. controller._strategySizeAlgorithm = sizeAlgorithm;
  7855. controller._strategyHWM = highWaterMark;
  7856. controller._pullAlgorithm = pullAlgorithm;
  7857. controller._cancelAlgorithm = cancelAlgorithm;
  7858. stream._readableStreamController = controller;
  7859. var startResult = startAlgorithm();
  7860. Promise.resolve(startResult).then(function () {
  7861. controller._started = true;
  7862. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  7863. }, function (r) {
  7864. ReadableStreamDefaultControllerError(controller, r);
  7865. }).catch(rethrowAssertionErrorRejection);
  7866. }
  7867. function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
  7868. var controller = Object.create(ReadableStreamDefaultController.prototype);
  7869. function startAlgorithm() {
  7870. return InvokeOrNoop(underlyingSource, 'start', [controller]);
  7871. }
  7872. var pullAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSource, 'pull', 0, [controller]);
  7873. var cancelAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingSource, 'cancel', 1, []);
  7874. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  7875. }
  7876. function defaultControllerBrandCheckException(name) {
  7877. return new TypeError("ReadableStreamDefaultController.prototype." + name + " can only be used on a ReadableStreamDefaultController");
  7878. }
  7879. function ReadableStreamTee(stream, cloneForBranch2) {
  7880. var reader = AcquireReadableStreamDefaultReader(stream);
  7881. var reading = false;
  7882. var canceled1 = false;
  7883. var canceled2 = false;
  7884. var reason1;
  7885. var reason2;
  7886. var branch1;
  7887. var branch2;
  7888. var resolveCancelPromise;
  7889. var cancelPromise = new Promise(function (resolve) {
  7890. resolveCancelPromise = resolve;
  7891. });
  7892. function pullAlgorithm() {
  7893. if (reading === true) {
  7894. return Promise.resolve();
  7895. }
  7896. reading = true;
  7897. var readPromise = ReadableStreamDefaultReaderRead(reader).then(function (result) {
  7898. reading = false;
  7899. var done = result.done;
  7900. if (done === true) {
  7901. if (canceled1 === false) {
  7902. ReadableStreamDefaultControllerClose(branch1._readableStreamController);
  7903. }
  7904. if (canceled2 === false) {
  7905. ReadableStreamDefaultControllerClose(branch2._readableStreamController);
  7906. }
  7907. return;
  7908. }
  7909. var value = result.value;
  7910. var value1 = value;
  7911. var value2 = value;
  7912. if (canceled1 === false) {
  7913. ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, value1);
  7914. }
  7915. if (canceled2 === false) {
  7916. ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
  7917. }
  7918. });
  7919. readPromise.catch(rethrowAssertionErrorRejection);
  7920. return Promise.resolve();
  7921. }
  7922. function cancel1Algorithm(reason) {
  7923. canceled1 = true;
  7924. reason1 = reason;
  7925. if (canceled2 === true) {
  7926. var compositeReason = createArrayFromList([
  7927. reason1,
  7928. reason2
  7929. ]);
  7930. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  7931. resolveCancelPromise(cancelResult);
  7932. }
  7933. return cancelPromise;
  7934. }
  7935. function cancel2Algorithm(reason) {
  7936. canceled2 = true;
  7937. reason2 = reason;
  7938. if (canceled1 === true) {
  7939. var compositeReason = createArrayFromList([
  7940. reason1,
  7941. reason2
  7942. ]);
  7943. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  7944. resolveCancelPromise(cancelResult);
  7945. }
  7946. return cancelPromise;
  7947. }
  7948. function startAlgorithm() {
  7949. }
  7950. branch1 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm);
  7951. branch2 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm);
  7952. reader._closedPromise.catch(function (r) {
  7953. ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
  7954. ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
  7955. });
  7956. return [
  7957. branch1,
  7958. branch2
  7959. ];
  7960. }
  7961. var NumberIsInteger = Number.isInteger || function (value) {
  7962. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  7963. };
  7964. var ReadableStreamBYOBRequest = function () {
  7965. function ReadableStreamBYOBRequest() {
  7966. throw new TypeError('ReadableStreamBYOBRequest cannot be used directly');
  7967. }
  7968. Object.defineProperty(ReadableStreamBYOBRequest.prototype, "view", {
  7969. get: function () {
  7970. if (IsReadableStreamBYOBRequest(this) === false) {
  7971. throw byobRequestBrandCheckException('view');
  7972. }
  7973. return this._view;
  7974. },
  7975. enumerable: true,
  7976. configurable: true
  7977. });
  7978. ReadableStreamBYOBRequest.prototype.respond = function (bytesWritten) {
  7979. if (IsReadableStreamBYOBRequest(this) === false) {
  7980. throw byobRequestBrandCheckException('respond');
  7981. }
  7982. if (this._associatedReadableByteStreamController === undefined) {
  7983. throw new TypeError('This BYOB request has been invalidated');
  7984. }
  7985. if (IsDetachedBuffer(this._view.buffer) === true);
  7986. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  7987. };
  7988. ReadableStreamBYOBRequest.prototype.respondWithNewView = function (view) {
  7989. if (IsReadableStreamBYOBRequest(this) === false) {
  7990. throw byobRequestBrandCheckException('respond');
  7991. }
  7992. if (this._associatedReadableByteStreamController === undefined) {
  7993. throw new TypeError('This BYOB request has been invalidated');
  7994. }
  7995. if (!ArrayBuffer.isView(view)) {
  7996. throw new TypeError('You can only respond with array buffer views');
  7997. }
  7998. if (IsDetachedBuffer(view.buffer) === true);
  7999. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  8000. };
  8001. return ReadableStreamBYOBRequest;
  8002. }();
  8003. var ReadableByteStreamController = function () {
  8004. function ReadableByteStreamController() {
  8005. throw new TypeError('ReadableByteStreamController constructor cannot be used directly');
  8006. }
  8007. Object.defineProperty(ReadableByteStreamController.prototype, "byobRequest", {
  8008. get: function () {
  8009. if (IsReadableByteStreamController(this) === false) {
  8010. throw byteStreamControllerBrandCheckException('byobRequest');
  8011. }
  8012. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  8013. var firstDescriptor = this._pendingPullIntos.peek();
  8014. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  8015. var byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
  8016. SetUpReadableStreamBYOBRequest(byobRequest, this, view);
  8017. this._byobRequest = byobRequest;
  8018. }
  8019. return this._byobRequest;
  8020. },
  8021. enumerable: true,
  8022. configurable: true
  8023. });
  8024. Object.defineProperty(ReadableByteStreamController.prototype, "desiredSize", {
  8025. get: function () {
  8026. if (IsReadableByteStreamController(this) === false) {
  8027. throw byteStreamControllerBrandCheckException('desiredSize');
  8028. }
  8029. return ReadableByteStreamControllerGetDesiredSize(this);
  8030. },
  8031. enumerable: true,
  8032. configurable: true
  8033. });
  8034. ReadableByteStreamController.prototype.close = function () {
  8035. if (IsReadableByteStreamController(this) === false) {
  8036. throw byteStreamControllerBrandCheckException('close');
  8037. }
  8038. if (this._closeRequested === true) {
  8039. throw new TypeError('The stream has already been closed; do not close it again!');
  8040. }
  8041. var state = this._controlledReadableByteStream._state;
  8042. if (state !== 'readable') {
  8043. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be closed");
  8044. }
  8045. ReadableByteStreamControllerClose(this);
  8046. };
  8047. ReadableByteStreamController.prototype.enqueue = function (chunk) {
  8048. if (IsReadableByteStreamController(this) === false) {
  8049. throw byteStreamControllerBrandCheckException('enqueue');
  8050. }
  8051. if (this._closeRequested === true) {
  8052. throw new TypeError('stream is closed or draining');
  8053. }
  8054. var state = this._controlledReadableByteStream._state;
  8055. if (state !== 'readable') {
  8056. throw new TypeError("The stream (in " + state + " state) is not in the readable state and cannot be enqueued to");
  8057. }
  8058. if (!ArrayBuffer.isView(chunk)) {
  8059. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  8060. }
  8061. if (IsDetachedBuffer(chunk.buffer) === true);
  8062. ReadableByteStreamControllerEnqueue(this, chunk);
  8063. };
  8064. ReadableByteStreamController.prototype.error = function (e) {
  8065. if (IsReadableByteStreamController(this) === false) {
  8066. throw byteStreamControllerBrandCheckException('error');
  8067. }
  8068. ReadableByteStreamControllerError(this, e);
  8069. };
  8070. ReadableByteStreamController.prototype[CancelSteps] = function (reason) {
  8071. if (this._pendingPullIntos.length > 0) {
  8072. var firstDescriptor = this._pendingPullIntos.peek();
  8073. firstDescriptor.bytesFilled = 0;
  8074. }
  8075. ResetQueue(this);
  8076. var result = this._cancelAlgorithm(reason);
  8077. ReadableByteStreamControllerClearAlgorithms(this);
  8078. return result;
  8079. };
  8080. ReadableByteStreamController.prototype[PullSteps] = function () {
  8081. var stream = this._controlledReadableByteStream;
  8082. if (this._queueTotalSize > 0) {
  8083. var entry = this._queue.shift();
  8084. this._queueTotalSize -= entry.byteLength;
  8085. ReadableByteStreamControllerHandleQueueDrain(this);
  8086. var view = void 0;
  8087. try {
  8088. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  8089. } catch (viewE) {
  8090. return Promise.reject(viewE);
  8091. }
  8092. return Promise.resolve(ReadableStreamCreateReadResult(view, false, stream._reader._forAuthorCode));
  8093. }
  8094. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  8095. if (autoAllocateChunkSize !== undefined) {
  8096. var buffer = void 0;
  8097. try {
  8098. buffer = new ArrayBuffer(autoAllocateChunkSize);
  8099. } catch (bufferE) {
  8100. return Promise.reject(bufferE);
  8101. }
  8102. var pullIntoDescriptor = {
  8103. buffer: buffer,
  8104. byteOffset: 0,
  8105. byteLength: autoAllocateChunkSize,
  8106. bytesFilled: 0,
  8107. elementSize: 1,
  8108. ctor: Uint8Array,
  8109. readerType: 'default'
  8110. };
  8111. this._pendingPullIntos.push(pullIntoDescriptor);
  8112. }
  8113. var promise = ReadableStreamAddReadRequest(stream);
  8114. ReadableByteStreamControllerCallPullIfNeeded(this);
  8115. return promise;
  8116. };
  8117. return ReadableByteStreamController;
  8118. }();
  8119. function IsReadableByteStreamController(x) {
  8120. if (!typeIsObject(x)) {
  8121. return false;
  8122. }
  8123. if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) {
  8124. return false;
  8125. }
  8126. return true;
  8127. }
  8128. function IsReadableStreamBYOBRequest(x) {
  8129. if (!typeIsObject(x)) {
  8130. return false;
  8131. }
  8132. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  8133. return false;
  8134. }
  8135. return true;
  8136. }
  8137. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  8138. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  8139. if (shouldPull === false) {
  8140. return;
  8141. }
  8142. if (controller._pulling === true) {
  8143. controller._pullAgain = true;
  8144. return;
  8145. }
  8146. controller._pulling = true;
  8147. var pullPromise = controller._pullAlgorithm();
  8148. pullPromise.then(function () {
  8149. controller._pulling = false;
  8150. if (controller._pullAgain === true) {
  8151. controller._pullAgain = false;
  8152. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8153. }
  8154. }, function (e) {
  8155. ReadableByteStreamControllerError(controller, e);
  8156. }).catch(rethrowAssertionErrorRejection);
  8157. }
  8158. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  8159. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8160. controller._pendingPullIntos = new SimpleQueue();
  8161. }
  8162. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  8163. var done = false;
  8164. if (stream._state === 'closed') {
  8165. done = true;
  8166. }
  8167. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  8168. if (pullIntoDescriptor.readerType === 'default') {
  8169. ReadableStreamFulfillReadRequest(stream, filledView, done);
  8170. } else {
  8171. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  8172. }
  8173. }
  8174. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  8175. var bytesFilled = pullIntoDescriptor.bytesFilled;
  8176. var elementSize = pullIntoDescriptor.elementSize;
  8177. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  8178. }
  8179. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  8180. controller._queue.push({
  8181. buffer: buffer,
  8182. byteOffset: byteOffset,
  8183. byteLength: byteLength
  8184. });
  8185. controller._queueTotalSize += byteLength;
  8186. }
  8187. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  8188. var elementSize = pullIntoDescriptor.elementSize;
  8189. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  8190. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  8191. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  8192. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  8193. var totalBytesToCopyRemaining = maxBytesToCopy;
  8194. var ready = false;
  8195. if (maxAlignedBytes > currentAlignedBytes) {
  8196. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  8197. ready = true;
  8198. }
  8199. var queue = controller._queue;
  8200. while (totalBytesToCopyRemaining > 0) {
  8201. var headOfQueue = queue.peek();
  8202. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  8203. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  8204. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  8205. if (headOfQueue.byteLength === bytesToCopy) {
  8206. queue.shift();
  8207. } else {
  8208. headOfQueue.byteOffset += bytesToCopy;
  8209. headOfQueue.byteLength -= bytesToCopy;
  8210. }
  8211. controller._queueTotalSize -= bytesToCopy;
  8212. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  8213. totalBytesToCopyRemaining -= bytesToCopy;
  8214. }
  8215. return ready;
  8216. }
  8217. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  8218. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8219. pullIntoDescriptor.bytesFilled += size;
  8220. }
  8221. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  8222. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  8223. ReadableByteStreamControllerClearAlgorithms(controller);
  8224. ReadableStreamClose(controller._controlledReadableByteStream);
  8225. } else {
  8226. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8227. }
  8228. }
  8229. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  8230. if (controller._byobRequest === undefined) {
  8231. return;
  8232. }
  8233. controller._byobRequest._associatedReadableByteStreamController = undefined;
  8234. controller._byobRequest._view = undefined;
  8235. controller._byobRequest = undefined;
  8236. }
  8237. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  8238. while (controller._pendingPullIntos.length > 0) {
  8239. if (controller._queueTotalSize === 0) {
  8240. return;
  8241. }
  8242. var pullIntoDescriptor = controller._pendingPullIntos.peek();
  8243. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  8244. ReadableByteStreamControllerShiftPendingPullInto(controller);
  8245. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  8246. }
  8247. }
  8248. }
  8249. function ReadableByteStreamControllerPullInto(controller, view) {
  8250. var stream = controller._controlledReadableByteStream;
  8251. var elementSize = 1;
  8252. if (view.constructor !== DataView) {
  8253. elementSize = view.constructor.BYTES_PER_ELEMENT;
  8254. }
  8255. var ctor = view.constructor;
  8256. var buffer = TransferArrayBuffer(view.buffer);
  8257. var pullIntoDescriptor = {
  8258. buffer: buffer,
  8259. byteOffset: view.byteOffset,
  8260. byteLength: view.byteLength,
  8261. bytesFilled: 0,
  8262. elementSize: elementSize,
  8263. ctor: ctor,
  8264. readerType: 'byob'
  8265. };
  8266. if (controller._pendingPullIntos.length > 0) {
  8267. controller._pendingPullIntos.push(pullIntoDescriptor);
  8268. return ReadableStreamAddReadIntoRequest(stream);
  8269. }
  8270. if (stream._state === 'closed') {
  8271. var emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  8272. return Promise.resolve(ReadableStreamCreateReadResult(emptyView, true, stream._reader._forAuthorCode));
  8273. }
  8274. if (controller._queueTotalSize > 0) {
  8275. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  8276. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  8277. ReadableByteStreamControllerHandleQueueDrain(controller);
  8278. return Promise.resolve(ReadableStreamCreateReadResult(filledView, false, stream._reader._forAuthorCode));
  8279. }
  8280. if (controller._closeRequested === true) {
  8281. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  8282. ReadableByteStreamControllerError(controller, e);
  8283. return Promise.reject(e);
  8284. }
  8285. }
  8286. controller._pendingPullIntos.push(pullIntoDescriptor);
  8287. var promise = ReadableStreamAddReadIntoRequest(stream);
  8288. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8289. return promise;
  8290. }
  8291. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  8292. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  8293. var stream = controller._controlledReadableByteStream;
  8294. if (ReadableStreamHasBYOBReader(stream) === true) {
  8295. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  8296. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  8297. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  8298. }
  8299. }
  8300. }
  8301. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  8302. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  8303. throw new RangeError('bytesWritten out of range');
  8304. }
  8305. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  8306. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  8307. return;
  8308. }
  8309. ReadableByteStreamControllerShiftPendingPullInto(controller);
  8310. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  8311. if (remainderSize > 0) {
  8312. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  8313. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  8314. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  8315. }
  8316. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  8317. pullIntoDescriptor.bytesFilled -= remainderSize;
  8318. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
  8319. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  8320. }
  8321. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  8322. var firstDescriptor = controller._pendingPullIntos.peek();
  8323. var stream = controller._controlledReadableByteStream;
  8324. if (stream._state === 'closed') {
  8325. if (bytesWritten !== 0) {
  8326. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  8327. }
  8328. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  8329. } else {
  8330. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  8331. }
  8332. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8333. }
  8334. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  8335. var descriptor = controller._pendingPullIntos.shift();
  8336. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  8337. return descriptor;
  8338. }
  8339. function ReadableByteStreamControllerShouldCallPull(controller) {
  8340. var stream = controller._controlledReadableByteStream;
  8341. if (stream._state !== 'readable') {
  8342. return false;
  8343. }
  8344. if (controller._closeRequested === true) {
  8345. return false;
  8346. }
  8347. if (controller._started === false) {
  8348. return false;
  8349. }
  8350. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  8351. return true;
  8352. }
  8353. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  8354. return true;
  8355. }
  8356. var desiredSize = ReadableByteStreamControllerGetDesiredSize(controller);
  8357. if (desiredSize > 0) {
  8358. return true;
  8359. }
  8360. return false;
  8361. }
  8362. function ReadableByteStreamControllerClearAlgorithms(controller) {
  8363. controller._pullAlgorithm = undefined;
  8364. controller._cancelAlgorithm = undefined;
  8365. }
  8366. function ReadableByteStreamControllerClose(controller) {
  8367. var stream = controller._controlledReadableByteStream;
  8368. if (controller._queueTotalSize > 0) {
  8369. controller._closeRequested = true;
  8370. return;
  8371. }
  8372. if (controller._pendingPullIntos.length > 0) {
  8373. var firstPendingPullInto = controller._pendingPullIntos.peek();
  8374. if (firstPendingPullInto.bytesFilled > 0) {
  8375. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  8376. ReadableByteStreamControllerError(controller, e);
  8377. throw e;
  8378. }
  8379. }
  8380. ReadableByteStreamControllerClearAlgorithms(controller);
  8381. ReadableStreamClose(stream);
  8382. }
  8383. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  8384. var stream = controller._controlledReadableByteStream;
  8385. var buffer = chunk.buffer;
  8386. var byteOffset = chunk.byteOffset;
  8387. var byteLength = chunk.byteLength;
  8388. var transferredBuffer = TransferArrayBuffer(buffer);
  8389. if (ReadableStreamHasDefaultReader(stream) === true) {
  8390. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  8391. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  8392. } else {
  8393. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  8394. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  8395. }
  8396. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  8397. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  8398. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  8399. } else {
  8400. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  8401. }
  8402. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8403. }
  8404. function ReadableByteStreamControllerError(controller, e) {
  8405. var stream = controller._controlledReadableByteStream;
  8406. if (stream._state !== 'readable') {
  8407. return;
  8408. }
  8409. ReadableByteStreamControllerClearPendingPullIntos(controller);
  8410. ResetQueue(controller);
  8411. ReadableByteStreamControllerClearAlgorithms(controller);
  8412. ReadableStreamError(stream, e);
  8413. }
  8414. function ReadableByteStreamControllerGetDesiredSize(controller) {
  8415. var stream = controller._controlledReadableByteStream;
  8416. var state = stream._state;
  8417. if (state === 'errored') {
  8418. return null;
  8419. }
  8420. if (state === 'closed') {
  8421. return 0;
  8422. }
  8423. return controller._strategyHWM - controller._queueTotalSize;
  8424. }
  8425. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  8426. bytesWritten = Number(bytesWritten);
  8427. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  8428. throw new RangeError('bytesWritten must be a finite');
  8429. }
  8430. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  8431. }
  8432. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  8433. var firstDescriptor = controller._pendingPullIntos.peek();
  8434. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  8435. throw new RangeError('The region specified by view does not match byobRequest');
  8436. }
  8437. if (firstDescriptor.byteLength !== view.byteLength) {
  8438. throw new RangeError('The buffer of view has different capacity than byobRequest');
  8439. }
  8440. firstDescriptor.buffer = view.buffer;
  8441. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  8442. }
  8443. function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
  8444. controller._controlledReadableByteStream = stream;
  8445. controller._pullAgain = false;
  8446. controller._pulling = false;
  8447. controller._byobRequest = undefined;
  8448. controller._queue = controller._queueTotalSize = undefined;
  8449. ResetQueue(controller);
  8450. controller._closeRequested = false;
  8451. controller._started = false;
  8452. controller._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  8453. controller._pullAlgorithm = pullAlgorithm;
  8454. controller._cancelAlgorithm = cancelAlgorithm;
  8455. controller._autoAllocateChunkSize = autoAllocateChunkSize;
  8456. controller._pendingPullIntos = new SimpleQueue();
  8457. stream._readableStreamController = controller;
  8458. var startResult = startAlgorithm();
  8459. Promise.resolve(startResult).then(function () {
  8460. controller._started = true;
  8461. ReadableByteStreamControllerCallPullIfNeeded(controller);
  8462. }, function (r) {
  8463. ReadableByteStreamControllerError(controller, r);
  8464. }).catch(rethrowAssertionErrorRejection);
  8465. }
  8466. function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
  8467. var controller = Object.create(ReadableByteStreamController.prototype);
  8468. function startAlgorithm() {
  8469. return InvokeOrNoop(underlyingByteSource, 'start', [controller]);
  8470. }
  8471. var pullAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingByteSource, 'pull', 0, [controller]);
  8472. var cancelAlgorithm = CreateAlgorithmFromUnderlyingMethod(underlyingByteSource, 'cancel', 1, []);
  8473. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  8474. if (autoAllocateChunkSize !== undefined) {
  8475. autoAllocateChunkSize = Number(autoAllocateChunkSize);
  8476. if (NumberIsInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  8477. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  8478. }
  8479. }
  8480. SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
  8481. }
  8482. function SetUpReadableStreamBYOBRequest(request, controller, view) {
  8483. request._associatedReadableByteStreamController = controller;
  8484. request._view = view;
  8485. }
  8486. function byobRequestBrandCheckException(name) {
  8487. return new TypeError("ReadableStreamBYOBRequest.prototype." + name + " can only be used on a ReadableStreamBYOBRequest");
  8488. }
  8489. function byteStreamControllerBrandCheckException(name) {
  8490. return new TypeError("ReadableByteStreamController.prototype." + name + " can only be used on a ReadableByteStreamController");
  8491. }
  8492. function AcquireReadableStreamBYOBReader(stream, forAuthorCode) {
  8493. if (forAuthorCode === void 0) {
  8494. forAuthorCode = false;
  8495. }
  8496. var reader = new ReadableStreamBYOBReader(stream);
  8497. reader._forAuthorCode = forAuthorCode;
  8498. return reader;
  8499. }
  8500. function ReadableStreamAddReadIntoRequest(stream) {
  8501. var promise = new Promise(function (resolve, reject) {
  8502. var readIntoRequest = {
  8503. _resolve: resolve,
  8504. _reject: reject
  8505. };
  8506. stream._reader._readIntoRequests.push(readIntoRequest);
  8507. });
  8508. return promise;
  8509. }
  8510. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  8511. var reader = stream._reader;
  8512. var readIntoRequest = reader._readIntoRequests.shift();
  8513. readIntoRequest._resolve(ReadableStreamCreateReadResult(chunk, done, reader._forAuthorCode));
  8514. }
  8515. function ReadableStreamGetNumReadIntoRequests(stream) {
  8516. return stream._reader._readIntoRequests.length;
  8517. }
  8518. function ReadableStreamHasBYOBReader(stream) {
  8519. var reader = stream._reader;
  8520. if (reader === undefined) {
  8521. return false;
  8522. }
  8523. if (!IsReadableStreamBYOBReader(reader)) {
  8524. return false;
  8525. }
  8526. return true;
  8527. }
  8528. var ReadableStreamBYOBReader = function () {
  8529. function ReadableStreamBYOBReader(stream) {
  8530. if (!IsReadableStream(stream)) {
  8531. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  8532. }
  8533. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  8534. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  8535. }
  8536. if (IsReadableStreamLocked(stream)) {
  8537. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  8538. }
  8539. ReadableStreamReaderGenericInitialize(this, stream);
  8540. this._readIntoRequests = new SimpleQueue();
  8541. }
  8542. Object.defineProperty(ReadableStreamBYOBReader.prototype, "closed", {
  8543. get: function () {
  8544. if (!IsReadableStreamBYOBReader(this)) {
  8545. return Promise.reject(byobReaderBrandCheckException('closed'));
  8546. }
  8547. return this._closedPromise;
  8548. },
  8549. enumerable: true,
  8550. configurable: true
  8551. });
  8552. ReadableStreamBYOBReader.prototype.cancel = function (reason) {
  8553. if (!IsReadableStreamBYOBReader(this)) {
  8554. return Promise.reject(byobReaderBrandCheckException('cancel'));
  8555. }
  8556. if (this._ownerReadableStream === undefined) {
  8557. return Promise.reject(readerLockException('cancel'));
  8558. }
  8559. return ReadableStreamReaderGenericCancel(this, reason);
  8560. };
  8561. ReadableStreamBYOBReader.prototype.read = function (view) {
  8562. if (!IsReadableStreamBYOBReader(this)) {
  8563. return Promise.reject(byobReaderBrandCheckException('read'));
  8564. }
  8565. if (this._ownerReadableStream === undefined) {
  8566. return Promise.reject(readerLockException('read from'));
  8567. }
  8568. if (!ArrayBuffer.isView(view)) {
  8569. return Promise.reject(new TypeError('view must be an array buffer view'));
  8570. }
  8571. if (IsDetachedBuffer(view.buffer) === true);
  8572. if (view.byteLength === 0) {
  8573. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  8574. }
  8575. return ReadableStreamBYOBReaderRead(this, view);
  8576. };
  8577. ReadableStreamBYOBReader.prototype.releaseLock = function () {
  8578. if (!IsReadableStreamBYOBReader(this)) {
  8579. throw byobReaderBrandCheckException('releaseLock');
  8580. }
  8581. if (this._ownerReadableStream === undefined) {
  8582. return;
  8583. }
  8584. if (this._readIntoRequests.length > 0) {
  8585. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  8586. }
  8587. ReadableStreamReaderGenericRelease(this);
  8588. };
  8589. return ReadableStreamBYOBReader;
  8590. }();
  8591. function IsReadableStreamBYOBReader(x) {
  8592. if (!typeIsObject(x)) {
  8593. return false;
  8594. }
  8595. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  8596. return false;
  8597. }
  8598. return true;
  8599. }
  8600. function ReadableStreamBYOBReaderRead(reader, view) {
  8601. var stream = reader._ownerReadableStream;
  8602. stream._disturbed = true;
  8603. if (stream._state === 'errored') {
  8604. return Promise.reject(stream._storedError);
  8605. }
  8606. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  8607. }
  8608. function byobReaderBrandCheckException(name) {
  8609. return new TypeError("ReadableStreamBYOBReader.prototype." + name + " can only be used on a ReadableStreamBYOBReader");
  8610. }
  8611. var ReadableStream = function () {
  8612. function ReadableStream(underlyingSource, strategy) {
  8613. if (underlyingSource === void 0) {
  8614. underlyingSource = {};
  8615. }
  8616. if (strategy === void 0) {
  8617. strategy = {};
  8618. }
  8619. InitializeReadableStream(this);
  8620. var size = strategy.size;
  8621. var highWaterMark = strategy.highWaterMark;
  8622. var type = underlyingSource.type;
  8623. var typeString = String(type);
  8624. if (typeString === 'bytes') {
  8625. if (size !== undefined) {
  8626. throw new RangeError('The strategy for a byte stream cannot have a size function');
  8627. }
  8628. if (highWaterMark === undefined) {
  8629. highWaterMark = 0;
  8630. }
  8631. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  8632. SetUpReadableByteStreamControllerFromUnderlyingSource(this, underlyingSource, highWaterMark);
  8633. } else if (type === undefined) {
  8634. var sizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(size);
  8635. if (highWaterMark === undefined) {
  8636. highWaterMark = 1;
  8637. }
  8638. highWaterMark = ValidateAndNormalizeHighWaterMark(highWaterMark);
  8639. SetUpReadableStreamDefaultControllerFromUnderlyingSource(this, underlyingSource, highWaterMark, sizeAlgorithm);
  8640. } else {
  8641. throw new RangeError('Invalid type is specified');
  8642. }
  8643. }
  8644. Object.defineProperty(ReadableStream.prototype, "locked", {
  8645. get: function () {
  8646. if (IsReadableStream(this) === false) {
  8647. throw streamBrandCheckException$1('locked');
  8648. }
  8649. return IsReadableStreamLocked(this);
  8650. },
  8651. enumerable: true,
  8652. configurable: true
  8653. });
  8654. ReadableStream.prototype.cancel = function (reason) {
  8655. if (IsReadableStream(this) === false) {
  8656. return Promise.reject(streamBrandCheckException$1('cancel'));
  8657. }
  8658. if (IsReadableStreamLocked(this) === true) {
  8659. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  8660. }
  8661. return ReadableStreamCancel(this, reason);
  8662. };
  8663. ReadableStream.prototype.getReader = function (_a) {
  8664. var mode = (_a === void 0 ? {} : _a).mode;
  8665. if (IsReadableStream(this) === false) {
  8666. throw streamBrandCheckException$1('getReader');
  8667. }
  8668. if (mode === undefined) {
  8669. return AcquireReadableStreamDefaultReader(this, true);
  8670. }
  8671. mode = String(mode);
  8672. if (mode === 'byob') {
  8673. return AcquireReadableStreamBYOBReader(this, true);
  8674. }
  8675. throw new RangeError('Invalid mode is specified');
  8676. };
  8677. ReadableStream.prototype.pipeThrough = function (_a, _b) {
  8678. var writable = _a.writable, readable = _a.readable;
  8679. var _c = _b === void 0 ? {} : _b, preventClose = _c.preventClose, preventAbort = _c.preventAbort, preventCancel = _c.preventCancel, signal = _c.signal;
  8680. if (IsReadableStream(this) === false) {
  8681. throw streamBrandCheckException$1('pipeThrough');
  8682. }
  8683. if (IsWritableStream(writable) === false) {
  8684. throw new TypeError('writable argument to pipeThrough must be a WritableStream');
  8685. }
  8686. if (IsReadableStream(readable) === false) {
  8687. throw new TypeError('readable argument to pipeThrough must be a ReadableStream');
  8688. }
  8689. preventClose = Boolean(preventClose);
  8690. preventAbort = Boolean(preventAbort);
  8691. preventCancel = Boolean(preventCancel);
  8692. if (signal !== undefined && !isAbortSignal(signal)) {
  8693. throw new TypeError('ReadableStream.prototype.pipeThrough\'s signal option must be an AbortSignal');
  8694. }
  8695. if (IsReadableStreamLocked(this) === true) {
  8696. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream');
  8697. }
  8698. if (IsWritableStreamLocked(writable) === true) {
  8699. throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream');
  8700. }
  8701. var promise = ReadableStreamPipeTo(this, writable, preventClose, preventAbort, preventCancel, signal);
  8702. promise.catch(noop);
  8703. return readable;
  8704. };
  8705. ReadableStream.prototype.pipeTo = function (dest, _a) {
  8706. var _b = _a === void 0 ? {} : _a, preventClose = _b.preventClose, preventAbort = _b.preventAbort, preventCancel = _b.preventCancel, signal = _b.signal;
  8707. if (IsReadableStream(this) === false) {
  8708. return Promise.reject(streamBrandCheckException$1('pipeTo'));
  8709. }
  8710. if (IsWritableStream(dest) === false) {
  8711. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  8712. }
  8713. preventClose = Boolean(preventClose);
  8714. preventAbort = Boolean(preventAbort);
  8715. preventCancel = Boolean(preventCancel);
  8716. if (signal !== undefined && !isAbortSignal(signal)) {
  8717. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s signal option must be an AbortSignal'));
  8718. }
  8719. if (IsReadableStreamLocked(this) === true) {
  8720. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  8721. }
  8722. if (IsWritableStreamLocked(dest) === true) {
  8723. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  8724. }
  8725. return ReadableStreamPipeTo(this, dest, preventClose, preventAbort, preventCancel, signal);
  8726. };
  8727. ReadableStream.prototype.tee = function () {
  8728. if (IsReadableStream(this) === false) {
  8729. throw streamBrandCheckException$1('tee');
  8730. }
  8731. var branches = ReadableStreamTee(this);
  8732. return createArrayFromList(branches);
  8733. };
  8734. ReadableStream.prototype.getIterator = function (_a) {
  8735. var _b = (_a === void 0 ? {} : _a).preventCancel, preventCancel = _b === void 0 ? false : _b;
  8736. if (IsReadableStream(this) === false) {
  8737. throw streamBrandCheckException$1('getIterator');
  8738. }
  8739. return AcquireReadableStreamAsyncIterator(this, preventCancel);
  8740. };
  8741. return ReadableStream;
  8742. }();
  8743. if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
  8744. Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.asyncIterator, {
  8745. value: ReadableStream.prototype.getIterator,
  8746. enumerable: false,
  8747. writable: true,
  8748. configurable: true
  8749. });
  8750. }
  8751. function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
  8752. if (highWaterMark === void 0) {
  8753. highWaterMark = 1;
  8754. }
  8755. if (sizeAlgorithm === void 0) {
  8756. sizeAlgorithm = function () {
  8757. return 1;
  8758. };
  8759. }
  8760. var stream = Object.create(ReadableStream.prototype);
  8761. InitializeReadableStream(stream);
  8762. var controller = Object.create(ReadableStreamDefaultController.prototype);
  8763. SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
  8764. return stream;
  8765. }
  8766. function InitializeReadableStream(stream) {
  8767. stream._state = 'readable';
  8768. stream._reader = undefined;
  8769. stream._storedError = undefined;
  8770. stream._disturbed = false;
  8771. }
  8772. function IsReadableStream(x) {
  8773. if (!typeIsObject(x)) {
  8774. return false;
  8775. }
  8776. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  8777. return false;
  8778. }
  8779. return true;
  8780. }
  8781. function IsReadableStreamLocked(stream) {
  8782. if (stream._reader === undefined) {
  8783. return false;
  8784. }
  8785. return true;
  8786. }
  8787. function ReadableStreamCancel(stream, reason) {
  8788. stream._disturbed = true;
  8789. if (stream._state === 'closed') {
  8790. return Promise.resolve(undefined);
  8791. }
  8792. if (stream._state === 'errored') {
  8793. return Promise.reject(stream._storedError);
  8794. }
  8795. ReadableStreamClose(stream);
  8796. var sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
  8797. return sourceCancelPromise.then(function () {
  8798. return undefined;
  8799. });
  8800. }
  8801. function ReadableStreamClose(stream) {
  8802. stream._state = 'closed';
  8803. var reader = stream._reader;
  8804. if (reader === undefined) {
  8805. return;
  8806. }
  8807. if (IsReadableStreamDefaultReader(reader)) {
  8808. reader._readRequests.forEach(function (readRequest) {
  8809. readRequest._resolve(ReadableStreamCreateReadResult(undefined, true, reader._forAuthorCode));
  8810. });
  8811. reader._readRequests = new SimpleQueue();
  8812. }
  8813. defaultReaderClosedPromiseResolve(reader);
  8814. }
  8815. function ReadableStreamError(stream, e) {
  8816. stream._state = 'errored';
  8817. stream._storedError = e;
  8818. var reader = stream._reader;
  8819. if (reader === undefined) {
  8820. return;
  8821. }
  8822. if (IsReadableStreamDefaultReader(reader)) {
  8823. reader._readRequests.forEach(function (readRequest) {
  8824. readRequest._reject(e);
  8825. });
  8826. reader._readRequests = new SimpleQueue();
  8827. } else {
  8828. reader._readIntoRequests.forEach(function (readIntoRequest) {
  8829. readIntoRequest._reject(e);
  8830. });
  8831. reader._readIntoRequests = new SimpleQueue();
  8832. }
  8833. defaultReaderClosedPromiseReject(reader, e);
  8834. }
  8835. function isAbortSignal(value) {
  8836. if (typeof value !== 'object' || value === null) {
  8837. return false;
  8838. }
  8839. var aborted = Object.getOwnPropertyDescriptor(AbortSignal.prototype, 'aborted').get;
  8840. try {
  8841. aborted.call(value);
  8842. return true;
  8843. } catch (e) {
  8844. return false;
  8845. }
  8846. }
  8847. function streamBrandCheckException$1(name) {
  8848. return new TypeError("ReadableStream.prototype." + name + " can only be used on a ReadableStream");
  8849. }
  8850. var ByteLengthQueuingStrategy = function () {
  8851. function ByteLengthQueuingStrategy(_a) {
  8852. var highWaterMark = _a.highWaterMark;
  8853. this.highWaterMark = highWaterMark;
  8854. }
  8855. ByteLengthQueuingStrategy.prototype.size = function (chunk) {
  8856. return chunk.byteLength;
  8857. };
  8858. return ByteLengthQueuingStrategy;
  8859. }();
  8860. var CountQueuingStrategy = function () {
  8861. function CountQueuingStrategy(_a) {
  8862. var highWaterMark = _a.highWaterMark;
  8863. this.highWaterMark = highWaterMark;
  8864. }
  8865. CountQueuingStrategy.prototype.size = function () {
  8866. return 1;
  8867. };
  8868. return CountQueuingStrategy;
  8869. }();
  8870. var TransformStream = function () {
  8871. function TransformStream(transformer, writableStrategy, readableStrategy) {
  8872. if (transformer === void 0) {
  8873. transformer = {};
  8874. }
  8875. if (writableStrategy === void 0) {
  8876. writableStrategy = {};
  8877. }
  8878. if (readableStrategy === void 0) {
  8879. readableStrategy = {};
  8880. }
  8881. var writableSizeFunction = writableStrategy.size;
  8882. var writableHighWaterMark = writableStrategy.highWaterMark;
  8883. var readableSizeFunction = readableStrategy.size;
  8884. var readableHighWaterMark = readableStrategy.highWaterMark;
  8885. var writableType = transformer.writableType;
  8886. if (writableType !== undefined) {
  8887. throw new RangeError('Invalid writable type specified');
  8888. }
  8889. var writableSizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(writableSizeFunction);
  8890. if (writableHighWaterMark === undefined) {
  8891. writableHighWaterMark = 1;
  8892. }
  8893. writableHighWaterMark = ValidateAndNormalizeHighWaterMark(writableHighWaterMark);
  8894. var readableType = transformer.readableType;
  8895. if (readableType !== undefined) {
  8896. throw new RangeError('Invalid readable type specified');
  8897. }
  8898. var readableSizeAlgorithm = MakeSizeAlgorithmFromSizeFunction(readableSizeFunction);
  8899. if (readableHighWaterMark === undefined) {
  8900. readableHighWaterMark = 0;
  8901. }
  8902. readableHighWaterMark = ValidateAndNormalizeHighWaterMark(readableHighWaterMark);
  8903. var startPromise_resolve;
  8904. var startPromise = new Promise(function (resolve) {
  8905. startPromise_resolve = resolve;
  8906. });
  8907. InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  8908. SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
  8909. var startResult = InvokeOrNoop(transformer, 'start', [this._transformStreamController]);
  8910. startPromise_resolve(startResult);
  8911. }
  8912. Object.defineProperty(TransformStream.prototype, "readable", {
  8913. get: function () {
  8914. if (IsTransformStream(this) === false) {
  8915. throw streamBrandCheckException$2('readable');
  8916. }
  8917. return this._readable;
  8918. },
  8919. enumerable: true,
  8920. configurable: true
  8921. });
  8922. Object.defineProperty(TransformStream.prototype, "writable", {
  8923. get: function () {
  8924. if (IsTransformStream(this) === false) {
  8925. throw streamBrandCheckException$2('writable');
  8926. }
  8927. return this._writable;
  8928. },
  8929. enumerable: true,
  8930. configurable: true
  8931. });
  8932. return TransformStream;
  8933. }();
  8934. function InitializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm) {
  8935. function startAlgorithm() {
  8936. return startPromise;
  8937. }
  8938. function writeAlgorithm(chunk) {
  8939. return TransformStreamDefaultSinkWriteAlgorithm(stream, chunk);
  8940. }
  8941. function abortAlgorithm(reason) {
  8942. return TransformStreamDefaultSinkAbortAlgorithm(stream, reason);
  8943. }
  8944. function closeAlgorithm() {
  8945. return TransformStreamDefaultSinkCloseAlgorithm(stream);
  8946. }
  8947. stream._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);
  8948. function pullAlgorithm() {
  8949. return TransformStreamDefaultSourcePullAlgorithm(stream);
  8950. }
  8951. function cancelAlgorithm(reason) {
  8952. TransformStreamErrorWritableAndUnblockWrite(stream, reason);
  8953. return Promise.resolve();
  8954. }
  8955. stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
  8956. stream._backpressure = undefined;
  8957. stream._backpressureChangePromise = undefined;
  8958. stream._backpressureChangePromise_resolve = undefined;
  8959. TransformStreamSetBackpressure(stream, true);
  8960. stream._transformStreamController = undefined;
  8961. }
  8962. function IsTransformStream(x) {
  8963. if (!typeIsObject(x)) {
  8964. return false;
  8965. }
  8966. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  8967. return false;
  8968. }
  8969. return true;
  8970. }
  8971. function TransformStreamError(stream, e) {
  8972. ReadableStreamDefaultControllerError(stream._readable._readableStreamController, e);
  8973. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  8974. }
  8975. function TransformStreamErrorWritableAndUnblockWrite(stream, e) {
  8976. TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
  8977. WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e);
  8978. if (stream._backpressure === true) {
  8979. TransformStreamSetBackpressure(stream, false);
  8980. }
  8981. }
  8982. function TransformStreamSetBackpressure(stream, backpressure) {
  8983. if (stream._backpressureChangePromise !== undefined) {
  8984. stream._backpressureChangePromise_resolve();
  8985. }
  8986. stream._backpressureChangePromise = new Promise(function (resolve) {
  8987. stream._backpressureChangePromise_resolve = resolve;
  8988. });
  8989. stream._backpressure = backpressure;
  8990. }
  8991. var TransformStreamDefaultController = function () {
  8992. function TransformStreamDefaultController() {
  8993. throw new TypeError('TransformStreamDefaultController instances cannot be created directly');
  8994. }
  8995. Object.defineProperty(TransformStreamDefaultController.prototype, "desiredSize", {
  8996. get: function () {
  8997. if (IsTransformStreamDefaultController(this) === false) {
  8998. throw defaultControllerBrandCheckException$1('desiredSize');
  8999. }
  9000. var readableController = this._controlledTransformStream._readable._readableStreamController;
  9001. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  9002. },
  9003. enumerable: true,
  9004. configurable: true
  9005. });
  9006. TransformStreamDefaultController.prototype.enqueue = function (chunk) {
  9007. if (IsTransformStreamDefaultController(this) === false) {
  9008. throw defaultControllerBrandCheckException$1('enqueue');
  9009. }
  9010. TransformStreamDefaultControllerEnqueue(this, chunk);
  9011. };
  9012. TransformStreamDefaultController.prototype.error = function (reason) {
  9013. if (IsTransformStreamDefaultController(this) === false) {
  9014. throw defaultControllerBrandCheckException$1('error');
  9015. }
  9016. TransformStreamDefaultControllerError(this, reason);
  9017. };
  9018. TransformStreamDefaultController.prototype.terminate = function () {
  9019. if (IsTransformStreamDefaultController(this) === false) {
  9020. throw defaultControllerBrandCheckException$1('terminate');
  9021. }
  9022. TransformStreamDefaultControllerTerminate(this);
  9023. };
  9024. return TransformStreamDefaultController;
  9025. }();
  9026. function IsTransformStreamDefaultController(x) {
  9027. if (!typeIsObject(x)) {
  9028. return false;
  9029. }
  9030. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  9031. return false;
  9032. }
  9033. return true;
  9034. }
  9035. function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
  9036. controller._controlledTransformStream = stream;
  9037. stream._transformStreamController = controller;
  9038. controller._transformAlgorithm = transformAlgorithm;
  9039. controller._flushAlgorithm = flushAlgorithm;
  9040. }
  9041. function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
  9042. var controller = Object.create(TransformStreamDefaultController.prototype);
  9043. var transformAlgorithm = function (chunk) {
  9044. try {
  9045. TransformStreamDefaultControllerEnqueue(controller, chunk);
  9046. return Promise.resolve();
  9047. } catch (transformResultE) {
  9048. return Promise.reject(transformResultE);
  9049. }
  9050. };
  9051. var transformMethod = transformer.transform;
  9052. if (transformMethod !== undefined) {
  9053. if (typeof transformMethod !== 'function') {
  9054. throw new TypeError('transform is not a method');
  9055. }
  9056. transformAlgorithm = function (chunk) {
  9057. return PromiseCall(transformMethod, transformer, [
  9058. chunk,
  9059. controller
  9060. ]);
  9061. };
  9062. }
  9063. var flushAlgorithm = CreateAlgorithmFromUnderlyingMethod(transformer, 'flush', 0, [controller]);
  9064. SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
  9065. }
  9066. function TransformStreamDefaultControllerClearAlgorithms(controller) {
  9067. controller._transformAlgorithm = undefined;
  9068. controller._flushAlgorithm = undefined;
  9069. }
  9070. function TransformStreamDefaultControllerEnqueue(controller, chunk) {
  9071. var stream = controller._controlledTransformStream;
  9072. var readableController = stream._readable._readableStreamController;
  9073. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === false) {
  9074. throw new TypeError('Readable side is not in a state that permits enqueue');
  9075. }
  9076. try {
  9077. ReadableStreamDefaultControllerEnqueue(readableController, chunk);
  9078. } catch (e) {
  9079. TransformStreamErrorWritableAndUnblockWrite(stream, e);
  9080. throw stream._readable._storedError;
  9081. }
  9082. var backpressure = ReadableStreamDefaultControllerHasBackpressure(readableController);
  9083. if (backpressure !== stream._backpressure) {
  9084. TransformStreamSetBackpressure(stream, true);
  9085. }
  9086. }
  9087. function TransformStreamDefaultControllerError(controller, e) {
  9088. TransformStreamError(controller._controlledTransformStream, e);
  9089. }
  9090. function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
  9091. var transformPromise = controller._transformAlgorithm(chunk);
  9092. return transformPromise.catch(function (r) {
  9093. TransformStreamError(controller._controlledTransformStream, r);
  9094. throw r;
  9095. });
  9096. }
  9097. function TransformStreamDefaultControllerTerminate(controller) {
  9098. var stream = controller._controlledTransformStream;
  9099. var readableController = stream._readable._readableStreamController;
  9100. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) {
  9101. ReadableStreamDefaultControllerClose(readableController);
  9102. }
  9103. var error = new TypeError('TransformStream terminated');
  9104. TransformStreamErrorWritableAndUnblockWrite(stream, error);
  9105. }
  9106. function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
  9107. var controller = stream._transformStreamController;
  9108. if (stream._backpressure === true) {
  9109. var backpressureChangePromise = stream._backpressureChangePromise;
  9110. return backpressureChangePromise.then(function () {
  9111. var writable = stream._writable;
  9112. var state = writable._state;
  9113. if (state === 'erroring') {
  9114. throw writable._storedError;
  9115. }
  9116. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9117. });
  9118. }
  9119. return TransformStreamDefaultControllerPerformTransform(controller, chunk);
  9120. }
  9121. function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
  9122. TransformStreamError(stream, reason);
  9123. return Promise.resolve();
  9124. }
  9125. function TransformStreamDefaultSinkCloseAlgorithm(stream) {
  9126. var readable = stream._readable;
  9127. var controller = stream._transformStreamController;
  9128. var flushPromise = controller._flushAlgorithm();
  9129. TransformStreamDefaultControllerClearAlgorithms(controller);
  9130. return flushPromise.then(function () {
  9131. if (readable._state === 'errored') {
  9132. throw readable._storedError;
  9133. }
  9134. var readableController = readable._readableStreamController;
  9135. if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) {
  9136. ReadableStreamDefaultControllerClose(readableController);
  9137. }
  9138. }).catch(function (r) {
  9139. TransformStreamError(stream, r);
  9140. throw readable._storedError;
  9141. });
  9142. }
  9143. function TransformStreamDefaultSourcePullAlgorithm(stream) {
  9144. TransformStreamSetBackpressure(stream, false);
  9145. return stream._backpressureChangePromise;
  9146. }
  9147. function defaultControllerBrandCheckException$1(name) {
  9148. return new TypeError("TransformStreamDefaultController.prototype." + name + " can only be used on a TransformStreamDefaultController");
  9149. }
  9150. function streamBrandCheckException$2(name) {
  9151. return new TypeError("TransformStream.prototype." + name + " can only be used on a TransformStream");
  9152. }
  9153. /***/ }),
  9154. /* 179 */
  9155. /***/ (function(module, exports, __w_pdfjs_require__) {
  9156. "use strict";
  9157. Object.defineProperty(exports, "__esModule", {
  9158. value: true
  9159. });
  9160. exports.getDocument = getDocument;
  9161. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  9162. exports.build = exports.version = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = void 0;
  9163. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  9164. var _util = __w_pdfjs_require__(1);
  9165. var _display_utils = __w_pdfjs_require__(183);
  9166. var _font_loader = __w_pdfjs_require__(184);
  9167. var _api_compatibility = __w_pdfjs_require__(185);
  9168. var _canvas = __w_pdfjs_require__(186);
  9169. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  9170. var _worker_options = __w_pdfjs_require__(188);
  9171. var _message_handler = __w_pdfjs_require__(189);
  9172. var _metadata = __w_pdfjs_require__(190);
  9173. var _transport_stream = __w_pdfjs_require__(192);
  9174. var _webgl = __w_pdfjs_require__(193);
  9175. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9176. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  9177. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  9178. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  9179. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  9180. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  9181. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9182. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  9183. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  9184. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  9185. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  9186. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9187. 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); } }
  9188. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9189. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9190. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  9191. var RENDERING_CANCELLED_TIMEOUT = 100;
  9192. var isWorkerDisabled = false;
  9193. var fallbackWorkerSrc;
  9194. var fakeWorkerFilesLoader = null;
  9195. {
  9196. var useRequireEnsure = false;
  9197. if (typeof window === 'undefined') {
  9198. isWorkerDisabled = true;
  9199. if (typeof require.ensure === 'undefined') {
  9200. require.ensure = require('node-ensure');
  9201. }
  9202. useRequireEnsure = true;
  9203. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  9204. useRequireEnsure = true;
  9205. }
  9206. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  9207. fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  9208. }
  9209. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  9210. fakeWorkerFilesLoader = useRequireEnsure ? function () {
  9211. return new Promise(function (resolve, reject) {
  9212. require.ensure([], function () {
  9213. try {
  9214. var worker;
  9215. worker = require('./pdf.worker.js');
  9216. resolve(worker.WorkerMessageHandler);
  9217. } catch (ex) {
  9218. reject(ex);
  9219. }
  9220. }, reject, 'pdfjsWorker');
  9221. });
  9222. } : dynamicLoaderSupported ? function () {
  9223. return new Promise(function (resolve, reject) {
  9224. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  9225. try {
  9226. resolve(worker.WorkerMessageHandler);
  9227. } catch (ex) {
  9228. reject(ex);
  9229. }
  9230. }, reject);
  9231. });
  9232. } : null;
  9233. if (!fallbackWorkerSrc && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && 'currentScript' in document) {
  9234. var pdfjsFilePath = document.currentScript && document.currentScript.src;
  9235. if (pdfjsFilePath) {
  9236. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  9237. }
  9238. }
  9239. }
  9240. var createPDFNetworkStream;
  9241. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  9242. createPDFNetworkStream = pdfNetworkStreamFactory;
  9243. }
  9244. function getDocument(src) {
  9245. var task = new PDFDocumentLoadingTask();
  9246. var source;
  9247. if (typeof src === 'string') {
  9248. source = {
  9249. url: src
  9250. };
  9251. } else if ((0, _util.isArrayBuffer)(src)) {
  9252. source = {
  9253. data: src
  9254. };
  9255. } else if (src instanceof PDFDataRangeTransport) {
  9256. source = {
  9257. range: src
  9258. };
  9259. } else {
  9260. if (_typeof(src) !== 'object') {
  9261. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  9262. }
  9263. if (!src.url && !src.data && !src.range) {
  9264. throw new Error('Invalid parameter object: need either .data, .range or .url');
  9265. }
  9266. source = src;
  9267. }
  9268. var params = Object.create(null);
  9269. var rangeTransport = null,
  9270. worker = null;
  9271. for (var key in source) {
  9272. if (key === 'url' && typeof window !== 'undefined') {
  9273. params[key] = new URL(source[key], window.location).href;
  9274. continue;
  9275. } else if (key === 'range') {
  9276. rangeTransport = source[key];
  9277. continue;
  9278. } else if (key === 'worker') {
  9279. worker = source[key];
  9280. continue;
  9281. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  9282. var pdfBytes = source[key];
  9283. if (typeof pdfBytes === 'string') {
  9284. params[key] = (0, _util.stringToBytes)(pdfBytes);
  9285. } else if (_typeof(pdfBytes) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  9286. params[key] = new Uint8Array(pdfBytes);
  9287. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  9288. params[key] = new Uint8Array(pdfBytes);
  9289. } else {
  9290. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  9291. }
  9292. continue;
  9293. }
  9294. params[key] = source[key];
  9295. }
  9296. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  9297. params.CMapReaderFactory = params.CMapReaderFactory || _display_utils.DOMCMapReaderFactory;
  9298. params.ignoreErrors = params.stopAtErrors !== true;
  9299. params.pdfBug = params.pdfBug === true;
  9300. var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
  9301. if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
  9302. params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
  9303. }
  9304. if (!Number.isInteger(params.maxImageSize)) {
  9305. params.maxImageSize = -1;
  9306. }
  9307. if (typeof params.isEvalSupported !== 'boolean') {
  9308. params.isEvalSupported = true;
  9309. }
  9310. if (typeof params.disableFontFace !== 'boolean') {
  9311. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  9312. }
  9313. if (typeof params.disableRange !== 'boolean') {
  9314. params.disableRange = false;
  9315. }
  9316. if (typeof params.disableStream !== 'boolean') {
  9317. params.disableStream = false;
  9318. }
  9319. if (typeof params.disableAutoFetch !== 'boolean') {
  9320. params.disableAutoFetch = false;
  9321. }
  9322. if (typeof params.disableCreateObjectURL !== 'boolean') {
  9323. params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
  9324. }
  9325. (0, _util.setVerbosityLevel)(params.verbosity);
  9326. if (!worker) {
  9327. var workerParams = {
  9328. verbosity: params.verbosity,
  9329. port: _worker_options.GlobalWorkerOptions.workerPort
  9330. };
  9331. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  9332. task._worker = worker;
  9333. }
  9334. var docId = task.docId;
  9335. worker.promise.then(function () {
  9336. if (task.destroyed) {
  9337. throw new Error('Loading aborted');
  9338. }
  9339. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  9340. if (task.destroyed) {
  9341. throw new Error('Loading aborted');
  9342. }
  9343. var networkStream;
  9344. if (rangeTransport) {
  9345. networkStream = new _transport_stream.PDFDataTransportStream({
  9346. length: params.length,
  9347. initialData: params.initialData,
  9348. progressiveDone: params.progressiveDone,
  9349. disableRange: params.disableRange,
  9350. disableStream: params.disableStream
  9351. }, rangeTransport);
  9352. } else if (!params.data) {
  9353. networkStream = createPDFNetworkStream({
  9354. url: params.url,
  9355. length: params.length,
  9356. httpHeaders: params.httpHeaders,
  9357. withCredentials: params.withCredentials,
  9358. rangeChunkSize: params.rangeChunkSize,
  9359. disableRange: params.disableRange,
  9360. disableStream: params.disableStream
  9361. });
  9362. }
  9363. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  9364. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  9365. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  9366. task._transport = transport;
  9367. messageHandler.send('Ready', null);
  9368. });
  9369. })["catch"](task._capability.reject);
  9370. return task;
  9371. }
  9372. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  9373. if (worker.destroyed) {
  9374. return Promise.reject(new Error('Worker was destroyed'));
  9375. }
  9376. if (pdfDataRangeTransport) {
  9377. source.length = pdfDataRangeTransport.length;
  9378. source.initialData = pdfDataRangeTransport.initialData;
  9379. source.progressiveDone = pdfDataRangeTransport.progressiveDone;
  9380. }
  9381. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  9382. docId: docId,
  9383. apiVersion: '2.3.200',
  9384. source: {
  9385. data: source.data,
  9386. url: source.url,
  9387. password: source.password,
  9388. disableAutoFetch: source.disableAutoFetch,
  9389. rangeChunkSize: source.rangeChunkSize,
  9390. length: source.length
  9391. },
  9392. maxImageSize: source.maxImageSize,
  9393. disableFontFace: source.disableFontFace,
  9394. disableCreateObjectURL: source.disableCreateObjectURL,
  9395. postMessageTransfers: worker.postMessageTransfers,
  9396. docBaseUrl: source.docBaseUrl,
  9397. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  9398. ignoreErrors: source.ignoreErrors,
  9399. isEvalSupported: source.isEvalSupported
  9400. }).then(function (workerId) {
  9401. if (worker.destroyed) {
  9402. throw new Error('Worker was destroyed');
  9403. }
  9404. return workerId;
  9405. });
  9406. }
  9407. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  9408. var nextDocumentId = 0;
  9409. var PDFDocumentLoadingTask =
  9410. /*#__PURE__*/
  9411. function () {
  9412. function PDFDocumentLoadingTask() {
  9413. _classCallCheck(this, PDFDocumentLoadingTask);
  9414. this._capability = (0, _util.createPromiseCapability)();
  9415. this._transport = null;
  9416. this._worker = null;
  9417. this.docId = 'd' + nextDocumentId++;
  9418. this.destroyed = false;
  9419. this.onPassword = null;
  9420. this.onProgress = null;
  9421. this.onUnsupportedFeature = null;
  9422. }
  9423. _createClass(PDFDocumentLoadingTask, [{
  9424. key: "destroy",
  9425. value: function destroy() {
  9426. var _this = this;
  9427. this.destroyed = true;
  9428. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  9429. return transportDestroyed.then(function () {
  9430. _this._transport = null;
  9431. if (_this._worker) {
  9432. _this._worker.destroy();
  9433. _this._worker = null;
  9434. }
  9435. });
  9436. }
  9437. }, {
  9438. key: "then",
  9439. value: function then(onFulfilled, onRejected) {
  9440. (0, _display_utils.deprecated)('PDFDocumentLoadingTask.then method, ' + 'use the `promise` getter instead.');
  9441. return this.promise.then.apply(this.promise, arguments);
  9442. }
  9443. }, {
  9444. key: "promise",
  9445. get: function get() {
  9446. return this._capability.promise;
  9447. }
  9448. }]);
  9449. return PDFDocumentLoadingTask;
  9450. }();
  9451. return PDFDocumentLoadingTask;
  9452. }();
  9453. var PDFDataRangeTransport =
  9454. /*#__PURE__*/
  9455. function () {
  9456. function PDFDataRangeTransport(length, initialData) {
  9457. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9458. _classCallCheck(this, PDFDataRangeTransport);
  9459. this.length = length;
  9460. this.initialData = initialData;
  9461. this.progressiveDone = progressiveDone;
  9462. this._rangeListeners = [];
  9463. this._progressListeners = [];
  9464. this._progressiveReadListeners = [];
  9465. this._progressiveDoneListeners = [];
  9466. this._readyCapability = (0, _util.createPromiseCapability)();
  9467. }
  9468. _createClass(PDFDataRangeTransport, [{
  9469. key: "addRangeListener",
  9470. value: function addRangeListener(listener) {
  9471. this._rangeListeners.push(listener);
  9472. }
  9473. }, {
  9474. key: "addProgressListener",
  9475. value: function addProgressListener(listener) {
  9476. this._progressListeners.push(listener);
  9477. }
  9478. }, {
  9479. key: "addProgressiveReadListener",
  9480. value: function addProgressiveReadListener(listener) {
  9481. this._progressiveReadListeners.push(listener);
  9482. }
  9483. }, {
  9484. key: "addProgressiveDoneListener",
  9485. value: function addProgressiveDoneListener(listener) {
  9486. this._progressiveDoneListeners.push(listener);
  9487. }
  9488. }, {
  9489. key: "onDataRange",
  9490. value: function onDataRange(begin, chunk) {
  9491. var _iteratorNormalCompletion = true;
  9492. var _didIteratorError = false;
  9493. var _iteratorError = undefined;
  9494. try {
  9495. for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9496. var listener = _step.value;
  9497. listener(begin, chunk);
  9498. }
  9499. } catch (err) {
  9500. _didIteratorError = true;
  9501. _iteratorError = err;
  9502. } finally {
  9503. try {
  9504. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  9505. _iterator["return"]();
  9506. }
  9507. } finally {
  9508. if (_didIteratorError) {
  9509. throw _iteratorError;
  9510. }
  9511. }
  9512. }
  9513. }
  9514. }, {
  9515. key: "onDataProgress",
  9516. value: function onDataProgress(loaded, total) {
  9517. var _this2 = this;
  9518. this._readyCapability.promise.then(function () {
  9519. var _iteratorNormalCompletion2 = true;
  9520. var _didIteratorError2 = false;
  9521. var _iteratorError2 = undefined;
  9522. try {
  9523. for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  9524. var listener = _step2.value;
  9525. listener(loaded, total);
  9526. }
  9527. } catch (err) {
  9528. _didIteratorError2 = true;
  9529. _iteratorError2 = err;
  9530. } finally {
  9531. try {
  9532. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  9533. _iterator2["return"]();
  9534. }
  9535. } finally {
  9536. if (_didIteratorError2) {
  9537. throw _iteratorError2;
  9538. }
  9539. }
  9540. }
  9541. });
  9542. }
  9543. }, {
  9544. key: "onDataProgressiveRead",
  9545. value: function onDataProgressiveRead(chunk) {
  9546. var _this3 = this;
  9547. this._readyCapability.promise.then(function () {
  9548. var _iteratorNormalCompletion3 = true;
  9549. var _didIteratorError3 = false;
  9550. var _iteratorError3 = undefined;
  9551. try {
  9552. for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  9553. var listener = _step3.value;
  9554. listener(chunk);
  9555. }
  9556. } catch (err) {
  9557. _didIteratorError3 = true;
  9558. _iteratorError3 = err;
  9559. } finally {
  9560. try {
  9561. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  9562. _iterator3["return"]();
  9563. }
  9564. } finally {
  9565. if (_didIteratorError3) {
  9566. throw _iteratorError3;
  9567. }
  9568. }
  9569. }
  9570. });
  9571. }
  9572. }, {
  9573. key: "onDataProgressiveDone",
  9574. value: function onDataProgressiveDone() {
  9575. var _this4 = this;
  9576. this._readyCapability.promise.then(function () {
  9577. var _iteratorNormalCompletion4 = true;
  9578. var _didIteratorError4 = false;
  9579. var _iteratorError4 = undefined;
  9580. try {
  9581. for (var _iterator4 = _this4._progressiveDoneListeners[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  9582. var listener = _step4.value;
  9583. listener();
  9584. }
  9585. } catch (err) {
  9586. _didIteratorError4 = true;
  9587. _iteratorError4 = err;
  9588. } finally {
  9589. try {
  9590. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  9591. _iterator4["return"]();
  9592. }
  9593. } finally {
  9594. if (_didIteratorError4) {
  9595. throw _iteratorError4;
  9596. }
  9597. }
  9598. }
  9599. });
  9600. }
  9601. }, {
  9602. key: "transportReady",
  9603. value: function transportReady() {
  9604. this._readyCapability.resolve();
  9605. }
  9606. }, {
  9607. key: "requestDataRange",
  9608. value: function requestDataRange(begin, end) {
  9609. (0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
  9610. }
  9611. }, {
  9612. key: "abort",
  9613. value: function abort() {}
  9614. }]);
  9615. return PDFDataRangeTransport;
  9616. }();
  9617. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  9618. var PDFDocumentProxy =
  9619. /*#__PURE__*/
  9620. function () {
  9621. function PDFDocumentProxy(pdfInfo, transport) {
  9622. _classCallCheck(this, PDFDocumentProxy);
  9623. this._pdfInfo = pdfInfo;
  9624. this._transport = transport;
  9625. }
  9626. _createClass(PDFDocumentProxy, [{
  9627. key: "getPage",
  9628. value: function getPage(pageNumber) {
  9629. return this._transport.getPage(pageNumber);
  9630. }
  9631. }, {
  9632. key: "getPageIndex",
  9633. value: function getPageIndex(ref) {
  9634. return this._transport.getPageIndex(ref);
  9635. }
  9636. }, {
  9637. key: "getDestinations",
  9638. value: function getDestinations() {
  9639. return this._transport.getDestinations();
  9640. }
  9641. }, {
  9642. key: "getDestination",
  9643. value: function getDestination(id) {
  9644. return this._transport.getDestination(id);
  9645. }
  9646. }, {
  9647. key: "getPageLabels",
  9648. value: function getPageLabels() {
  9649. return this._transport.getPageLabels();
  9650. }
  9651. }, {
  9652. key: "getPageLayout",
  9653. value: function getPageLayout() {
  9654. return this._transport.getPageLayout();
  9655. }
  9656. }, {
  9657. key: "getPageMode",
  9658. value: function getPageMode() {
  9659. return this._transport.getPageMode();
  9660. }
  9661. }, {
  9662. key: "getViewerPreferences",
  9663. value: function getViewerPreferences() {
  9664. return this._transport.getViewerPreferences();
  9665. }
  9666. }, {
  9667. key: "getOpenActionDestination",
  9668. value: function getOpenActionDestination() {
  9669. return this._transport.getOpenActionDestination();
  9670. }
  9671. }, {
  9672. key: "getAttachments",
  9673. value: function getAttachments() {
  9674. return this._transport.getAttachments();
  9675. }
  9676. }, {
  9677. key: "getJavaScript",
  9678. value: function getJavaScript() {
  9679. return this._transport.getJavaScript();
  9680. }
  9681. }, {
  9682. key: "getOutline",
  9683. value: function getOutline() {
  9684. return this._transport.getOutline();
  9685. }
  9686. }, {
  9687. key: "getPermissions",
  9688. value: function getPermissions() {
  9689. return this._transport.getPermissions();
  9690. }
  9691. }, {
  9692. key: "getMetadata",
  9693. value: function getMetadata() {
  9694. return this._transport.getMetadata();
  9695. }
  9696. }, {
  9697. key: "getData",
  9698. value: function getData() {
  9699. return this._transport.getData();
  9700. }
  9701. }, {
  9702. key: "getDownloadInfo",
  9703. value: function getDownloadInfo() {
  9704. return this._transport.downloadInfoCapability.promise;
  9705. }
  9706. }, {
  9707. key: "getStats",
  9708. value: function getStats() {
  9709. return this._transport.getStats();
  9710. }
  9711. }, {
  9712. key: "cleanup",
  9713. value: function cleanup() {
  9714. this._transport.startCleanup();
  9715. }
  9716. }, {
  9717. key: "destroy",
  9718. value: function destroy() {
  9719. return this.loadingTask.destroy();
  9720. }
  9721. }, {
  9722. key: "numPages",
  9723. get: function get() {
  9724. return this._pdfInfo.numPages;
  9725. }
  9726. }, {
  9727. key: "fingerprint",
  9728. get: function get() {
  9729. return this._pdfInfo.fingerprint;
  9730. }
  9731. }, {
  9732. key: "loadingParams",
  9733. get: function get() {
  9734. return this._transport.loadingParams;
  9735. }
  9736. }, {
  9737. key: "loadingTask",
  9738. get: function get() {
  9739. return this._transport.loadingTask;
  9740. }
  9741. }]);
  9742. return PDFDocumentProxy;
  9743. }();
  9744. exports.PDFDocumentProxy = PDFDocumentProxy;
  9745. var PDFPageProxy =
  9746. /*#__PURE__*/
  9747. function () {
  9748. function PDFPageProxy(pageIndex, pageInfo, transport) {
  9749. var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9750. _classCallCheck(this, PDFPageProxy);
  9751. this.pageIndex = pageIndex;
  9752. this._pageInfo = pageInfo;
  9753. this._transport = transport;
  9754. this._stats = pdfBug ? new _display_utils.StatTimer() : _display_utils.DummyStatTimer;
  9755. this._pdfBug = pdfBug;
  9756. this.commonObjs = transport.commonObjs;
  9757. this.objs = new PDFObjects();
  9758. this.cleanupAfterRender = false;
  9759. this.pendingCleanup = false;
  9760. this.intentStates = Object.create(null);
  9761. this.destroyed = false;
  9762. }
  9763. _createClass(PDFPageProxy, [{
  9764. key: "getViewport",
  9765. value: function getViewport() {
  9766. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  9767. scale = _ref.scale,
  9768. _ref$rotation = _ref.rotation,
  9769. rotation = _ref$rotation === void 0 ? this.rotate : _ref$rotation,
  9770. _ref$dontFlip = _ref.dontFlip,
  9771. dontFlip = _ref$dontFlip === void 0 ? false : _ref$dontFlip;
  9772. if (arguments.length > 1 || typeof arguments[0] === 'number') {
  9773. (0, _display_utils.deprecated)('getViewport is called with obsolete arguments.');
  9774. scale = arguments[0];
  9775. rotation = typeof arguments[1] === 'number' ? arguments[1] : this.rotate;
  9776. dontFlip = typeof arguments[2] === 'boolean' ? arguments[2] : false;
  9777. }
  9778. return new _display_utils.PageViewport({
  9779. viewBox: this.view,
  9780. scale: scale,
  9781. rotation: rotation,
  9782. dontFlip: dontFlip
  9783. });
  9784. }
  9785. }, {
  9786. key: "getAnnotations",
  9787. value: function getAnnotations() {
  9788. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  9789. _ref2$intent = _ref2.intent,
  9790. intent = _ref2$intent === void 0 ? null : _ref2$intent;
  9791. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  9792. this.annotationsPromise = this._transport.getAnnotations(this.pageIndex, intent);
  9793. this.annotationsIntent = intent;
  9794. }
  9795. return this.annotationsPromise;
  9796. }
  9797. }, {
  9798. key: "render",
  9799. value: function render(_ref3) {
  9800. var _this5 = this;
  9801. var canvasContext = _ref3.canvasContext,
  9802. viewport = _ref3.viewport,
  9803. _ref3$intent = _ref3.intent,
  9804. intent = _ref3$intent === void 0 ? 'display' : _ref3$intent,
  9805. _ref3$enableWebGL = _ref3.enableWebGL,
  9806. enableWebGL = _ref3$enableWebGL === void 0 ? false : _ref3$enableWebGL,
  9807. _ref3$renderInteracti = _ref3.renderInteractiveForms,
  9808. renderInteractiveForms = _ref3$renderInteracti === void 0 ? false : _ref3$renderInteracti,
  9809. _ref3$transform = _ref3.transform,
  9810. transform = _ref3$transform === void 0 ? null : _ref3$transform,
  9811. _ref3$imageLayer = _ref3.imageLayer,
  9812. imageLayer = _ref3$imageLayer === void 0 ? null : _ref3$imageLayer,
  9813. _ref3$canvasFactory = _ref3.canvasFactory,
  9814. canvasFactory = _ref3$canvasFactory === void 0 ? null : _ref3$canvasFactory,
  9815. _ref3$background = _ref3.background,
  9816. background = _ref3$background === void 0 ? null : _ref3$background;
  9817. var stats = this._stats;
  9818. stats.time('Overall');
  9819. var renderingIntent = intent === 'print' ? 'print' : 'display';
  9820. this.pendingCleanup = false;
  9821. if (!this.intentStates[renderingIntent]) {
  9822. this.intentStates[renderingIntent] = Object.create(null);
  9823. }
  9824. var intentState = this.intentStates[renderingIntent];
  9825. if (intentState.streamReaderCancelTimeout) {
  9826. clearTimeout(intentState.streamReaderCancelTimeout);
  9827. intentState.streamReaderCancelTimeout = null;
  9828. }
  9829. var canvasFactoryInstance = canvasFactory || new _display_utils.DOMCanvasFactory();
  9830. var webGLContext = new _webgl.WebGLContext({
  9831. enable: enableWebGL
  9832. });
  9833. if (!intentState.displayReadyCapability) {
  9834. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  9835. intentState.operatorList = {
  9836. fnArray: [],
  9837. argsArray: [],
  9838. lastChunk: false
  9839. };
  9840. stats.time('Page Request');
  9841. this._pumpOperatorList({
  9842. pageIndex: this.pageNumber - 1,
  9843. intent: renderingIntent,
  9844. renderInteractiveForms: renderInteractiveForms === true
  9845. });
  9846. }
  9847. var complete = function complete(error) {
  9848. var i = intentState.renderTasks.indexOf(internalRenderTask);
  9849. if (i >= 0) {
  9850. intentState.renderTasks.splice(i, 1);
  9851. }
  9852. if (_this5.cleanupAfterRender || renderingIntent === 'print') {
  9853. _this5.pendingCleanup = true;
  9854. }
  9855. _this5._tryCleanup();
  9856. if (error) {
  9857. internalRenderTask.capability.reject(error);
  9858. _this5._abortOperatorList({
  9859. intentState: intentState,
  9860. reason: error
  9861. });
  9862. } else {
  9863. internalRenderTask.capability.resolve();
  9864. }
  9865. stats.timeEnd('Rendering');
  9866. stats.timeEnd('Overall');
  9867. };
  9868. var internalRenderTask = new InternalRenderTask({
  9869. callback: complete,
  9870. params: {
  9871. canvasContext: canvasContext,
  9872. viewport: viewport,
  9873. transform: transform,
  9874. imageLayer: imageLayer,
  9875. background: background
  9876. },
  9877. objs: this.objs,
  9878. commonObjs: this.commonObjs,
  9879. operatorList: intentState.operatorList,
  9880. pageNumber: this.pageNumber,
  9881. canvasFactory: canvasFactoryInstance,
  9882. webGLContext: webGLContext,
  9883. useRequestAnimationFrame: renderingIntent !== 'print',
  9884. pdfBug: this._pdfBug
  9885. });
  9886. if (!intentState.renderTasks) {
  9887. intentState.renderTasks = [];
  9888. }
  9889. intentState.renderTasks.push(internalRenderTask);
  9890. var renderTask = internalRenderTask.task;
  9891. intentState.displayReadyCapability.promise.then(function (transparency) {
  9892. if (_this5.pendingCleanup) {
  9893. complete();
  9894. return;
  9895. }
  9896. stats.time('Rendering');
  9897. internalRenderTask.initializeGraphics(transparency);
  9898. internalRenderTask.operatorListChanged();
  9899. })["catch"](complete);
  9900. return renderTask;
  9901. }
  9902. }, {
  9903. key: "getOperatorList",
  9904. value: function getOperatorList() {
  9905. function operatorListChanged() {
  9906. if (intentState.operatorList.lastChunk) {
  9907. intentState.opListReadCapability.resolve(intentState.operatorList);
  9908. var i = intentState.renderTasks.indexOf(opListTask);
  9909. if (i >= 0) {
  9910. intentState.renderTasks.splice(i, 1);
  9911. }
  9912. }
  9913. }
  9914. var renderingIntent = 'oplist';
  9915. if (!this.intentStates[renderingIntent]) {
  9916. this.intentStates[renderingIntent] = Object.create(null);
  9917. }
  9918. var intentState = this.intentStates[renderingIntent];
  9919. var opListTask;
  9920. if (!intentState.opListReadCapability) {
  9921. opListTask = {};
  9922. opListTask.operatorListChanged = operatorListChanged;
  9923. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  9924. intentState.renderTasks = [];
  9925. intentState.renderTasks.push(opListTask);
  9926. intentState.operatorList = {
  9927. fnArray: [],
  9928. argsArray: [],
  9929. lastChunk: false
  9930. };
  9931. this._stats.time('Page Request');
  9932. this._pumpOperatorList({
  9933. pageIndex: this.pageIndex,
  9934. intent: renderingIntent
  9935. });
  9936. }
  9937. return intentState.opListReadCapability.promise;
  9938. }
  9939. }, {
  9940. key: "streamTextContent",
  9941. value: function streamTextContent() {
  9942. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  9943. _ref4$normalizeWhites = _ref4.normalizeWhitespace,
  9944. normalizeWhitespace = _ref4$normalizeWhites === void 0 ? false : _ref4$normalizeWhites,
  9945. _ref4$disableCombineT = _ref4.disableCombineTextItems,
  9946. disableCombineTextItems = _ref4$disableCombineT === void 0 ? false : _ref4$disableCombineT;
  9947. var TEXT_CONTENT_CHUNK_SIZE = 100;
  9948. return this._transport.messageHandler.sendWithStream('GetTextContent', {
  9949. pageIndex: this.pageNumber - 1,
  9950. normalizeWhitespace: normalizeWhitespace === true,
  9951. combineTextItems: disableCombineTextItems !== true
  9952. }, {
  9953. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  9954. size: function size(textContent) {
  9955. return textContent.items.length;
  9956. }
  9957. });
  9958. }
  9959. }, {
  9960. key: "getTextContent",
  9961. value: function getTextContent() {
  9962. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9963. var readableStream = this.streamTextContent(params);
  9964. return new Promise(function (resolve, reject) {
  9965. function pump() {
  9966. reader.read().then(function (_ref5) {
  9967. var _textContent$items;
  9968. var value = _ref5.value,
  9969. done = _ref5.done;
  9970. if (done) {
  9971. resolve(textContent);
  9972. return;
  9973. }
  9974. Object.assign(textContent.styles, value.styles);
  9975. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  9976. pump();
  9977. }, reject);
  9978. }
  9979. var reader = readableStream.getReader();
  9980. var textContent = {
  9981. items: [],
  9982. styles: Object.create(null)
  9983. };
  9984. pump();
  9985. });
  9986. }
  9987. }, {
  9988. key: "_destroy",
  9989. value: function _destroy() {
  9990. var _this6 = this;
  9991. this.destroyed = true;
  9992. this._transport.pageCache[this.pageIndex] = null;
  9993. var waitOn = [];
  9994. Object.keys(this.intentStates).forEach(function (intent) {
  9995. var intentState = _this6.intentStates[intent];
  9996. _this6._abortOperatorList({
  9997. intentState: intentState,
  9998. reason: new Error('Page was destroyed.'),
  9999. force: true
  10000. });
  10001. if (intent === 'oplist') {
  10002. return;
  10003. }
  10004. intentState.renderTasks.forEach(function (renderTask) {
  10005. var renderCompleted = renderTask.capability.promise["catch"](function () {});
  10006. waitOn.push(renderCompleted);
  10007. renderTask.cancel();
  10008. });
  10009. });
  10010. this.objs.clear();
  10011. this.annotationsPromise = null;
  10012. this.pendingCleanup = false;
  10013. return Promise.all(waitOn);
  10014. }
  10015. }, {
  10016. key: "cleanup",
  10017. value: function cleanup() {
  10018. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10019. this.pendingCleanup = true;
  10020. this._tryCleanup(resetStats);
  10021. }
  10022. }, {
  10023. key: "_tryCleanup",
  10024. value: function _tryCleanup() {
  10025. var _this7 = this;
  10026. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10027. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  10028. var intentState = _this7.intentStates[intent];
  10029. return intentState.renderTasks.length !== 0 || !intentState.operatorList.lastChunk;
  10030. })) {
  10031. return;
  10032. }
  10033. Object.keys(this.intentStates).forEach(function (intent) {
  10034. delete _this7.intentStates[intent];
  10035. });
  10036. this.objs.clear();
  10037. this.annotationsPromise = null;
  10038. if (resetStats && this._stats instanceof _display_utils.StatTimer) {
  10039. this._stats = new _display_utils.StatTimer();
  10040. }
  10041. this.pendingCleanup = false;
  10042. }
  10043. }, {
  10044. key: "_startRenderPage",
  10045. value: function _startRenderPage(transparency, intent) {
  10046. var intentState = this.intentStates[intent];
  10047. if (!intentState) {
  10048. return;
  10049. }
  10050. this._stats.timeEnd('Page Request');
  10051. if (intentState.displayReadyCapability) {
  10052. intentState.displayReadyCapability.resolve(transparency);
  10053. }
  10054. }
  10055. }, {
  10056. key: "_renderPageChunk",
  10057. value: function _renderPageChunk(operatorListChunk, intentState) {
  10058. for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
  10059. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  10060. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  10061. }
  10062. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  10063. for (var _i = 0; _i < intentState.renderTasks.length; _i++) {
  10064. intentState.renderTasks[_i].operatorListChanged();
  10065. }
  10066. if (operatorListChunk.lastChunk) {
  10067. this._tryCleanup();
  10068. }
  10069. }
  10070. }, {
  10071. key: "_pumpOperatorList",
  10072. value: function _pumpOperatorList(args) {
  10073. var _this8 = this;
  10074. (0, _util.assert)(args.intent, 'PDFPageProxy._pumpOperatorList: Expected "intent" argument.');
  10075. var readableStream = this._transport.messageHandler.sendWithStream('GetOperatorList', args);
  10076. var reader = readableStream.getReader();
  10077. var intentState = this.intentStates[args.intent];
  10078. intentState.streamReader = reader;
  10079. var pump = function pump() {
  10080. reader.read().then(function (_ref6) {
  10081. var value = _ref6.value,
  10082. done = _ref6.done;
  10083. if (done) {
  10084. intentState.streamReader = null;
  10085. return;
  10086. }
  10087. if (_this8._transport.destroyed) {
  10088. return;
  10089. }
  10090. _this8._renderPageChunk(value, intentState);
  10091. pump();
  10092. }, function (reason) {
  10093. intentState.streamReader = null;
  10094. if (_this8._transport.destroyed) {
  10095. return;
  10096. }
  10097. if (intentState.operatorList) {
  10098. intentState.operatorList.lastChunk = true;
  10099. for (var i = 0; i < intentState.renderTasks.length; i++) {
  10100. intentState.renderTasks[i].operatorListChanged();
  10101. }
  10102. _this8._tryCleanup();
  10103. }
  10104. if (intentState.displayReadyCapability) {
  10105. intentState.displayReadyCapability.reject(reason);
  10106. } else if (intentState.opListReadCapability) {
  10107. intentState.opListReadCapability.reject(reason);
  10108. } else {
  10109. throw reason;
  10110. }
  10111. });
  10112. };
  10113. pump();
  10114. }
  10115. }, {
  10116. key: "_abortOperatorList",
  10117. value: function _abortOperatorList(_ref7) {
  10118. var _this9 = this;
  10119. var intentState = _ref7.intentState,
  10120. reason = _ref7.reason,
  10121. _ref7$force = _ref7.force,
  10122. force = _ref7$force === void 0 ? false : _ref7$force;
  10123. (0, _util.assert)(reason instanceof Error, 'PDFPageProxy._abortOperatorList: Expected "reason" argument.');
  10124. if (!intentState.streamReader) {
  10125. return;
  10126. }
  10127. if (!force) {
  10128. if (intentState.renderTasks.length !== 0) {
  10129. return;
  10130. }
  10131. if (reason instanceof _display_utils.RenderingCancelledException) {
  10132. intentState.streamReaderCancelTimeout = setTimeout(function () {
  10133. _this9._abortOperatorList({
  10134. intentState: intentState,
  10135. reason: reason,
  10136. force: true
  10137. });
  10138. intentState.streamReaderCancelTimeout = null;
  10139. }, RENDERING_CANCELLED_TIMEOUT);
  10140. return;
  10141. }
  10142. }
  10143. intentState.streamReader.cancel(new _util.AbortException(reason && reason.message));
  10144. intentState.streamReader = null;
  10145. if (this._transport.destroyed) {
  10146. return;
  10147. }
  10148. Object.keys(this.intentStates).some(function (intent) {
  10149. if (_this9.intentStates[intent] === intentState) {
  10150. delete _this9.intentStates[intent];
  10151. return true;
  10152. }
  10153. return false;
  10154. });
  10155. this.cleanup();
  10156. }
  10157. }, {
  10158. key: "pageNumber",
  10159. get: function get() {
  10160. return this.pageIndex + 1;
  10161. }
  10162. }, {
  10163. key: "rotate",
  10164. get: function get() {
  10165. return this._pageInfo.rotate;
  10166. }
  10167. }, {
  10168. key: "ref",
  10169. get: function get() {
  10170. return this._pageInfo.ref;
  10171. }
  10172. }, {
  10173. key: "userUnit",
  10174. get: function get() {
  10175. return this._pageInfo.userUnit;
  10176. }
  10177. }, {
  10178. key: "view",
  10179. get: function get() {
  10180. return this._pageInfo.view;
  10181. }
  10182. }, {
  10183. key: "stats",
  10184. get: function get() {
  10185. return this._stats instanceof _display_utils.StatTimer ? this._stats : null;
  10186. }
  10187. }]);
  10188. return PDFPageProxy;
  10189. }();
  10190. exports.PDFPageProxy = PDFPageProxy;
  10191. var LoopbackPort =
  10192. /*#__PURE__*/
  10193. function () {
  10194. function LoopbackPort() {
  10195. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  10196. _classCallCheck(this, LoopbackPort);
  10197. this._listeners = [];
  10198. this._defer = defer;
  10199. this._deferred = Promise.resolve(undefined);
  10200. }
  10201. _createClass(LoopbackPort, [{
  10202. key: "postMessage",
  10203. value: function postMessage(obj, transfers) {
  10204. var _this10 = this;
  10205. function cloneValue(value) {
  10206. if (_typeof(value) !== 'object' || value === null) {
  10207. return value;
  10208. }
  10209. if (cloned.has(value)) {
  10210. return cloned.get(value);
  10211. }
  10212. var buffer, result;
  10213. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  10214. var transferable = transfers && transfers.includes(buffer);
  10215. if (value === buffer) {
  10216. result = value;
  10217. } else if (transferable) {
  10218. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  10219. } else {
  10220. result = new value.constructor(value);
  10221. }
  10222. cloned.set(value, result);
  10223. return result;
  10224. }
  10225. result = Array.isArray(value) ? [] : {};
  10226. cloned.set(value, result);
  10227. for (var i in value) {
  10228. var desc = void 0,
  10229. p = value;
  10230. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  10231. p = Object.getPrototypeOf(p);
  10232. }
  10233. if (typeof desc.value === 'undefined') {
  10234. continue;
  10235. }
  10236. if (typeof desc.value === 'function') {
  10237. if (value.hasOwnProperty && value.hasOwnProperty(i)) {
  10238. throw new Error("LoopbackPort.postMessage - cannot clone: ".concat(value[i]));
  10239. }
  10240. continue;
  10241. }
  10242. result[i] = cloneValue(desc.value);
  10243. }
  10244. return result;
  10245. }
  10246. if (!this._defer) {
  10247. this._listeners.forEach(function (listener) {
  10248. listener.call(_this10, {
  10249. data: obj
  10250. });
  10251. });
  10252. return;
  10253. }
  10254. var cloned = new WeakMap();
  10255. var e = {
  10256. data: cloneValue(obj)
  10257. };
  10258. this._deferred.then(function () {
  10259. _this10._listeners.forEach(function (listener) {
  10260. listener.call(_this10, e);
  10261. });
  10262. });
  10263. }
  10264. }, {
  10265. key: "addEventListener",
  10266. value: function addEventListener(name, listener) {
  10267. this._listeners.push(listener);
  10268. }
  10269. }, {
  10270. key: "removeEventListener",
  10271. value: function removeEventListener(name, listener) {
  10272. var i = this._listeners.indexOf(listener);
  10273. this._listeners.splice(i, 1);
  10274. }
  10275. }, {
  10276. key: "terminate",
  10277. value: function terminate() {
  10278. this._listeners.length = 0;
  10279. }
  10280. }]);
  10281. return LoopbackPort;
  10282. }();
  10283. exports.LoopbackPort = LoopbackPort;
  10284. var PDFWorker = function PDFWorkerClosure() {
  10285. var pdfWorkerPorts = new WeakMap();
  10286. var nextFakeWorkerId = 0;
  10287. var fakeWorkerFilesLoadedCapability;
  10288. function _getWorkerSrc() {
  10289. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  10290. return _worker_options.GlobalWorkerOptions.workerSrc;
  10291. }
  10292. if (typeof fallbackWorkerSrc !== 'undefined') {
  10293. return fallbackWorkerSrc;
  10294. }
  10295. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  10296. }
  10297. function getMainThreadWorkerMessageHandler() {
  10298. try {
  10299. if (typeof window !== 'undefined') {
  10300. return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler;
  10301. }
  10302. } catch (ex) {}
  10303. return null;
  10304. }
  10305. function setupFakeWorkerGlobal() {
  10306. if (fakeWorkerFilesLoadedCapability) {
  10307. return fakeWorkerFilesLoadedCapability.promise;
  10308. }
  10309. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  10310. var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  10311. if (mainWorkerMessageHandler) {
  10312. fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler);
  10313. return fakeWorkerFilesLoadedCapability.promise;
  10314. }
  10315. var loader = fakeWorkerFilesLoader || function () {
  10316. return (0, _display_utils.loadScript)(_getWorkerSrc()).then(function () {
  10317. return window.pdfjsWorker.WorkerMessageHandler;
  10318. });
  10319. };
  10320. loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject);
  10321. return fakeWorkerFilesLoadedCapability.promise;
  10322. }
  10323. function createCDNWrapper(url) {
  10324. var wrapper = 'importScripts(\'' + url + '\');';
  10325. return URL.createObjectURL(new Blob([wrapper]));
  10326. }
  10327. var PDFWorker =
  10328. /*#__PURE__*/
  10329. function () {
  10330. function PDFWorker() {
  10331. var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10332. _ref8$name = _ref8.name,
  10333. name = _ref8$name === void 0 ? null : _ref8$name,
  10334. _ref8$port = _ref8.port,
  10335. port = _ref8$port === void 0 ? null : _ref8$port,
  10336. _ref8$verbosity = _ref8.verbosity,
  10337. verbosity = _ref8$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref8$verbosity;
  10338. _classCallCheck(this, PDFWorker);
  10339. if (port && pdfWorkerPorts.has(port)) {
  10340. throw new Error('Cannot use more than one PDFWorker per port');
  10341. }
  10342. this.name = name;
  10343. this.destroyed = false;
  10344. this.postMessageTransfers = true;
  10345. this.verbosity = verbosity;
  10346. this._readyCapability = (0, _util.createPromiseCapability)();
  10347. this._port = null;
  10348. this._webWorker = null;
  10349. this._messageHandler = null;
  10350. if (port) {
  10351. pdfWorkerPorts.set(port, this);
  10352. this._initializeFromPort(port);
  10353. return;
  10354. }
  10355. this._initialize();
  10356. }
  10357. _createClass(PDFWorker, [{
  10358. key: "_initializeFromPort",
  10359. value: function _initializeFromPort(port) {
  10360. this._port = port;
  10361. this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port);
  10362. this._messageHandler.on('ready', function () {});
  10363. this._readyCapability.resolve();
  10364. }
  10365. }, {
  10366. key: "_initialize",
  10367. value: function _initialize() {
  10368. var _this11 = this;
  10369. if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  10370. var workerSrc = _getWorkerSrc();
  10371. try {
  10372. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  10373. workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
  10374. }
  10375. var worker = new Worker(workerSrc);
  10376. var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker);
  10377. var terminateEarly = function terminateEarly() {
  10378. worker.removeEventListener('error', onWorkerError);
  10379. messageHandler.destroy();
  10380. worker.terminate();
  10381. if (_this11.destroyed) {
  10382. _this11._readyCapability.reject(new Error('Worker was destroyed'));
  10383. } else {
  10384. _this11._setupFakeWorker();
  10385. }
  10386. };
  10387. var onWorkerError = function onWorkerError() {
  10388. if (!_this11._webWorker) {
  10389. terminateEarly();
  10390. }
  10391. };
  10392. worker.addEventListener('error', onWorkerError);
  10393. messageHandler.on('test', function (data) {
  10394. worker.removeEventListener('error', onWorkerError);
  10395. if (_this11.destroyed) {
  10396. terminateEarly();
  10397. return;
  10398. }
  10399. if (data) {
  10400. _this11._messageHandler = messageHandler;
  10401. _this11._port = worker;
  10402. _this11._webWorker = worker;
  10403. if (!data.supportTransfers) {
  10404. _this11.postMessageTransfers = false;
  10405. }
  10406. _this11._readyCapability.resolve();
  10407. messageHandler.send('configure', {
  10408. verbosity: _this11.verbosity
  10409. });
  10410. } else {
  10411. _this11._setupFakeWorker();
  10412. messageHandler.destroy();
  10413. worker.terminate();
  10414. }
  10415. });
  10416. messageHandler.on('ready', function (data) {
  10417. worker.removeEventListener('error', onWorkerError);
  10418. if (_this11.destroyed) {
  10419. terminateEarly();
  10420. return;
  10421. }
  10422. try {
  10423. sendTest();
  10424. } catch (e) {
  10425. _this11._setupFakeWorker();
  10426. }
  10427. });
  10428. var sendTest = function sendTest() {
  10429. var testObj = new Uint8Array([_this11.postMessageTransfers ? 255 : 0]);
  10430. try {
  10431. messageHandler.send('test', testObj, [testObj.buffer]);
  10432. } catch (ex) {
  10433. (0, _util.warn)('Cannot use postMessage transfers.');
  10434. testObj[0] = 0;
  10435. messageHandler.send('test', testObj);
  10436. }
  10437. };
  10438. sendTest();
  10439. return;
  10440. } catch (e) {
  10441. (0, _util.info)('The worker has been disabled.');
  10442. }
  10443. }
  10444. this._setupFakeWorker();
  10445. }
  10446. }, {
  10447. key: "_setupFakeWorker",
  10448. value: function _setupFakeWorker() {
  10449. var _this12 = this;
  10450. if (!isWorkerDisabled) {
  10451. (0, _util.warn)('Setting up fake worker.');
  10452. isWorkerDisabled = true;
  10453. }
  10454. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  10455. if (_this12.destroyed) {
  10456. _this12._readyCapability.reject(new Error('Worker was destroyed'));
  10457. return;
  10458. }
  10459. var port = new LoopbackPort();
  10460. _this12._port = port;
  10461. var id = 'fake' + nextFakeWorkerId++;
  10462. var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port);
  10463. WorkerMessageHandler.setup(workerHandler, port);
  10464. var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port);
  10465. _this12._messageHandler = messageHandler;
  10466. _this12._readyCapability.resolve();
  10467. })["catch"](function (reason) {
  10468. _this12._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
  10469. });
  10470. }
  10471. }, {
  10472. key: "destroy",
  10473. value: function destroy() {
  10474. this.destroyed = true;
  10475. if (this._webWorker) {
  10476. this._webWorker.terminate();
  10477. this._webWorker = null;
  10478. }
  10479. pdfWorkerPorts["delete"](this._port);
  10480. this._port = null;
  10481. if (this._messageHandler) {
  10482. this._messageHandler.destroy();
  10483. this._messageHandler = null;
  10484. }
  10485. }
  10486. }, {
  10487. key: "promise",
  10488. get: function get() {
  10489. return this._readyCapability.promise;
  10490. }
  10491. }, {
  10492. key: "port",
  10493. get: function get() {
  10494. return this._port;
  10495. }
  10496. }, {
  10497. key: "messageHandler",
  10498. get: function get() {
  10499. return this._messageHandler;
  10500. }
  10501. }], [{
  10502. key: "fromPort",
  10503. value: function fromPort(params) {
  10504. if (!params || !params.port) {
  10505. throw new Error('PDFWorker.fromPort - invalid method signature.');
  10506. }
  10507. if (pdfWorkerPorts.has(params.port)) {
  10508. return pdfWorkerPorts.get(params.port);
  10509. }
  10510. return new PDFWorker(params);
  10511. }
  10512. }, {
  10513. key: "getWorkerSrc",
  10514. value: function getWorkerSrc() {
  10515. return _getWorkerSrc();
  10516. }
  10517. }]);
  10518. return PDFWorker;
  10519. }();
  10520. return PDFWorker;
  10521. }();
  10522. exports.PDFWorker = PDFWorker;
  10523. var WorkerTransport =
  10524. /*#__PURE__*/
  10525. function () {
  10526. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  10527. _classCallCheck(this, WorkerTransport);
  10528. this.messageHandler = messageHandler;
  10529. this.loadingTask = loadingTask;
  10530. this.commonObjs = new PDFObjects();
  10531. this.fontLoader = new _font_loader.FontLoader({
  10532. docId: loadingTask.docId,
  10533. onUnsupportedFeature: this._onUnsupportedFeature.bind(this)
  10534. });
  10535. this._params = params;
  10536. this.CMapReaderFactory = new params.CMapReaderFactory({
  10537. baseUrl: params.cMapUrl,
  10538. isCompressed: params.cMapPacked
  10539. });
  10540. this.destroyed = false;
  10541. this.destroyCapability = null;
  10542. this._passwordCapability = null;
  10543. this._networkStream = networkStream;
  10544. this._fullReader = null;
  10545. this._lastProgress = null;
  10546. this.pageCache = [];
  10547. this.pagePromises = [];
  10548. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  10549. this.setupMessageHandler();
  10550. }
  10551. _createClass(WorkerTransport, [{
  10552. key: "destroy",
  10553. value: function destroy() {
  10554. var _this13 = this;
  10555. if (this.destroyCapability) {
  10556. return this.destroyCapability.promise;
  10557. }
  10558. this.destroyed = true;
  10559. this.destroyCapability = (0, _util.createPromiseCapability)();
  10560. if (this._passwordCapability) {
  10561. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  10562. }
  10563. var waitOn = [];
  10564. this.pageCache.forEach(function (page) {
  10565. if (page) {
  10566. waitOn.push(page._destroy());
  10567. }
  10568. });
  10569. this.pageCache.length = 0;
  10570. this.pagePromises.length = 0;
  10571. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  10572. waitOn.push(terminated);
  10573. Promise.all(waitOn).then(function () {
  10574. _this13.fontLoader.clear();
  10575. if (_this13._networkStream) {
  10576. _this13._networkStream.cancelAllRequests(new _util.AbortException('Worker was terminated.'));
  10577. }
  10578. if (_this13.messageHandler) {
  10579. _this13.messageHandler.destroy();
  10580. _this13.messageHandler = null;
  10581. }
  10582. _this13.destroyCapability.resolve();
  10583. }, this.destroyCapability.reject);
  10584. return this.destroyCapability.promise;
  10585. }
  10586. }, {
  10587. key: "setupMessageHandler",
  10588. value: function setupMessageHandler() {
  10589. var _this14 = this;
  10590. var messageHandler = this.messageHandler,
  10591. loadingTask = this.loadingTask;
  10592. messageHandler.on('GetReader', function (data, sink) {
  10593. (0, _util.assert)(_this14._networkStream);
  10594. _this14._fullReader = _this14._networkStream.getFullReader();
  10595. _this14._fullReader.onProgress = function (evt) {
  10596. _this14._lastProgress = {
  10597. loaded: evt.loaded,
  10598. total: evt.total
  10599. };
  10600. };
  10601. sink.onPull = function () {
  10602. _this14._fullReader.read().then(function (_ref9) {
  10603. var value = _ref9.value,
  10604. done = _ref9.done;
  10605. if (done) {
  10606. sink.close();
  10607. return;
  10608. }
  10609. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  10610. sink.enqueue(new Uint8Array(value), 1, [value]);
  10611. })["catch"](function (reason) {
  10612. sink.error(reason);
  10613. });
  10614. };
  10615. sink.onCancel = function (reason) {
  10616. _this14._fullReader.cancel(reason);
  10617. };
  10618. });
  10619. messageHandler.on('ReaderHeadersReady', function (data) {
  10620. var headersCapability = (0, _util.createPromiseCapability)();
  10621. var fullReader = _this14._fullReader;
  10622. fullReader.headersReady.then(function () {
  10623. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  10624. if (_this14._lastProgress && loadingTask.onProgress) {
  10625. loadingTask.onProgress(_this14._lastProgress);
  10626. }
  10627. fullReader.onProgress = function (evt) {
  10628. if (loadingTask.onProgress) {
  10629. loadingTask.onProgress({
  10630. loaded: evt.loaded,
  10631. total: evt.total
  10632. });
  10633. }
  10634. };
  10635. }
  10636. headersCapability.resolve({
  10637. isStreamingSupported: fullReader.isStreamingSupported,
  10638. isRangeSupported: fullReader.isRangeSupported,
  10639. contentLength: fullReader.contentLength
  10640. });
  10641. }, headersCapability.reject);
  10642. return headersCapability.promise;
  10643. });
  10644. messageHandler.on('GetRangeReader', function (data, sink) {
  10645. (0, _util.assert)(_this14._networkStream);
  10646. var rangeReader = _this14._networkStream.getRangeReader(data.begin, data.end);
  10647. if (!rangeReader) {
  10648. sink.close();
  10649. return;
  10650. }
  10651. sink.onPull = function () {
  10652. rangeReader.read().then(function (_ref10) {
  10653. var value = _ref10.value,
  10654. done = _ref10.done;
  10655. if (done) {
  10656. sink.close();
  10657. return;
  10658. }
  10659. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  10660. sink.enqueue(new Uint8Array(value), 1, [value]);
  10661. })["catch"](function (reason) {
  10662. sink.error(reason);
  10663. });
  10664. };
  10665. sink.onCancel = function (reason) {
  10666. rangeReader.cancel(reason);
  10667. };
  10668. });
  10669. messageHandler.on('GetDoc', function (_ref11) {
  10670. var pdfInfo = _ref11.pdfInfo;
  10671. _this14._numPages = pdfInfo.numPages;
  10672. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, _this14));
  10673. });
  10674. messageHandler.on('PasswordRequest', function (exception) {
  10675. _this14._passwordCapability = (0, _util.createPromiseCapability)();
  10676. if (loadingTask.onPassword) {
  10677. var updatePassword = function updatePassword(password) {
  10678. _this14._passwordCapability.resolve({
  10679. password: password
  10680. });
  10681. };
  10682. try {
  10683. loadingTask.onPassword(updatePassword, exception.code);
  10684. } catch (ex) {
  10685. _this14._passwordCapability.reject(ex);
  10686. }
  10687. } else {
  10688. _this14._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  10689. }
  10690. return _this14._passwordCapability.promise;
  10691. });
  10692. messageHandler.on('PasswordException', function (exception) {
  10693. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  10694. });
  10695. messageHandler.on('InvalidPDF', function (exception) {
  10696. loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  10697. });
  10698. messageHandler.on('MissingPDF', function (exception) {
  10699. loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  10700. });
  10701. messageHandler.on('UnexpectedResponse', function (exception) {
  10702. loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  10703. });
  10704. messageHandler.on('UnknownError', function (exception) {
  10705. loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  10706. });
  10707. messageHandler.on('DataLoaded', function (data) {
  10708. if (loadingTask.onProgress) {
  10709. loadingTask.onProgress({
  10710. loaded: data.length,
  10711. total: data.length
  10712. });
  10713. }
  10714. _this14.downloadInfoCapability.resolve(data);
  10715. });
  10716. messageHandler.on('StartRenderPage', function (data) {
  10717. if (_this14.destroyed) {
  10718. return;
  10719. }
  10720. var page = _this14.pageCache[data.pageIndex];
  10721. page._startRenderPage(data.transparency, data.intent);
  10722. });
  10723. messageHandler.on('commonobj', function (data) {
  10724. if (_this14.destroyed) {
  10725. return;
  10726. }
  10727. var _data = _slicedToArray(data, 3),
  10728. id = _data[0],
  10729. type = _data[1],
  10730. exportedData = _data[2];
  10731. if (_this14.commonObjs.has(id)) {
  10732. return;
  10733. }
  10734. switch (type) {
  10735. case 'Font':
  10736. var params = _this14._params;
  10737. if ('error' in exportedData) {
  10738. var exportedError = exportedData.error;
  10739. (0, _util.warn)("Error during font loading: ".concat(exportedError));
  10740. _this14.commonObjs.resolve(id, exportedError);
  10741. break;
  10742. }
  10743. var fontRegistry = null;
  10744. if (params.pdfBug && _global_scope["default"].FontInspector && _global_scope["default"].FontInspector.enabled) {
  10745. fontRegistry = {
  10746. registerFont: function registerFont(font, url) {
  10747. _global_scope["default"]['FontInspector'].fontAdded(font, url);
  10748. }
  10749. };
  10750. }
  10751. var font = new _font_loader.FontFaceObject(exportedData, {
  10752. isEvalSupported: params.isEvalSupported,
  10753. disableFontFace: params.disableFontFace,
  10754. ignoreErrors: params.ignoreErrors,
  10755. onUnsupportedFeature: _this14._onUnsupportedFeature.bind(_this14),
  10756. fontRegistry: fontRegistry
  10757. });
  10758. _this14.fontLoader.bind(font).then(function () {
  10759. _this14.commonObjs.resolve(id, font);
  10760. }, function (reason) {
  10761. messageHandler.sendWithPromise('FontFallback', {
  10762. id: id
  10763. })["finally"](function () {
  10764. _this14.commonObjs.resolve(id, font);
  10765. });
  10766. });
  10767. break;
  10768. case 'FontPath':
  10769. case 'FontType3Res':
  10770. _this14.commonObjs.resolve(id, exportedData);
  10771. break;
  10772. default:
  10773. throw new Error("Got unknown common object type ".concat(type));
  10774. }
  10775. });
  10776. messageHandler.on('obj', function (data) {
  10777. if (_this14.destroyed) {
  10778. return undefined;
  10779. }
  10780. var _data2 = _slicedToArray(data, 4),
  10781. id = _data2[0],
  10782. pageIndex = _data2[1],
  10783. type = _data2[2],
  10784. imageData = _data2[3];
  10785. var pageProxy = _this14.pageCache[pageIndex];
  10786. if (pageProxy.objs.has(id)) {
  10787. return undefined;
  10788. }
  10789. switch (type) {
  10790. case 'JpegStream':
  10791. return new Promise(function (resolve, reject) {
  10792. var img = new Image();
  10793. img.onload = function () {
  10794. resolve(img);
  10795. };
  10796. img.onerror = function () {
  10797. reject(new Error('Error during JPEG image loading'));
  10798. (0, _display_utils.releaseImageResources)(img);
  10799. };
  10800. img.src = imageData;
  10801. }).then(function (img) {
  10802. pageProxy.objs.resolve(id, img);
  10803. });
  10804. case 'Image':
  10805. pageProxy.objs.resolve(id, imageData);
  10806. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  10807. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  10808. pageProxy.cleanupAfterRender = true;
  10809. }
  10810. break;
  10811. default:
  10812. throw new Error("Got unknown object type ".concat(type));
  10813. }
  10814. return undefined;
  10815. });
  10816. messageHandler.on('DocProgress', function (data) {
  10817. if (_this14.destroyed) {
  10818. return;
  10819. }
  10820. if (loadingTask.onProgress) {
  10821. loadingTask.onProgress({
  10822. loaded: data.loaded,
  10823. total: data.total
  10824. });
  10825. }
  10826. });
  10827. messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature.bind(this));
  10828. messageHandler.on('JpegDecode', function (data) {
  10829. if (_this14.destroyed) {
  10830. return Promise.reject(new Error('Worker was destroyed'));
  10831. }
  10832. if (typeof document === 'undefined') {
  10833. return Promise.reject(new Error('"document" is not defined.'));
  10834. }
  10835. var _data3 = _slicedToArray(data, 2),
  10836. imageUrl = _data3[0],
  10837. components = _data3[1];
  10838. if (components !== 3 && components !== 1) {
  10839. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  10840. }
  10841. return new Promise(function (resolve, reject) {
  10842. var img = new Image();
  10843. img.onload = function () {
  10844. var width = img.width,
  10845. height = img.height;
  10846. var size = width * height;
  10847. var rgbaLength = size * 4;
  10848. var buf = new Uint8ClampedArray(size * components);
  10849. var tmpCanvas = document.createElement('canvas');
  10850. tmpCanvas.width = width;
  10851. tmpCanvas.height = height;
  10852. var tmpCtx = tmpCanvas.getContext('2d');
  10853. tmpCtx.drawImage(img, 0, 0);
  10854. var data = tmpCtx.getImageData(0, 0, width, height).data;
  10855. if (components === 3) {
  10856. for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  10857. buf[j] = data[i];
  10858. buf[j + 1] = data[i + 1];
  10859. buf[j + 2] = data[i + 2];
  10860. }
  10861. } else if (components === 1) {
  10862. for (var _i2 = 0, _j = 0; _i2 < rgbaLength; _i2 += 4, _j++) {
  10863. buf[_j] = data[_i2];
  10864. }
  10865. }
  10866. resolve({
  10867. data: buf,
  10868. width: width,
  10869. height: height
  10870. });
  10871. (0, _display_utils.releaseImageResources)(img);
  10872. tmpCanvas.width = 0;
  10873. tmpCanvas.height = 0;
  10874. tmpCanvas = null;
  10875. tmpCtx = null;
  10876. };
  10877. img.onerror = function () {
  10878. reject(new Error('JpegDecode failed to load image'));
  10879. (0, _display_utils.releaseImageResources)(img);
  10880. };
  10881. img.src = imageUrl;
  10882. });
  10883. });
  10884. messageHandler.on('FetchBuiltInCMap', function (data, sink) {
  10885. if (_this14.destroyed) {
  10886. sink.error(new Error('Worker was destroyed'));
  10887. return;
  10888. }
  10889. var fetched = false;
  10890. sink.onPull = function () {
  10891. if (fetched) {
  10892. sink.close();
  10893. return;
  10894. }
  10895. fetched = true;
  10896. _this14.CMapReaderFactory.fetch(data).then(function (builtInCMap) {
  10897. sink.enqueue(builtInCMap, 1, [builtInCMap.cMapData.buffer]);
  10898. })["catch"](function (reason) {
  10899. sink.error(reason);
  10900. });
  10901. };
  10902. });
  10903. }
  10904. }, {
  10905. key: "_onUnsupportedFeature",
  10906. value: function _onUnsupportedFeature(_ref12) {
  10907. var featureId = _ref12.featureId;
  10908. if (this.destroyed) {
  10909. return;
  10910. }
  10911. if (this.loadingTask.onUnsupportedFeature) {
  10912. this.loadingTask.onUnsupportedFeature(featureId);
  10913. }
  10914. }
  10915. }, {
  10916. key: "getData",
  10917. value: function getData() {
  10918. return this.messageHandler.sendWithPromise('GetData', null);
  10919. }
  10920. }, {
  10921. key: "getPage",
  10922. value: function getPage(pageNumber) {
  10923. var _this15 = this;
  10924. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  10925. return Promise.reject(new Error('Invalid page request'));
  10926. }
  10927. var pageIndex = pageNumber - 1;
  10928. if (pageIndex in this.pagePromises) {
  10929. return this.pagePromises[pageIndex];
  10930. }
  10931. var promise = this.messageHandler.sendWithPromise('GetPage', {
  10932. pageIndex: pageIndex
  10933. }).then(function (pageInfo) {
  10934. if (_this15.destroyed) {
  10935. throw new Error('Transport destroyed');
  10936. }
  10937. var page = new PDFPageProxy(pageIndex, pageInfo, _this15, _this15._params.pdfBug);
  10938. _this15.pageCache[pageIndex] = page;
  10939. return page;
  10940. });
  10941. this.pagePromises[pageIndex] = promise;
  10942. return promise;
  10943. }
  10944. }, {
  10945. key: "getPageIndex",
  10946. value: function getPageIndex(ref) {
  10947. return this.messageHandler.sendWithPromise('GetPageIndex', {
  10948. ref: ref
  10949. })["catch"](function (reason) {
  10950. return Promise.reject(new Error(reason));
  10951. });
  10952. }
  10953. }, {
  10954. key: "getAnnotations",
  10955. value: function getAnnotations(pageIndex, intent) {
  10956. return this.messageHandler.sendWithPromise('GetAnnotations', {
  10957. pageIndex: pageIndex,
  10958. intent: intent
  10959. });
  10960. }
  10961. }, {
  10962. key: "getDestinations",
  10963. value: function getDestinations() {
  10964. return this.messageHandler.sendWithPromise('GetDestinations', null);
  10965. }
  10966. }, {
  10967. key: "getDestination",
  10968. value: function getDestination(id) {
  10969. if (typeof id !== 'string') {
  10970. return Promise.reject(new Error('Invalid destination request.'));
  10971. }
  10972. return this.messageHandler.sendWithPromise('GetDestination', {
  10973. id: id
  10974. });
  10975. }
  10976. }, {
  10977. key: "getPageLabels",
  10978. value: function getPageLabels() {
  10979. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  10980. }
  10981. }, {
  10982. key: "getPageLayout",
  10983. value: function getPageLayout() {
  10984. return this.messageHandler.sendWithPromise('GetPageLayout', null);
  10985. }
  10986. }, {
  10987. key: "getPageMode",
  10988. value: function getPageMode() {
  10989. return this.messageHandler.sendWithPromise('GetPageMode', null);
  10990. }
  10991. }, {
  10992. key: "getViewerPreferences",
  10993. value: function getViewerPreferences() {
  10994. return this.messageHandler.sendWithPromise('GetViewerPreferences', null);
  10995. }
  10996. }, {
  10997. key: "getOpenActionDestination",
  10998. value: function getOpenActionDestination() {
  10999. return this.messageHandler.sendWithPromise('GetOpenActionDestination', null);
  11000. }
  11001. }, {
  11002. key: "getAttachments",
  11003. value: function getAttachments() {
  11004. return this.messageHandler.sendWithPromise('GetAttachments', null);
  11005. }
  11006. }, {
  11007. key: "getJavaScript",
  11008. value: function getJavaScript() {
  11009. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  11010. }
  11011. }, {
  11012. key: "getOutline",
  11013. value: function getOutline() {
  11014. return this.messageHandler.sendWithPromise('GetOutline', null);
  11015. }
  11016. }, {
  11017. key: "getPermissions",
  11018. value: function getPermissions() {
  11019. return this.messageHandler.sendWithPromise('GetPermissions', null);
  11020. }
  11021. }, {
  11022. key: "getMetadata",
  11023. value: function getMetadata() {
  11024. var _this16 = this;
  11025. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) {
  11026. return {
  11027. info: results[0],
  11028. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  11029. contentDispositionFilename: _this16._fullReader ? _this16._fullReader.filename : null
  11030. };
  11031. });
  11032. }
  11033. }, {
  11034. key: "getStats",
  11035. value: function getStats() {
  11036. return this.messageHandler.sendWithPromise('GetStats', null);
  11037. }
  11038. }, {
  11039. key: "startCleanup",
  11040. value: function startCleanup() {
  11041. var _this17 = this;
  11042. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  11043. for (var i = 0, ii = _this17.pageCache.length; i < ii; i++) {
  11044. var page = _this17.pageCache[i];
  11045. if (page) {
  11046. page.cleanup();
  11047. }
  11048. }
  11049. _this17.commonObjs.clear();
  11050. _this17.fontLoader.clear();
  11051. });
  11052. }
  11053. }, {
  11054. key: "loadingParams",
  11055. get: function get() {
  11056. var params = this._params;
  11057. return (0, _util.shadow)(this, 'loadingParams', {
  11058. disableAutoFetch: params.disableAutoFetch,
  11059. disableCreateObjectURL: params.disableCreateObjectURL,
  11060. disableFontFace: params.disableFontFace,
  11061. nativeImageDecoderSupport: params.nativeImageDecoderSupport
  11062. });
  11063. }
  11064. }]);
  11065. return WorkerTransport;
  11066. }();
  11067. var PDFObjects =
  11068. /*#__PURE__*/
  11069. function () {
  11070. function PDFObjects() {
  11071. _classCallCheck(this, PDFObjects);
  11072. this._objs = Object.create(null);
  11073. }
  11074. _createClass(PDFObjects, [{
  11075. key: "_ensureObj",
  11076. value: function _ensureObj(objId) {
  11077. if (this._objs[objId]) {
  11078. return this._objs[objId];
  11079. }
  11080. return this._objs[objId] = {
  11081. capability: (0, _util.createPromiseCapability)(),
  11082. data: null,
  11083. resolved: false
  11084. };
  11085. }
  11086. }, {
  11087. key: "get",
  11088. value: function get(objId) {
  11089. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11090. if (callback) {
  11091. this._ensureObj(objId).capability.promise.then(callback);
  11092. return null;
  11093. }
  11094. var obj = this._objs[objId];
  11095. if (!obj || !obj.resolved) {
  11096. throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
  11097. }
  11098. return obj.data;
  11099. }
  11100. }, {
  11101. key: "has",
  11102. value: function has(objId) {
  11103. var obj = this._objs[objId];
  11104. return obj ? obj.resolved : false;
  11105. }
  11106. }, {
  11107. key: "resolve",
  11108. value: function resolve(objId, data) {
  11109. var obj = this._ensureObj(objId);
  11110. obj.resolved = true;
  11111. obj.data = data;
  11112. obj.capability.resolve(data);
  11113. }
  11114. }, {
  11115. key: "clear",
  11116. value: function clear() {
  11117. for (var objId in this._objs) {
  11118. var data = this._objs[objId].data;
  11119. if (typeof Image !== 'undefined' && data instanceof Image) {
  11120. (0, _display_utils.releaseImageResources)(data);
  11121. }
  11122. }
  11123. this._objs = Object.create(null);
  11124. }
  11125. }]);
  11126. return PDFObjects;
  11127. }();
  11128. var RenderTask =
  11129. /*#__PURE__*/
  11130. function () {
  11131. function RenderTask(internalRenderTask) {
  11132. _classCallCheck(this, RenderTask);
  11133. this._internalRenderTask = internalRenderTask;
  11134. this.onContinue = null;
  11135. }
  11136. _createClass(RenderTask, [{
  11137. key: "cancel",
  11138. value: function cancel() {
  11139. this._internalRenderTask.cancel();
  11140. }
  11141. }, {
  11142. key: "then",
  11143. value: function then(onFulfilled, onRejected) {
  11144. (0, _display_utils.deprecated)('RenderTask.then method, use the `promise` getter instead.');
  11145. return this.promise.then.apply(this.promise, arguments);
  11146. }
  11147. }, {
  11148. key: "promise",
  11149. get: function get() {
  11150. return this._internalRenderTask.capability.promise;
  11151. }
  11152. }]);
  11153. return RenderTask;
  11154. }();
  11155. var InternalRenderTask = function InternalRenderTaskClosure() {
  11156. var canvasInRendering = new WeakSet();
  11157. var InternalRenderTask =
  11158. /*#__PURE__*/
  11159. function () {
  11160. function InternalRenderTask(_ref13) {
  11161. var callback = _ref13.callback,
  11162. params = _ref13.params,
  11163. objs = _ref13.objs,
  11164. commonObjs = _ref13.commonObjs,
  11165. operatorList = _ref13.operatorList,
  11166. pageNumber = _ref13.pageNumber,
  11167. canvasFactory = _ref13.canvasFactory,
  11168. webGLContext = _ref13.webGLContext,
  11169. _ref13$useRequestAnim = _ref13.useRequestAnimationFrame,
  11170. useRequestAnimationFrame = _ref13$useRequestAnim === void 0 ? false : _ref13$useRequestAnim,
  11171. _ref13$pdfBug = _ref13.pdfBug,
  11172. pdfBug = _ref13$pdfBug === void 0 ? false : _ref13$pdfBug;
  11173. _classCallCheck(this, InternalRenderTask);
  11174. this.callback = callback;
  11175. this.params = params;
  11176. this.objs = objs;
  11177. this.commonObjs = commonObjs;
  11178. this.operatorListIdx = null;
  11179. this.operatorList = operatorList;
  11180. this.pageNumber = pageNumber;
  11181. this.canvasFactory = canvasFactory;
  11182. this.webGLContext = webGLContext;
  11183. this._pdfBug = pdfBug;
  11184. this.running = false;
  11185. this.graphicsReadyCallback = null;
  11186. this.graphicsReady = false;
  11187. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== 'undefined';
  11188. this.cancelled = false;
  11189. this.capability = (0, _util.createPromiseCapability)();
  11190. this.task = new RenderTask(this);
  11191. this._continueBound = this._continue.bind(this);
  11192. this._scheduleNextBound = this._scheduleNext.bind(this);
  11193. this._nextBound = this._next.bind(this);
  11194. this._canvas = params.canvasContext.canvas;
  11195. }
  11196. _createClass(InternalRenderTask, [{
  11197. key: "initializeGraphics",
  11198. value: function initializeGraphics() {
  11199. var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11200. if (this.cancelled) {
  11201. return;
  11202. }
  11203. if (this._canvas) {
  11204. if (canvasInRendering.has(this._canvas)) {
  11205. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  11206. }
  11207. canvasInRendering.add(this._canvas);
  11208. }
  11209. if (this._pdfBug && _global_scope["default"].StepperManager && _global_scope["default"].StepperManager.enabled) {
  11210. this.stepper = _global_scope["default"].StepperManager.create(this.pageNumber - 1);
  11211. this.stepper.init(this.operatorList);
  11212. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  11213. }
  11214. var _this$params = this.params,
  11215. canvasContext = _this$params.canvasContext,
  11216. viewport = _this$params.viewport,
  11217. transform = _this$params.transform,
  11218. imageLayer = _this$params.imageLayer,
  11219. background = _this$params.background;
  11220. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer);
  11221. this.gfx.beginDrawing({
  11222. transform: transform,
  11223. viewport: viewport,
  11224. transparency: transparency,
  11225. background: background
  11226. });
  11227. this.operatorListIdx = 0;
  11228. this.graphicsReady = true;
  11229. if (this.graphicsReadyCallback) {
  11230. this.graphicsReadyCallback();
  11231. }
  11232. }
  11233. }, {
  11234. key: "cancel",
  11235. value: function cancel() {
  11236. var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11237. this.running = false;
  11238. this.cancelled = true;
  11239. if (this.gfx) {
  11240. this.gfx.endDrawing();
  11241. }
  11242. if (this._canvas) {
  11243. canvasInRendering["delete"](this._canvas);
  11244. }
  11245. this.callback(error || new _display_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this.pageNumber), 'canvas'));
  11246. }
  11247. }, {
  11248. key: "operatorListChanged",
  11249. value: function operatorListChanged() {
  11250. if (!this.graphicsReady) {
  11251. if (!this.graphicsReadyCallback) {
  11252. this.graphicsReadyCallback = this._continueBound;
  11253. }
  11254. return;
  11255. }
  11256. if (this.stepper) {
  11257. this.stepper.updateOperatorList(this.operatorList);
  11258. }
  11259. if (this.running) {
  11260. return;
  11261. }
  11262. this._continue();
  11263. }
  11264. }, {
  11265. key: "_continue",
  11266. value: function _continue() {
  11267. this.running = true;
  11268. if (this.cancelled) {
  11269. return;
  11270. }
  11271. if (this.task.onContinue) {
  11272. this.task.onContinue(this._scheduleNextBound);
  11273. } else {
  11274. this._scheduleNext();
  11275. }
  11276. }
  11277. }, {
  11278. key: "_scheduleNext",
  11279. value: function _scheduleNext() {
  11280. var _this18 = this;
  11281. if (this._useRequestAnimationFrame) {
  11282. window.requestAnimationFrame(function () {
  11283. _this18._nextBound()["catch"](_this18.cancel.bind(_this18));
  11284. });
  11285. } else {
  11286. Promise.resolve().then(this._nextBound)["catch"](this.cancel.bind(this));
  11287. }
  11288. }
  11289. }, {
  11290. key: "_next",
  11291. value: function () {
  11292. var _next2 = _asyncToGenerator(
  11293. /*#__PURE__*/
  11294. _regenerator["default"].mark(function _callee() {
  11295. return _regenerator["default"].wrap(function _callee$(_context) {
  11296. while (1) {
  11297. switch (_context.prev = _context.next) {
  11298. case 0:
  11299. if (!this.cancelled) {
  11300. _context.next = 2;
  11301. break;
  11302. }
  11303. return _context.abrupt("return");
  11304. case 2:
  11305. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  11306. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  11307. this.running = false;
  11308. if (this.operatorList.lastChunk) {
  11309. this.gfx.endDrawing();
  11310. if (this._canvas) {
  11311. canvasInRendering["delete"](this._canvas);
  11312. }
  11313. this.callback();
  11314. }
  11315. }
  11316. case 4:
  11317. case "end":
  11318. return _context.stop();
  11319. }
  11320. }
  11321. }, _callee, this);
  11322. }));
  11323. function _next() {
  11324. return _next2.apply(this, arguments);
  11325. }
  11326. return _next;
  11327. }()
  11328. }]);
  11329. return InternalRenderTask;
  11330. }();
  11331. return InternalRenderTask;
  11332. }();
  11333. var version = '2.3.200';
  11334. exports.version = version;
  11335. var build = '4ae3f9fc';
  11336. exports.build = build;
  11337. /***/ }),
  11338. /* 180 */
  11339. /***/ (function(module, exports, __w_pdfjs_require__) {
  11340. "use strict";
  11341. module.exports = __w_pdfjs_require__(181);
  11342. /***/ }),
  11343. /* 181 */
  11344. /***/ (function(module, exports, __w_pdfjs_require__) {
  11345. "use strict";
  11346. /* WEBPACK VAR INJECTION */(function(module) {
  11347. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11348. var runtime = function (exports) {
  11349. "use strict";
  11350. var Op = Object.prototype;
  11351. var hasOwn = Op.hasOwnProperty;
  11352. var undefined;
  11353. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  11354. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  11355. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  11356. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  11357. function wrap(innerFn, outerFn, self, tryLocsList) {
  11358. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  11359. var generator = Object.create(protoGenerator.prototype);
  11360. var context = new Context(tryLocsList || []);
  11361. generator._invoke = makeInvokeMethod(innerFn, self, context);
  11362. return generator;
  11363. }
  11364. exports.wrap = wrap;
  11365. function tryCatch(fn, obj, arg) {
  11366. try {
  11367. return {
  11368. type: "normal",
  11369. arg: fn.call(obj, arg)
  11370. };
  11371. } catch (err) {
  11372. return {
  11373. type: "throw",
  11374. arg: err
  11375. };
  11376. }
  11377. }
  11378. var GenStateSuspendedStart = "suspendedStart";
  11379. var GenStateSuspendedYield = "suspendedYield";
  11380. var GenStateExecuting = "executing";
  11381. var GenStateCompleted = "completed";
  11382. var ContinueSentinel = {};
  11383. function Generator() {}
  11384. function GeneratorFunction() {}
  11385. function GeneratorFunctionPrototype() {}
  11386. var IteratorPrototype = {};
  11387. IteratorPrototype[iteratorSymbol] = function () {
  11388. return this;
  11389. };
  11390. var getProto = Object.getPrototypeOf;
  11391. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  11392. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  11393. IteratorPrototype = NativeIteratorPrototype;
  11394. }
  11395. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  11396. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  11397. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  11398. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  11399. function defineIteratorMethods(prototype) {
  11400. ["next", "throw", "return"].forEach(function (method) {
  11401. prototype[method] = function (arg) {
  11402. return this._invoke(method, arg);
  11403. };
  11404. });
  11405. }
  11406. exports.isGeneratorFunction = function (genFun) {
  11407. var ctor = typeof genFun === "function" && genFun.constructor;
  11408. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  11409. };
  11410. exports.mark = function (genFun) {
  11411. if (Object.setPrototypeOf) {
  11412. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  11413. } else {
  11414. genFun.__proto__ = GeneratorFunctionPrototype;
  11415. if (!(toStringTagSymbol in genFun)) {
  11416. genFun[toStringTagSymbol] = "GeneratorFunction";
  11417. }
  11418. }
  11419. genFun.prototype = Object.create(Gp);
  11420. return genFun;
  11421. };
  11422. exports.awrap = function (arg) {
  11423. return {
  11424. __await: arg
  11425. };
  11426. };
  11427. function AsyncIterator(generator) {
  11428. function invoke(method, arg, resolve, reject) {
  11429. var record = tryCatch(generator[method], generator, arg);
  11430. if (record.type === "throw") {
  11431. reject(record.arg);
  11432. } else {
  11433. var result = record.arg;
  11434. var value = result.value;
  11435. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  11436. return Promise.resolve(value.__await).then(function (value) {
  11437. invoke("next", value, resolve, reject);
  11438. }, function (err) {
  11439. invoke("throw", err, resolve, reject);
  11440. });
  11441. }
  11442. return Promise.resolve(value).then(function (unwrapped) {
  11443. result.value = unwrapped;
  11444. resolve(result);
  11445. }, function (error) {
  11446. return invoke("throw", error, resolve, reject);
  11447. });
  11448. }
  11449. }
  11450. var previousPromise;
  11451. function enqueue(method, arg) {
  11452. function callInvokeWithMethodAndArg() {
  11453. return new Promise(function (resolve, reject) {
  11454. invoke(method, arg, resolve, reject);
  11455. });
  11456. }
  11457. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  11458. }
  11459. this._invoke = enqueue;
  11460. }
  11461. defineIteratorMethods(AsyncIterator.prototype);
  11462. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  11463. return this;
  11464. };
  11465. exports.AsyncIterator = AsyncIterator;
  11466. exports.async = function (innerFn, outerFn, self, tryLocsList) {
  11467. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  11468. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  11469. return result.done ? result.value : iter.next();
  11470. });
  11471. };
  11472. function makeInvokeMethod(innerFn, self, context) {
  11473. var state = GenStateSuspendedStart;
  11474. return function invoke(method, arg) {
  11475. if (state === GenStateExecuting) {
  11476. throw new Error("Generator is already running");
  11477. }
  11478. if (state === GenStateCompleted) {
  11479. if (method === "throw") {
  11480. throw arg;
  11481. }
  11482. return doneResult();
  11483. }
  11484. context.method = method;
  11485. context.arg = arg;
  11486. while (true) {
  11487. var delegate = context.delegate;
  11488. if (delegate) {
  11489. var delegateResult = maybeInvokeDelegate(delegate, context);
  11490. if (delegateResult) {
  11491. if (delegateResult === ContinueSentinel) continue;
  11492. return delegateResult;
  11493. }
  11494. }
  11495. if (context.method === "next") {
  11496. context.sent = context._sent = context.arg;
  11497. } else if (context.method === "throw") {
  11498. if (state === GenStateSuspendedStart) {
  11499. state = GenStateCompleted;
  11500. throw context.arg;
  11501. }
  11502. context.dispatchException(context.arg);
  11503. } else if (context.method === "return") {
  11504. context.abrupt("return", context.arg);
  11505. }
  11506. state = GenStateExecuting;
  11507. var record = tryCatch(innerFn, self, context);
  11508. if (record.type === "normal") {
  11509. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  11510. if (record.arg === ContinueSentinel) {
  11511. continue;
  11512. }
  11513. return {
  11514. value: record.arg,
  11515. done: context.done
  11516. };
  11517. } else if (record.type === "throw") {
  11518. state = GenStateCompleted;
  11519. context.method = "throw";
  11520. context.arg = record.arg;
  11521. }
  11522. }
  11523. };
  11524. }
  11525. function maybeInvokeDelegate(delegate, context) {
  11526. var method = delegate.iterator[context.method];
  11527. if (method === undefined) {
  11528. context.delegate = null;
  11529. if (context.method === "throw") {
  11530. if (delegate.iterator["return"]) {
  11531. context.method = "return";
  11532. context.arg = undefined;
  11533. maybeInvokeDelegate(delegate, context);
  11534. if (context.method === "throw") {
  11535. return ContinueSentinel;
  11536. }
  11537. }
  11538. context.method = "throw";
  11539. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  11540. }
  11541. return ContinueSentinel;
  11542. }
  11543. var record = tryCatch(method, delegate.iterator, context.arg);
  11544. if (record.type === "throw") {
  11545. context.method = "throw";
  11546. context.arg = record.arg;
  11547. context.delegate = null;
  11548. return ContinueSentinel;
  11549. }
  11550. var info = record.arg;
  11551. if (!info) {
  11552. context.method = "throw";
  11553. context.arg = new TypeError("iterator result is not an object");
  11554. context.delegate = null;
  11555. return ContinueSentinel;
  11556. }
  11557. if (info.done) {
  11558. context[delegate.resultName] = info.value;
  11559. context.next = delegate.nextLoc;
  11560. if (context.method !== "return") {
  11561. context.method = "next";
  11562. context.arg = undefined;
  11563. }
  11564. } else {
  11565. return info;
  11566. }
  11567. context.delegate = null;
  11568. return ContinueSentinel;
  11569. }
  11570. defineIteratorMethods(Gp);
  11571. Gp[toStringTagSymbol] = "Generator";
  11572. Gp[iteratorSymbol] = function () {
  11573. return this;
  11574. };
  11575. Gp.toString = function () {
  11576. return "[object Generator]";
  11577. };
  11578. function pushTryEntry(locs) {
  11579. var entry = {
  11580. tryLoc: locs[0]
  11581. };
  11582. if (1 in locs) {
  11583. entry.catchLoc = locs[1];
  11584. }
  11585. if (2 in locs) {
  11586. entry.finallyLoc = locs[2];
  11587. entry.afterLoc = locs[3];
  11588. }
  11589. this.tryEntries.push(entry);
  11590. }
  11591. function resetTryEntry(entry) {
  11592. var record = entry.completion || {};
  11593. record.type = "normal";
  11594. delete record.arg;
  11595. entry.completion = record;
  11596. }
  11597. function Context(tryLocsList) {
  11598. this.tryEntries = [{
  11599. tryLoc: "root"
  11600. }];
  11601. tryLocsList.forEach(pushTryEntry, this);
  11602. this.reset(true);
  11603. }
  11604. exports.keys = function (object) {
  11605. var keys = [];
  11606. for (var key in object) {
  11607. keys.push(key);
  11608. }
  11609. keys.reverse();
  11610. return function next() {
  11611. while (keys.length) {
  11612. var key = keys.pop();
  11613. if (key in object) {
  11614. next.value = key;
  11615. next.done = false;
  11616. return next;
  11617. }
  11618. }
  11619. next.done = true;
  11620. return next;
  11621. };
  11622. };
  11623. function values(iterable) {
  11624. if (iterable) {
  11625. var iteratorMethod = iterable[iteratorSymbol];
  11626. if (iteratorMethod) {
  11627. return iteratorMethod.call(iterable);
  11628. }
  11629. if (typeof iterable.next === "function") {
  11630. return iterable;
  11631. }
  11632. if (!isNaN(iterable.length)) {
  11633. var i = -1,
  11634. next = function next() {
  11635. while (++i < iterable.length) {
  11636. if (hasOwn.call(iterable, i)) {
  11637. next.value = iterable[i];
  11638. next.done = false;
  11639. return next;
  11640. }
  11641. }
  11642. next.value = undefined;
  11643. next.done = true;
  11644. return next;
  11645. };
  11646. return next.next = next;
  11647. }
  11648. }
  11649. return {
  11650. next: doneResult
  11651. };
  11652. }
  11653. exports.values = values;
  11654. function doneResult() {
  11655. return {
  11656. value: undefined,
  11657. done: true
  11658. };
  11659. }
  11660. Context.prototype = {
  11661. constructor: Context,
  11662. reset: function reset(skipTempReset) {
  11663. this.prev = 0;
  11664. this.next = 0;
  11665. this.sent = this._sent = undefined;
  11666. this.done = false;
  11667. this.delegate = null;
  11668. this.method = "next";
  11669. this.arg = undefined;
  11670. this.tryEntries.forEach(resetTryEntry);
  11671. if (!skipTempReset) {
  11672. for (var name in this) {
  11673. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  11674. this[name] = undefined;
  11675. }
  11676. }
  11677. }
  11678. },
  11679. stop: function stop() {
  11680. this.done = true;
  11681. var rootEntry = this.tryEntries[0];
  11682. var rootRecord = rootEntry.completion;
  11683. if (rootRecord.type === "throw") {
  11684. throw rootRecord.arg;
  11685. }
  11686. return this.rval;
  11687. },
  11688. dispatchException: function dispatchException(exception) {
  11689. if (this.done) {
  11690. throw exception;
  11691. }
  11692. var context = this;
  11693. function handle(loc, caught) {
  11694. record.type = "throw";
  11695. record.arg = exception;
  11696. context.next = loc;
  11697. if (caught) {
  11698. context.method = "next";
  11699. context.arg = undefined;
  11700. }
  11701. return !!caught;
  11702. }
  11703. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  11704. var entry = this.tryEntries[i];
  11705. var record = entry.completion;
  11706. if (entry.tryLoc === "root") {
  11707. return handle("end");
  11708. }
  11709. if (entry.tryLoc <= this.prev) {
  11710. var hasCatch = hasOwn.call(entry, "catchLoc");
  11711. var hasFinally = hasOwn.call(entry, "finallyLoc");
  11712. if (hasCatch && hasFinally) {
  11713. if (this.prev < entry.catchLoc) {
  11714. return handle(entry.catchLoc, true);
  11715. } else if (this.prev < entry.finallyLoc) {
  11716. return handle(entry.finallyLoc);
  11717. }
  11718. } else if (hasCatch) {
  11719. if (this.prev < entry.catchLoc) {
  11720. return handle(entry.catchLoc, true);
  11721. }
  11722. } else if (hasFinally) {
  11723. if (this.prev < entry.finallyLoc) {
  11724. return handle(entry.finallyLoc);
  11725. }
  11726. } else {
  11727. throw new Error("try statement without catch or finally");
  11728. }
  11729. }
  11730. }
  11731. },
  11732. abrupt: function abrupt(type, arg) {
  11733. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  11734. var entry = this.tryEntries[i];
  11735. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  11736. var finallyEntry = entry;
  11737. break;
  11738. }
  11739. }
  11740. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  11741. finallyEntry = null;
  11742. }
  11743. var record = finallyEntry ? finallyEntry.completion : {};
  11744. record.type = type;
  11745. record.arg = arg;
  11746. if (finallyEntry) {
  11747. this.method = "next";
  11748. this.next = finallyEntry.finallyLoc;
  11749. return ContinueSentinel;
  11750. }
  11751. return this.complete(record);
  11752. },
  11753. complete: function complete(record, afterLoc) {
  11754. if (record.type === "throw") {
  11755. throw record.arg;
  11756. }
  11757. if (record.type === "break" || record.type === "continue") {
  11758. this.next = record.arg;
  11759. } else if (record.type === "return") {
  11760. this.rval = this.arg = record.arg;
  11761. this.method = "return";
  11762. this.next = "end";
  11763. } else if (record.type === "normal" && afterLoc) {
  11764. this.next = afterLoc;
  11765. }
  11766. return ContinueSentinel;
  11767. },
  11768. finish: function finish(finallyLoc) {
  11769. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  11770. var entry = this.tryEntries[i];
  11771. if (entry.finallyLoc === finallyLoc) {
  11772. this.complete(entry.completion, entry.afterLoc);
  11773. resetTryEntry(entry);
  11774. return ContinueSentinel;
  11775. }
  11776. }
  11777. },
  11778. "catch": function _catch(tryLoc) {
  11779. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  11780. var entry = this.tryEntries[i];
  11781. if (entry.tryLoc === tryLoc) {
  11782. var record = entry.completion;
  11783. if (record.type === "throw") {
  11784. var thrown = record.arg;
  11785. resetTryEntry(entry);
  11786. }
  11787. return thrown;
  11788. }
  11789. }
  11790. throw new Error("illegal catch attempt");
  11791. },
  11792. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  11793. this.delegate = {
  11794. iterator: values(iterable),
  11795. resultName: resultName,
  11796. nextLoc: nextLoc
  11797. };
  11798. if (this.method === "next") {
  11799. this.arg = undefined;
  11800. }
  11801. return ContinueSentinel;
  11802. }
  11803. };
  11804. return exports;
  11805. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  11806. try {
  11807. regeneratorRuntime = runtime;
  11808. } catch (accidentalStrictMode) {
  11809. Function("r", "regeneratorRuntime = r")(runtime);
  11810. }
  11811. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(182)(module)))
  11812. /***/ }),
  11813. /* 182 */
  11814. /***/ (function(module, exports, __w_pdfjs_require__) {
  11815. "use strict";
  11816. module.exports = function (module) {
  11817. if (!module.webpackPolyfill) {
  11818. module.deprecate = function () {};
  11819. module.paths = [];
  11820. if (!module.children) module.children = [];
  11821. Object.defineProperty(module, "loaded", {
  11822. enumerable: true,
  11823. get: function get() {
  11824. return module.l;
  11825. }
  11826. });
  11827. Object.defineProperty(module, "id", {
  11828. enumerable: true,
  11829. get: function get() {
  11830. return module.i;
  11831. }
  11832. });
  11833. module.webpackPolyfill = 1;
  11834. }
  11835. return module;
  11836. };
  11837. /***/ }),
  11838. /* 183 */
  11839. /***/ (function(module, exports, __w_pdfjs_require__) {
  11840. "use strict";
  11841. Object.defineProperty(exports, "__esModule", {
  11842. value: true
  11843. });
  11844. exports.addLinkAttributes = addLinkAttributes;
  11845. exports.getFilenameFromUrl = getFilenameFromUrl;
  11846. exports.isFetchSupported = isFetchSupported;
  11847. exports.isValidFetchUrl = isValidFetchUrl;
  11848. exports.loadScript = loadScript;
  11849. exports.deprecated = deprecated;
  11850. exports.releaseImageResources = releaseImageResources;
  11851. exports.PDFDateString = exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
  11852. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  11853. var _util = __w_pdfjs_require__(1);
  11854. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11855. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11856. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11857. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11858. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11859. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11860. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11861. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11862. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11863. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11864. 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); } }
  11865. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11866. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  11867. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  11868. var SVG_NS = 'http://www.w3.org/2000/svg';
  11869. var DOMCanvasFactory =
  11870. /*#__PURE__*/
  11871. function () {
  11872. function DOMCanvasFactory() {
  11873. _classCallCheck(this, DOMCanvasFactory);
  11874. }
  11875. _createClass(DOMCanvasFactory, [{
  11876. key: "create",
  11877. value: function create(width, height) {
  11878. if (width <= 0 || height <= 0) {
  11879. throw new Error('Invalid canvas size');
  11880. }
  11881. var canvas = document.createElement('canvas');
  11882. var context = canvas.getContext('2d');
  11883. canvas.width = width;
  11884. canvas.height = height;
  11885. return {
  11886. canvas: canvas,
  11887. context: context
  11888. };
  11889. }
  11890. }, {
  11891. key: "reset",
  11892. value: function reset(canvasAndContext, width, height) {
  11893. if (!canvasAndContext.canvas) {
  11894. throw new Error('Canvas is not specified');
  11895. }
  11896. if (width <= 0 || height <= 0) {
  11897. throw new Error('Invalid canvas size');
  11898. }
  11899. canvasAndContext.canvas.width = width;
  11900. canvasAndContext.canvas.height = height;
  11901. }
  11902. }, {
  11903. key: "destroy",
  11904. value: function destroy(canvasAndContext) {
  11905. if (!canvasAndContext.canvas) {
  11906. throw new Error('Canvas is not specified');
  11907. }
  11908. canvasAndContext.canvas.width = 0;
  11909. canvasAndContext.canvas.height = 0;
  11910. canvasAndContext.canvas = null;
  11911. canvasAndContext.context = null;
  11912. }
  11913. }]);
  11914. return DOMCanvasFactory;
  11915. }();
  11916. exports.DOMCanvasFactory = DOMCanvasFactory;
  11917. var DOMCMapReaderFactory =
  11918. /*#__PURE__*/
  11919. function () {
  11920. function DOMCMapReaderFactory(_ref) {
  11921. var _ref$baseUrl = _ref.baseUrl,
  11922. baseUrl = _ref$baseUrl === void 0 ? null : _ref$baseUrl,
  11923. _ref$isCompressed = _ref.isCompressed,
  11924. isCompressed = _ref$isCompressed === void 0 ? false : _ref$isCompressed;
  11925. _classCallCheck(this, DOMCMapReaderFactory);
  11926. this.baseUrl = baseUrl;
  11927. this.isCompressed = isCompressed;
  11928. }
  11929. _createClass(DOMCMapReaderFactory, [{
  11930. key: "fetch",
  11931. value: function (_fetch) {
  11932. function fetch(_x) {
  11933. return _fetch.apply(this, arguments);
  11934. }
  11935. fetch.toString = function () {
  11936. return _fetch.toString();
  11937. };
  11938. return fetch;
  11939. }(
  11940. /*#__PURE__*/
  11941. function () {
  11942. var _ref3 = _asyncToGenerator(
  11943. /*#__PURE__*/
  11944. _regenerator["default"].mark(function _callee2(_ref2) {
  11945. var _this = this;
  11946. var name, url, compressionType;
  11947. return _regenerator["default"].wrap(function _callee2$(_context2) {
  11948. while (1) {
  11949. switch (_context2.prev = _context2.next) {
  11950. case 0:
  11951. name = _ref2.name;
  11952. if (this.baseUrl) {
  11953. _context2.next = 3;
  11954. break;
  11955. }
  11956. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  11957. case 3:
  11958. if (name) {
  11959. _context2.next = 5;
  11960. break;
  11961. }
  11962. throw new Error('CMap name must be specified.');
  11963. case 5:
  11964. url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
  11965. compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  11966. if (!(isFetchSupported() && isValidFetchUrl(url, document.baseURI))) {
  11967. _context2.next = 9;
  11968. break;
  11969. }
  11970. return _context2.abrupt("return", fetch(url).then(
  11971. /*#__PURE__*/
  11972. function () {
  11973. var _ref4 = _asyncToGenerator(
  11974. /*#__PURE__*/
  11975. _regenerator["default"].mark(function _callee(response) {
  11976. var cMapData;
  11977. return _regenerator["default"].wrap(function _callee$(_context) {
  11978. while (1) {
  11979. switch (_context.prev = _context.next) {
  11980. case 0:
  11981. if (response.ok) {
  11982. _context.next = 2;
  11983. break;
  11984. }
  11985. throw new Error(response.statusText);
  11986. case 2:
  11987. if (!_this.isCompressed) {
  11988. _context.next = 10;
  11989. break;
  11990. }
  11991. _context.t0 = Uint8Array;
  11992. _context.next = 6;
  11993. return response.arrayBuffer();
  11994. case 6:
  11995. _context.t1 = _context.sent;
  11996. cMapData = new _context.t0(_context.t1);
  11997. _context.next = 15;
  11998. break;
  11999. case 10:
  12000. _context.t2 = _util.stringToBytes;
  12001. _context.next = 13;
  12002. return response.text();
  12003. case 13:
  12004. _context.t3 = _context.sent;
  12005. cMapData = (0, _context.t2)(_context.t3);
  12006. case 15:
  12007. return _context.abrupt("return", {
  12008. cMapData: cMapData,
  12009. compressionType: compressionType
  12010. });
  12011. case 16:
  12012. case "end":
  12013. return _context.stop();
  12014. }
  12015. }
  12016. }, _callee);
  12017. }));
  12018. return function (_x3) {
  12019. return _ref4.apply(this, arguments);
  12020. };
  12021. }())["catch"](function (reason) {
  12022. throw new Error("Unable to load ".concat(_this.isCompressed ? 'binary ' : '') + "CMap at: ".concat(url));
  12023. }));
  12024. case 9:
  12025. return _context2.abrupt("return", new Promise(function (resolve, reject) {
  12026. var request = new XMLHttpRequest();
  12027. request.open('GET', url, true);
  12028. if (_this.isCompressed) {
  12029. request.responseType = 'arraybuffer';
  12030. }
  12031. request.onreadystatechange = function () {
  12032. if (request.readyState !== XMLHttpRequest.DONE) {
  12033. return;
  12034. }
  12035. if (request.status === 200 || request.status === 0) {
  12036. var cMapData;
  12037. if (_this.isCompressed && request.response) {
  12038. cMapData = new Uint8Array(request.response);
  12039. } else if (!_this.isCompressed && request.responseText) {
  12040. cMapData = (0, _util.stringToBytes)(request.responseText);
  12041. }
  12042. if (cMapData) {
  12043. resolve({
  12044. cMapData: cMapData,
  12045. compressionType: compressionType
  12046. });
  12047. return;
  12048. }
  12049. }
  12050. reject(new Error(request.statusText));
  12051. };
  12052. request.send(null);
  12053. })["catch"](function (reason) {
  12054. throw new Error("Unable to load ".concat(_this.isCompressed ? 'binary ' : '') + "CMap at: ".concat(url));
  12055. }));
  12056. case 10:
  12057. case "end":
  12058. return _context2.stop();
  12059. }
  12060. }
  12061. }, _callee2, this);
  12062. }));
  12063. return function (_x2) {
  12064. return _ref3.apply(this, arguments);
  12065. };
  12066. }())
  12067. }]);
  12068. return DOMCMapReaderFactory;
  12069. }();
  12070. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  12071. var DOMSVGFactory =
  12072. /*#__PURE__*/
  12073. function () {
  12074. function DOMSVGFactory() {
  12075. _classCallCheck(this, DOMSVGFactory);
  12076. }
  12077. _createClass(DOMSVGFactory, [{
  12078. key: "create",
  12079. value: function create(width, height) {
  12080. (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
  12081. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  12082. svg.setAttribute('version', '1.1');
  12083. svg.setAttribute('width', width + 'px');
  12084. svg.setAttribute('height', height + 'px');
  12085. svg.setAttribute('preserveAspectRatio', 'none');
  12086. svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
  12087. return svg;
  12088. }
  12089. }, {
  12090. key: "createElement",
  12091. value: function createElement(type) {
  12092. (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
  12093. return document.createElementNS(SVG_NS, type);
  12094. }
  12095. }]);
  12096. return DOMSVGFactory;
  12097. }();
  12098. exports.DOMSVGFactory = DOMSVGFactory;
  12099. var PageViewport =
  12100. /*#__PURE__*/
  12101. function () {
  12102. function PageViewport(_ref5) {
  12103. var viewBox = _ref5.viewBox,
  12104. scale = _ref5.scale,
  12105. rotation = _ref5.rotation,
  12106. _ref5$offsetX = _ref5.offsetX,
  12107. offsetX = _ref5$offsetX === void 0 ? 0 : _ref5$offsetX,
  12108. _ref5$offsetY = _ref5.offsetY,
  12109. offsetY = _ref5$offsetY === void 0 ? 0 : _ref5$offsetY,
  12110. _ref5$dontFlip = _ref5.dontFlip,
  12111. dontFlip = _ref5$dontFlip === void 0 ? false : _ref5$dontFlip;
  12112. _classCallCheck(this, PageViewport);
  12113. this.viewBox = viewBox;
  12114. this.scale = scale;
  12115. this.rotation = rotation;
  12116. this.offsetX = offsetX;
  12117. this.offsetY = offsetY;
  12118. var centerX = (viewBox[2] + viewBox[0]) / 2;
  12119. var centerY = (viewBox[3] + viewBox[1]) / 2;
  12120. var rotateA, rotateB, rotateC, rotateD;
  12121. rotation = rotation % 360;
  12122. rotation = rotation < 0 ? rotation + 360 : rotation;
  12123. switch (rotation) {
  12124. case 180:
  12125. rotateA = -1;
  12126. rotateB = 0;
  12127. rotateC = 0;
  12128. rotateD = 1;
  12129. break;
  12130. case 90:
  12131. rotateA = 0;
  12132. rotateB = 1;
  12133. rotateC = 1;
  12134. rotateD = 0;
  12135. break;
  12136. case 270:
  12137. rotateA = 0;
  12138. rotateB = -1;
  12139. rotateC = -1;
  12140. rotateD = 0;
  12141. break;
  12142. default:
  12143. rotateA = 1;
  12144. rotateB = 0;
  12145. rotateC = 0;
  12146. rotateD = -1;
  12147. break;
  12148. }
  12149. if (dontFlip) {
  12150. rotateC = -rotateC;
  12151. rotateD = -rotateD;
  12152. }
  12153. var offsetCanvasX, offsetCanvasY;
  12154. var width, height;
  12155. if (rotateA === 0) {
  12156. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  12157. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  12158. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  12159. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  12160. } else {
  12161. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  12162. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  12163. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  12164. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  12165. }
  12166. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  12167. this.width = width;
  12168. this.height = height;
  12169. }
  12170. _createClass(PageViewport, [{
  12171. key: "clone",
  12172. value: function clone() {
  12173. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  12174. _ref6$scale = _ref6.scale,
  12175. scale = _ref6$scale === void 0 ? this.scale : _ref6$scale,
  12176. _ref6$rotation = _ref6.rotation,
  12177. rotation = _ref6$rotation === void 0 ? this.rotation : _ref6$rotation,
  12178. _ref6$dontFlip = _ref6.dontFlip,
  12179. dontFlip = _ref6$dontFlip === void 0 ? false : _ref6$dontFlip;
  12180. return new PageViewport({
  12181. viewBox: this.viewBox.slice(),
  12182. scale: scale,
  12183. rotation: rotation,
  12184. offsetX: this.offsetX,
  12185. offsetY: this.offsetY,
  12186. dontFlip: dontFlip
  12187. });
  12188. }
  12189. }, {
  12190. key: "convertToViewportPoint",
  12191. value: function convertToViewportPoint(x, y) {
  12192. return _util.Util.applyTransform([x, y], this.transform);
  12193. }
  12194. }, {
  12195. key: "convertToViewportRectangle",
  12196. value: function convertToViewportRectangle(rect) {
  12197. var topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  12198. var bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  12199. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  12200. }
  12201. }, {
  12202. key: "convertToPdfPoint",
  12203. value: function convertToPdfPoint(x, y) {
  12204. return _util.Util.applyInverseTransform([x, y], this.transform);
  12205. }
  12206. }]);
  12207. return PageViewport;
  12208. }();
  12209. exports.PageViewport = PageViewport;
  12210. var RenderingCancelledException =
  12211. /*#__PURE__*/
  12212. function (_BaseException) {
  12213. _inherits(RenderingCancelledException, _BaseException);
  12214. function RenderingCancelledException(msg, type) {
  12215. var _this2;
  12216. _classCallCheck(this, RenderingCancelledException);
  12217. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(RenderingCancelledException).call(this, msg));
  12218. _this2.type = type;
  12219. return _this2;
  12220. }
  12221. return RenderingCancelledException;
  12222. }(_util.BaseException);
  12223. exports.RenderingCancelledException = RenderingCancelledException;
  12224. var LinkTarget = {
  12225. NONE: 0,
  12226. SELF: 1,
  12227. BLANK: 2,
  12228. PARENT: 3,
  12229. TOP: 4
  12230. };
  12231. exports.LinkTarget = LinkTarget;
  12232. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  12233. function addLinkAttributes(link) {
  12234. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  12235. url = _ref7.url,
  12236. target = _ref7.target,
  12237. rel = _ref7.rel,
  12238. _ref7$enabled = _ref7.enabled,
  12239. enabled = _ref7$enabled === void 0 ? true : _ref7$enabled;
  12240. (0, _util.assert)(url && typeof url === 'string', 'addLinkAttributes: A valid "url" parameter must provided.');
  12241. var urlNullRemoved = (0, _util.removeNullCharacters)(url);
  12242. if (enabled) {
  12243. link.href = link.title = urlNullRemoved;
  12244. } else {
  12245. link.href = '';
  12246. link.title = "Disabled: ".concat(urlNullRemoved);
  12247. link.onclick = function () {
  12248. return false;
  12249. };
  12250. }
  12251. var LinkTargetValues = Object.values(LinkTarget);
  12252. var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE;
  12253. link.target = LinkTargetStringMap[targetIndex];
  12254. link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL;
  12255. }
  12256. function getFilenameFromUrl(url) {
  12257. var anchor = url.indexOf('#');
  12258. var query = url.indexOf('?');
  12259. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  12260. return url.substring(url.lastIndexOf('/', end) + 1, end);
  12261. }
  12262. var StatTimer =
  12263. /*#__PURE__*/
  12264. function () {
  12265. function StatTimer() {
  12266. var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  12267. _classCallCheck(this, StatTimer);
  12268. this.enabled = !!enable;
  12269. this.started = Object.create(null);
  12270. this.times = [];
  12271. }
  12272. _createClass(StatTimer, [{
  12273. key: "time",
  12274. value: function time(name) {
  12275. if (!this.enabled) {
  12276. return;
  12277. }
  12278. if (name in this.started) {
  12279. (0, _util.warn)('Timer is already running for ' + name);
  12280. }
  12281. this.started[name] = Date.now();
  12282. }
  12283. }, {
  12284. key: "timeEnd",
  12285. value: function timeEnd(name) {
  12286. if (!this.enabled) {
  12287. return;
  12288. }
  12289. if (!(name in this.started)) {
  12290. (0, _util.warn)('Timer has not been started for ' + name);
  12291. }
  12292. this.times.push({
  12293. 'name': name,
  12294. 'start': this.started[name],
  12295. 'end': Date.now()
  12296. });
  12297. delete this.started[name];
  12298. }
  12299. }, {
  12300. key: "toString",
  12301. value: function toString() {
  12302. var out = '',
  12303. longest = 0;
  12304. var _iteratorNormalCompletion = true;
  12305. var _didIteratorError = false;
  12306. var _iteratorError = undefined;
  12307. try {
  12308. for (var _iterator = this.times[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  12309. var time = _step.value;
  12310. var name = time.name;
  12311. if (name.length > longest) {
  12312. longest = name.length;
  12313. }
  12314. }
  12315. } catch (err) {
  12316. _didIteratorError = true;
  12317. _iteratorError = err;
  12318. } finally {
  12319. try {
  12320. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  12321. _iterator["return"]();
  12322. }
  12323. } finally {
  12324. if (_didIteratorError) {
  12325. throw _iteratorError;
  12326. }
  12327. }
  12328. }
  12329. var _iteratorNormalCompletion2 = true;
  12330. var _didIteratorError2 = false;
  12331. var _iteratorError2 = undefined;
  12332. try {
  12333. for (var _iterator2 = this.times[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  12334. var _time = _step2.value;
  12335. var duration = _time.end - _time.start;
  12336. out += "".concat(_time.name.padEnd(longest), " ").concat(duration, "ms\n");
  12337. }
  12338. } catch (err) {
  12339. _didIteratorError2 = true;
  12340. _iteratorError2 = err;
  12341. } finally {
  12342. try {
  12343. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  12344. _iterator2["return"]();
  12345. }
  12346. } finally {
  12347. if (_didIteratorError2) {
  12348. throw _iteratorError2;
  12349. }
  12350. }
  12351. }
  12352. return out;
  12353. }
  12354. }]);
  12355. return StatTimer;
  12356. }();
  12357. exports.StatTimer = StatTimer;
  12358. var DummyStatTimer =
  12359. /*#__PURE__*/
  12360. function () {
  12361. function DummyStatTimer() {
  12362. _classCallCheck(this, DummyStatTimer);
  12363. (0, _util.unreachable)('Cannot initialize DummyStatTimer.');
  12364. }
  12365. _createClass(DummyStatTimer, null, [{
  12366. key: "time",
  12367. value: function time(name) {}
  12368. }, {
  12369. key: "timeEnd",
  12370. value: function timeEnd(name) {}
  12371. }, {
  12372. key: "toString",
  12373. value: function toString() {
  12374. return '';
  12375. }
  12376. }]);
  12377. return DummyStatTimer;
  12378. }();
  12379. exports.DummyStatTimer = DummyStatTimer;
  12380. function isFetchSupported() {
  12381. return typeof fetch !== 'undefined' && typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined';
  12382. }
  12383. function isValidFetchUrl(url, baseUrl) {
  12384. try {
  12385. var _ref8 = baseUrl ? new URL(url, baseUrl) : new URL(url),
  12386. protocol = _ref8.protocol;
  12387. return protocol === 'http:' || protocol === 'https:';
  12388. } catch (ex) {
  12389. return false;
  12390. }
  12391. }
  12392. function loadScript(src) {
  12393. return new Promise(function (resolve, reject) {
  12394. var script = document.createElement('script');
  12395. script.src = src;
  12396. script.onload = resolve;
  12397. script.onerror = function () {
  12398. reject(new Error("Cannot load script at: ".concat(script.src)));
  12399. };
  12400. (document.head || document.documentElement).appendChild(script);
  12401. });
  12402. }
  12403. function deprecated(details) {
  12404. console.log('Deprecated API usage: ' + details);
  12405. }
  12406. function releaseImageResources(img) {
  12407. (0, _util.assert)(img instanceof Image, 'Invalid `img` parameter.');
  12408. var url = img.src;
  12409. if (typeof url === 'string' && url.startsWith('blob:') && URL.revokeObjectURL) {
  12410. URL.revokeObjectURL(url);
  12411. }
  12412. img.removeAttribute('src');
  12413. }
  12414. var pdfDateStringRegex;
  12415. var PDFDateString =
  12416. /*#__PURE__*/
  12417. function () {
  12418. function PDFDateString() {
  12419. _classCallCheck(this, PDFDateString);
  12420. }
  12421. _createClass(PDFDateString, null, [{
  12422. key: "toDateObject",
  12423. value: function toDateObject(input) {
  12424. if (!input || !(0, _util.isString)(input)) {
  12425. return null;
  12426. }
  12427. if (!pdfDateStringRegex) {
  12428. pdfDateStringRegex = new RegExp('^D:' + '(\\d{4})' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '(\\d{2})?' + '([Z|+|-])?' + '(\\d{2})?' + '\'?' + '(\\d{2})?' + '\'?');
  12429. }
  12430. var matches = pdfDateStringRegex.exec(input);
  12431. if (!matches) {
  12432. return null;
  12433. }
  12434. var year = parseInt(matches[1], 10);
  12435. var month = parseInt(matches[2], 10);
  12436. month = month >= 1 && month <= 12 ? month - 1 : 0;
  12437. var day = parseInt(matches[3], 10);
  12438. day = day >= 1 && day <= 31 ? day : 1;
  12439. var hour = parseInt(matches[4], 10);
  12440. hour = hour >= 0 && hour <= 23 ? hour : 0;
  12441. var minute = parseInt(matches[5], 10);
  12442. minute = minute >= 0 && minute <= 59 ? minute : 0;
  12443. var second = parseInt(matches[6], 10);
  12444. second = second >= 0 && second <= 59 ? second : 0;
  12445. var universalTimeRelation = matches[7] || 'Z';
  12446. var offsetHour = parseInt(matches[8], 10);
  12447. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  12448. var offsetMinute = parseInt(matches[9], 10) || 0;
  12449. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  12450. if (universalTimeRelation === '-') {
  12451. hour += offsetHour;
  12452. minute += offsetMinute;
  12453. } else if (universalTimeRelation === '+') {
  12454. hour -= offsetHour;
  12455. minute -= offsetMinute;
  12456. }
  12457. return new Date(Date.UTC(year, month, day, hour, minute, second));
  12458. }
  12459. }]);
  12460. return PDFDateString;
  12461. }();
  12462. exports.PDFDateString = PDFDateString;
  12463. /***/ }),
  12464. /* 184 */
  12465. /***/ (function(module, exports, __w_pdfjs_require__) {
  12466. "use strict";
  12467. Object.defineProperty(exports, "__esModule", {
  12468. value: true
  12469. });
  12470. exports.FontLoader = exports.FontFaceObject = void 0;
  12471. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  12472. var _util = __w_pdfjs_require__(1);
  12473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12474. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  12475. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12476. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12477. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12478. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  12479. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12480. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  12481. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  12482. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12483. 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); } }
  12484. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12485. var BaseFontLoader =
  12486. /*#__PURE__*/
  12487. function () {
  12488. function BaseFontLoader(_ref) {
  12489. var docId = _ref.docId,
  12490. onUnsupportedFeature = _ref.onUnsupportedFeature;
  12491. _classCallCheck(this, BaseFontLoader);
  12492. if (this.constructor === BaseFontLoader) {
  12493. (0, _util.unreachable)('Cannot initialize BaseFontLoader.');
  12494. }
  12495. this.docId = docId;
  12496. this._onUnsupportedFeature = onUnsupportedFeature;
  12497. this.nativeFontFaces = [];
  12498. this.styleElement = null;
  12499. }
  12500. _createClass(BaseFontLoader, [{
  12501. key: "addNativeFontFace",
  12502. value: function addNativeFontFace(nativeFontFace) {
  12503. this.nativeFontFaces.push(nativeFontFace);
  12504. document.fonts.add(nativeFontFace);
  12505. }
  12506. }, {
  12507. key: "insertRule",
  12508. value: function insertRule(rule) {
  12509. var styleElement = this.styleElement;
  12510. if (!styleElement) {
  12511. styleElement = this.styleElement = document.createElement('style');
  12512. styleElement.id = "PDFJS_FONT_STYLE_TAG_".concat(this.docId);
  12513. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  12514. }
  12515. var styleSheet = styleElement.sheet;
  12516. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  12517. }
  12518. }, {
  12519. key: "clear",
  12520. value: function clear() {
  12521. this.nativeFontFaces.forEach(function (nativeFontFace) {
  12522. document.fonts["delete"](nativeFontFace);
  12523. });
  12524. this.nativeFontFaces.length = 0;
  12525. if (this.styleElement) {
  12526. this.styleElement.remove();
  12527. this.styleElement = null;
  12528. }
  12529. }
  12530. }, {
  12531. key: "bind",
  12532. value: function () {
  12533. var _bind = _asyncToGenerator(
  12534. /*#__PURE__*/
  12535. _regenerator["default"].mark(function _callee(font) {
  12536. var _this = this;
  12537. var nativeFontFace, rule;
  12538. return _regenerator["default"].wrap(function _callee$(_context) {
  12539. while (1) {
  12540. switch (_context.prev = _context.next) {
  12541. case 0:
  12542. if (!(font.attached || font.missingFile)) {
  12543. _context.next = 2;
  12544. break;
  12545. }
  12546. return _context.abrupt("return", undefined);
  12547. case 2:
  12548. font.attached = true;
  12549. if (!this.isFontLoadingAPISupported) {
  12550. _context.next = 19;
  12551. break;
  12552. }
  12553. nativeFontFace = font.createNativeFontFace();
  12554. if (!nativeFontFace) {
  12555. _context.next = 18;
  12556. break;
  12557. }
  12558. this.addNativeFontFace(nativeFontFace);
  12559. _context.prev = 7;
  12560. _context.next = 10;
  12561. return nativeFontFace.loaded;
  12562. case 10:
  12563. _context.next = 18;
  12564. break;
  12565. case 12:
  12566. _context.prev = 12;
  12567. _context.t0 = _context["catch"](7);
  12568. this._onUnsupportedFeature({
  12569. featureId: _util.UNSUPPORTED_FEATURES.font
  12570. });
  12571. (0, _util.warn)("Failed to load font '".concat(nativeFontFace.family, "': '").concat(_context.t0, "'."));
  12572. font.disableFontFace = true;
  12573. throw _context.t0;
  12574. case 18:
  12575. return _context.abrupt("return", undefined);
  12576. case 19:
  12577. rule = font.createFontFaceRule();
  12578. if (!rule) {
  12579. _context.next = 25;
  12580. break;
  12581. }
  12582. this.insertRule(rule);
  12583. if (!this.isSyncFontLoadingSupported) {
  12584. _context.next = 24;
  12585. break;
  12586. }
  12587. return _context.abrupt("return", undefined);
  12588. case 24:
  12589. return _context.abrupt("return", new Promise(function (resolve) {
  12590. var request = _this._queueLoadingCallback(resolve);
  12591. _this._prepareFontLoadEvent([rule], [font], request);
  12592. }));
  12593. case 25:
  12594. return _context.abrupt("return", undefined);
  12595. case 26:
  12596. case "end":
  12597. return _context.stop();
  12598. }
  12599. }
  12600. }, _callee, this, [[7, 12]]);
  12601. }));
  12602. function bind(_x) {
  12603. return _bind.apply(this, arguments);
  12604. }
  12605. return bind;
  12606. }()
  12607. }, {
  12608. key: "_queueLoadingCallback",
  12609. value: function _queueLoadingCallback(callback) {
  12610. (0, _util.unreachable)('Abstract method `_queueLoadingCallback`.');
  12611. }
  12612. }, {
  12613. key: "_prepareFontLoadEvent",
  12614. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  12615. (0, _util.unreachable)('Abstract method `_prepareFontLoadEvent`.');
  12616. }
  12617. }, {
  12618. key: "isFontLoadingAPISupported",
  12619. get: function get() {
  12620. (0, _util.unreachable)('Abstract method `isFontLoadingAPISupported`.');
  12621. }
  12622. }, {
  12623. key: "isSyncFontLoadingSupported",
  12624. get: function get() {
  12625. (0, _util.unreachable)('Abstract method `isSyncFontLoadingSupported`.');
  12626. }
  12627. }, {
  12628. key: "_loadTestFont",
  12629. get: function get() {
  12630. (0, _util.unreachable)('Abstract method `_loadTestFont`.');
  12631. }
  12632. }]);
  12633. return BaseFontLoader;
  12634. }();
  12635. var FontLoader;
  12636. exports.FontLoader = FontLoader;
  12637. {
  12638. exports.FontLoader = FontLoader =
  12639. /*#__PURE__*/
  12640. function (_BaseFontLoader) {
  12641. _inherits(GenericFontLoader, _BaseFontLoader);
  12642. function GenericFontLoader(docId) {
  12643. var _this2;
  12644. _classCallCheck(this, GenericFontLoader);
  12645. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(GenericFontLoader).call(this, docId));
  12646. _this2.loadingContext = {
  12647. requests: [],
  12648. nextRequestId: 0
  12649. };
  12650. _this2.loadTestFontId = 0;
  12651. return _this2;
  12652. }
  12653. _createClass(GenericFontLoader, [{
  12654. key: "_queueLoadingCallback",
  12655. value: function _queueLoadingCallback(callback) {
  12656. function completeRequest() {
  12657. (0, _util.assert)(!request.done, 'completeRequest() cannot be called twice.');
  12658. request.done = true;
  12659. while (context.requests.length > 0 && context.requests[0].done) {
  12660. var otherRequest = context.requests.shift();
  12661. setTimeout(otherRequest.callback, 0);
  12662. }
  12663. }
  12664. var context = this.loadingContext;
  12665. var request = {
  12666. id: "pdfjs-font-loading-".concat(context.nextRequestId++),
  12667. done: false,
  12668. complete: completeRequest,
  12669. callback: callback
  12670. };
  12671. context.requests.push(request);
  12672. return request;
  12673. }
  12674. }, {
  12675. key: "_prepareFontLoadEvent",
  12676. value: function _prepareFontLoadEvent(rules, fonts, request) {
  12677. function int32(data, offset) {
  12678. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  12679. }
  12680. function spliceString(s, offset, remove, insert) {
  12681. var chunk1 = s.substring(0, offset);
  12682. var chunk2 = s.substring(offset + remove);
  12683. return chunk1 + insert + chunk2;
  12684. }
  12685. var i, ii;
  12686. var canvas = document.createElement('canvas');
  12687. canvas.width = 1;
  12688. canvas.height = 1;
  12689. var ctx = canvas.getContext('2d');
  12690. var called = 0;
  12691. function isFontReady(name, callback) {
  12692. called++;
  12693. if (called > 30) {
  12694. (0, _util.warn)('Load test font never loaded.');
  12695. callback();
  12696. return;
  12697. }
  12698. ctx.font = '30px ' + name;
  12699. ctx.fillText('.', 0, 20);
  12700. var imageData = ctx.getImageData(0, 0, 1, 1);
  12701. if (imageData.data[3] > 0) {
  12702. callback();
  12703. return;
  12704. }
  12705. setTimeout(isFontReady.bind(null, name, callback));
  12706. }
  12707. var loadTestFontId = "lt".concat(Date.now()).concat(this.loadTestFontId++);
  12708. var data = this._loadTestFont;
  12709. var COMMENT_OFFSET = 976;
  12710. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  12711. var CFF_CHECKSUM_OFFSET = 16;
  12712. var XXXX_VALUE = 0x58585858;
  12713. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  12714. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  12715. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  12716. }
  12717. if (i < loadTestFontId.length) {
  12718. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  12719. }
  12720. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  12721. var url = "url(data:font/opentype;base64,".concat(btoa(data), ");");
  12722. var rule = "@font-face {font-family:\"".concat(loadTestFontId, "\";src:").concat(url, "}");
  12723. this.insertRule(rule);
  12724. var names = [];
  12725. for (i = 0, ii = fonts.length; i < ii; i++) {
  12726. names.push(fonts[i].loadedName);
  12727. }
  12728. names.push(loadTestFontId);
  12729. var div = document.createElement('div');
  12730. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  12731. for (i = 0, ii = names.length; i < ii; ++i) {
  12732. var span = document.createElement('span');
  12733. span.textContent = 'Hi';
  12734. span.style.fontFamily = names[i];
  12735. div.appendChild(span);
  12736. }
  12737. document.body.appendChild(div);
  12738. isFontReady(loadTestFontId, function () {
  12739. document.body.removeChild(div);
  12740. request.complete();
  12741. });
  12742. }
  12743. }, {
  12744. key: "isFontLoadingAPISupported",
  12745. get: function get() {
  12746. var supported = typeof document !== 'undefined' && !!document.fonts;
  12747. if (supported && typeof navigator !== 'undefined') {
  12748. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  12749. if (m && m[1] < 63) {
  12750. supported = false;
  12751. }
  12752. }
  12753. return (0, _util.shadow)(this, 'isFontLoadingAPISupported', supported);
  12754. }
  12755. }, {
  12756. key: "isSyncFontLoadingSupported",
  12757. get: function get() {
  12758. var supported = false;
  12759. if (typeof navigator === 'undefined') {
  12760. supported = true;
  12761. } else {
  12762. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  12763. if (m && m[1] >= 14) {
  12764. supported = true;
  12765. }
  12766. }
  12767. return (0, _util.shadow)(this, 'isSyncFontLoadingSupported', supported);
  12768. }
  12769. }, {
  12770. key: "_loadTestFont",
  12771. get: function get() {
  12772. var getLoadTestFont = function getLoadTestFont() {
  12773. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA' + 'FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA' + 'ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA' + 'AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1' + 'AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD' + '6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM' + 'AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D' + 'IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA' + 'AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA' + 'AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB' + 'AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY' + 'AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA' + 'AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA' + 'AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC' + 'AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3' + 'Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj' + 'FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==');
  12774. };
  12775. return (0, _util.shadow)(this, '_loadTestFont', getLoadTestFont());
  12776. }
  12777. }]);
  12778. return GenericFontLoader;
  12779. }(BaseFontLoader);
  12780. }
  12781. var IsEvalSupportedCached = {
  12782. get value() {
  12783. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  12784. }
  12785. };
  12786. var FontFaceObject =
  12787. /*#__PURE__*/
  12788. function () {
  12789. function FontFaceObject(translatedData, _ref2) {
  12790. var _ref2$isEvalSupported = _ref2.isEvalSupported,
  12791. isEvalSupported = _ref2$isEvalSupported === void 0 ? true : _ref2$isEvalSupported,
  12792. _ref2$disableFontFace = _ref2.disableFontFace,
  12793. disableFontFace = _ref2$disableFontFace === void 0 ? false : _ref2$disableFontFace,
  12794. _ref2$ignoreErrors = _ref2.ignoreErrors,
  12795. ignoreErrors = _ref2$ignoreErrors === void 0 ? false : _ref2$ignoreErrors,
  12796. _ref2$onUnsupportedFe = _ref2.onUnsupportedFeature,
  12797. onUnsupportedFeature = _ref2$onUnsupportedFe === void 0 ? null : _ref2$onUnsupportedFe,
  12798. _ref2$fontRegistry = _ref2.fontRegistry,
  12799. fontRegistry = _ref2$fontRegistry === void 0 ? null : _ref2$fontRegistry;
  12800. _classCallCheck(this, FontFaceObject);
  12801. this.compiledGlyphs = Object.create(null);
  12802. for (var i in translatedData) {
  12803. this[i] = translatedData[i];
  12804. }
  12805. this.isEvalSupported = isEvalSupported !== false;
  12806. this.disableFontFace = disableFontFace === true;
  12807. this.ignoreErrors = ignoreErrors === true;
  12808. this._onUnsupportedFeature = onUnsupportedFeature;
  12809. this.fontRegistry = fontRegistry;
  12810. }
  12811. _createClass(FontFaceObject, [{
  12812. key: "createNativeFontFace",
  12813. value: function createNativeFontFace() {
  12814. if (!this.data || this.disableFontFace) {
  12815. return null;
  12816. }
  12817. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  12818. if (this.fontRegistry) {
  12819. this.fontRegistry.registerFont(this);
  12820. }
  12821. return nativeFontFace;
  12822. }
  12823. }, {
  12824. key: "createFontFaceRule",
  12825. value: function createFontFaceRule() {
  12826. if (!this.data || this.disableFontFace) {
  12827. return null;
  12828. }
  12829. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  12830. var url = "url(data:".concat(this.mimetype, ";base64,").concat(btoa(data), ");");
  12831. var rule = "@font-face {font-family:\"".concat(this.loadedName, "\";src:").concat(url, "}");
  12832. if (this.fontRegistry) {
  12833. this.fontRegistry.registerFont(this, url);
  12834. }
  12835. return rule;
  12836. }
  12837. }, {
  12838. key: "getPathGenerator",
  12839. value: function getPathGenerator(objs, character) {
  12840. if (this.compiledGlyphs[character] !== undefined) {
  12841. return this.compiledGlyphs[character];
  12842. }
  12843. var cmds, current;
  12844. try {
  12845. cmds = objs.get(this.loadedName + '_path_' + character);
  12846. } catch (ex) {
  12847. if (!this.ignoreErrors) {
  12848. throw ex;
  12849. }
  12850. if (this._onUnsupportedFeature) {
  12851. this._onUnsupportedFeature({
  12852. featureId: _util.UNSUPPORTED_FEATURES.font
  12853. });
  12854. }
  12855. (0, _util.warn)("getPathGenerator - ignoring character: \"".concat(ex, "\"."));
  12856. return this.compiledGlyphs[character] = function (c, size) {};
  12857. }
  12858. if (this.isEvalSupported && IsEvalSupportedCached.value) {
  12859. var args,
  12860. js = '';
  12861. for (var i = 0, ii = cmds.length; i < ii; i++) {
  12862. current = cmds[i];
  12863. if (current.args !== undefined) {
  12864. args = current.args.join(',');
  12865. } else {
  12866. args = '';
  12867. }
  12868. js += 'c.' + current.cmd + '(' + args + ');\n';
  12869. }
  12870. return this.compiledGlyphs[character] = new Function('c', 'size', js);
  12871. }
  12872. return this.compiledGlyphs[character] = function (c, size) {
  12873. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  12874. current = cmds[_i];
  12875. if (current.cmd === 'scale') {
  12876. current.args = [size, -size];
  12877. }
  12878. c[current.cmd].apply(c, current.args);
  12879. }
  12880. };
  12881. }
  12882. }]);
  12883. return FontFaceObject;
  12884. }();
  12885. exports.FontFaceObject = FontFaceObject;
  12886. /***/ }),
  12887. /* 185 */
  12888. /***/ (function(module, exports, __w_pdfjs_require__) {
  12889. "use strict";
  12890. var compatibilityParams = Object.create(null);
  12891. {
  12892. var isNodeJS = __w_pdfjs_require__(4);
  12893. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  12894. var isIE = /Trident/.test(userAgent);
  12895. var isIOSChrome = /CriOS/.test(userAgent);
  12896. (function checkOnBlobSupport() {
  12897. if (isIE || isIOSChrome) {
  12898. compatibilityParams.disableCreateObjectURL = true;
  12899. }
  12900. })();
  12901. (function checkFontFaceAndImage() {
  12902. if (isNodeJS()) {
  12903. compatibilityParams.disableFontFace = true;
  12904. compatibilityParams.nativeImageDecoderSupport = 'none';
  12905. }
  12906. })();
  12907. }
  12908. exports.apiCompatibilityParams = Object.freeze(compatibilityParams);
  12909. /***/ }),
  12910. /* 186 */
  12911. /***/ (function(module, exports, __w_pdfjs_require__) {
  12912. "use strict";
  12913. Object.defineProperty(exports, "__esModule", {
  12914. value: true
  12915. });
  12916. exports.CanvasGraphics = void 0;
  12917. var _util = __w_pdfjs_require__(1);
  12918. var _pattern_helper = __w_pdfjs_require__(187);
  12919. var MIN_FONT_SIZE = 16;
  12920. var MAX_FONT_SIZE = 100;
  12921. var MAX_GROUP_SIZE = 4096;
  12922. var MIN_WIDTH_FACTOR = 0.65;
  12923. var COMPILE_TYPE3_GLYPHS = true;
  12924. var MAX_SIZE_TO_COMPILE = 1000;
  12925. var FULL_CHUNK_HEIGHT = 16;
  12926. var IsLittleEndianCached = {
  12927. get value() {
  12928. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  12929. }
  12930. };
  12931. function addContextCurrentTransform(ctx) {
  12932. if (!ctx.mozCurrentTransform) {
  12933. ctx._originalSave = ctx.save;
  12934. ctx._originalRestore = ctx.restore;
  12935. ctx._originalRotate = ctx.rotate;
  12936. ctx._originalScale = ctx.scale;
  12937. ctx._originalTranslate = ctx.translate;
  12938. ctx._originalTransform = ctx.transform;
  12939. ctx._originalSetTransform = ctx.setTransform;
  12940. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  12941. ctx._transformStack = [];
  12942. Object.defineProperty(ctx, 'mozCurrentTransform', {
  12943. get: function getCurrentTransform() {
  12944. return this._transformMatrix;
  12945. }
  12946. });
  12947. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  12948. get: function getCurrentTransformInverse() {
  12949. var m = this._transformMatrix;
  12950. var a = m[0],
  12951. b = m[1],
  12952. c = m[2],
  12953. d = m[3],
  12954. e = m[4],
  12955. f = m[5];
  12956. var ad_bc = a * d - b * c;
  12957. var bc_ad = b * c - a * d;
  12958. 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];
  12959. }
  12960. });
  12961. ctx.save = function ctxSave() {
  12962. var old = this._transformMatrix;
  12963. this._transformStack.push(old);
  12964. this._transformMatrix = old.slice(0, 6);
  12965. this._originalSave();
  12966. };
  12967. ctx.restore = function ctxRestore() {
  12968. var prev = this._transformStack.pop();
  12969. if (prev) {
  12970. this._transformMatrix = prev;
  12971. this._originalRestore();
  12972. }
  12973. };
  12974. ctx.translate = function ctxTranslate(x, y) {
  12975. var m = this._transformMatrix;
  12976. m[4] = m[0] * x + m[2] * y + m[4];
  12977. m[5] = m[1] * x + m[3] * y + m[5];
  12978. this._originalTranslate(x, y);
  12979. };
  12980. ctx.scale = function ctxScale(x, y) {
  12981. var m = this._transformMatrix;
  12982. m[0] = m[0] * x;
  12983. m[1] = m[1] * x;
  12984. m[2] = m[2] * y;
  12985. m[3] = m[3] * y;
  12986. this._originalScale(x, y);
  12987. };
  12988. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  12989. var m = this._transformMatrix;
  12990. 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]];
  12991. ctx._originalTransform(a, b, c, d, e, f);
  12992. };
  12993. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  12994. this._transformMatrix = [a, b, c, d, e, f];
  12995. ctx._originalSetTransform(a, b, c, d, e, f);
  12996. };
  12997. ctx.rotate = function ctxRotate(angle) {
  12998. var cosValue = Math.cos(angle);
  12999. var sinValue = Math.sin(angle);
  13000. var m = this._transformMatrix;
  13001. 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]];
  13002. this._originalRotate(angle);
  13003. };
  13004. }
  13005. }
  13006. var CachedCanvases = function CachedCanvasesClosure() {
  13007. function CachedCanvases(canvasFactory) {
  13008. this.canvasFactory = canvasFactory;
  13009. this.cache = Object.create(null);
  13010. }
  13011. CachedCanvases.prototype = {
  13012. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  13013. var canvasEntry;
  13014. if (this.cache[id] !== undefined) {
  13015. canvasEntry = this.cache[id];
  13016. this.canvasFactory.reset(canvasEntry, width, height);
  13017. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  13018. } else {
  13019. canvasEntry = this.canvasFactory.create(width, height);
  13020. this.cache[id] = canvasEntry;
  13021. }
  13022. if (trackTransform) {
  13023. addContextCurrentTransform(canvasEntry.context);
  13024. }
  13025. return canvasEntry;
  13026. },
  13027. clear: function clear() {
  13028. for (var id in this.cache) {
  13029. var canvasEntry = this.cache[id];
  13030. this.canvasFactory.destroy(canvasEntry);
  13031. delete this.cache[id];
  13032. }
  13033. }
  13034. };
  13035. return CachedCanvases;
  13036. }();
  13037. function compileType3Glyph(imgData) {
  13038. var POINT_TO_PROCESS_LIMIT = 1000;
  13039. var width = imgData.width,
  13040. height = imgData.height;
  13041. var i,
  13042. j,
  13043. j0,
  13044. width1 = width + 1;
  13045. var points = new Uint8Array(width1 * (height + 1));
  13046. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  13047. var lineSize = width + 7 & ~7,
  13048. data0 = imgData.data;
  13049. var data = new Uint8Array(lineSize * height),
  13050. pos = 0,
  13051. ii;
  13052. for (i = 0, ii = data0.length; i < ii; i++) {
  13053. var mask = 128,
  13054. elem = data0[i];
  13055. while (mask > 0) {
  13056. data[pos++] = elem & mask ? 0 : 255;
  13057. mask >>= 1;
  13058. }
  13059. }
  13060. var count = 0;
  13061. pos = 0;
  13062. if (data[pos] !== 0) {
  13063. points[0] = 1;
  13064. ++count;
  13065. }
  13066. for (j = 1; j < width; j++) {
  13067. if (data[pos] !== data[pos + 1]) {
  13068. points[j] = data[pos] ? 2 : 1;
  13069. ++count;
  13070. }
  13071. pos++;
  13072. }
  13073. if (data[pos] !== 0) {
  13074. points[j] = 2;
  13075. ++count;
  13076. }
  13077. for (i = 1; i < height; i++) {
  13078. pos = i * lineSize;
  13079. j0 = i * width1;
  13080. if (data[pos - lineSize] !== data[pos]) {
  13081. points[j0] = data[pos] ? 1 : 8;
  13082. ++count;
  13083. }
  13084. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  13085. for (j = 1; j < width; j++) {
  13086. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  13087. if (POINT_TYPES[sum]) {
  13088. points[j0 + j] = POINT_TYPES[sum];
  13089. ++count;
  13090. }
  13091. pos++;
  13092. }
  13093. if (data[pos - lineSize] !== data[pos]) {
  13094. points[j0 + j] = data[pos] ? 2 : 4;
  13095. ++count;
  13096. }
  13097. if (count > POINT_TO_PROCESS_LIMIT) {
  13098. return null;
  13099. }
  13100. }
  13101. pos = lineSize * (height - 1);
  13102. j0 = i * width1;
  13103. if (data[pos] !== 0) {
  13104. points[j0] = 8;
  13105. ++count;
  13106. }
  13107. for (j = 1; j < width; j++) {
  13108. if (data[pos] !== data[pos + 1]) {
  13109. points[j0 + j] = data[pos] ? 4 : 8;
  13110. ++count;
  13111. }
  13112. pos++;
  13113. }
  13114. if (data[pos] !== 0) {
  13115. points[j0 + j] = 4;
  13116. ++count;
  13117. }
  13118. if (count > POINT_TO_PROCESS_LIMIT) {
  13119. return null;
  13120. }
  13121. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  13122. var outlines = [];
  13123. for (i = 0; count && i <= height; i++) {
  13124. var p = i * width1;
  13125. var end = p + width;
  13126. while (p < end && !points[p]) {
  13127. p++;
  13128. }
  13129. if (p === end) {
  13130. continue;
  13131. }
  13132. var coords = [p % width1, i];
  13133. var type = points[p],
  13134. p0 = p,
  13135. pp;
  13136. do {
  13137. var step = steps[type];
  13138. do {
  13139. p += step;
  13140. } while (!points[p]);
  13141. pp = points[p];
  13142. if (pp !== 5 && pp !== 10) {
  13143. type = pp;
  13144. points[p] = 0;
  13145. } else {
  13146. type = pp & 0x33 * type >> 4;
  13147. points[p] &= type >> 2 | type << 2;
  13148. }
  13149. coords.push(p % width1);
  13150. coords.push(p / width1 | 0);
  13151. if (!points[p]) {
  13152. --count;
  13153. }
  13154. } while (p0 !== p);
  13155. outlines.push(coords);
  13156. --i;
  13157. }
  13158. var drawOutline = function drawOutline(c) {
  13159. c.save();
  13160. c.scale(1 / width, -1 / height);
  13161. c.translate(0, -height);
  13162. c.beginPath();
  13163. for (var i = 0, ii = outlines.length; i < ii; i++) {
  13164. var o = outlines[i];
  13165. c.moveTo(o[0], o[1]);
  13166. for (var j = 2, jj = o.length; j < jj; j += 2) {
  13167. c.lineTo(o[j], o[j + 1]);
  13168. }
  13169. }
  13170. c.fill();
  13171. c.beginPath();
  13172. c.restore();
  13173. };
  13174. return drawOutline;
  13175. }
  13176. var CanvasExtraState = function CanvasExtraStateClosure() {
  13177. function CanvasExtraState() {
  13178. this.alphaIsShape = false;
  13179. this.fontSize = 0;
  13180. this.fontSizeScale = 1;
  13181. this.textMatrix = _util.IDENTITY_MATRIX;
  13182. this.textMatrixScale = 1;
  13183. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  13184. this.leading = 0;
  13185. this.x = 0;
  13186. this.y = 0;
  13187. this.lineX = 0;
  13188. this.lineY = 0;
  13189. this.charSpacing = 0;
  13190. this.wordSpacing = 0;
  13191. this.textHScale = 1;
  13192. this.textRenderingMode = _util.TextRenderingMode.FILL;
  13193. this.textRise = 0;
  13194. this.fillColor = '#000000';
  13195. this.strokeColor = '#000000';
  13196. this.patternFill = false;
  13197. this.fillAlpha = 1;
  13198. this.strokeAlpha = 1;
  13199. this.lineWidth = 1;
  13200. this.activeSMask = null;
  13201. this.resumeSMaskCtx = null;
  13202. }
  13203. CanvasExtraState.prototype = {
  13204. clone: function CanvasExtraState_clone() {
  13205. return Object.create(this);
  13206. },
  13207. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  13208. this.x = x;
  13209. this.y = y;
  13210. }
  13211. };
  13212. return CanvasExtraState;
  13213. }();
  13214. var CanvasGraphics = function CanvasGraphicsClosure() {
  13215. var EXECUTION_TIME = 15;
  13216. var EXECUTION_STEPS = 10;
  13217. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
  13218. this.ctx = canvasCtx;
  13219. this.current = new CanvasExtraState();
  13220. this.stateStack = [];
  13221. this.pendingClip = null;
  13222. this.pendingEOFill = false;
  13223. this.res = null;
  13224. this.xobjs = null;
  13225. this.commonObjs = commonObjs;
  13226. this.objs = objs;
  13227. this.canvasFactory = canvasFactory;
  13228. this.webGLContext = webGLContext;
  13229. this.imageLayer = imageLayer;
  13230. this.groupStack = [];
  13231. this.processingType3 = null;
  13232. this.baseTransform = null;
  13233. this.baseTransformStack = [];
  13234. this.groupLevel = 0;
  13235. this.smaskStack = [];
  13236. this.smaskCounter = 0;
  13237. this.tempSMask = null;
  13238. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  13239. if (canvasCtx) {
  13240. addContextCurrentTransform(canvasCtx);
  13241. }
  13242. this._cachedGetSinglePixelWidth = null;
  13243. }
  13244. function putBinaryImageData(ctx, imgData) {
  13245. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  13246. ctx.putImageData(imgData, 0, 0);
  13247. return;
  13248. }
  13249. var height = imgData.height,
  13250. width = imgData.width;
  13251. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  13252. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  13253. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  13254. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  13255. var srcPos = 0,
  13256. destPos;
  13257. var src = imgData.data;
  13258. var dest = chunkImgData.data;
  13259. var i, j, thisChunkHeight, elemsInThisChunk;
  13260. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  13261. var srcLength = src.byteLength;
  13262. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  13263. var dest32DataLength = dest32.length;
  13264. var fullSrcDiff = width + 7 >> 3;
  13265. var white = 0xFFFFFFFF;
  13266. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  13267. for (i = 0; i < totalChunks; i++) {
  13268. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  13269. destPos = 0;
  13270. for (j = 0; j < thisChunkHeight; j++) {
  13271. var srcDiff = srcLength - srcPos;
  13272. var k = 0;
  13273. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  13274. var kEndUnrolled = kEnd & ~7;
  13275. var mask = 0;
  13276. var srcByte = 0;
  13277. for (; k < kEndUnrolled; k += 8) {
  13278. srcByte = src[srcPos++];
  13279. dest32[destPos++] = srcByte & 128 ? white : black;
  13280. dest32[destPos++] = srcByte & 64 ? white : black;
  13281. dest32[destPos++] = srcByte & 32 ? white : black;
  13282. dest32[destPos++] = srcByte & 16 ? white : black;
  13283. dest32[destPos++] = srcByte & 8 ? white : black;
  13284. dest32[destPos++] = srcByte & 4 ? white : black;
  13285. dest32[destPos++] = srcByte & 2 ? white : black;
  13286. dest32[destPos++] = srcByte & 1 ? white : black;
  13287. }
  13288. for (; k < kEnd; k++) {
  13289. if (mask === 0) {
  13290. srcByte = src[srcPos++];
  13291. mask = 128;
  13292. }
  13293. dest32[destPos++] = srcByte & mask ? white : black;
  13294. mask >>= 1;
  13295. }
  13296. }
  13297. while (destPos < dest32DataLength) {
  13298. dest32[destPos++] = 0;
  13299. }
  13300. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13301. }
  13302. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  13303. j = 0;
  13304. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  13305. for (i = 0; i < fullChunks; i++) {
  13306. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  13307. srcPos += elemsInThisChunk;
  13308. ctx.putImageData(chunkImgData, 0, j);
  13309. j += FULL_CHUNK_HEIGHT;
  13310. }
  13311. if (i < totalChunks) {
  13312. elemsInThisChunk = width * partialChunkHeight * 4;
  13313. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  13314. ctx.putImageData(chunkImgData, 0, j);
  13315. }
  13316. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  13317. thisChunkHeight = FULL_CHUNK_HEIGHT;
  13318. elemsInThisChunk = width * thisChunkHeight;
  13319. for (i = 0; i < totalChunks; i++) {
  13320. if (i >= fullChunks) {
  13321. thisChunkHeight = partialChunkHeight;
  13322. elemsInThisChunk = width * thisChunkHeight;
  13323. }
  13324. destPos = 0;
  13325. for (j = elemsInThisChunk; j--;) {
  13326. dest[destPos++] = src[srcPos++];
  13327. dest[destPos++] = src[srcPos++];
  13328. dest[destPos++] = src[srcPos++];
  13329. dest[destPos++] = 255;
  13330. }
  13331. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13332. }
  13333. } else {
  13334. throw new Error("bad image kind: ".concat(imgData.kind));
  13335. }
  13336. }
  13337. function putBinaryImageMask(ctx, imgData) {
  13338. var height = imgData.height,
  13339. width = imgData.width;
  13340. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  13341. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  13342. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  13343. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  13344. var srcPos = 0;
  13345. var src = imgData.data;
  13346. var dest = chunkImgData.data;
  13347. for (var i = 0; i < totalChunks; i++) {
  13348. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  13349. var destPos = 3;
  13350. for (var j = 0; j < thisChunkHeight; j++) {
  13351. var mask = 0;
  13352. for (var k = 0; k < width; k++) {
  13353. if (!mask) {
  13354. var elem = src[srcPos++];
  13355. mask = 128;
  13356. }
  13357. dest[destPos] = elem & mask ? 0 : 255;
  13358. destPos += 4;
  13359. mask >>= 1;
  13360. }
  13361. }
  13362. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  13363. }
  13364. }
  13365. function copyCtxState(sourceCtx, destCtx) {
  13366. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  13367. for (var i = 0, ii = properties.length; i < ii; i++) {
  13368. var property = properties[i];
  13369. if (sourceCtx[property] !== undefined) {
  13370. destCtx[property] = sourceCtx[property];
  13371. }
  13372. }
  13373. if (sourceCtx.setLineDash !== undefined) {
  13374. destCtx.setLineDash(sourceCtx.getLineDash());
  13375. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  13376. }
  13377. }
  13378. function resetCtxToDefault(ctx) {
  13379. ctx.strokeStyle = '#000000';
  13380. ctx.fillStyle = '#000000';
  13381. ctx.fillRule = 'nonzero';
  13382. ctx.globalAlpha = 1;
  13383. ctx.lineWidth = 1;
  13384. ctx.lineCap = 'butt';
  13385. ctx.lineJoin = 'miter';
  13386. ctx.miterLimit = 10;
  13387. ctx.globalCompositeOperation = 'source-over';
  13388. ctx.font = '10px sans-serif';
  13389. if (ctx.setLineDash !== undefined) {
  13390. ctx.setLineDash([]);
  13391. ctx.lineDashOffset = 0;
  13392. }
  13393. }
  13394. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  13395. var length = bytes.length;
  13396. for (var i = 3; i < length; i += 4) {
  13397. var alpha = bytes[i];
  13398. if (alpha === 0) {
  13399. bytes[i - 3] = r0;
  13400. bytes[i - 2] = g0;
  13401. bytes[i - 1] = b0;
  13402. } else if (alpha < 255) {
  13403. var alpha_ = 255 - alpha;
  13404. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  13405. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  13406. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  13407. }
  13408. }
  13409. }
  13410. function composeSMaskAlpha(maskData, layerData, transferMap) {
  13411. var length = maskData.length;
  13412. var scale = 1 / 255;
  13413. for (var i = 3; i < length; i += 4) {
  13414. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  13415. layerData[i] = layerData[i] * alpha * scale | 0;
  13416. }
  13417. }
  13418. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  13419. var length = maskData.length;
  13420. for (var i = 3; i < length; i += 4) {
  13421. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  13422. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  13423. }
  13424. }
  13425. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  13426. var hasBackdrop = !!backdrop;
  13427. var r0 = hasBackdrop ? backdrop[0] : 0;
  13428. var g0 = hasBackdrop ? backdrop[1] : 0;
  13429. var b0 = hasBackdrop ? backdrop[2] : 0;
  13430. var composeFn;
  13431. if (subtype === 'Luminosity') {
  13432. composeFn = composeSMaskLuminosity;
  13433. } else {
  13434. composeFn = composeSMaskAlpha;
  13435. }
  13436. var PIXELS_TO_PROCESS = 1048576;
  13437. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  13438. for (var row = 0; row < height; row += chunkSize) {
  13439. var chunkHeight = Math.min(chunkSize, height - row);
  13440. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  13441. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  13442. if (hasBackdrop) {
  13443. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  13444. }
  13445. composeFn(maskData.data, layerData.data, transferMap);
  13446. maskCtx.putImageData(layerData, 0, row);
  13447. }
  13448. }
  13449. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  13450. var mask = smask.canvas;
  13451. var maskCtx = smask.context;
  13452. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  13453. var backdrop = smask.backdrop || null;
  13454. if (!smask.transferMap && webGLContext.isEnabled) {
  13455. var composed = webGLContext.composeSMask({
  13456. layer: layerCtx.canvas,
  13457. mask: mask,
  13458. properties: {
  13459. subtype: smask.subtype,
  13460. backdrop: backdrop
  13461. }
  13462. });
  13463. ctx.setTransform(1, 0, 0, 1, 0, 0);
  13464. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  13465. return;
  13466. }
  13467. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  13468. ctx.drawImage(mask, 0, 0);
  13469. }
  13470. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  13471. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  13472. var NORMAL_CLIP = {};
  13473. var EO_CLIP = {};
  13474. CanvasGraphics.prototype = {
  13475. beginDrawing: function beginDrawing(_ref) {
  13476. var transform = _ref.transform,
  13477. viewport = _ref.viewport,
  13478. _ref$transparency = _ref.transparency,
  13479. transparency = _ref$transparency === void 0 ? false : _ref$transparency,
  13480. _ref$background = _ref.background,
  13481. background = _ref$background === void 0 ? null : _ref$background;
  13482. var width = this.ctx.canvas.width;
  13483. var height = this.ctx.canvas.height;
  13484. this.ctx.save();
  13485. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  13486. this.ctx.fillRect(0, 0, width, height);
  13487. this.ctx.restore();
  13488. if (transparency) {
  13489. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  13490. this.compositeCtx = this.ctx;
  13491. this.transparentCanvas = transparentCanvas.canvas;
  13492. this.ctx = transparentCanvas.context;
  13493. this.ctx.save();
  13494. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  13495. }
  13496. this.ctx.save();
  13497. resetCtxToDefault(this.ctx);
  13498. if (transform) {
  13499. this.ctx.transform.apply(this.ctx, transform);
  13500. }
  13501. this.ctx.transform.apply(this.ctx, viewport.transform);
  13502. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  13503. if (this.imageLayer) {
  13504. this.imageLayer.beginLayout();
  13505. }
  13506. },
  13507. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  13508. var argsArray = operatorList.argsArray;
  13509. var fnArray = operatorList.fnArray;
  13510. var i = executionStartIdx || 0;
  13511. var argsArrayLen = argsArray.length;
  13512. if (argsArrayLen === i) {
  13513. return i;
  13514. }
  13515. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  13516. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  13517. var steps = 0;
  13518. var commonObjs = this.commonObjs;
  13519. var objs = this.objs;
  13520. var fnId;
  13521. while (true) {
  13522. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  13523. stepper.breakIt(i, continueCallback);
  13524. return i;
  13525. }
  13526. fnId = fnArray[i];
  13527. if (fnId !== _util.OPS.dependency) {
  13528. this[fnId].apply(this, argsArray[i]);
  13529. } else {
  13530. var _iteratorNormalCompletion = true;
  13531. var _didIteratorError = false;
  13532. var _iteratorError = undefined;
  13533. try {
  13534. for (var _iterator = argsArray[i][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  13535. var depObjId = _step.value;
  13536. var objsPool = depObjId.startsWith('g_') ? commonObjs : objs;
  13537. if (!objsPool.has(depObjId)) {
  13538. objsPool.get(depObjId, continueCallback);
  13539. return i;
  13540. }
  13541. }
  13542. } catch (err) {
  13543. _didIteratorError = true;
  13544. _iteratorError = err;
  13545. } finally {
  13546. try {
  13547. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  13548. _iterator["return"]();
  13549. }
  13550. } finally {
  13551. if (_didIteratorError) {
  13552. throw _iteratorError;
  13553. }
  13554. }
  13555. }
  13556. }
  13557. i++;
  13558. if (i === argsArrayLen) {
  13559. return i;
  13560. }
  13561. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  13562. if (Date.now() > endTime) {
  13563. continueCallback();
  13564. return i;
  13565. }
  13566. steps = 0;
  13567. }
  13568. }
  13569. },
  13570. endDrawing: function CanvasGraphics_endDrawing() {
  13571. if (this.current.activeSMask !== null) {
  13572. this.endSMaskGroup();
  13573. }
  13574. this.ctx.restore();
  13575. if (this.transparentCanvas) {
  13576. this.ctx = this.compositeCtx;
  13577. this.ctx.save();
  13578. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  13579. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  13580. this.ctx.restore();
  13581. this.transparentCanvas = null;
  13582. }
  13583. this.cachedCanvases.clear();
  13584. this.webGLContext.clear();
  13585. if (this.imageLayer) {
  13586. this.imageLayer.endLayout();
  13587. }
  13588. },
  13589. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  13590. this.current.lineWidth = width;
  13591. this.ctx.lineWidth = width;
  13592. },
  13593. setLineCap: function CanvasGraphics_setLineCap(style) {
  13594. this.ctx.lineCap = LINE_CAP_STYLES[style];
  13595. },
  13596. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  13597. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  13598. },
  13599. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  13600. this.ctx.miterLimit = limit;
  13601. },
  13602. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  13603. var ctx = this.ctx;
  13604. if (ctx.setLineDash !== undefined) {
  13605. ctx.setLineDash(dashArray);
  13606. ctx.lineDashOffset = dashPhase;
  13607. }
  13608. },
  13609. setRenderingIntent: function setRenderingIntent(intent) {},
  13610. setFlatness: function setFlatness(flatness) {},
  13611. setGState: function CanvasGraphics_setGState(states) {
  13612. for (var i = 0, ii = states.length; i < ii; i++) {
  13613. var state = states[i];
  13614. var key = state[0];
  13615. var value = state[1];
  13616. switch (key) {
  13617. case 'LW':
  13618. this.setLineWidth(value);
  13619. break;
  13620. case 'LC':
  13621. this.setLineCap(value);
  13622. break;
  13623. case 'LJ':
  13624. this.setLineJoin(value);
  13625. break;
  13626. case 'ML':
  13627. this.setMiterLimit(value);
  13628. break;
  13629. case 'D':
  13630. this.setDash(value[0], value[1]);
  13631. break;
  13632. case 'RI':
  13633. this.setRenderingIntent(value);
  13634. break;
  13635. case 'FL':
  13636. this.setFlatness(value);
  13637. break;
  13638. case 'Font':
  13639. this.setFont(value[0], value[1]);
  13640. break;
  13641. case 'CA':
  13642. this.current.strokeAlpha = state[1];
  13643. break;
  13644. case 'ca':
  13645. this.current.fillAlpha = state[1];
  13646. this.ctx.globalAlpha = state[1];
  13647. break;
  13648. case 'BM':
  13649. this.ctx.globalCompositeOperation = value;
  13650. break;
  13651. case 'SMask':
  13652. if (this.current.activeSMask) {
  13653. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  13654. this.suspendSMaskGroup();
  13655. } else {
  13656. this.endSMaskGroup();
  13657. }
  13658. }
  13659. this.current.activeSMask = value ? this.tempSMask : null;
  13660. if (this.current.activeSMask) {
  13661. this.beginSMaskGroup();
  13662. }
  13663. this.tempSMask = null;
  13664. break;
  13665. }
  13666. }
  13667. },
  13668. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  13669. var activeSMask = this.current.activeSMask;
  13670. var drawnWidth = activeSMask.canvas.width;
  13671. var drawnHeight = activeSMask.canvas.height;
  13672. var cacheId = 'smaskGroupAt' + this.groupLevel;
  13673. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  13674. var currentCtx = this.ctx;
  13675. var currentTransform = currentCtx.mozCurrentTransform;
  13676. this.ctx.save();
  13677. var groupCtx = scratchCanvas.context;
  13678. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  13679. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  13680. groupCtx.transform.apply(groupCtx, currentTransform);
  13681. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  13682. copyCtxState(currentCtx, groupCtx);
  13683. this.ctx = groupCtx;
  13684. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  13685. this.groupStack.push(currentCtx);
  13686. this.groupLevel++;
  13687. },
  13688. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  13689. var groupCtx = this.ctx;
  13690. this.groupLevel--;
  13691. this.ctx = this.groupStack.pop();
  13692. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  13693. this.ctx.restore();
  13694. this.ctx.save();
  13695. copyCtxState(groupCtx, this.ctx);
  13696. this.current.resumeSMaskCtx = groupCtx;
  13697. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  13698. this.ctx.transform.apply(this.ctx, deltaTransform);
  13699. groupCtx.save();
  13700. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  13701. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  13702. groupCtx.restore();
  13703. },
  13704. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  13705. var groupCtx = this.current.resumeSMaskCtx;
  13706. var currentCtx = this.ctx;
  13707. this.ctx = groupCtx;
  13708. this.groupStack.push(currentCtx);
  13709. this.groupLevel++;
  13710. },
  13711. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  13712. var groupCtx = this.ctx;
  13713. this.groupLevel--;
  13714. this.ctx = this.groupStack.pop();
  13715. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  13716. this.ctx.restore();
  13717. copyCtxState(groupCtx, this.ctx);
  13718. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  13719. this.ctx.transform.apply(this.ctx, deltaTransform);
  13720. },
  13721. save: function CanvasGraphics_save() {
  13722. this.ctx.save();
  13723. var old = this.current;
  13724. this.stateStack.push(old);
  13725. this.current = old.clone();
  13726. this.current.resumeSMaskCtx = null;
  13727. },
  13728. restore: function CanvasGraphics_restore() {
  13729. if (this.current.resumeSMaskCtx) {
  13730. this.resumeSMaskGroup();
  13731. }
  13732. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  13733. this.endSMaskGroup();
  13734. }
  13735. if (this.stateStack.length !== 0) {
  13736. this.current = this.stateStack.pop();
  13737. this.ctx.restore();
  13738. this.pendingClip = null;
  13739. this._cachedGetSinglePixelWidth = null;
  13740. }
  13741. },
  13742. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  13743. this.ctx.transform(a, b, c, d, e, f);
  13744. this._cachedGetSinglePixelWidth = null;
  13745. },
  13746. constructPath: function CanvasGraphics_constructPath(ops, args) {
  13747. var ctx = this.ctx;
  13748. var current = this.current;
  13749. var x = current.x,
  13750. y = current.y;
  13751. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  13752. switch (ops[i] | 0) {
  13753. case _util.OPS.rectangle:
  13754. x = args[j++];
  13755. y = args[j++];
  13756. var width = args[j++];
  13757. var height = args[j++];
  13758. if (width === 0) {
  13759. width = this.getSinglePixelWidth();
  13760. }
  13761. if (height === 0) {
  13762. height = this.getSinglePixelWidth();
  13763. }
  13764. var xw = x + width;
  13765. var yh = y + height;
  13766. this.ctx.moveTo(x, y);
  13767. this.ctx.lineTo(xw, y);
  13768. this.ctx.lineTo(xw, yh);
  13769. this.ctx.lineTo(x, yh);
  13770. this.ctx.lineTo(x, y);
  13771. this.ctx.closePath();
  13772. break;
  13773. case _util.OPS.moveTo:
  13774. x = args[j++];
  13775. y = args[j++];
  13776. ctx.moveTo(x, y);
  13777. break;
  13778. case _util.OPS.lineTo:
  13779. x = args[j++];
  13780. y = args[j++];
  13781. ctx.lineTo(x, y);
  13782. break;
  13783. case _util.OPS.curveTo:
  13784. x = args[j + 4];
  13785. y = args[j + 5];
  13786. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  13787. j += 6;
  13788. break;
  13789. case _util.OPS.curveTo2:
  13790. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  13791. x = args[j + 2];
  13792. y = args[j + 3];
  13793. j += 4;
  13794. break;
  13795. case _util.OPS.curveTo3:
  13796. x = args[j + 2];
  13797. y = args[j + 3];
  13798. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  13799. j += 4;
  13800. break;
  13801. case _util.OPS.closePath:
  13802. ctx.closePath();
  13803. break;
  13804. }
  13805. }
  13806. current.setCurrentPoint(x, y);
  13807. },
  13808. closePath: function CanvasGraphics_closePath() {
  13809. this.ctx.closePath();
  13810. },
  13811. stroke: function CanvasGraphics_stroke(consumePath) {
  13812. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  13813. var ctx = this.ctx;
  13814. var strokeColor = this.current.strokeColor;
  13815. ctx.globalAlpha = this.current.strokeAlpha;
  13816. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  13817. ctx.save();
  13818. var transform = ctx.mozCurrentTransform;
  13819. var scale = _util.Util.singularValueDecompose2dScale(transform)[0];
  13820. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  13821. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
  13822. ctx.stroke();
  13823. ctx.restore();
  13824. } else {
  13825. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  13826. ctx.stroke();
  13827. }
  13828. if (consumePath) {
  13829. this.consumePath();
  13830. }
  13831. ctx.globalAlpha = this.current.fillAlpha;
  13832. },
  13833. closeStroke: function CanvasGraphics_closeStroke() {
  13834. this.closePath();
  13835. this.stroke();
  13836. },
  13837. fill: function CanvasGraphics_fill(consumePath) {
  13838. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  13839. var ctx = this.ctx;
  13840. var fillColor = this.current.fillColor;
  13841. var isPatternFill = this.current.patternFill;
  13842. var needRestore = false;
  13843. if (isPatternFill) {
  13844. ctx.save();
  13845. if (this.baseTransform) {
  13846. ctx.setTransform.apply(ctx, this.baseTransform);
  13847. }
  13848. ctx.fillStyle = fillColor.getPattern(ctx, this);
  13849. needRestore = true;
  13850. }
  13851. if (this.pendingEOFill) {
  13852. ctx.fill('evenodd');
  13853. this.pendingEOFill = false;
  13854. } else {
  13855. ctx.fill();
  13856. }
  13857. if (needRestore) {
  13858. ctx.restore();
  13859. }
  13860. if (consumePath) {
  13861. this.consumePath();
  13862. }
  13863. },
  13864. eoFill: function CanvasGraphics_eoFill() {
  13865. this.pendingEOFill = true;
  13866. this.fill();
  13867. },
  13868. fillStroke: function CanvasGraphics_fillStroke() {
  13869. this.fill(false);
  13870. this.stroke(false);
  13871. this.consumePath();
  13872. },
  13873. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  13874. this.pendingEOFill = true;
  13875. this.fillStroke();
  13876. },
  13877. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  13878. this.closePath();
  13879. this.fillStroke();
  13880. },
  13881. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  13882. this.pendingEOFill = true;
  13883. this.closePath();
  13884. this.fillStroke();
  13885. },
  13886. endPath: function CanvasGraphics_endPath() {
  13887. this.consumePath();
  13888. },
  13889. clip: function CanvasGraphics_clip() {
  13890. this.pendingClip = NORMAL_CLIP;
  13891. },
  13892. eoClip: function CanvasGraphics_eoClip() {
  13893. this.pendingClip = EO_CLIP;
  13894. },
  13895. beginText: function CanvasGraphics_beginText() {
  13896. this.current.textMatrix = _util.IDENTITY_MATRIX;
  13897. this.current.textMatrixScale = 1;
  13898. this.current.x = this.current.lineX = 0;
  13899. this.current.y = this.current.lineY = 0;
  13900. },
  13901. endText: function CanvasGraphics_endText() {
  13902. var paths = this.pendingTextPaths;
  13903. var ctx = this.ctx;
  13904. if (paths === undefined) {
  13905. ctx.beginPath();
  13906. return;
  13907. }
  13908. ctx.save();
  13909. ctx.beginPath();
  13910. for (var i = 0; i < paths.length; i++) {
  13911. var path = paths[i];
  13912. ctx.setTransform.apply(ctx, path.transform);
  13913. ctx.translate(path.x, path.y);
  13914. path.addToPath(ctx, path.fontSize);
  13915. }
  13916. ctx.restore();
  13917. ctx.clip();
  13918. ctx.beginPath();
  13919. delete this.pendingTextPaths;
  13920. },
  13921. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  13922. this.current.charSpacing = spacing;
  13923. },
  13924. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  13925. this.current.wordSpacing = spacing;
  13926. },
  13927. setHScale: function CanvasGraphics_setHScale(scale) {
  13928. this.current.textHScale = scale / 100;
  13929. },
  13930. setLeading: function CanvasGraphics_setLeading(leading) {
  13931. this.current.leading = -leading;
  13932. },
  13933. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  13934. var fontObj = this.commonObjs.get(fontRefName);
  13935. var current = this.current;
  13936. if (!fontObj) {
  13937. throw new Error("Can't find font for ".concat(fontRefName));
  13938. }
  13939. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  13940. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  13941. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  13942. }
  13943. if (size < 0) {
  13944. size = -size;
  13945. current.fontDirection = -1;
  13946. } else {
  13947. current.fontDirection = 1;
  13948. }
  13949. this.current.font = fontObj;
  13950. this.current.fontSize = size;
  13951. if (fontObj.isType3Font) {
  13952. return;
  13953. }
  13954. var name = fontObj.loadedName || 'sans-serif';
  13955. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  13956. var italic = fontObj.italic ? 'italic' : 'normal';
  13957. var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
  13958. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  13959. this.current.fontSizeScale = size / browserFontSize;
  13960. this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
  13961. },
  13962. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  13963. this.current.textRenderingMode = mode;
  13964. },
  13965. setTextRise: function CanvasGraphics_setTextRise(rise) {
  13966. this.current.textRise = rise;
  13967. },
  13968. moveText: function CanvasGraphics_moveText(x, y) {
  13969. this.current.x = this.current.lineX += x;
  13970. this.current.y = this.current.lineY += y;
  13971. },
  13972. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  13973. this.setLeading(-y);
  13974. this.moveText(x, y);
  13975. },
  13976. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  13977. this.current.textMatrix = [a, b, c, d, e, f];
  13978. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  13979. this.current.x = this.current.lineX = 0;
  13980. this.current.y = this.current.lineY = 0;
  13981. },
  13982. nextLine: function CanvasGraphics_nextLine() {
  13983. this.moveText(0, this.current.leading);
  13984. },
  13985. paintChar: function paintChar(character, x, y, patternTransform) {
  13986. var ctx = this.ctx;
  13987. var current = this.current;
  13988. var font = current.font;
  13989. var textRenderingMode = current.textRenderingMode;
  13990. var fontSize = current.fontSize / current.fontSizeScale;
  13991. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  13992. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  13993. var patternFill = current.patternFill && font.data;
  13994. var addToPath;
  13995. if (font.disableFontFace || isAddToPathSet || patternFill) {
  13996. addToPath = font.getPathGenerator(this.commonObjs, character);
  13997. }
  13998. if (font.disableFontFace || patternFill) {
  13999. ctx.save();
  14000. ctx.translate(x, y);
  14001. ctx.beginPath();
  14002. addToPath(ctx, fontSize);
  14003. if (patternTransform) {
  14004. ctx.setTransform.apply(ctx, patternTransform);
  14005. }
  14006. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14007. ctx.fill();
  14008. }
  14009. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14010. ctx.stroke();
  14011. }
  14012. ctx.restore();
  14013. } else {
  14014. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14015. ctx.fillText(character, x, y);
  14016. }
  14017. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14018. ctx.strokeText(character, x, y);
  14019. }
  14020. }
  14021. if (isAddToPathSet) {
  14022. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  14023. paths.push({
  14024. transform: ctx.mozCurrentTransform,
  14025. x: x,
  14026. y: y,
  14027. fontSize: fontSize,
  14028. addToPath: addToPath
  14029. });
  14030. }
  14031. },
  14032. get isFontSubpixelAAEnabled() {
  14033. var _this$cachedCanvases$ = this.cachedCanvases.getCanvas('isFontSubpixelAAEnabled', 10, 10),
  14034. ctx = _this$cachedCanvases$.context;
  14035. ctx.scale(1.5, 1);
  14036. ctx.fillText('I', 0, 10);
  14037. var data = ctx.getImageData(0, 0, 10, 10).data;
  14038. var enabled = false;
  14039. for (var i = 3; i < data.length; i += 4) {
  14040. if (data[i] > 0 && data[i] < 255) {
  14041. enabled = true;
  14042. break;
  14043. }
  14044. }
  14045. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  14046. },
  14047. showText: function CanvasGraphics_showText(glyphs) {
  14048. var current = this.current;
  14049. var font = current.font;
  14050. if (font.isType3Font) {
  14051. return this.showType3Text(glyphs);
  14052. }
  14053. var fontSize = current.fontSize;
  14054. if (fontSize === 0) {
  14055. return undefined;
  14056. }
  14057. var ctx = this.ctx;
  14058. var fontSizeScale = current.fontSizeScale;
  14059. var charSpacing = current.charSpacing;
  14060. var wordSpacing = current.wordSpacing;
  14061. var fontDirection = current.fontDirection;
  14062. var textHScale = current.textHScale * fontDirection;
  14063. var glyphsLength = glyphs.length;
  14064. var vertical = font.vertical;
  14065. var spacingDir = vertical ? 1 : -1;
  14066. var defaultVMetrics = font.defaultVMetrics;
  14067. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  14068. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  14069. ctx.save();
  14070. var patternTransform;
  14071. if (current.patternFill) {
  14072. ctx.save();
  14073. var pattern = current.fillColor.getPattern(ctx, this);
  14074. patternTransform = ctx.mozCurrentTransform;
  14075. ctx.restore();
  14076. ctx.fillStyle = pattern;
  14077. }
  14078. ctx.transform.apply(ctx, current.textMatrix);
  14079. ctx.translate(current.x, current.y + current.textRise);
  14080. if (fontDirection > 0) {
  14081. ctx.scale(textHScale, -1);
  14082. } else {
  14083. ctx.scale(textHScale, 1);
  14084. }
  14085. var lineWidth = current.lineWidth;
  14086. var scale = current.textMatrixScale;
  14087. if (scale === 0 || lineWidth === 0) {
  14088. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  14089. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  14090. this._cachedGetSinglePixelWidth = null;
  14091. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  14092. }
  14093. } else {
  14094. lineWidth /= scale;
  14095. }
  14096. if (fontSizeScale !== 1.0) {
  14097. ctx.scale(fontSizeScale, fontSizeScale);
  14098. lineWidth /= fontSizeScale;
  14099. }
  14100. ctx.lineWidth = lineWidth;
  14101. var x = 0,
  14102. i;
  14103. for (i = 0; i < glyphsLength; ++i) {
  14104. var glyph = glyphs[i];
  14105. if ((0, _util.isNum)(glyph)) {
  14106. x += spacingDir * glyph * fontSize / 1000;
  14107. continue;
  14108. }
  14109. var restoreNeeded = false;
  14110. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  14111. var character = glyph.fontChar;
  14112. var accent = glyph.accent;
  14113. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  14114. var width = glyph.width;
  14115. if (vertical) {
  14116. var vmetric, vx, vy;
  14117. vmetric = glyph.vmetric || defaultVMetrics;
  14118. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  14119. vx = -vx * widthAdvanceScale;
  14120. vy = vmetric[2] * widthAdvanceScale;
  14121. width = vmetric ? -vmetric[0] : width;
  14122. scaledX = vx / fontSizeScale;
  14123. scaledY = (x + vy) / fontSizeScale;
  14124. } else {
  14125. scaledX = x / fontSizeScale;
  14126. scaledY = 0;
  14127. }
  14128. if (font.remeasure && width > 0) {
  14129. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  14130. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  14131. var characterScaleX = width / measuredWidth;
  14132. restoreNeeded = true;
  14133. ctx.save();
  14134. ctx.scale(characterScaleX, 1);
  14135. scaledX /= characterScaleX;
  14136. } else if (width !== measuredWidth) {
  14137. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  14138. }
  14139. }
  14140. if (glyph.isInFont || font.missingFile) {
  14141. if (simpleFillText && !accent) {
  14142. ctx.fillText(character, scaledX, scaledY);
  14143. } else {
  14144. this.paintChar(character, scaledX, scaledY, patternTransform);
  14145. if (accent) {
  14146. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  14147. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  14148. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  14149. }
  14150. }
  14151. }
  14152. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  14153. x += charWidth;
  14154. if (restoreNeeded) {
  14155. ctx.restore();
  14156. }
  14157. }
  14158. if (vertical) {
  14159. current.y -= x * textHScale;
  14160. } else {
  14161. current.x += x * textHScale;
  14162. }
  14163. ctx.restore();
  14164. },
  14165. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  14166. var ctx = this.ctx;
  14167. var current = this.current;
  14168. var font = current.font;
  14169. var fontSize = current.fontSize;
  14170. var fontDirection = current.fontDirection;
  14171. var spacingDir = font.vertical ? 1 : -1;
  14172. var charSpacing = current.charSpacing;
  14173. var wordSpacing = current.wordSpacing;
  14174. var textHScale = current.textHScale * fontDirection;
  14175. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  14176. var glyphsLength = glyphs.length;
  14177. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  14178. var i, glyph, width, spacingLength;
  14179. if (isTextInvisible || fontSize === 0) {
  14180. return;
  14181. }
  14182. this._cachedGetSinglePixelWidth = null;
  14183. ctx.save();
  14184. ctx.transform.apply(ctx, current.textMatrix);
  14185. ctx.translate(current.x, current.y);
  14186. ctx.scale(textHScale, fontDirection);
  14187. for (i = 0; i < glyphsLength; ++i) {
  14188. glyph = glyphs[i];
  14189. if ((0, _util.isNum)(glyph)) {
  14190. spacingLength = spacingDir * glyph * fontSize / 1000;
  14191. this.ctx.translate(spacingLength, 0);
  14192. current.x += spacingLength * textHScale;
  14193. continue;
  14194. }
  14195. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  14196. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  14197. if (!operatorList) {
  14198. (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
  14199. continue;
  14200. }
  14201. this.processingType3 = glyph;
  14202. this.save();
  14203. ctx.scale(fontSize, fontSize);
  14204. ctx.transform.apply(ctx, fontMatrix);
  14205. this.executeOperatorList(operatorList);
  14206. this.restore();
  14207. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  14208. width = transformed[0] * fontSize + spacing;
  14209. ctx.translate(width, 0);
  14210. current.x += width * textHScale;
  14211. }
  14212. ctx.restore();
  14213. this.processingType3 = null;
  14214. },
  14215. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  14216. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  14217. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  14218. this.clip();
  14219. this.endPath();
  14220. },
  14221. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  14222. var _this = this;
  14223. var pattern;
  14224. if (IR[0] === 'TilingPattern') {
  14225. var color = IR[1];
  14226. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  14227. var canvasGraphicsFactory = {
  14228. createCanvasGraphics: function createCanvasGraphics(ctx) {
  14229. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  14230. }
  14231. };
  14232. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  14233. } else {
  14234. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  14235. }
  14236. return pattern;
  14237. },
  14238. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  14239. this.current.strokeColor = this.getColorN_Pattern(arguments);
  14240. },
  14241. setFillColorN: function CanvasGraphics_setFillColorN() {
  14242. this.current.fillColor = this.getColorN_Pattern(arguments);
  14243. this.current.patternFill = true;
  14244. },
  14245. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  14246. var color = _util.Util.makeCssRgb(r, g, b);
  14247. this.ctx.strokeStyle = color;
  14248. this.current.strokeColor = color;
  14249. },
  14250. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  14251. var color = _util.Util.makeCssRgb(r, g, b);
  14252. this.ctx.fillStyle = color;
  14253. this.current.fillColor = color;
  14254. this.current.patternFill = false;
  14255. },
  14256. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  14257. var ctx = this.ctx;
  14258. this.save();
  14259. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  14260. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  14261. var inv = ctx.mozCurrentTransformInverse;
  14262. if (inv) {
  14263. var canvas = ctx.canvas;
  14264. var width = canvas.width;
  14265. var height = canvas.height;
  14266. var bl = _util.Util.applyTransform([0, 0], inv);
  14267. var br = _util.Util.applyTransform([0, height], inv);
  14268. var ul = _util.Util.applyTransform([width, 0], inv);
  14269. var ur = _util.Util.applyTransform([width, height], inv);
  14270. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  14271. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  14272. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  14273. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  14274. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  14275. } else {
  14276. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  14277. }
  14278. this.restore();
  14279. },
  14280. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  14281. (0, _util.unreachable)('Should not call beginInlineImage');
  14282. },
  14283. beginImageData: function CanvasGraphics_beginImageData() {
  14284. (0, _util.unreachable)('Should not call beginImageData');
  14285. },
  14286. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  14287. this.save();
  14288. this.baseTransformStack.push(this.baseTransform);
  14289. if (Array.isArray(matrix) && matrix.length === 6) {
  14290. this.transform.apply(this, matrix);
  14291. }
  14292. this.baseTransform = this.ctx.mozCurrentTransform;
  14293. if (bbox) {
  14294. var width = bbox[2] - bbox[0];
  14295. var height = bbox[3] - bbox[1];
  14296. this.ctx.rect(bbox[0], bbox[1], width, height);
  14297. this.clip();
  14298. this.endPath();
  14299. }
  14300. },
  14301. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  14302. this.restore();
  14303. this.baseTransform = this.baseTransformStack.pop();
  14304. },
  14305. beginGroup: function CanvasGraphics_beginGroup(group) {
  14306. this.save();
  14307. var currentCtx = this.ctx;
  14308. if (!group.isolated) {
  14309. (0, _util.info)('TODO: Support non-isolated groups.');
  14310. }
  14311. if (group.knockout) {
  14312. (0, _util.warn)('Knockout groups not supported.');
  14313. }
  14314. var currentTransform = currentCtx.mozCurrentTransform;
  14315. if (group.matrix) {
  14316. currentCtx.transform.apply(currentCtx, group.matrix);
  14317. }
  14318. if (!group.bbox) {
  14319. throw new Error('Bounding box is required.');
  14320. }
  14321. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  14322. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  14323. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  14324. var offsetX = Math.floor(bounds[0]);
  14325. var offsetY = Math.floor(bounds[1]);
  14326. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  14327. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  14328. var scaleX = 1,
  14329. scaleY = 1;
  14330. if (drawnWidth > MAX_GROUP_SIZE) {
  14331. scaleX = drawnWidth / MAX_GROUP_SIZE;
  14332. drawnWidth = MAX_GROUP_SIZE;
  14333. }
  14334. if (drawnHeight > MAX_GROUP_SIZE) {
  14335. scaleY = drawnHeight / MAX_GROUP_SIZE;
  14336. drawnHeight = MAX_GROUP_SIZE;
  14337. }
  14338. var cacheId = 'groupAt' + this.groupLevel;
  14339. if (group.smask) {
  14340. cacheId += '_smask_' + this.smaskCounter++ % 2;
  14341. }
  14342. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  14343. var groupCtx = scratchCanvas.context;
  14344. groupCtx.scale(1 / scaleX, 1 / scaleY);
  14345. groupCtx.translate(-offsetX, -offsetY);
  14346. groupCtx.transform.apply(groupCtx, currentTransform);
  14347. if (group.smask) {
  14348. this.smaskStack.push({
  14349. canvas: scratchCanvas.canvas,
  14350. context: groupCtx,
  14351. offsetX: offsetX,
  14352. offsetY: offsetY,
  14353. scaleX: scaleX,
  14354. scaleY: scaleY,
  14355. subtype: group.smask.subtype,
  14356. backdrop: group.smask.backdrop,
  14357. transferMap: group.smask.transferMap || null,
  14358. startTransformInverse: null
  14359. });
  14360. } else {
  14361. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  14362. currentCtx.translate(offsetX, offsetY);
  14363. currentCtx.scale(scaleX, scaleY);
  14364. }
  14365. copyCtxState(currentCtx, groupCtx);
  14366. this.ctx = groupCtx;
  14367. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  14368. this.groupStack.push(currentCtx);
  14369. this.groupLevel++;
  14370. this.current.activeSMask = null;
  14371. },
  14372. endGroup: function CanvasGraphics_endGroup(group) {
  14373. this.groupLevel--;
  14374. var groupCtx = this.ctx;
  14375. this.ctx = this.groupStack.pop();
  14376. if (this.ctx.imageSmoothingEnabled !== undefined) {
  14377. this.ctx.imageSmoothingEnabled = false;
  14378. } else {
  14379. this.ctx.mozImageSmoothingEnabled = false;
  14380. }
  14381. if (group.smask) {
  14382. this.tempSMask = this.smaskStack.pop();
  14383. } else {
  14384. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  14385. }
  14386. this.restore();
  14387. },
  14388. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  14389. this.save();
  14390. if (this.baseTransform) {
  14391. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  14392. }
  14393. },
  14394. endAnnotations: function CanvasGraphics_endAnnotations() {
  14395. this.restore();
  14396. },
  14397. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  14398. this.save();
  14399. resetCtxToDefault(this.ctx);
  14400. this.current = new CanvasExtraState();
  14401. if (Array.isArray(rect) && rect.length === 4) {
  14402. var width = rect[2] - rect[0];
  14403. var height = rect[3] - rect[1];
  14404. this.ctx.rect(rect[0], rect[1], width, height);
  14405. this.clip();
  14406. this.endPath();
  14407. }
  14408. this.transform.apply(this, transform);
  14409. this.transform.apply(this, matrix);
  14410. },
  14411. endAnnotation: function CanvasGraphics_endAnnotation() {
  14412. this.restore();
  14413. },
  14414. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  14415. var domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  14416. if (!domImage) {
  14417. (0, _util.warn)('Dependent image isn\'t ready yet');
  14418. return;
  14419. }
  14420. this.save();
  14421. var ctx = this.ctx;
  14422. ctx.scale(1 / w, -1 / h);
  14423. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  14424. if (this.imageLayer) {
  14425. var currentTransform = ctx.mozCurrentTransformInverse;
  14426. var position = this.getCanvasPosition(0, 0);
  14427. this.imageLayer.appendImage({
  14428. objId: objId,
  14429. left: position[0],
  14430. top: position[1],
  14431. width: w / currentTransform[0],
  14432. height: h / currentTransform[3]
  14433. });
  14434. }
  14435. this.restore();
  14436. },
  14437. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  14438. var ctx = this.ctx;
  14439. var width = img.width,
  14440. height = img.height;
  14441. var fillColor = this.current.fillColor;
  14442. var isPatternFill = this.current.patternFill;
  14443. var glyph = this.processingType3;
  14444. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  14445. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  14446. glyph.compiled = compileType3Glyph({
  14447. data: img.data,
  14448. width: width,
  14449. height: height
  14450. });
  14451. } else {
  14452. glyph.compiled = null;
  14453. }
  14454. }
  14455. if (glyph && glyph.compiled) {
  14456. glyph.compiled(ctx);
  14457. return;
  14458. }
  14459. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  14460. var maskCtx = maskCanvas.context;
  14461. maskCtx.save();
  14462. putBinaryImageMask(maskCtx, img);
  14463. maskCtx.globalCompositeOperation = 'source-in';
  14464. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14465. maskCtx.fillRect(0, 0, width, height);
  14466. maskCtx.restore();
  14467. this.paintInlineImageXObject(maskCanvas.canvas);
  14468. },
  14469. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  14470. var width = imgData.width;
  14471. var height = imgData.height;
  14472. var fillColor = this.current.fillColor;
  14473. var isPatternFill = this.current.patternFill;
  14474. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  14475. var maskCtx = maskCanvas.context;
  14476. maskCtx.save();
  14477. putBinaryImageMask(maskCtx, imgData);
  14478. maskCtx.globalCompositeOperation = 'source-in';
  14479. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14480. maskCtx.fillRect(0, 0, width, height);
  14481. maskCtx.restore();
  14482. var ctx = this.ctx;
  14483. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  14484. ctx.save();
  14485. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  14486. ctx.scale(1, -1);
  14487. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  14488. ctx.restore();
  14489. }
  14490. },
  14491. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  14492. var ctx = this.ctx;
  14493. var fillColor = this.current.fillColor;
  14494. var isPatternFill = this.current.patternFill;
  14495. for (var i = 0, ii = images.length; i < ii; i++) {
  14496. var image = images[i];
  14497. var width = image.width,
  14498. height = image.height;
  14499. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  14500. var maskCtx = maskCanvas.context;
  14501. maskCtx.save();
  14502. putBinaryImageMask(maskCtx, image);
  14503. maskCtx.globalCompositeOperation = 'source-in';
  14504. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  14505. maskCtx.fillRect(0, 0, width, height);
  14506. maskCtx.restore();
  14507. ctx.save();
  14508. ctx.transform.apply(ctx, image.transform);
  14509. ctx.scale(1, -1);
  14510. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  14511. ctx.restore();
  14512. }
  14513. },
  14514. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  14515. var imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  14516. if (!imgData) {
  14517. (0, _util.warn)('Dependent image isn\'t ready yet');
  14518. return;
  14519. }
  14520. this.paintInlineImageXObject(imgData);
  14521. },
  14522. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  14523. var imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
  14524. if (!imgData) {
  14525. (0, _util.warn)('Dependent image isn\'t ready yet');
  14526. return;
  14527. }
  14528. var width = imgData.width;
  14529. var height = imgData.height;
  14530. var map = [];
  14531. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  14532. map.push({
  14533. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  14534. x: 0,
  14535. y: 0,
  14536. w: width,
  14537. h: height
  14538. });
  14539. }
  14540. this.paintInlineImageXObjectGroup(imgData, map);
  14541. },
  14542. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  14543. var width = imgData.width;
  14544. var height = imgData.height;
  14545. var ctx = this.ctx;
  14546. this.save();
  14547. ctx.scale(1 / width, -1 / height);
  14548. var currentTransform = ctx.mozCurrentTransformInverse;
  14549. var a = currentTransform[0],
  14550. b = currentTransform[1];
  14551. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  14552. var c = currentTransform[2],
  14553. d = currentTransform[3];
  14554. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  14555. var imgToPaint, tmpCanvas;
  14556. if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
  14557. imgToPaint = imgData;
  14558. } else {
  14559. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  14560. var tmpCtx = tmpCanvas.context;
  14561. putBinaryImageData(tmpCtx, imgData);
  14562. imgToPaint = tmpCanvas.canvas;
  14563. }
  14564. var paintWidth = width,
  14565. paintHeight = height;
  14566. var tmpCanvasId = 'prescale1';
  14567. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  14568. var newWidth = paintWidth,
  14569. newHeight = paintHeight;
  14570. if (widthScale > 2 && paintWidth > 1) {
  14571. newWidth = Math.ceil(paintWidth / 2);
  14572. widthScale /= paintWidth / newWidth;
  14573. }
  14574. if (heightScale > 2 && paintHeight > 1) {
  14575. newHeight = Math.ceil(paintHeight / 2);
  14576. heightScale /= paintHeight / newHeight;
  14577. }
  14578. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  14579. tmpCtx = tmpCanvas.context;
  14580. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  14581. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  14582. imgToPaint = tmpCanvas.canvas;
  14583. paintWidth = newWidth;
  14584. paintHeight = newHeight;
  14585. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  14586. }
  14587. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  14588. if (this.imageLayer) {
  14589. var position = this.getCanvasPosition(0, -height);
  14590. this.imageLayer.appendImage({
  14591. imgData: imgData,
  14592. left: position[0],
  14593. top: position[1],
  14594. width: width / currentTransform[0],
  14595. height: height / currentTransform[3]
  14596. });
  14597. }
  14598. this.restore();
  14599. },
  14600. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  14601. var ctx = this.ctx;
  14602. var w = imgData.width;
  14603. var h = imgData.height;
  14604. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  14605. var tmpCtx = tmpCanvas.context;
  14606. putBinaryImageData(tmpCtx, imgData);
  14607. for (var i = 0, ii = map.length; i < ii; i++) {
  14608. var entry = map[i];
  14609. ctx.save();
  14610. ctx.transform.apply(ctx, entry.transform);
  14611. ctx.scale(1, -1);
  14612. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  14613. if (this.imageLayer) {
  14614. var position = this.getCanvasPosition(entry.x, entry.y);
  14615. this.imageLayer.appendImage({
  14616. imgData: imgData,
  14617. left: position[0],
  14618. top: position[1],
  14619. width: w,
  14620. height: h
  14621. });
  14622. }
  14623. ctx.restore();
  14624. }
  14625. },
  14626. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  14627. this.ctx.fillRect(0, 0, 1, 1);
  14628. },
  14629. paintXObject: function CanvasGraphics_paintXObject() {
  14630. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  14631. },
  14632. markPoint: function CanvasGraphics_markPoint(tag) {},
  14633. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  14634. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  14635. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  14636. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  14637. beginCompat: function CanvasGraphics_beginCompat() {},
  14638. endCompat: function CanvasGraphics_endCompat() {},
  14639. consumePath: function CanvasGraphics_consumePath() {
  14640. var ctx = this.ctx;
  14641. if (this.pendingClip) {
  14642. if (this.pendingClip === EO_CLIP) {
  14643. ctx.clip('evenodd');
  14644. } else {
  14645. ctx.clip();
  14646. }
  14647. this.pendingClip = null;
  14648. }
  14649. ctx.beginPath();
  14650. },
  14651. getSinglePixelWidth: function getSinglePixelWidth(scale) {
  14652. if (this._cachedGetSinglePixelWidth === null) {
  14653. var inverse = this.ctx.mozCurrentTransformInverse;
  14654. this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  14655. }
  14656. return this._cachedGetSinglePixelWidth;
  14657. },
  14658. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  14659. var transform = this.ctx.mozCurrentTransform;
  14660. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  14661. }
  14662. };
  14663. for (var op in _util.OPS) {
  14664. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  14665. }
  14666. return CanvasGraphics;
  14667. }();
  14668. exports.CanvasGraphics = CanvasGraphics;
  14669. /***/ }),
  14670. /* 187 */
  14671. /***/ (function(module, exports, __w_pdfjs_require__) {
  14672. "use strict";
  14673. Object.defineProperty(exports, "__esModule", {
  14674. value: true
  14675. });
  14676. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  14677. exports.TilingPattern = void 0;
  14678. var _util = __w_pdfjs_require__(1);
  14679. var ShadingIRs = {};
  14680. function applyBoundingBox(ctx, bbox) {
  14681. if (!bbox || typeof Path2D === 'undefined') {
  14682. return;
  14683. }
  14684. var width = bbox[2] - bbox[0];
  14685. var height = bbox[3] - bbox[1];
  14686. var region = new Path2D();
  14687. region.rect(bbox[0], bbox[1], width, height);
  14688. ctx.clip(region);
  14689. }
  14690. ShadingIRs.RadialAxial = {
  14691. fromIR: function RadialAxial_fromIR(raw) {
  14692. var type = raw[1];
  14693. var bbox = raw[2];
  14694. var colorStops = raw[3];
  14695. var p0 = raw[4];
  14696. var p1 = raw[5];
  14697. var r0 = raw[6];
  14698. var r1 = raw[7];
  14699. return {
  14700. type: 'Pattern',
  14701. getPattern: function RadialAxial_getPattern(ctx) {
  14702. applyBoundingBox(ctx, bbox);
  14703. var grad;
  14704. if (type === 'axial') {
  14705. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  14706. } else if (type === 'radial') {
  14707. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  14708. }
  14709. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  14710. var c = colorStops[i];
  14711. grad.addColorStop(c[0], c[1]);
  14712. }
  14713. return grad;
  14714. }
  14715. };
  14716. }
  14717. };
  14718. var createMeshCanvas = function createMeshCanvasClosure() {
  14719. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  14720. var coords = context.coords,
  14721. colors = context.colors;
  14722. var bytes = data.data,
  14723. rowSize = data.width * 4;
  14724. var tmp;
  14725. if (coords[p1 + 1] > coords[p2 + 1]) {
  14726. tmp = p1;
  14727. p1 = p2;
  14728. p2 = tmp;
  14729. tmp = c1;
  14730. c1 = c2;
  14731. c2 = tmp;
  14732. }
  14733. if (coords[p2 + 1] > coords[p3 + 1]) {
  14734. tmp = p2;
  14735. p2 = p3;
  14736. p3 = tmp;
  14737. tmp = c2;
  14738. c2 = c3;
  14739. c3 = tmp;
  14740. }
  14741. if (coords[p1 + 1] > coords[p2 + 1]) {
  14742. tmp = p1;
  14743. p1 = p2;
  14744. p2 = tmp;
  14745. tmp = c1;
  14746. c1 = c2;
  14747. c2 = tmp;
  14748. }
  14749. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  14750. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  14751. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  14752. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  14753. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  14754. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  14755. if (y1 >= y3) {
  14756. return;
  14757. }
  14758. var c1r = colors[c1],
  14759. c1g = colors[c1 + 1],
  14760. c1b = colors[c1 + 2];
  14761. var c2r = colors[c2],
  14762. c2g = colors[c2 + 1],
  14763. c2b = colors[c2 + 2];
  14764. var c3r = colors[c3],
  14765. c3g = colors[c3 + 1],
  14766. c3b = colors[c3 + 2];
  14767. var minY = Math.round(y1),
  14768. maxY = Math.round(y3);
  14769. var xa, car, cag, cab;
  14770. var xb, cbr, cbg, cbb;
  14771. var k;
  14772. for (var y = minY; y <= maxY; y++) {
  14773. if (y < y2) {
  14774. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  14775. xa = x1 - (x1 - x2) * k;
  14776. car = c1r - (c1r - c2r) * k;
  14777. cag = c1g - (c1g - c2g) * k;
  14778. cab = c1b - (c1b - c2b) * k;
  14779. } else {
  14780. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  14781. xa = x2 - (x2 - x3) * k;
  14782. car = c2r - (c2r - c3r) * k;
  14783. cag = c2g - (c2g - c3g) * k;
  14784. cab = c2b - (c2b - c3b) * k;
  14785. }
  14786. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  14787. xb = x1 - (x1 - x3) * k;
  14788. cbr = c1r - (c1r - c3r) * k;
  14789. cbg = c1g - (c1g - c3g) * k;
  14790. cbb = c1b - (c1b - c3b) * k;
  14791. var x1_ = Math.round(Math.min(xa, xb));
  14792. var x2_ = Math.round(Math.max(xa, xb));
  14793. var j = rowSize * y + x1_ * 4;
  14794. for (var x = x1_; x <= x2_; x++) {
  14795. k = (xa - x) / (xa - xb);
  14796. k = k < 0 ? 0 : k > 1 ? 1 : k;
  14797. bytes[j++] = car - (car - cbr) * k | 0;
  14798. bytes[j++] = cag - (cag - cbg) * k | 0;
  14799. bytes[j++] = cab - (cab - cbb) * k | 0;
  14800. bytes[j++] = 255;
  14801. }
  14802. }
  14803. }
  14804. function drawFigure(data, figure, context) {
  14805. var ps = figure.coords;
  14806. var cs = figure.colors;
  14807. var i, ii;
  14808. switch (figure.type) {
  14809. case 'lattice':
  14810. var verticesPerRow = figure.verticesPerRow;
  14811. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  14812. var cols = verticesPerRow - 1;
  14813. for (i = 0; i < rows; i++) {
  14814. var q = i * verticesPerRow;
  14815. for (var j = 0; j < cols; j++, q++) {
  14816. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  14817. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  14818. }
  14819. }
  14820. break;
  14821. case 'triangles':
  14822. for (i = 0, ii = ps.length; i < ii; i += 3) {
  14823. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  14824. }
  14825. break;
  14826. default:
  14827. throw new Error('illegal figure');
  14828. }
  14829. }
  14830. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  14831. var EXPECTED_SCALE = 1.1;
  14832. var MAX_PATTERN_SIZE = 3000;
  14833. var BORDER_SIZE = 2;
  14834. var offsetX = Math.floor(bounds[0]);
  14835. var offsetY = Math.floor(bounds[1]);
  14836. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  14837. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  14838. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  14839. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  14840. var scaleX = boundsWidth / width;
  14841. var scaleY = boundsHeight / height;
  14842. var context = {
  14843. coords: coords,
  14844. colors: colors,
  14845. offsetX: -offsetX,
  14846. offsetY: -offsetY,
  14847. scaleX: 1 / scaleX,
  14848. scaleY: 1 / scaleY
  14849. };
  14850. var paddedWidth = width + BORDER_SIZE * 2;
  14851. var paddedHeight = height + BORDER_SIZE * 2;
  14852. var canvas, tmpCanvas, i, ii;
  14853. if (webGLContext.isEnabled) {
  14854. canvas = webGLContext.drawFigures({
  14855. width: width,
  14856. height: height,
  14857. backgroundColor: backgroundColor,
  14858. figures: figures,
  14859. context: context
  14860. });
  14861. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  14862. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  14863. canvas = tmpCanvas.canvas;
  14864. } else {
  14865. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  14866. var tmpCtx = tmpCanvas.context;
  14867. var data = tmpCtx.createImageData(width, height);
  14868. if (backgroundColor) {
  14869. var bytes = data.data;
  14870. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  14871. bytes[i] = backgroundColor[0];
  14872. bytes[i + 1] = backgroundColor[1];
  14873. bytes[i + 2] = backgroundColor[2];
  14874. bytes[i + 3] = 255;
  14875. }
  14876. }
  14877. for (i = 0; i < figures.length; i++) {
  14878. drawFigure(data, figures[i], context);
  14879. }
  14880. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  14881. canvas = tmpCanvas.canvas;
  14882. }
  14883. return {
  14884. canvas: canvas,
  14885. offsetX: offsetX - BORDER_SIZE * scaleX,
  14886. offsetY: offsetY - BORDER_SIZE * scaleY,
  14887. scaleX: scaleX,
  14888. scaleY: scaleY
  14889. };
  14890. }
  14891. return createMeshCanvas;
  14892. }();
  14893. ShadingIRs.Mesh = {
  14894. fromIR: function Mesh_fromIR(raw) {
  14895. var coords = raw[2];
  14896. var colors = raw[3];
  14897. var figures = raw[4];
  14898. var bounds = raw[5];
  14899. var matrix = raw[6];
  14900. var bbox = raw[7];
  14901. var background = raw[8];
  14902. return {
  14903. type: 'Pattern',
  14904. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  14905. applyBoundingBox(ctx, bbox);
  14906. var scale;
  14907. if (shadingFill) {
  14908. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  14909. } else {
  14910. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  14911. if (matrix) {
  14912. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  14913. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  14914. }
  14915. }
  14916. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  14917. if (!shadingFill) {
  14918. ctx.setTransform.apply(ctx, owner.baseTransform);
  14919. if (matrix) {
  14920. ctx.transform.apply(ctx, matrix);
  14921. }
  14922. }
  14923. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  14924. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  14925. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  14926. }
  14927. };
  14928. }
  14929. };
  14930. ShadingIRs.Dummy = {
  14931. fromIR: function Dummy_fromIR() {
  14932. return {
  14933. type: 'Pattern',
  14934. getPattern: function Dummy_fromIR_getPattern() {
  14935. return 'hotpink';
  14936. }
  14937. };
  14938. }
  14939. };
  14940. function getShadingPatternFromIR(raw) {
  14941. var shadingIR = ShadingIRs[raw[0]];
  14942. if (!shadingIR) {
  14943. throw new Error("Unknown IR type: ".concat(raw[0]));
  14944. }
  14945. return shadingIR.fromIR(raw);
  14946. }
  14947. var TilingPattern = function TilingPatternClosure() {
  14948. var PaintType = {
  14949. COLORED: 1,
  14950. UNCOLORED: 2
  14951. };
  14952. var MAX_PATTERN_SIZE = 3000;
  14953. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  14954. this.operatorList = IR[2];
  14955. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  14956. this.bbox = IR[4];
  14957. this.xstep = IR[5];
  14958. this.ystep = IR[6];
  14959. this.paintType = IR[7];
  14960. this.tilingType = IR[8];
  14961. this.color = color;
  14962. this.canvasGraphicsFactory = canvasGraphicsFactory;
  14963. this.baseTransform = baseTransform;
  14964. this.type = 'Pattern';
  14965. this.ctx = ctx;
  14966. }
  14967. TilingPattern.prototype = {
  14968. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  14969. var operatorList = this.operatorList;
  14970. var bbox = this.bbox;
  14971. var xstep = this.xstep;
  14972. var ystep = this.ystep;
  14973. var paintType = this.paintType;
  14974. var tilingType = this.tilingType;
  14975. var color = this.color;
  14976. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  14977. (0, _util.info)('TilingType: ' + tilingType);
  14978. var x0 = bbox[0],
  14979. y0 = bbox[1],
  14980. x1 = bbox[2],
  14981. y1 = bbox[3];
  14982. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  14983. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  14984. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  14985. var dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  14986. var dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  14987. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', dimx.size, dimy.size, true);
  14988. var tmpCtx = tmpCanvas.context;
  14989. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  14990. graphics.groupLevel = owner.groupLevel;
  14991. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  14992. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  14993. graphics.transform(1, 0, 0, 1, -x0, -y0);
  14994. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  14995. graphics.executeOperatorList(operatorList);
  14996. this.ctx.transform(1, 0, 0, 1, x0, y0);
  14997. this.ctx.scale(1 / dimx.scale, 1 / dimy.scale);
  14998. return tmpCanvas.canvas;
  14999. },
  15000. getSizeAndScale: function TilingPattern_getSizeAndScale(step, realOutputSize, scale) {
  15001. step = Math.abs(step);
  15002. var maxSize = Math.max(MAX_PATTERN_SIZE, realOutputSize);
  15003. var size = Math.ceil(step * scale);
  15004. if (size >= maxSize) {
  15005. size = maxSize;
  15006. } else {
  15007. scale = size / step;
  15008. }
  15009. return {
  15010. scale: scale,
  15011. size: size
  15012. };
  15013. },
  15014. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  15015. if (Array.isArray(bbox) && bbox.length === 4) {
  15016. var bboxWidth = x1 - x0;
  15017. var bboxHeight = y1 - y0;
  15018. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  15019. graphics.clip();
  15020. graphics.endPath();
  15021. }
  15022. },
  15023. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  15024. var context = graphics.ctx,
  15025. current = graphics.current;
  15026. switch (paintType) {
  15027. case PaintType.COLORED:
  15028. var ctx = this.ctx;
  15029. context.fillStyle = ctx.fillStyle;
  15030. context.strokeStyle = ctx.strokeStyle;
  15031. current.fillColor = ctx.fillStyle;
  15032. current.strokeColor = ctx.strokeStyle;
  15033. break;
  15034. case PaintType.UNCOLORED:
  15035. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  15036. context.fillStyle = cssColor;
  15037. context.strokeStyle = cssColor;
  15038. current.fillColor = cssColor;
  15039. current.strokeColor = cssColor;
  15040. break;
  15041. default:
  15042. throw new _util.FormatError("Unsupported paint type: ".concat(paintType));
  15043. }
  15044. },
  15045. getPattern: function TilingPattern_getPattern(ctx, owner) {
  15046. ctx = this.ctx;
  15047. ctx.setTransform.apply(ctx, this.baseTransform);
  15048. ctx.transform.apply(ctx, this.matrix);
  15049. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  15050. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  15051. }
  15052. };
  15053. return TilingPattern;
  15054. }();
  15055. exports.TilingPattern = TilingPattern;
  15056. /***/ }),
  15057. /* 188 */
  15058. /***/ (function(module, exports, __w_pdfjs_require__) {
  15059. "use strict";
  15060. Object.defineProperty(exports, "__esModule", {
  15061. value: true
  15062. });
  15063. exports.GlobalWorkerOptions = void 0;
  15064. var GlobalWorkerOptions = Object.create(null);
  15065. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  15066. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  15067. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? '' : GlobalWorkerOptions.workerSrc;
  15068. /***/ }),
  15069. /* 189 */
  15070. /***/ (function(module, exports, __w_pdfjs_require__) {
  15071. "use strict";
  15072. Object.defineProperty(exports, "__esModule", {
  15073. value: true
  15074. });
  15075. exports.MessageHandler = MessageHandler;
  15076. var _util = __w_pdfjs_require__(1);
  15077. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15078. var StreamKind = {
  15079. UNKNOWN: 0,
  15080. CANCEL: 1,
  15081. CANCEL_COMPLETE: 2,
  15082. CLOSE: 3,
  15083. ENQUEUE: 4,
  15084. ERROR: 5,
  15085. PULL: 6,
  15086. PULL_COMPLETE: 7,
  15087. START_COMPLETE: 8
  15088. };
  15089. function wrapReason(reason) {
  15090. if (_typeof(reason) !== 'object') {
  15091. return reason;
  15092. }
  15093. switch (reason.name) {
  15094. case 'AbortException':
  15095. return new _util.AbortException(reason.message);
  15096. case 'MissingPDFException':
  15097. return new _util.MissingPDFException(reason.message);
  15098. case 'UnexpectedResponseException':
  15099. return new _util.UnexpectedResponseException(reason.message, reason.status);
  15100. case 'UnknownErrorException':
  15101. return new _util.UnknownErrorException(reason.message, reason.details);
  15102. default:
  15103. return new _util.UnknownErrorException(reason.message, reason.toString());
  15104. }
  15105. }
  15106. function MessageHandler(sourceName, targetName, comObj) {
  15107. var _this = this;
  15108. this.sourceName = sourceName;
  15109. this.targetName = targetName;
  15110. this.comObj = comObj;
  15111. this.callbackId = 1;
  15112. this.streamId = 1;
  15113. this.postMessageTransfers = true;
  15114. this.streamSinks = Object.create(null);
  15115. this.streamControllers = Object.create(null);
  15116. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  15117. var ah = this.actionHandler = Object.create(null);
  15118. this._onComObjOnMessage = function (event) {
  15119. var data = event.data;
  15120. if (data.targetName !== _this.sourceName) {
  15121. return;
  15122. }
  15123. if (data.stream) {
  15124. _this._processStreamMessage(data);
  15125. } else if (data.isReply) {
  15126. var callbackId = data.callbackId;
  15127. if (data.callbackId in callbacksCapabilities) {
  15128. var callback = callbacksCapabilities[callbackId];
  15129. delete callbacksCapabilities[callbackId];
  15130. if ('reason' in data) {
  15131. callback.reject(wrapReason(data.reason));
  15132. } else {
  15133. callback.resolve(data.data);
  15134. }
  15135. } else {
  15136. throw new Error("Cannot resolve callback ".concat(callbackId));
  15137. }
  15138. } else if (data.action in ah) {
  15139. var action = ah[data.action];
  15140. if (data.callbackId) {
  15141. var _sourceName = _this.sourceName;
  15142. var _targetName = data.sourceName;
  15143. new Promise(function (resolve) {
  15144. resolve(action(data.data));
  15145. }).then(function (result) {
  15146. comObj.postMessage({
  15147. sourceName: _sourceName,
  15148. targetName: _targetName,
  15149. isReply: true,
  15150. callbackId: data.callbackId,
  15151. data: result
  15152. });
  15153. }, function (reason) {
  15154. comObj.postMessage({
  15155. sourceName: _sourceName,
  15156. targetName: _targetName,
  15157. isReply: true,
  15158. callbackId: data.callbackId,
  15159. reason: wrapReason(reason)
  15160. });
  15161. });
  15162. } else if (data.streamId) {
  15163. _this._createStreamSink(data);
  15164. } else {
  15165. action(data.data);
  15166. }
  15167. } else {
  15168. throw new Error("Unknown action from worker: ".concat(data.action));
  15169. }
  15170. };
  15171. comObj.addEventListener('message', this._onComObjOnMessage);
  15172. }
  15173. MessageHandler.prototype = {
  15174. on: function on(actionName, handler) {
  15175. var ah = this.actionHandler;
  15176. if (ah[actionName]) {
  15177. throw new Error("There is already an actionName called \"".concat(actionName, "\""));
  15178. }
  15179. ah[actionName] = handler;
  15180. },
  15181. send: function send(actionName, data, transfers) {
  15182. this.postMessage({
  15183. sourceName: this.sourceName,
  15184. targetName: this.targetName,
  15185. action: actionName,
  15186. data: data
  15187. }, transfers);
  15188. },
  15189. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  15190. var callbackId = this.callbackId++;
  15191. var capability = (0, _util.createPromiseCapability)();
  15192. this.callbacksCapabilities[callbackId] = capability;
  15193. try {
  15194. this.postMessage({
  15195. sourceName: this.sourceName,
  15196. targetName: this.targetName,
  15197. action: actionName,
  15198. callbackId: callbackId,
  15199. data: data
  15200. }, transfers);
  15201. } catch (ex) {
  15202. capability.reject(ex);
  15203. }
  15204. return capability.promise;
  15205. },
  15206. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  15207. var _this2 = this;
  15208. var streamId = this.streamId++;
  15209. var sourceName = this.sourceName;
  15210. var targetName = this.targetName;
  15211. var comObj = this.comObj;
  15212. return new _util.ReadableStream({
  15213. start: function start(controller) {
  15214. var startCapability = (0, _util.createPromiseCapability)();
  15215. _this2.streamControllers[streamId] = {
  15216. controller: controller,
  15217. startCall: startCapability,
  15218. pullCall: null,
  15219. cancelCall: null,
  15220. isClosed: false
  15221. };
  15222. _this2.postMessage({
  15223. sourceName: sourceName,
  15224. targetName: targetName,
  15225. action: actionName,
  15226. streamId: streamId,
  15227. data: data,
  15228. desiredSize: controller.desiredSize
  15229. }, transfers);
  15230. return startCapability.promise;
  15231. },
  15232. pull: function pull(controller) {
  15233. var pullCapability = (0, _util.createPromiseCapability)();
  15234. _this2.streamControllers[streamId].pullCall = pullCapability;
  15235. comObj.postMessage({
  15236. sourceName: sourceName,
  15237. targetName: targetName,
  15238. stream: StreamKind.PULL,
  15239. streamId: streamId,
  15240. desiredSize: controller.desiredSize
  15241. });
  15242. return pullCapability.promise;
  15243. },
  15244. cancel: function cancel(reason) {
  15245. (0, _util.assert)(reason instanceof Error, 'cancel must have a valid reason');
  15246. var cancelCapability = (0, _util.createPromiseCapability)();
  15247. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  15248. _this2.streamControllers[streamId].isClosed = true;
  15249. comObj.postMessage({
  15250. sourceName: sourceName,
  15251. targetName: targetName,
  15252. stream: StreamKind.CANCEL,
  15253. streamId: streamId,
  15254. reason: wrapReason(reason)
  15255. });
  15256. return cancelCapability.promise;
  15257. }
  15258. }, queueingStrategy);
  15259. },
  15260. _createStreamSink: function _createStreamSink(data) {
  15261. var self = this;
  15262. var action = this.actionHandler[data.action];
  15263. var streamId = data.streamId;
  15264. var desiredSize = data.desiredSize;
  15265. var sourceName = this.sourceName;
  15266. var targetName = data.sourceName;
  15267. var capability = (0, _util.createPromiseCapability)();
  15268. var comObj = this.comObj;
  15269. var streamSink = {
  15270. enqueue: function enqueue(chunk) {
  15271. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  15272. var transfers = arguments.length > 2 ? arguments[2] : undefined;
  15273. if (this.isCancelled) {
  15274. return;
  15275. }
  15276. var lastDesiredSize = this.desiredSize;
  15277. this.desiredSize -= size;
  15278. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  15279. this.sinkCapability = (0, _util.createPromiseCapability)();
  15280. this.ready = this.sinkCapability.promise;
  15281. }
  15282. self.postMessage({
  15283. sourceName: sourceName,
  15284. targetName: targetName,
  15285. stream: StreamKind.ENQUEUE,
  15286. streamId: streamId,
  15287. chunk: chunk
  15288. }, transfers);
  15289. },
  15290. close: function close() {
  15291. if (this.isCancelled) {
  15292. return;
  15293. }
  15294. this.isCancelled = true;
  15295. comObj.postMessage({
  15296. sourceName: sourceName,
  15297. targetName: targetName,
  15298. stream: StreamKind.CLOSE,
  15299. streamId: streamId
  15300. });
  15301. delete self.streamSinks[streamId];
  15302. },
  15303. error: function error(reason) {
  15304. (0, _util.assert)(reason instanceof Error, 'error must have a valid reason');
  15305. if (this.isCancelled) {
  15306. return;
  15307. }
  15308. this.isCancelled = true;
  15309. comObj.postMessage({
  15310. sourceName: sourceName,
  15311. targetName: targetName,
  15312. stream: StreamKind.ERROR,
  15313. streamId: streamId,
  15314. reason: wrapReason(reason)
  15315. });
  15316. },
  15317. sinkCapability: capability,
  15318. onPull: null,
  15319. onCancel: null,
  15320. isCancelled: false,
  15321. desiredSize: desiredSize,
  15322. ready: null
  15323. };
  15324. streamSink.sinkCapability.resolve();
  15325. streamSink.ready = streamSink.sinkCapability.promise;
  15326. this.streamSinks[streamId] = streamSink;
  15327. new Promise(function (resolve) {
  15328. resolve(action(data.data, streamSink));
  15329. }).then(function () {
  15330. comObj.postMessage({
  15331. sourceName: sourceName,
  15332. targetName: targetName,
  15333. stream: StreamKind.START_COMPLETE,
  15334. streamId: streamId,
  15335. success: true
  15336. });
  15337. }, function (reason) {
  15338. comObj.postMessage({
  15339. sourceName: sourceName,
  15340. targetName: targetName,
  15341. stream: StreamKind.START_COMPLETE,
  15342. streamId: streamId,
  15343. reason: wrapReason(reason)
  15344. });
  15345. });
  15346. },
  15347. _processStreamMessage: function _processStreamMessage(data) {
  15348. var _this3 = this;
  15349. var sourceName = this.sourceName;
  15350. var targetName = data.sourceName;
  15351. var streamId = data.streamId;
  15352. var comObj = this.comObj;
  15353. var deleteStreamController = function deleteStreamController() {
  15354. Promise.all([_this3.streamControllers[streamId].startCall, _this3.streamControllers[streamId].pullCall, _this3.streamControllers[streamId].cancelCall].map(function (capability) {
  15355. return capability && capability.promise["catch"](function () {});
  15356. })).then(function () {
  15357. delete _this3.streamControllers[streamId];
  15358. });
  15359. };
  15360. switch (data.stream) {
  15361. case StreamKind.START_COMPLETE:
  15362. if (data.success) {
  15363. this.streamControllers[streamId].startCall.resolve();
  15364. } else {
  15365. this.streamControllers[streamId].startCall.reject(wrapReason(data.reason));
  15366. }
  15367. break;
  15368. case StreamKind.PULL_COMPLETE:
  15369. if (data.success) {
  15370. this.streamControllers[streamId].pullCall.resolve();
  15371. } else {
  15372. this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason));
  15373. }
  15374. break;
  15375. case StreamKind.PULL:
  15376. if (!this.streamSinks[streamId]) {
  15377. comObj.postMessage({
  15378. sourceName: sourceName,
  15379. targetName: targetName,
  15380. stream: StreamKind.PULL_COMPLETE,
  15381. streamId: streamId,
  15382. success: true
  15383. });
  15384. break;
  15385. }
  15386. if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) {
  15387. this.streamSinks[streamId].sinkCapability.resolve();
  15388. }
  15389. this.streamSinks[streamId].desiredSize = data.desiredSize;
  15390. var onPull = this.streamSinks[data.streamId].onPull;
  15391. new Promise(function (resolve) {
  15392. resolve(onPull && onPull());
  15393. }).then(function () {
  15394. comObj.postMessage({
  15395. sourceName: sourceName,
  15396. targetName: targetName,
  15397. stream: StreamKind.PULL_COMPLETE,
  15398. streamId: streamId,
  15399. success: true
  15400. });
  15401. }, function (reason) {
  15402. comObj.postMessage({
  15403. sourceName: sourceName,
  15404. targetName: targetName,
  15405. stream: StreamKind.PULL_COMPLETE,
  15406. streamId: streamId,
  15407. reason: wrapReason(reason)
  15408. });
  15409. });
  15410. break;
  15411. case StreamKind.ENQUEUE:
  15412. (0, _util.assert)(this.streamControllers[streamId], 'enqueue should have stream controller');
  15413. if (this.streamControllers[streamId].isClosed) {
  15414. break;
  15415. }
  15416. this.streamControllers[streamId].controller.enqueue(data.chunk);
  15417. break;
  15418. case StreamKind.CLOSE:
  15419. (0, _util.assert)(this.streamControllers[streamId], 'close should have stream controller');
  15420. if (this.streamControllers[streamId].isClosed) {
  15421. break;
  15422. }
  15423. this.streamControllers[streamId].isClosed = true;
  15424. this.streamControllers[streamId].controller.close();
  15425. deleteStreamController();
  15426. break;
  15427. case StreamKind.ERROR:
  15428. (0, _util.assert)(this.streamControllers[streamId], 'error should have stream controller');
  15429. this.streamControllers[streamId].controller.error(wrapReason(data.reason));
  15430. deleteStreamController();
  15431. break;
  15432. case StreamKind.CANCEL_COMPLETE:
  15433. if (data.success) {
  15434. this.streamControllers[streamId].cancelCall.resolve();
  15435. } else {
  15436. this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason));
  15437. }
  15438. deleteStreamController();
  15439. break;
  15440. case StreamKind.CANCEL:
  15441. if (!this.streamSinks[streamId]) {
  15442. break;
  15443. }
  15444. var onCancel = this.streamSinks[data.streamId].onCancel;
  15445. new Promise(function (resolve) {
  15446. resolve(onCancel && onCancel(wrapReason(data.reason)));
  15447. }).then(function () {
  15448. comObj.postMessage({
  15449. sourceName: sourceName,
  15450. targetName: targetName,
  15451. stream: StreamKind.CANCEL_COMPLETE,
  15452. streamId: streamId,
  15453. success: true
  15454. });
  15455. }, function (reason) {
  15456. comObj.postMessage({
  15457. sourceName: sourceName,
  15458. targetName: targetName,
  15459. stream: StreamKind.CANCEL_COMPLETE,
  15460. streamId: streamId,
  15461. reason: wrapReason(reason)
  15462. });
  15463. });
  15464. this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason));
  15465. this.streamSinks[streamId].isCancelled = true;
  15466. delete this.streamSinks[streamId];
  15467. break;
  15468. default:
  15469. throw new Error('Unexpected stream case');
  15470. }
  15471. },
  15472. postMessage: function postMessage(message, transfers) {
  15473. if (transfers && this.postMessageTransfers) {
  15474. this.comObj.postMessage(message, transfers);
  15475. } else {
  15476. this.comObj.postMessage(message);
  15477. }
  15478. },
  15479. destroy: function destroy() {
  15480. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  15481. }
  15482. };
  15483. /***/ }),
  15484. /* 190 */
  15485. /***/ (function(module, exports, __w_pdfjs_require__) {
  15486. "use strict";
  15487. Object.defineProperty(exports, "__esModule", {
  15488. value: true
  15489. });
  15490. exports.Metadata = void 0;
  15491. var _util = __w_pdfjs_require__(1);
  15492. var _xml_parser = __w_pdfjs_require__(191);
  15493. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15494. 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); } }
  15495. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15496. var Metadata =
  15497. /*#__PURE__*/
  15498. function () {
  15499. function Metadata(data) {
  15500. _classCallCheck(this, Metadata);
  15501. (0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string');
  15502. data = this._repair(data);
  15503. var parser = new _xml_parser.SimpleXMLParser();
  15504. var xmlDocument = parser.parseFromString(data);
  15505. this._metadata = Object.create(null);
  15506. if (xmlDocument) {
  15507. this._parse(xmlDocument);
  15508. }
  15509. }
  15510. _createClass(Metadata, [{
  15511. key: "_repair",
  15512. value: function _repair(data) {
  15513. return data.replace(/^([^<]+)/, '').replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  15514. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  15515. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  15516. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  15517. switch (name) {
  15518. case 'amp':
  15519. return '&';
  15520. case 'apos':
  15521. return '\'';
  15522. case 'gt':
  15523. return '>';
  15524. case 'lt':
  15525. return '<';
  15526. case 'quot':
  15527. return '\"';
  15528. }
  15529. throw new Error("_repair: ".concat(name, " isn't defined."));
  15530. });
  15531. var chars = '';
  15532. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  15533. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  15534. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  15535. chars += String.fromCharCode(code);
  15536. } else {
  15537. chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  15538. }
  15539. }
  15540. return '>' + chars;
  15541. });
  15542. }
  15543. }, {
  15544. key: "_parse",
  15545. value: function _parse(xmlDocument) {
  15546. var rdf = xmlDocument.documentElement;
  15547. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  15548. rdf = rdf.firstChild;
  15549. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  15550. rdf = rdf.nextSibling;
  15551. }
  15552. }
  15553. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  15554. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  15555. return;
  15556. }
  15557. var children = rdf.childNodes;
  15558. for (var i = 0, ii = children.length; i < ii; i++) {
  15559. var desc = children[i];
  15560. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  15561. continue;
  15562. }
  15563. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  15564. if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
  15565. var entry = desc.childNodes[j];
  15566. var name = entry.nodeName.toLowerCase();
  15567. this._metadata[name] = entry.textContent.trim();
  15568. }
  15569. }
  15570. }
  15571. }
  15572. }, {
  15573. key: "get",
  15574. value: function get(name) {
  15575. var data = this._metadata[name];
  15576. return typeof data !== 'undefined' ? data : null;
  15577. }
  15578. }, {
  15579. key: "getAll",
  15580. value: function getAll() {
  15581. return this._metadata;
  15582. }
  15583. }, {
  15584. key: "has",
  15585. value: function has(name) {
  15586. return typeof this._metadata[name] !== 'undefined';
  15587. }
  15588. }]);
  15589. return Metadata;
  15590. }();
  15591. exports.Metadata = Metadata;
  15592. /***/ }),
  15593. /* 191 */
  15594. /***/ (function(module, exports, __w_pdfjs_require__) {
  15595. "use strict";
  15596. Object.defineProperty(exports, "__esModule", {
  15597. value: true
  15598. });
  15599. exports.SimpleXMLParser = void 0;
  15600. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  15601. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  15602. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  15603. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  15604. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  15605. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15606. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15607. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  15608. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  15609. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15610. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  15611. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15612. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15613. 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); } }
  15614. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15615. var XMLParserErrorCode = {
  15616. NoError: 0,
  15617. EndOfDocument: -1,
  15618. UnterminatedCdat: -2,
  15619. UnterminatedXmlDeclaration: -3,
  15620. UnterminatedDoctypeDeclaration: -4,
  15621. UnterminatedComment: -5,
  15622. MalformedElement: -6,
  15623. OutOfMemory: -7,
  15624. UnterminatedAttributeValue: -8,
  15625. UnterminatedElement: -9,
  15626. ElementNeverBegun: -10
  15627. };
  15628. function isWhitespace(s, index) {
  15629. var ch = s[index];
  15630. return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
  15631. }
  15632. function isWhitespaceString(s) {
  15633. for (var i = 0, ii = s.length; i < ii; i++) {
  15634. if (!isWhitespace(s, i)) {
  15635. return false;
  15636. }
  15637. }
  15638. return true;
  15639. }
  15640. var XMLParserBase =
  15641. /*#__PURE__*/
  15642. function () {
  15643. function XMLParserBase() {
  15644. _classCallCheck(this, XMLParserBase);
  15645. }
  15646. _createClass(XMLParserBase, [{
  15647. key: "_resolveEntities",
  15648. value: function _resolveEntities(s) {
  15649. var _this = this;
  15650. return s.replace(/&([^;]+);/g, function (all, entity) {
  15651. if (entity.substring(0, 2) === '#x') {
  15652. return String.fromCharCode(parseInt(entity.substring(2), 16));
  15653. } else if (entity.substring(0, 1) === '#') {
  15654. return String.fromCharCode(parseInt(entity.substring(1), 10));
  15655. }
  15656. switch (entity) {
  15657. case 'lt':
  15658. return '<';
  15659. case 'gt':
  15660. return '>';
  15661. case 'amp':
  15662. return '&';
  15663. case 'quot':
  15664. return '\"';
  15665. }
  15666. return _this.onResolveEntity(entity);
  15667. });
  15668. }
  15669. }, {
  15670. key: "_parseContent",
  15671. value: function _parseContent(s, start) {
  15672. var pos = start,
  15673. name,
  15674. attributes = [];
  15675. function skipWs() {
  15676. while (pos < s.length && isWhitespace(s, pos)) {
  15677. ++pos;
  15678. }
  15679. }
  15680. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  15681. ++pos;
  15682. }
  15683. name = s.substring(start, pos);
  15684. skipWs();
  15685. while (pos < s.length && s[pos] !== '>' && s[pos] !== '/' && s[pos] !== '?') {
  15686. skipWs();
  15687. var attrName = '',
  15688. attrValue = '';
  15689. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '=') {
  15690. attrName += s[pos];
  15691. ++pos;
  15692. }
  15693. skipWs();
  15694. if (s[pos] !== '=') {
  15695. return null;
  15696. }
  15697. ++pos;
  15698. skipWs();
  15699. var attrEndChar = s[pos];
  15700. if (attrEndChar !== '\"' && attrEndChar !== '\'') {
  15701. return null;
  15702. }
  15703. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  15704. if (attrEndIndex < 0) {
  15705. return null;
  15706. }
  15707. attrValue = s.substring(pos, attrEndIndex);
  15708. attributes.push({
  15709. name: attrName,
  15710. value: this._resolveEntities(attrValue)
  15711. });
  15712. pos = attrEndIndex + 1;
  15713. skipWs();
  15714. }
  15715. return {
  15716. name: name,
  15717. attributes: attributes,
  15718. parsed: pos - start
  15719. };
  15720. }
  15721. }, {
  15722. key: "_parseProcessingInstruction",
  15723. value: function _parseProcessingInstruction(s, start) {
  15724. var pos = start,
  15725. name,
  15726. value;
  15727. function skipWs() {
  15728. while (pos < s.length && isWhitespace(s, pos)) {
  15729. ++pos;
  15730. }
  15731. }
  15732. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  15733. ++pos;
  15734. }
  15735. name = s.substring(start, pos);
  15736. skipWs();
  15737. var attrStart = pos;
  15738. while (pos < s.length && (s[pos] !== '?' || s[pos + 1] !== '>')) {
  15739. ++pos;
  15740. }
  15741. value = s.substring(attrStart, pos);
  15742. return {
  15743. name: name,
  15744. value: value,
  15745. parsed: pos - start
  15746. };
  15747. }
  15748. }, {
  15749. key: "parseXml",
  15750. value: function parseXml(s) {
  15751. var i = 0;
  15752. while (i < s.length) {
  15753. var ch = s[i];
  15754. var j = i;
  15755. if (ch === '<') {
  15756. ++j;
  15757. var ch2 = s[j];
  15758. var q = void 0;
  15759. switch (ch2) {
  15760. case '/':
  15761. ++j;
  15762. q = s.indexOf('>', j);
  15763. if (q < 0) {
  15764. this.onError(XMLParserErrorCode.UnterminatedElement);
  15765. return;
  15766. }
  15767. this.onEndElement(s.substring(j, q));
  15768. j = q + 1;
  15769. break;
  15770. case '?':
  15771. ++j;
  15772. var pi = this._parseProcessingInstruction(s, j);
  15773. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== '?>') {
  15774. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  15775. return;
  15776. }
  15777. this.onPi(pi.name, pi.value);
  15778. j += pi.parsed + 2;
  15779. break;
  15780. case '!':
  15781. if (s.substring(j + 1, j + 3) === '--') {
  15782. q = s.indexOf('-->', j + 3);
  15783. if (q < 0) {
  15784. this.onError(XMLParserErrorCode.UnterminatedComment);
  15785. return;
  15786. }
  15787. this.onComment(s.substring(j + 3, q));
  15788. j = q + 3;
  15789. } else if (s.substring(j + 1, j + 8) === '[CDATA[') {
  15790. q = s.indexOf(']]>', j + 8);
  15791. if (q < 0) {
  15792. this.onError(XMLParserErrorCode.UnterminatedCdat);
  15793. return;
  15794. }
  15795. this.onCdata(s.substring(j + 8, q));
  15796. j = q + 3;
  15797. } else if (s.substring(j + 1, j + 8) === 'DOCTYPE') {
  15798. var q2 = s.indexOf('[', j + 8);
  15799. var complexDoctype = false;
  15800. q = s.indexOf('>', j + 8);
  15801. if (q < 0) {
  15802. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  15803. return;
  15804. }
  15805. if (q2 > 0 && q > q2) {
  15806. q = s.indexOf(']>', j + 8);
  15807. if (q < 0) {
  15808. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  15809. return;
  15810. }
  15811. complexDoctype = true;
  15812. }
  15813. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  15814. this.onDoctype(doctypeContent);
  15815. j = q + (complexDoctype ? 2 : 1);
  15816. } else {
  15817. this.onError(XMLParserErrorCode.MalformedElement);
  15818. return;
  15819. }
  15820. break;
  15821. default:
  15822. var content = this._parseContent(s, j);
  15823. if (content === null) {
  15824. this.onError(XMLParserErrorCode.MalformedElement);
  15825. return;
  15826. }
  15827. var isClosed = false;
  15828. if (s.substring(j + content.parsed, j + content.parsed + 2) === '/>') {
  15829. isClosed = true;
  15830. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== '>') {
  15831. this.onError(XMLParserErrorCode.UnterminatedElement);
  15832. return;
  15833. }
  15834. this.onBeginElement(content.name, content.attributes, isClosed);
  15835. j += content.parsed + (isClosed ? 2 : 1);
  15836. break;
  15837. }
  15838. } else {
  15839. while (j < s.length && s[j] !== '<') {
  15840. j++;
  15841. }
  15842. var text = s.substring(i, j);
  15843. this.onText(this._resolveEntities(text));
  15844. }
  15845. i = j;
  15846. }
  15847. }
  15848. }, {
  15849. key: "onResolveEntity",
  15850. value: function onResolveEntity(name) {
  15851. return "&".concat(name, ";");
  15852. }
  15853. }, {
  15854. key: "onPi",
  15855. value: function onPi(name, value) {}
  15856. }, {
  15857. key: "onComment",
  15858. value: function onComment(text) {}
  15859. }, {
  15860. key: "onCdata",
  15861. value: function onCdata(text) {}
  15862. }, {
  15863. key: "onDoctype",
  15864. value: function onDoctype(doctypeContent) {}
  15865. }, {
  15866. key: "onText",
  15867. value: function onText(text) {}
  15868. }, {
  15869. key: "onBeginElement",
  15870. value: function onBeginElement(name, attributes, isEmpty) {}
  15871. }, {
  15872. key: "onEndElement",
  15873. value: function onEndElement(name) {}
  15874. }, {
  15875. key: "onError",
  15876. value: function onError(code) {}
  15877. }]);
  15878. return XMLParserBase;
  15879. }();
  15880. var SimpleDOMNode =
  15881. /*#__PURE__*/
  15882. function () {
  15883. function SimpleDOMNode(nodeName, nodeValue) {
  15884. _classCallCheck(this, SimpleDOMNode);
  15885. this.nodeName = nodeName;
  15886. this.nodeValue = nodeValue;
  15887. Object.defineProperty(this, 'parentNode', {
  15888. value: null,
  15889. writable: true
  15890. });
  15891. }
  15892. _createClass(SimpleDOMNode, [{
  15893. key: "hasChildNodes",
  15894. value: function hasChildNodes() {
  15895. return this.childNodes && this.childNodes.length > 0;
  15896. }
  15897. }, {
  15898. key: "firstChild",
  15899. get: function get() {
  15900. return this.childNodes && this.childNodes[0];
  15901. }
  15902. }, {
  15903. key: "nextSibling",
  15904. get: function get() {
  15905. var childNodes = this.parentNode.childNodes;
  15906. if (!childNodes) {
  15907. return undefined;
  15908. }
  15909. var index = childNodes.indexOf(this);
  15910. if (index === -1) {
  15911. return undefined;
  15912. }
  15913. return childNodes[index + 1];
  15914. }
  15915. }, {
  15916. key: "textContent",
  15917. get: function get() {
  15918. if (!this.childNodes) {
  15919. return this.nodeValue || '';
  15920. }
  15921. return this.childNodes.map(function (child) {
  15922. return child.textContent;
  15923. }).join('');
  15924. }
  15925. }]);
  15926. return SimpleDOMNode;
  15927. }();
  15928. var SimpleXMLParser =
  15929. /*#__PURE__*/
  15930. function (_XMLParserBase) {
  15931. _inherits(SimpleXMLParser, _XMLParserBase);
  15932. function SimpleXMLParser() {
  15933. var _this2;
  15934. _classCallCheck(this, SimpleXMLParser);
  15935. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(SimpleXMLParser).call(this));
  15936. _this2._currentFragment = null;
  15937. _this2._stack = null;
  15938. _this2._errorCode = XMLParserErrorCode.NoError;
  15939. return _this2;
  15940. }
  15941. _createClass(SimpleXMLParser, [{
  15942. key: "parseFromString",
  15943. value: function parseFromString(data) {
  15944. this._currentFragment = [];
  15945. this._stack = [];
  15946. this._errorCode = XMLParserErrorCode.NoError;
  15947. this.parseXml(data);
  15948. if (this._errorCode !== XMLParserErrorCode.NoError) {
  15949. return undefined;
  15950. }
  15951. var _this$_currentFragmen = _slicedToArray(this._currentFragment, 1),
  15952. documentElement = _this$_currentFragmen[0];
  15953. if (!documentElement) {
  15954. return undefined;
  15955. }
  15956. return {
  15957. documentElement: documentElement
  15958. };
  15959. }
  15960. }, {
  15961. key: "onResolveEntity",
  15962. value: function onResolveEntity(name) {
  15963. switch (name) {
  15964. case 'apos':
  15965. return '\'';
  15966. }
  15967. return _get(_getPrototypeOf(SimpleXMLParser.prototype), "onResolveEntity", this).call(this, name);
  15968. }
  15969. }, {
  15970. key: "onText",
  15971. value: function onText(text) {
  15972. if (isWhitespaceString(text)) {
  15973. return;
  15974. }
  15975. var node = new SimpleDOMNode('#text', text);
  15976. this._currentFragment.push(node);
  15977. }
  15978. }, {
  15979. key: "onCdata",
  15980. value: function onCdata(text) {
  15981. var node = new SimpleDOMNode('#text', text);
  15982. this._currentFragment.push(node);
  15983. }
  15984. }, {
  15985. key: "onBeginElement",
  15986. value: function onBeginElement(name, attributes, isEmpty) {
  15987. var node = new SimpleDOMNode(name);
  15988. node.childNodes = [];
  15989. this._currentFragment.push(node);
  15990. if (isEmpty) {
  15991. return;
  15992. }
  15993. this._stack.push(this._currentFragment);
  15994. this._currentFragment = node.childNodes;
  15995. }
  15996. }, {
  15997. key: "onEndElement",
  15998. value: function onEndElement(name) {
  15999. this._currentFragment = this._stack.pop() || [];
  16000. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  16001. if (!lastElement) {
  16002. return;
  16003. }
  16004. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  16005. lastElement.childNodes[i].parentNode = lastElement;
  16006. }
  16007. }
  16008. }, {
  16009. key: "onError",
  16010. value: function onError(code) {
  16011. this._errorCode = code;
  16012. }
  16013. }]);
  16014. return SimpleXMLParser;
  16015. }(XMLParserBase);
  16016. exports.SimpleXMLParser = SimpleXMLParser;
  16017. /***/ }),
  16018. /* 192 */
  16019. /***/ (function(module, exports, __w_pdfjs_require__) {
  16020. "use strict";
  16021. Object.defineProperty(exports, "__esModule", {
  16022. value: true
  16023. });
  16024. exports.PDFDataTransportStream = void 0;
  16025. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  16026. var _util = __w_pdfjs_require__(1);
  16027. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16028. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  16029. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  16030. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16031. 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); } }
  16032. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16033. var PDFDataTransportStream =
  16034. /*#__PURE__*/
  16035. function () {
  16036. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  16037. var _this = this;
  16038. _classCallCheck(this, PDFDataTransportStream);
  16039. (0, _util.assert)(pdfDataRangeTransport);
  16040. this._queuedChunks = [];
  16041. this._progressiveDone = params.progressiveDone || false;
  16042. var initialData = params.initialData;
  16043. if (initialData && initialData.length > 0) {
  16044. var buffer = new Uint8Array(initialData).buffer;
  16045. this._queuedChunks.push(buffer);
  16046. }
  16047. this._pdfDataRangeTransport = pdfDataRangeTransport;
  16048. this._isStreamingSupported = !params.disableStream;
  16049. this._isRangeSupported = !params.disableRange;
  16050. this._contentLength = params.length;
  16051. this._fullRequestReader = null;
  16052. this._rangeReaders = [];
  16053. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  16054. _this._onReceiveData({
  16055. begin: begin,
  16056. chunk: chunk
  16057. });
  16058. });
  16059. this._pdfDataRangeTransport.addProgressListener(function (loaded, total) {
  16060. _this._onProgress({
  16061. loaded: loaded,
  16062. total: total
  16063. });
  16064. });
  16065. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  16066. _this._onReceiveData({
  16067. chunk: chunk
  16068. });
  16069. });
  16070. this._pdfDataRangeTransport.addProgressiveDoneListener(function () {
  16071. _this._onProgressiveDone();
  16072. });
  16073. this._pdfDataRangeTransport.transportReady();
  16074. }
  16075. _createClass(PDFDataTransportStream, [{
  16076. key: "_onReceiveData",
  16077. value: function _onReceiveData(args) {
  16078. var buffer = new Uint8Array(args.chunk).buffer;
  16079. if (args.begin === undefined) {
  16080. if (this._fullRequestReader) {
  16081. this._fullRequestReader._enqueue(buffer);
  16082. } else {
  16083. this._queuedChunks.push(buffer);
  16084. }
  16085. } else {
  16086. var found = this._rangeReaders.some(function (rangeReader) {
  16087. if (rangeReader._begin !== args.begin) {
  16088. return false;
  16089. }
  16090. rangeReader._enqueue(buffer);
  16091. return true;
  16092. });
  16093. (0, _util.assert)(found);
  16094. }
  16095. }
  16096. }, {
  16097. key: "_onProgress",
  16098. value: function _onProgress(evt) {
  16099. if (evt.total === undefined) {
  16100. var firstReader = this._rangeReaders[0];
  16101. if (firstReader && firstReader.onProgress) {
  16102. firstReader.onProgress({
  16103. loaded: evt.loaded
  16104. });
  16105. }
  16106. } else {
  16107. var fullReader = this._fullRequestReader;
  16108. if (fullReader && fullReader.onProgress) {
  16109. fullReader.onProgress({
  16110. loaded: evt.loaded,
  16111. total: evt.total
  16112. });
  16113. }
  16114. }
  16115. }
  16116. }, {
  16117. key: "_onProgressiveDone",
  16118. value: function _onProgressiveDone() {
  16119. if (this._fullRequestReader) {
  16120. this._fullRequestReader.progressiveDone();
  16121. }
  16122. this._progressiveDone = true;
  16123. }
  16124. }, {
  16125. key: "_removeRangeReader",
  16126. value: function _removeRangeReader(reader) {
  16127. var i = this._rangeReaders.indexOf(reader);
  16128. if (i >= 0) {
  16129. this._rangeReaders.splice(i, 1);
  16130. }
  16131. }
  16132. }, {
  16133. key: "getFullReader",
  16134. value: function getFullReader() {
  16135. (0, _util.assert)(!this._fullRequestReader);
  16136. var queuedChunks = this._queuedChunks;
  16137. this._queuedChunks = null;
  16138. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
  16139. }
  16140. }, {
  16141. key: "getRangeReader",
  16142. value: function getRangeReader(begin, end) {
  16143. if (end <= this._progressiveDataLength) {
  16144. return null;
  16145. }
  16146. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  16147. this._pdfDataRangeTransport.requestDataRange(begin, end);
  16148. this._rangeReaders.push(reader);
  16149. return reader;
  16150. }
  16151. }, {
  16152. key: "cancelAllRequests",
  16153. value: function cancelAllRequests(reason) {
  16154. if (this._fullRequestReader) {
  16155. this._fullRequestReader.cancel(reason);
  16156. }
  16157. var readers = this._rangeReaders.slice(0);
  16158. readers.forEach(function (rangeReader) {
  16159. rangeReader.cancel(reason);
  16160. });
  16161. this._pdfDataRangeTransport.abort();
  16162. }
  16163. }, {
  16164. key: "_progressiveDataLength",
  16165. get: function get() {
  16166. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  16167. }
  16168. }]);
  16169. return PDFDataTransportStream;
  16170. }();
  16171. exports.PDFDataTransportStream = PDFDataTransportStream;
  16172. var PDFDataTransportStreamReader =
  16173. /*#__PURE__*/
  16174. function () {
  16175. function PDFDataTransportStreamReader(stream, queuedChunks) {
  16176. var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  16177. _classCallCheck(this, PDFDataTransportStreamReader);
  16178. this._stream = stream;
  16179. this._done = progressiveDone || false;
  16180. this._filename = null;
  16181. this._queuedChunks = queuedChunks || [];
  16182. this._loaded = 0;
  16183. var _iteratorNormalCompletion = true;
  16184. var _didIteratorError = false;
  16185. var _iteratorError = undefined;
  16186. try {
  16187. for (var _iterator = this._queuedChunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  16188. var chunk = _step.value;
  16189. this._loaded += chunk.byteLength;
  16190. }
  16191. } catch (err) {
  16192. _didIteratorError = true;
  16193. _iteratorError = err;
  16194. } finally {
  16195. try {
  16196. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  16197. _iterator["return"]();
  16198. }
  16199. } finally {
  16200. if (_didIteratorError) {
  16201. throw _iteratorError;
  16202. }
  16203. }
  16204. }
  16205. this._requests = [];
  16206. this._headersReady = Promise.resolve();
  16207. stream._fullRequestReader = this;
  16208. this.onProgress = null;
  16209. }
  16210. _createClass(PDFDataTransportStreamReader, [{
  16211. key: "_enqueue",
  16212. value: function _enqueue(chunk) {
  16213. if (this._done) {
  16214. return;
  16215. }
  16216. if (this._requests.length > 0) {
  16217. var requestCapability = this._requests.shift();
  16218. requestCapability.resolve({
  16219. value: chunk,
  16220. done: false
  16221. });
  16222. } else {
  16223. this._queuedChunks.push(chunk);
  16224. }
  16225. this._loaded += chunk.byteLength;
  16226. }
  16227. }, {
  16228. key: "read",
  16229. value: function () {
  16230. var _read = _asyncToGenerator(
  16231. /*#__PURE__*/
  16232. _regenerator["default"].mark(function _callee() {
  16233. var chunk, requestCapability;
  16234. return _regenerator["default"].wrap(function _callee$(_context) {
  16235. while (1) {
  16236. switch (_context.prev = _context.next) {
  16237. case 0:
  16238. if (!(this._queuedChunks.length > 0)) {
  16239. _context.next = 3;
  16240. break;
  16241. }
  16242. chunk = this._queuedChunks.shift();
  16243. return _context.abrupt("return", {
  16244. value: chunk,
  16245. done: false
  16246. });
  16247. case 3:
  16248. if (!this._done) {
  16249. _context.next = 5;
  16250. break;
  16251. }
  16252. return _context.abrupt("return", {
  16253. value: undefined,
  16254. done: true
  16255. });
  16256. case 5:
  16257. requestCapability = (0, _util.createPromiseCapability)();
  16258. this._requests.push(requestCapability);
  16259. return _context.abrupt("return", requestCapability.promise);
  16260. case 8:
  16261. case "end":
  16262. return _context.stop();
  16263. }
  16264. }
  16265. }, _callee, this);
  16266. }));
  16267. function read() {
  16268. return _read.apply(this, arguments);
  16269. }
  16270. return read;
  16271. }()
  16272. }, {
  16273. key: "cancel",
  16274. value: function cancel(reason) {
  16275. this._done = true;
  16276. this._requests.forEach(function (requestCapability) {
  16277. requestCapability.resolve({
  16278. value: undefined,
  16279. done: true
  16280. });
  16281. });
  16282. this._requests = [];
  16283. }
  16284. }, {
  16285. key: "progressiveDone",
  16286. value: function progressiveDone() {
  16287. if (this._done) {
  16288. return;
  16289. }
  16290. this._done = true;
  16291. }
  16292. }, {
  16293. key: "headersReady",
  16294. get: function get() {
  16295. return this._headersReady;
  16296. }
  16297. }, {
  16298. key: "filename",
  16299. get: function get() {
  16300. return this._filename;
  16301. }
  16302. }, {
  16303. key: "isRangeSupported",
  16304. get: function get() {
  16305. return this._stream._isRangeSupported;
  16306. }
  16307. }, {
  16308. key: "isStreamingSupported",
  16309. get: function get() {
  16310. return this._stream._isStreamingSupported;
  16311. }
  16312. }, {
  16313. key: "contentLength",
  16314. get: function get() {
  16315. return this._stream._contentLength;
  16316. }
  16317. }]);
  16318. return PDFDataTransportStreamReader;
  16319. }();
  16320. var PDFDataTransportStreamRangeReader =
  16321. /*#__PURE__*/
  16322. function () {
  16323. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  16324. _classCallCheck(this, PDFDataTransportStreamRangeReader);
  16325. this._stream = stream;
  16326. this._begin = begin;
  16327. this._end = end;
  16328. this._queuedChunk = null;
  16329. this._requests = [];
  16330. this._done = false;
  16331. this.onProgress = null;
  16332. }
  16333. _createClass(PDFDataTransportStreamRangeReader, [{
  16334. key: "_enqueue",
  16335. value: function _enqueue(chunk) {
  16336. if (this._done) {
  16337. return;
  16338. }
  16339. if (this._requests.length === 0) {
  16340. this._queuedChunk = chunk;
  16341. } else {
  16342. var requestsCapability = this._requests.shift();
  16343. requestsCapability.resolve({
  16344. value: chunk,
  16345. done: false
  16346. });
  16347. this._requests.forEach(function (requestCapability) {
  16348. requestCapability.resolve({
  16349. value: undefined,
  16350. done: true
  16351. });
  16352. });
  16353. this._requests = [];
  16354. }
  16355. this._done = true;
  16356. this._stream._removeRangeReader(this);
  16357. }
  16358. }, {
  16359. key: "read",
  16360. value: function () {
  16361. var _read2 = _asyncToGenerator(
  16362. /*#__PURE__*/
  16363. _regenerator["default"].mark(function _callee2() {
  16364. var chunk, requestCapability;
  16365. return _regenerator["default"].wrap(function _callee2$(_context2) {
  16366. while (1) {
  16367. switch (_context2.prev = _context2.next) {
  16368. case 0:
  16369. if (!this._queuedChunk) {
  16370. _context2.next = 4;
  16371. break;
  16372. }
  16373. chunk = this._queuedChunk;
  16374. this._queuedChunk = null;
  16375. return _context2.abrupt("return", {
  16376. value: chunk,
  16377. done: false
  16378. });
  16379. case 4:
  16380. if (!this._done) {
  16381. _context2.next = 6;
  16382. break;
  16383. }
  16384. return _context2.abrupt("return", {
  16385. value: undefined,
  16386. done: true
  16387. });
  16388. case 6:
  16389. requestCapability = (0, _util.createPromiseCapability)();
  16390. this._requests.push(requestCapability);
  16391. return _context2.abrupt("return", requestCapability.promise);
  16392. case 9:
  16393. case "end":
  16394. return _context2.stop();
  16395. }
  16396. }
  16397. }, _callee2, this);
  16398. }));
  16399. function read() {
  16400. return _read2.apply(this, arguments);
  16401. }
  16402. return read;
  16403. }()
  16404. }, {
  16405. key: "cancel",
  16406. value: function cancel(reason) {
  16407. this._done = true;
  16408. this._requests.forEach(function (requestCapability) {
  16409. requestCapability.resolve({
  16410. value: undefined,
  16411. done: true
  16412. });
  16413. });
  16414. this._requests = [];
  16415. this._stream._removeRangeReader(this);
  16416. }
  16417. }, {
  16418. key: "isStreamingSupported",
  16419. get: function get() {
  16420. return false;
  16421. }
  16422. }]);
  16423. return PDFDataTransportStreamRangeReader;
  16424. }();
  16425. /***/ }),
  16426. /* 193 */
  16427. /***/ (function(module, exports, __w_pdfjs_require__) {
  16428. "use strict";
  16429. Object.defineProperty(exports, "__esModule", {
  16430. value: true
  16431. });
  16432. exports.WebGLContext = void 0;
  16433. var _util = __w_pdfjs_require__(1);
  16434. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16435. 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); } }
  16436. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16437. var WebGLContext =
  16438. /*#__PURE__*/
  16439. function () {
  16440. function WebGLContext(_ref) {
  16441. var _ref$enable = _ref.enable,
  16442. enable = _ref$enable === void 0 ? false : _ref$enable;
  16443. _classCallCheck(this, WebGLContext);
  16444. this._enabled = enable === true;
  16445. }
  16446. _createClass(WebGLContext, [{
  16447. key: "composeSMask",
  16448. value: function composeSMask(_ref2) {
  16449. var layer = _ref2.layer,
  16450. mask = _ref2.mask,
  16451. properties = _ref2.properties;
  16452. return WebGLUtils.composeSMask(layer, mask, properties);
  16453. }
  16454. }, {
  16455. key: "drawFigures",
  16456. value: function drawFigures(_ref3) {
  16457. var width = _ref3.width,
  16458. height = _ref3.height,
  16459. backgroundColor = _ref3.backgroundColor,
  16460. figures = _ref3.figures,
  16461. context = _ref3.context;
  16462. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  16463. }
  16464. }, {
  16465. key: "clear",
  16466. value: function clear() {
  16467. WebGLUtils.cleanup();
  16468. }
  16469. }, {
  16470. key: "isEnabled",
  16471. get: function get() {
  16472. var enabled = this._enabled;
  16473. if (enabled) {
  16474. enabled = WebGLUtils.tryInitGL();
  16475. }
  16476. return (0, _util.shadow)(this, 'isEnabled', enabled);
  16477. }
  16478. }]);
  16479. return WebGLContext;
  16480. }();
  16481. exports.WebGLContext = WebGLContext;
  16482. var WebGLUtils = function WebGLUtilsClosure() {
  16483. function loadShader(gl, code, shaderType) {
  16484. var shader = gl.createShader(shaderType);
  16485. gl.shaderSource(shader, code);
  16486. gl.compileShader(shader);
  16487. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  16488. if (!compiled) {
  16489. var errorMsg = gl.getShaderInfoLog(shader);
  16490. throw new Error('Error during shader compilation: ' + errorMsg);
  16491. }
  16492. return shader;
  16493. }
  16494. function createVertexShader(gl, code) {
  16495. return loadShader(gl, code, gl.VERTEX_SHADER);
  16496. }
  16497. function createFragmentShader(gl, code) {
  16498. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  16499. }
  16500. function createProgram(gl, shaders) {
  16501. var program = gl.createProgram();
  16502. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  16503. gl.attachShader(program, shaders[i]);
  16504. }
  16505. gl.linkProgram(program);
  16506. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  16507. if (!linked) {
  16508. var errorMsg = gl.getProgramInfoLog(program);
  16509. throw new Error('Error during program linking: ' + errorMsg);
  16510. }
  16511. return program;
  16512. }
  16513. function createTexture(gl, image, textureId) {
  16514. gl.activeTexture(textureId);
  16515. var texture = gl.createTexture();
  16516. gl.bindTexture(gl.TEXTURE_2D, texture);
  16517. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  16518. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  16519. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  16520. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  16521. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  16522. return texture;
  16523. }
  16524. var currentGL, currentCanvas;
  16525. function generateGL() {
  16526. if (currentGL) {
  16527. return;
  16528. }
  16529. currentCanvas = document.createElement('canvas');
  16530. currentGL = currentCanvas.getContext('webgl', {
  16531. premultipliedalpha: false
  16532. });
  16533. }
  16534. var smaskVertexShaderCode = '\
  16535. attribute vec2 a_position; \
  16536. attribute vec2 a_texCoord; \
  16537. \
  16538. uniform vec2 u_resolution; \
  16539. \
  16540. varying vec2 v_texCoord; \
  16541. \
  16542. void main() { \
  16543. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  16544. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  16545. \
  16546. v_texCoord = a_texCoord; \
  16547. } ';
  16548. var smaskFragmentShaderCode = '\
  16549. precision mediump float; \
  16550. \
  16551. uniform vec4 u_backdrop; \
  16552. uniform int u_subtype; \
  16553. uniform sampler2D u_image; \
  16554. uniform sampler2D u_mask; \
  16555. \
  16556. varying vec2 v_texCoord; \
  16557. \
  16558. void main() { \
  16559. vec4 imageColor = texture2D(u_image, v_texCoord); \
  16560. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  16561. if (u_backdrop.a > 0.0) { \
  16562. maskColor.rgb = maskColor.rgb * maskColor.a + \
  16563. u_backdrop.rgb * (1.0 - maskColor.a); \
  16564. } \
  16565. float lum; \
  16566. if (u_subtype == 0) { \
  16567. lum = maskColor.a; \
  16568. } else { \
  16569. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  16570. maskColor.b * 0.11; \
  16571. } \
  16572. imageColor.a *= lum; \
  16573. imageColor.rgb *= imageColor.a; \
  16574. gl_FragColor = imageColor; \
  16575. } ';
  16576. var smaskCache = null;
  16577. function initSmaskGL() {
  16578. var canvas, gl;
  16579. generateGL();
  16580. canvas = currentCanvas;
  16581. currentCanvas = null;
  16582. gl = currentGL;
  16583. currentGL = null;
  16584. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  16585. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  16586. var program = createProgram(gl, [vertexShader, fragmentShader]);
  16587. gl.useProgram(program);
  16588. var cache = {};
  16589. cache.gl = gl;
  16590. cache.canvas = canvas;
  16591. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  16592. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  16593. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  16594. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  16595. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  16596. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  16597. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  16598. var texCoordBuffer = gl.createBuffer();
  16599. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  16600. 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);
  16601. gl.enableVertexAttribArray(texCoordLocation);
  16602. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  16603. gl.uniform1i(texLayerLocation, 0);
  16604. gl.uniform1i(texMaskLocation, 1);
  16605. smaskCache = cache;
  16606. }
  16607. function composeSMask(layer, mask, properties) {
  16608. var width = layer.width,
  16609. height = layer.height;
  16610. if (!smaskCache) {
  16611. initSmaskGL();
  16612. }
  16613. var cache = smaskCache,
  16614. canvas = cache.canvas,
  16615. gl = cache.gl;
  16616. canvas.width = width;
  16617. canvas.height = height;
  16618. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  16619. gl.uniform2f(cache.resolutionLocation, width, height);
  16620. if (properties.backdrop) {
  16621. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  16622. } else {
  16623. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  16624. }
  16625. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  16626. var texture = createTexture(gl, layer, gl.TEXTURE0);
  16627. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  16628. var buffer = gl.createBuffer();
  16629. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  16630. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  16631. gl.enableVertexAttribArray(cache.positionLocation);
  16632. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  16633. gl.clearColor(0, 0, 0, 0);
  16634. gl.enable(gl.BLEND);
  16635. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  16636. gl.clear(gl.COLOR_BUFFER_BIT);
  16637. gl.drawArrays(gl.TRIANGLES, 0, 6);
  16638. gl.flush();
  16639. gl.deleteTexture(texture);
  16640. gl.deleteTexture(maskTexture);
  16641. gl.deleteBuffer(buffer);
  16642. return canvas;
  16643. }
  16644. var figuresVertexShaderCode = '\
  16645. attribute vec2 a_position; \
  16646. attribute vec3 a_color; \
  16647. \
  16648. uniform vec2 u_resolution; \
  16649. uniform vec2 u_scale; \
  16650. uniform vec2 u_offset; \
  16651. \
  16652. varying vec4 v_color; \
  16653. \
  16654. void main() { \
  16655. vec2 position = (a_position + u_offset) * u_scale; \
  16656. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  16657. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  16658. \
  16659. v_color = vec4(a_color / 255.0, 1.0); \
  16660. } ';
  16661. var figuresFragmentShaderCode = '\
  16662. precision mediump float; \
  16663. \
  16664. varying vec4 v_color; \
  16665. \
  16666. void main() { \
  16667. gl_FragColor = v_color; \
  16668. } ';
  16669. var figuresCache = null;
  16670. function initFiguresGL() {
  16671. var canvas, gl;
  16672. generateGL();
  16673. canvas = currentCanvas;
  16674. currentCanvas = null;
  16675. gl = currentGL;
  16676. currentGL = null;
  16677. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  16678. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  16679. var program = createProgram(gl, [vertexShader, fragmentShader]);
  16680. gl.useProgram(program);
  16681. var cache = {};
  16682. cache.gl = gl;
  16683. cache.canvas = canvas;
  16684. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  16685. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  16686. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  16687. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  16688. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  16689. figuresCache = cache;
  16690. }
  16691. function drawFigures(width, height, backgroundColor, figures, context) {
  16692. if (!figuresCache) {
  16693. initFiguresGL();
  16694. }
  16695. var cache = figuresCache,
  16696. canvas = cache.canvas,
  16697. gl = cache.gl;
  16698. canvas.width = width;
  16699. canvas.height = height;
  16700. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  16701. gl.uniform2f(cache.resolutionLocation, width, height);
  16702. var count = 0;
  16703. var i, ii, rows;
  16704. for (i = 0, ii = figures.length; i < ii; i++) {
  16705. switch (figures[i].type) {
  16706. case 'lattice':
  16707. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  16708. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  16709. break;
  16710. case 'triangles':
  16711. count += figures[i].coords.length;
  16712. break;
  16713. }
  16714. }
  16715. var coords = new Float32Array(count * 2);
  16716. var colors = new Uint8Array(count * 3);
  16717. var coordsMap = context.coords,
  16718. colorsMap = context.colors;
  16719. var pIndex = 0,
  16720. cIndex = 0;
  16721. for (i = 0, ii = figures.length; i < ii; i++) {
  16722. var figure = figures[i],
  16723. ps = figure.coords,
  16724. cs = figure.colors;
  16725. switch (figure.type) {
  16726. case 'lattice':
  16727. var cols = figure.verticesPerRow;
  16728. rows = ps.length / cols | 0;
  16729. for (var row = 1; row < rows; row++) {
  16730. var offset = row * cols + 1;
  16731. for (var col = 1; col < cols; col++, offset++) {
  16732. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  16733. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  16734. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  16735. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  16736. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  16737. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  16738. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  16739. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  16740. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  16741. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  16742. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  16743. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  16744. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  16745. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  16746. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  16747. coords[pIndex + 6] = coords[pIndex + 2];
  16748. coords[pIndex + 7] = coords[pIndex + 3];
  16749. coords[pIndex + 8] = coords[pIndex + 4];
  16750. coords[pIndex + 9] = coords[pIndex + 5];
  16751. coords[pIndex + 10] = coordsMap[ps[offset]];
  16752. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  16753. colors[cIndex + 9] = colors[cIndex + 3];
  16754. colors[cIndex + 10] = colors[cIndex + 4];
  16755. colors[cIndex + 11] = colors[cIndex + 5];
  16756. colors[cIndex + 12] = colors[cIndex + 6];
  16757. colors[cIndex + 13] = colors[cIndex + 7];
  16758. colors[cIndex + 14] = colors[cIndex + 8];
  16759. colors[cIndex + 15] = colorsMap[cs[offset]];
  16760. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  16761. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  16762. pIndex += 12;
  16763. cIndex += 18;
  16764. }
  16765. }
  16766. break;
  16767. case 'triangles':
  16768. for (var j = 0, jj = ps.length; j < jj; j++) {
  16769. coords[pIndex] = coordsMap[ps[j]];
  16770. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  16771. colors[cIndex] = colorsMap[cs[j]];
  16772. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  16773. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  16774. pIndex += 2;
  16775. cIndex += 3;
  16776. }
  16777. break;
  16778. }
  16779. }
  16780. if (backgroundColor) {
  16781. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  16782. } else {
  16783. gl.clearColor(0, 0, 0, 0);
  16784. }
  16785. gl.clear(gl.COLOR_BUFFER_BIT);
  16786. var coordsBuffer = gl.createBuffer();
  16787. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  16788. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  16789. gl.enableVertexAttribArray(cache.positionLocation);
  16790. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  16791. var colorsBuffer = gl.createBuffer();
  16792. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  16793. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  16794. gl.enableVertexAttribArray(cache.colorLocation);
  16795. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  16796. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  16797. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  16798. gl.drawArrays(gl.TRIANGLES, 0, count);
  16799. gl.flush();
  16800. gl.deleteBuffer(coordsBuffer);
  16801. gl.deleteBuffer(colorsBuffer);
  16802. return canvas;
  16803. }
  16804. return {
  16805. tryInitGL: function tryInitGL() {
  16806. try {
  16807. generateGL();
  16808. return !!currentGL;
  16809. } catch (ex) {}
  16810. return false;
  16811. },
  16812. composeSMask: composeSMask,
  16813. drawFigures: drawFigures,
  16814. cleanup: function cleanup() {
  16815. if (smaskCache && smaskCache.canvas) {
  16816. smaskCache.canvas.width = 0;
  16817. smaskCache.canvas.height = 0;
  16818. }
  16819. if (figuresCache && figuresCache.canvas) {
  16820. figuresCache.canvas.width = 0;
  16821. figuresCache.canvas.height = 0;
  16822. }
  16823. smaskCache = null;
  16824. figuresCache = null;
  16825. }
  16826. };
  16827. }();
  16828. /***/ }),
  16829. /* 194 */
  16830. /***/ (function(module, exports, __w_pdfjs_require__) {
  16831. "use strict";
  16832. Object.defineProperty(exports, "__esModule", {
  16833. value: true
  16834. });
  16835. exports.renderTextLayer = void 0;
  16836. var _util = __w_pdfjs_require__(1);
  16837. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  16838. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  16839. var renderTextLayer = function renderTextLayerClosure() {
  16840. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  16841. var NonWhitespaceRegexp = /\S/;
  16842. function isAllWhitespace(str) {
  16843. return !NonWhitespaceRegexp.test(str);
  16844. }
  16845. function appendText(task, geom, styles) {
  16846. var textDiv = document.createElement('span');
  16847. var textDivProperties = {
  16848. angle: 0,
  16849. canvasWidth: 0,
  16850. isWhitespace: false,
  16851. originalTransform: null,
  16852. paddingBottom: 0,
  16853. paddingLeft: 0,
  16854. paddingRight: 0,
  16855. paddingTop: 0,
  16856. scale: 1
  16857. };
  16858. task._textDivs.push(textDiv);
  16859. if (isAllWhitespace(geom.str)) {
  16860. textDivProperties.isWhitespace = true;
  16861. task._textDivProperties.set(textDiv, textDivProperties);
  16862. return;
  16863. }
  16864. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  16865. var angle = Math.atan2(tx[1], tx[0]);
  16866. var style = styles[geom.fontName];
  16867. if (style.vertical) {
  16868. angle += Math.PI / 2;
  16869. }
  16870. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  16871. var fontAscent = fontHeight;
  16872. if (style.ascent) {
  16873. fontAscent = style.ascent * fontAscent;
  16874. } else if (style.descent) {
  16875. fontAscent = (1 + style.descent) * fontAscent;
  16876. }
  16877. var left, top;
  16878. if (angle === 0) {
  16879. left = tx[4];
  16880. top = tx[5] - fontAscent;
  16881. } else {
  16882. left = tx[4] + fontAscent * Math.sin(angle);
  16883. top = tx[5] - fontAscent * Math.cos(angle);
  16884. }
  16885. textDiv.style.left = "".concat(left, "px");
  16886. textDiv.style.top = "".concat(top, "px");
  16887. textDiv.style.fontSize = "".concat(fontHeight, "px");
  16888. textDiv.style.fontFamily = style.fontFamily;
  16889. textDiv.textContent = geom.str;
  16890. if (task._fontInspectorEnabled) {
  16891. textDiv.dataset.fontName = geom.fontName;
  16892. }
  16893. if (angle !== 0) {
  16894. textDivProperties.angle = angle * (180 / Math.PI);
  16895. }
  16896. if (geom.str.length > 1) {
  16897. if (style.vertical) {
  16898. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  16899. } else {
  16900. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  16901. }
  16902. }
  16903. task._textDivProperties.set(textDiv, textDivProperties);
  16904. if (task._textContentStream) {
  16905. task._layoutText(textDiv);
  16906. }
  16907. if (task._enhanceTextSelection) {
  16908. var angleCos = 1,
  16909. angleSin = 0;
  16910. if (angle !== 0) {
  16911. angleCos = Math.cos(angle);
  16912. angleSin = Math.sin(angle);
  16913. }
  16914. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  16915. var divHeight = fontHeight;
  16916. var m, b;
  16917. if (angle !== 0) {
  16918. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  16919. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  16920. } else {
  16921. b = [left, top, left + divWidth, top + divHeight];
  16922. }
  16923. task._bounds.push({
  16924. left: b[0],
  16925. top: b[1],
  16926. right: b[2],
  16927. bottom: b[3],
  16928. div: textDiv,
  16929. size: [divWidth, divHeight],
  16930. m: m
  16931. });
  16932. }
  16933. }
  16934. function render(task) {
  16935. if (task._canceled) {
  16936. return;
  16937. }
  16938. var textDivs = task._textDivs;
  16939. var capability = task._capability;
  16940. var textDivsLength = textDivs.length;
  16941. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  16942. task._renderingDone = true;
  16943. capability.resolve();
  16944. return;
  16945. }
  16946. if (!task._textContentStream) {
  16947. for (var i = 0; i < textDivsLength; i++) {
  16948. task._layoutText(textDivs[i]);
  16949. }
  16950. }
  16951. task._renderingDone = true;
  16952. capability.resolve();
  16953. }
  16954. function expand(task) {
  16955. var bounds = task._bounds;
  16956. var viewport = task._viewport;
  16957. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  16958. for (var i = 0; i < expanded.length; i++) {
  16959. var div = bounds[i].div;
  16960. var divProperties = task._textDivProperties.get(div);
  16961. if (divProperties.angle === 0) {
  16962. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  16963. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  16964. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  16965. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  16966. task._textDivProperties.set(div, divProperties);
  16967. continue;
  16968. }
  16969. var e = expanded[i],
  16970. b = bounds[i];
  16971. var m = b.m,
  16972. c = m[0],
  16973. s = m[1];
  16974. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  16975. var ts = new Float64Array(64);
  16976. points.forEach(function (p, i) {
  16977. var t = _util.Util.applyTransform(p, m);
  16978. ts[i + 0] = c && (e.left - t[0]) / c;
  16979. ts[i + 4] = s && (e.top - t[1]) / s;
  16980. ts[i + 8] = c && (e.right - t[0]) / c;
  16981. ts[i + 12] = s && (e.bottom - t[1]) / s;
  16982. ts[i + 16] = s && (e.left - t[0]) / -s;
  16983. ts[i + 20] = c && (e.top - t[1]) / c;
  16984. ts[i + 24] = s && (e.right - t[0]) / -s;
  16985. ts[i + 28] = c && (e.bottom - t[1]) / c;
  16986. ts[i + 32] = c && (e.left - t[0]) / -c;
  16987. ts[i + 36] = s && (e.top - t[1]) / -s;
  16988. ts[i + 40] = c && (e.right - t[0]) / -c;
  16989. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  16990. ts[i + 48] = s && (e.left - t[0]) / s;
  16991. ts[i + 52] = c && (e.top - t[1]) / -c;
  16992. ts[i + 56] = s && (e.right - t[0]) / s;
  16993. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  16994. });
  16995. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  16996. var result = 0;
  16997. for (var i = 0; i < count; i++) {
  16998. var t = ts[offset++];
  16999. if (t > 0) {
  17000. result = result ? Math.min(t, result) : t;
  17001. }
  17002. }
  17003. return result;
  17004. };
  17005. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  17006. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  17007. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  17008. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  17009. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  17010. task._textDivProperties.set(div, divProperties);
  17011. }
  17012. }
  17013. function expandBounds(width, height, boxes) {
  17014. var bounds = boxes.map(function (box, i) {
  17015. return {
  17016. x1: box.left,
  17017. y1: box.top,
  17018. x2: box.right,
  17019. y2: box.bottom,
  17020. index: i,
  17021. x1New: undefined,
  17022. x2New: undefined
  17023. };
  17024. });
  17025. expandBoundsLTR(width, bounds);
  17026. var expanded = new Array(boxes.length);
  17027. bounds.forEach(function (b) {
  17028. var i = b.index;
  17029. expanded[i] = {
  17030. left: b.x1New,
  17031. top: 0,
  17032. right: b.x2New,
  17033. bottom: 0
  17034. };
  17035. });
  17036. boxes.map(function (box, i) {
  17037. var e = expanded[i],
  17038. b = bounds[i];
  17039. b.x1 = box.top;
  17040. b.y1 = width - e.right;
  17041. b.x2 = box.bottom;
  17042. b.y2 = width - e.left;
  17043. b.index = i;
  17044. b.x1New = undefined;
  17045. b.x2New = undefined;
  17046. });
  17047. expandBoundsLTR(height, bounds);
  17048. bounds.forEach(function (b) {
  17049. var i = b.index;
  17050. expanded[i].top = b.x1New;
  17051. expanded[i].bottom = b.x2New;
  17052. });
  17053. return expanded;
  17054. }
  17055. function expandBoundsLTR(width, bounds) {
  17056. bounds.sort(function (a, b) {
  17057. return a.x1 - b.x1 || a.index - b.index;
  17058. });
  17059. var fakeBoundary = {
  17060. x1: -Infinity,
  17061. y1: -Infinity,
  17062. x2: 0,
  17063. y2: Infinity,
  17064. index: -1,
  17065. x1New: 0,
  17066. x2New: 0
  17067. };
  17068. var horizon = [{
  17069. start: -Infinity,
  17070. end: Infinity,
  17071. boundary: fakeBoundary
  17072. }];
  17073. bounds.forEach(function (boundary) {
  17074. var i = 0;
  17075. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  17076. i++;
  17077. }
  17078. var j = horizon.length - 1;
  17079. while (j >= 0 && horizon[j].start >= boundary.y2) {
  17080. j--;
  17081. }
  17082. var horizonPart, affectedBoundary;
  17083. var q,
  17084. k,
  17085. maxXNew = -Infinity;
  17086. for (q = i; q <= j; q++) {
  17087. horizonPart = horizon[q];
  17088. affectedBoundary = horizonPart.boundary;
  17089. var xNew;
  17090. if (affectedBoundary.x2 > boundary.x1) {
  17091. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  17092. } else if (affectedBoundary.x2New === undefined) {
  17093. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  17094. } else {
  17095. xNew = affectedBoundary.x2New;
  17096. }
  17097. if (xNew > maxXNew) {
  17098. maxXNew = xNew;
  17099. }
  17100. }
  17101. boundary.x1New = maxXNew;
  17102. for (q = i; q <= j; q++) {
  17103. horizonPart = horizon[q];
  17104. affectedBoundary = horizonPart.boundary;
  17105. if (affectedBoundary.x2New === undefined) {
  17106. if (affectedBoundary.x2 > boundary.x1) {
  17107. if (affectedBoundary.index > boundary.index) {
  17108. affectedBoundary.x2New = affectedBoundary.x2;
  17109. }
  17110. } else {
  17111. affectedBoundary.x2New = maxXNew;
  17112. }
  17113. } else if (affectedBoundary.x2New > maxXNew) {
  17114. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  17115. }
  17116. }
  17117. var changedHorizon = [],
  17118. lastBoundary = null;
  17119. for (q = i; q <= j; q++) {
  17120. horizonPart = horizon[q];
  17121. affectedBoundary = horizonPart.boundary;
  17122. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  17123. if (lastBoundary === useBoundary) {
  17124. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  17125. } else {
  17126. changedHorizon.push({
  17127. start: horizonPart.start,
  17128. end: horizonPart.end,
  17129. boundary: useBoundary
  17130. });
  17131. lastBoundary = useBoundary;
  17132. }
  17133. }
  17134. if (horizon[i].start < boundary.y1) {
  17135. changedHorizon[0].start = boundary.y1;
  17136. changedHorizon.unshift({
  17137. start: horizon[i].start,
  17138. end: boundary.y1,
  17139. boundary: horizon[i].boundary
  17140. });
  17141. }
  17142. if (boundary.y2 < horizon[j].end) {
  17143. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  17144. changedHorizon.push({
  17145. start: boundary.y2,
  17146. end: horizon[j].end,
  17147. boundary: horizon[j].boundary
  17148. });
  17149. }
  17150. for (q = i; q <= j; q++) {
  17151. horizonPart = horizon[q];
  17152. affectedBoundary = horizonPart.boundary;
  17153. if (affectedBoundary.x2New !== undefined) {
  17154. continue;
  17155. }
  17156. var used = false;
  17157. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  17158. used = horizon[k].boundary === affectedBoundary;
  17159. }
  17160. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  17161. used = horizon[k].boundary === affectedBoundary;
  17162. }
  17163. for (k = 0; !used && k < changedHorizon.length; k++) {
  17164. used = changedHorizon[k].boundary === affectedBoundary;
  17165. }
  17166. if (!used) {
  17167. affectedBoundary.x2New = maxXNew;
  17168. }
  17169. }
  17170. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  17171. });
  17172. horizon.forEach(function (horizonPart) {
  17173. var affectedBoundary = horizonPart.boundary;
  17174. if (affectedBoundary.x2New === undefined) {
  17175. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  17176. }
  17177. });
  17178. }
  17179. function TextLayerRenderTask(_ref) {
  17180. var _this = this;
  17181. var textContent = _ref.textContent,
  17182. textContentStream = _ref.textContentStream,
  17183. container = _ref.container,
  17184. viewport = _ref.viewport,
  17185. textDivs = _ref.textDivs,
  17186. textContentItemsStr = _ref.textContentItemsStr,
  17187. enhanceTextSelection = _ref.enhanceTextSelection;
  17188. this._textContent = textContent;
  17189. this._textContentStream = textContentStream;
  17190. this._container = container;
  17191. this._viewport = viewport;
  17192. this._textDivs = textDivs || [];
  17193. this._textContentItemsStr = textContentItemsStr || [];
  17194. this._enhanceTextSelection = !!enhanceTextSelection;
  17195. this._fontInspectorEnabled = !!(_global_scope["default"].FontInspector && _global_scope["default"].FontInspector.enabled);
  17196. this._reader = null;
  17197. this._layoutTextLastFontSize = null;
  17198. this._layoutTextLastFontFamily = null;
  17199. this._layoutTextCtx = null;
  17200. this._textDivProperties = new WeakMap();
  17201. this._renderingDone = false;
  17202. this._canceled = false;
  17203. this._capability = (0, _util.createPromiseCapability)();
  17204. this._renderTimer = null;
  17205. this._bounds = [];
  17206. this._capability.promise["finally"](function () {
  17207. if (_this._layoutTextCtx) {
  17208. _this._layoutTextCtx.canvas.width = 0;
  17209. _this._layoutTextCtx.canvas.height = 0;
  17210. _this._layoutTextCtx = null;
  17211. }
  17212. })["catch"](function () {});
  17213. }
  17214. TextLayerRenderTask.prototype = {
  17215. get promise() {
  17216. return this._capability.promise;
  17217. },
  17218. cancel: function TextLayer_cancel() {
  17219. this._canceled = true;
  17220. if (this._reader) {
  17221. this._reader.cancel(new _util.AbortException('TextLayer task cancelled.'));
  17222. this._reader = null;
  17223. }
  17224. if (this._renderTimer !== null) {
  17225. clearTimeout(this._renderTimer);
  17226. this._renderTimer = null;
  17227. }
  17228. this._capability.reject(new Error('TextLayer task cancelled.'));
  17229. },
  17230. _processItems: function _processItems(items, styleCache) {
  17231. for (var i = 0, len = items.length; i < len; i++) {
  17232. this._textContentItemsStr.push(items[i].str);
  17233. appendText(this, items[i], styleCache);
  17234. }
  17235. },
  17236. _layoutText: function _layoutText(textDiv) {
  17237. var textDivProperties = this._textDivProperties.get(textDiv);
  17238. if (textDivProperties.isWhitespace) {
  17239. return;
  17240. }
  17241. var transform = '';
  17242. if (textDivProperties.canvasWidth !== 0) {
  17243. var _textDiv$style = textDiv.style,
  17244. fontSize = _textDiv$style.fontSize,
  17245. fontFamily = _textDiv$style.fontFamily;
  17246. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  17247. this._layoutTextCtx.font = "".concat(fontSize, " ").concat(fontFamily);
  17248. this._layoutTextLastFontSize = fontSize;
  17249. this._layoutTextLastFontFamily = fontFamily;
  17250. }
  17251. var _this$_layoutTextCtx$ = this._layoutTextCtx.measureText(textDiv.textContent),
  17252. width = _this$_layoutTextCtx$.width;
  17253. if (width > 0) {
  17254. textDivProperties.scale = textDivProperties.canvasWidth / width;
  17255. transform = "scaleX(".concat(textDivProperties.scale, ")");
  17256. }
  17257. }
  17258. if (textDivProperties.angle !== 0) {
  17259. transform = "rotate(".concat(textDivProperties.angle, "deg) ").concat(transform);
  17260. }
  17261. if (transform.length > 0) {
  17262. if (this._enhanceTextSelection) {
  17263. textDivProperties.originalTransform = transform;
  17264. }
  17265. textDiv.style.transform = transform;
  17266. }
  17267. this._textDivProperties.set(textDiv, textDivProperties);
  17268. this._container.appendChild(textDiv);
  17269. },
  17270. _render: function TextLayer_render(timeout) {
  17271. var _this2 = this;
  17272. var capability = (0, _util.createPromiseCapability)();
  17273. var styleCache = Object.create(null);
  17274. var canvas = document.createElement('canvas');
  17275. canvas.mozOpaque = true;
  17276. this._layoutTextCtx = canvas.getContext('2d', {
  17277. alpha: false
  17278. });
  17279. if (this._textContent) {
  17280. var textItems = this._textContent.items;
  17281. var textStyles = this._textContent.styles;
  17282. this._processItems(textItems, textStyles);
  17283. capability.resolve();
  17284. } else if (this._textContentStream) {
  17285. var pump = function pump() {
  17286. _this2._reader.read().then(function (_ref2) {
  17287. var value = _ref2.value,
  17288. done = _ref2.done;
  17289. if (done) {
  17290. capability.resolve();
  17291. return;
  17292. }
  17293. Object.assign(styleCache, value.styles);
  17294. _this2._processItems(value.items, styleCache);
  17295. pump();
  17296. }, capability.reject);
  17297. };
  17298. this._reader = this._textContentStream.getReader();
  17299. pump();
  17300. } else {
  17301. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  17302. }
  17303. capability.promise.then(function () {
  17304. styleCache = null;
  17305. if (!timeout) {
  17306. render(_this2);
  17307. } else {
  17308. _this2._renderTimer = setTimeout(function () {
  17309. render(_this2);
  17310. _this2._renderTimer = null;
  17311. }, timeout);
  17312. }
  17313. }, this._capability.reject);
  17314. },
  17315. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  17316. if (!this._enhanceTextSelection || !this._renderingDone) {
  17317. return;
  17318. }
  17319. if (this._bounds !== null) {
  17320. expand(this);
  17321. this._bounds = null;
  17322. }
  17323. var NO_PADDING = '0 0 0 0';
  17324. var transformBuf = [],
  17325. paddingBuf = [];
  17326. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  17327. var div = this._textDivs[i];
  17328. var divProps = this._textDivProperties.get(div);
  17329. if (divProps.isWhitespace) {
  17330. continue;
  17331. }
  17332. if (expandDivs) {
  17333. transformBuf.length = 0;
  17334. paddingBuf.length = 0;
  17335. if (divProps.originalTransform) {
  17336. transformBuf.push(divProps.originalTransform);
  17337. }
  17338. if (divProps.paddingTop > 0) {
  17339. paddingBuf.push("".concat(divProps.paddingTop, "px"));
  17340. transformBuf.push("translateY(".concat(-divProps.paddingTop, "px)"));
  17341. } else {
  17342. paddingBuf.push(0);
  17343. }
  17344. if (divProps.paddingRight > 0) {
  17345. paddingBuf.push("".concat(divProps.paddingRight / divProps.scale, "px"));
  17346. } else {
  17347. paddingBuf.push(0);
  17348. }
  17349. if (divProps.paddingBottom > 0) {
  17350. paddingBuf.push("".concat(divProps.paddingBottom, "px"));
  17351. } else {
  17352. paddingBuf.push(0);
  17353. }
  17354. if (divProps.paddingLeft > 0) {
  17355. paddingBuf.push("".concat(divProps.paddingLeft / divProps.scale, "px"));
  17356. transformBuf.push("translateX(".concat(-divProps.paddingLeft / divProps.scale, "px)"));
  17357. } else {
  17358. paddingBuf.push(0);
  17359. }
  17360. var padding = paddingBuf.join(' ');
  17361. if (padding !== NO_PADDING) {
  17362. div.style.padding = padding;
  17363. }
  17364. if (transformBuf.length) {
  17365. div.style.transform = transformBuf.join(' ');
  17366. }
  17367. } else {
  17368. div.style.padding = null;
  17369. div.style.transform = divProps.originalTransform;
  17370. }
  17371. }
  17372. }
  17373. };
  17374. function renderTextLayer(renderParameters) {
  17375. var task = new TextLayerRenderTask({
  17376. textContent: renderParameters.textContent,
  17377. textContentStream: renderParameters.textContentStream,
  17378. container: renderParameters.container,
  17379. viewport: renderParameters.viewport,
  17380. textDivs: renderParameters.textDivs,
  17381. textContentItemsStr: renderParameters.textContentItemsStr,
  17382. enhanceTextSelection: renderParameters.enhanceTextSelection
  17383. });
  17384. task._render(renderParameters.timeout);
  17385. return task;
  17386. }
  17387. return renderTextLayer;
  17388. }();
  17389. exports.renderTextLayer = renderTextLayer;
  17390. /***/ }),
  17391. /* 195 */
  17392. /***/ (function(module, exports, __w_pdfjs_require__) {
  17393. "use strict";
  17394. Object.defineProperty(exports, "__esModule", {
  17395. value: true
  17396. });
  17397. exports.AnnotationLayer = void 0;
  17398. var _display_utils = __w_pdfjs_require__(183);
  17399. var _util = __w_pdfjs_require__(1);
  17400. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  17401. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  17402. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17403. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17404. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17405. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17406. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17407. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17408. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17409. 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); } }
  17410. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17411. var AnnotationElementFactory =
  17412. /*#__PURE__*/
  17413. function () {
  17414. function AnnotationElementFactory() {
  17415. _classCallCheck(this, AnnotationElementFactory);
  17416. }
  17417. _createClass(AnnotationElementFactory, null, [{
  17418. key: "create",
  17419. value: function create(parameters) {
  17420. var subtype = parameters.data.annotationType;
  17421. switch (subtype) {
  17422. case _util.AnnotationType.LINK:
  17423. return new LinkAnnotationElement(parameters);
  17424. case _util.AnnotationType.TEXT:
  17425. return new TextAnnotationElement(parameters);
  17426. case _util.AnnotationType.WIDGET:
  17427. var fieldType = parameters.data.fieldType;
  17428. switch (fieldType) {
  17429. case 'Tx':
  17430. return new TextWidgetAnnotationElement(parameters);
  17431. case 'Btn':
  17432. if (parameters.data.radioButton) {
  17433. return new RadioButtonWidgetAnnotationElement(parameters);
  17434. } else if (parameters.data.checkBox) {
  17435. return new CheckboxWidgetAnnotationElement(parameters);
  17436. }
  17437. return new PushButtonWidgetAnnotationElement(parameters);
  17438. case 'Ch':
  17439. return new ChoiceWidgetAnnotationElement(parameters);
  17440. }
  17441. return new WidgetAnnotationElement(parameters);
  17442. case _util.AnnotationType.POPUP:
  17443. return new PopupAnnotationElement(parameters);
  17444. case _util.AnnotationType.FREETEXT:
  17445. return new FreeTextAnnotationElement(parameters);
  17446. case _util.AnnotationType.LINE:
  17447. return new LineAnnotationElement(parameters);
  17448. case _util.AnnotationType.SQUARE:
  17449. return new SquareAnnotationElement(parameters);
  17450. case _util.AnnotationType.CIRCLE:
  17451. return new CircleAnnotationElement(parameters);
  17452. case _util.AnnotationType.POLYLINE:
  17453. return new PolylineAnnotationElement(parameters);
  17454. case _util.AnnotationType.CARET:
  17455. return new CaretAnnotationElement(parameters);
  17456. case _util.AnnotationType.INK:
  17457. return new InkAnnotationElement(parameters);
  17458. case _util.AnnotationType.POLYGON:
  17459. return new PolygonAnnotationElement(parameters);
  17460. case _util.AnnotationType.HIGHLIGHT:
  17461. return new HighlightAnnotationElement(parameters);
  17462. case _util.AnnotationType.UNDERLINE:
  17463. return new UnderlineAnnotationElement(parameters);
  17464. case _util.AnnotationType.SQUIGGLY:
  17465. return new SquigglyAnnotationElement(parameters);
  17466. case _util.AnnotationType.STRIKEOUT:
  17467. return new StrikeOutAnnotationElement(parameters);
  17468. case _util.AnnotationType.STAMP:
  17469. return new StampAnnotationElement(parameters);
  17470. case _util.AnnotationType.FILEATTACHMENT:
  17471. return new FileAttachmentAnnotationElement(parameters);
  17472. default:
  17473. return new AnnotationElement(parameters);
  17474. }
  17475. }
  17476. }]);
  17477. return AnnotationElementFactory;
  17478. }();
  17479. var AnnotationElement =
  17480. /*#__PURE__*/
  17481. function () {
  17482. function AnnotationElement(parameters) {
  17483. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  17484. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17485. _classCallCheck(this, AnnotationElement);
  17486. this.isRenderable = isRenderable;
  17487. this.data = parameters.data;
  17488. this.layer = parameters.layer;
  17489. this.page = parameters.page;
  17490. this.viewport = parameters.viewport;
  17491. this.linkService = parameters.linkService;
  17492. this.downloadManager = parameters.downloadManager;
  17493. this.imageResourcesPath = parameters.imageResourcesPath;
  17494. this.renderInteractiveForms = parameters.renderInteractiveForms;
  17495. this.svgFactory = parameters.svgFactory;
  17496. if (isRenderable) {
  17497. this.container = this._createContainer(ignoreBorder);
  17498. }
  17499. }
  17500. _createClass(AnnotationElement, [{
  17501. key: "_createContainer",
  17502. value: function _createContainer() {
  17503. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17504. var data = this.data,
  17505. page = this.page,
  17506. viewport = this.viewport;
  17507. var container = document.createElement('section');
  17508. var width = data.rect[2] - data.rect[0];
  17509. var height = data.rect[3] - data.rect[1];
  17510. container.setAttribute('data-annotation-id', data.id);
  17511. 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]]);
  17512. container.style.transform = "matrix(".concat(viewport.transform.join(','), ")");
  17513. container.style.transformOrigin = "-".concat(rect[0], "px -").concat(rect[1], "px");
  17514. if (!ignoreBorder && data.borderStyle.width > 0) {
  17515. container.style.borderWidth = "".concat(data.borderStyle.width, "px");
  17516. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  17517. width = width - 2 * data.borderStyle.width;
  17518. height = height - 2 * data.borderStyle.width;
  17519. }
  17520. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  17521. var verticalRadius = data.borderStyle.verticalCornerRadius;
  17522. if (horizontalRadius > 0 || verticalRadius > 0) {
  17523. var radius = "".concat(horizontalRadius, "px / ").concat(verticalRadius, "px");
  17524. container.style.borderRadius = radius;
  17525. }
  17526. switch (data.borderStyle.style) {
  17527. case _util.AnnotationBorderStyleType.SOLID:
  17528. container.style.borderStyle = 'solid';
  17529. break;
  17530. case _util.AnnotationBorderStyleType.DASHED:
  17531. container.style.borderStyle = 'dashed';
  17532. break;
  17533. case _util.AnnotationBorderStyleType.BEVELED:
  17534. (0, _util.warn)('Unimplemented border style: beveled');
  17535. break;
  17536. case _util.AnnotationBorderStyleType.INSET:
  17537. (0, _util.warn)('Unimplemented border style: inset');
  17538. break;
  17539. case _util.AnnotationBorderStyleType.UNDERLINE:
  17540. container.style.borderBottomStyle = 'solid';
  17541. break;
  17542. default:
  17543. break;
  17544. }
  17545. if (data.color) {
  17546. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  17547. } else {
  17548. container.style.borderWidth = 0;
  17549. }
  17550. }
  17551. container.style.left = "".concat(rect[0], "px");
  17552. container.style.top = "".concat(rect[1], "px");
  17553. container.style.width = "".concat(width, "px");
  17554. container.style.height = "".concat(height, "px");
  17555. return container;
  17556. }
  17557. }, {
  17558. key: "_createPopup",
  17559. value: function _createPopup(container, trigger, data) {
  17560. if (!trigger) {
  17561. trigger = document.createElement('div');
  17562. trigger.style.height = container.style.height;
  17563. trigger.style.width = container.style.width;
  17564. container.appendChild(trigger);
  17565. }
  17566. var popupElement = new PopupElement({
  17567. container: container,
  17568. trigger: trigger,
  17569. color: data.color,
  17570. title: data.title,
  17571. modificationDate: data.modificationDate,
  17572. contents: data.contents,
  17573. hideWrapper: true
  17574. });
  17575. var popup = popupElement.render();
  17576. popup.style.left = container.style.width;
  17577. container.appendChild(popup);
  17578. }
  17579. }, {
  17580. key: "render",
  17581. value: function render() {
  17582. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  17583. }
  17584. }]);
  17585. return AnnotationElement;
  17586. }();
  17587. var LinkAnnotationElement =
  17588. /*#__PURE__*/
  17589. function (_AnnotationElement) {
  17590. _inherits(LinkAnnotationElement, _AnnotationElement);
  17591. function LinkAnnotationElement(parameters) {
  17592. _classCallCheck(this, LinkAnnotationElement);
  17593. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  17594. return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
  17595. }
  17596. _createClass(LinkAnnotationElement, [{
  17597. key: "render",
  17598. value: function render() {
  17599. this.container.className = 'linkAnnotation';
  17600. var data = this.data,
  17601. linkService = this.linkService;
  17602. var link = document.createElement('a');
  17603. if (data.url) {
  17604. (0, _display_utils.addLinkAttributes)(link, {
  17605. url: data.url,
  17606. target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  17607. rel: linkService.externalLinkRel,
  17608. enabled: linkService.externalLinkEnabled
  17609. });
  17610. } else if (data.action) {
  17611. this._bindNamedAction(link, data.action);
  17612. } else {
  17613. this._bindLink(link, data.dest);
  17614. }
  17615. this.container.appendChild(link);
  17616. return this.container;
  17617. }
  17618. }, {
  17619. key: "_bindLink",
  17620. value: function _bindLink(link, destination) {
  17621. var _this = this;
  17622. link.href = this.linkService.getDestinationHash(destination);
  17623. link.onclick = function () {
  17624. if (destination) {
  17625. _this.linkService.navigateTo(destination);
  17626. }
  17627. return false;
  17628. };
  17629. if (destination) {
  17630. link.className = 'internalLink';
  17631. }
  17632. }
  17633. }, {
  17634. key: "_bindNamedAction",
  17635. value: function _bindNamedAction(link, action) {
  17636. var _this2 = this;
  17637. link.href = this.linkService.getAnchorUrl('');
  17638. link.onclick = function () {
  17639. _this2.linkService.executeNamedAction(action);
  17640. return false;
  17641. };
  17642. link.className = 'internalLink';
  17643. }
  17644. }]);
  17645. return LinkAnnotationElement;
  17646. }(AnnotationElement);
  17647. var TextAnnotationElement =
  17648. /*#__PURE__*/
  17649. function (_AnnotationElement2) {
  17650. _inherits(TextAnnotationElement, _AnnotationElement2);
  17651. function TextAnnotationElement(parameters) {
  17652. _classCallCheck(this, TextAnnotationElement);
  17653. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  17654. return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
  17655. }
  17656. _createClass(TextAnnotationElement, [{
  17657. key: "render",
  17658. value: function render() {
  17659. this.container.className = 'textAnnotation';
  17660. var image = document.createElement('img');
  17661. image.style.height = this.container.style.height;
  17662. image.style.width = this.container.style.width;
  17663. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  17664. image.alt = '[{{type}} Annotation]';
  17665. image.dataset.l10nId = 'text_annotation_type';
  17666. image.dataset.l10nArgs = JSON.stringify({
  17667. type: this.data.name
  17668. });
  17669. if (!this.data.hasPopup) {
  17670. this._createPopup(this.container, image, this.data);
  17671. }
  17672. this.container.appendChild(image);
  17673. return this.container;
  17674. }
  17675. }]);
  17676. return TextAnnotationElement;
  17677. }(AnnotationElement);
  17678. var WidgetAnnotationElement =
  17679. /*#__PURE__*/
  17680. function (_AnnotationElement3) {
  17681. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  17682. function WidgetAnnotationElement() {
  17683. _classCallCheck(this, WidgetAnnotationElement);
  17684. return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
  17685. }
  17686. _createClass(WidgetAnnotationElement, [{
  17687. key: "render",
  17688. value: function render() {
  17689. return this.container;
  17690. }
  17691. }]);
  17692. return WidgetAnnotationElement;
  17693. }(AnnotationElement);
  17694. var TextWidgetAnnotationElement =
  17695. /*#__PURE__*/
  17696. function (_WidgetAnnotationElem) {
  17697. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  17698. function TextWidgetAnnotationElement(parameters) {
  17699. _classCallCheck(this, TextWidgetAnnotationElement);
  17700. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  17701. return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
  17702. }
  17703. _createClass(TextWidgetAnnotationElement, [{
  17704. key: "render",
  17705. value: function render() {
  17706. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  17707. this.container.className = 'textWidgetAnnotation';
  17708. var element = null;
  17709. if (this.renderInteractiveForms) {
  17710. if (this.data.multiLine) {
  17711. element = document.createElement('textarea');
  17712. element.textContent = this.data.fieldValue;
  17713. } else {
  17714. element = document.createElement('input');
  17715. element.type = 'text';
  17716. element.setAttribute('value', this.data.fieldValue);
  17717. }
  17718. element.disabled = this.data.readOnly;
  17719. if (this.data.maxLen !== null) {
  17720. element.maxLength = this.data.maxLen;
  17721. }
  17722. if (this.data.comb) {
  17723. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  17724. var combWidth = fieldWidth / this.data.maxLen;
  17725. element.classList.add('comb');
  17726. element.style.letterSpacing = "calc(".concat(combWidth, "px - 1ch)");
  17727. }
  17728. } else {
  17729. element = document.createElement('div');
  17730. element.textContent = this.data.fieldValue;
  17731. element.style.verticalAlign = 'middle';
  17732. element.style.display = 'table-cell';
  17733. var font = null;
  17734. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  17735. font = this.page.commonObjs.get(this.data.fontRefName);
  17736. }
  17737. this._setTextStyle(element, font);
  17738. }
  17739. if (this.data.textAlignment !== null) {
  17740. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  17741. }
  17742. this.container.appendChild(element);
  17743. return this.container;
  17744. }
  17745. }, {
  17746. key: "_setTextStyle",
  17747. value: function _setTextStyle(element, font) {
  17748. var style = element.style;
  17749. style.fontSize = "".concat(this.data.fontSize, "px");
  17750. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  17751. if (!font) {
  17752. return;
  17753. }
  17754. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  17755. style.fontStyle = font.italic ? 'italic' : 'normal';
  17756. var fontFamily = font.loadedName ? "\"".concat(font.loadedName, "\", ") : '';
  17757. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  17758. style.fontFamily = fontFamily + fallbackName;
  17759. }
  17760. }]);
  17761. return TextWidgetAnnotationElement;
  17762. }(WidgetAnnotationElement);
  17763. var CheckboxWidgetAnnotationElement =
  17764. /*#__PURE__*/
  17765. function (_WidgetAnnotationElem2) {
  17766. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  17767. function CheckboxWidgetAnnotationElement(parameters) {
  17768. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  17769. return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  17770. }
  17771. _createClass(CheckboxWidgetAnnotationElement, [{
  17772. key: "render",
  17773. value: function render() {
  17774. this.container.className = 'buttonWidgetAnnotation checkBox';
  17775. var element = document.createElement('input');
  17776. element.disabled = this.data.readOnly;
  17777. element.type = 'checkbox';
  17778. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  17779. element.setAttribute('checked', true);
  17780. }
  17781. this.container.appendChild(element);
  17782. return this.container;
  17783. }
  17784. }]);
  17785. return CheckboxWidgetAnnotationElement;
  17786. }(WidgetAnnotationElement);
  17787. var RadioButtonWidgetAnnotationElement =
  17788. /*#__PURE__*/
  17789. function (_WidgetAnnotationElem3) {
  17790. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  17791. function RadioButtonWidgetAnnotationElement(parameters) {
  17792. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  17793. return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  17794. }
  17795. _createClass(RadioButtonWidgetAnnotationElement, [{
  17796. key: "render",
  17797. value: function render() {
  17798. this.container.className = 'buttonWidgetAnnotation radioButton';
  17799. var element = document.createElement('input');
  17800. element.disabled = this.data.readOnly;
  17801. element.type = 'radio';
  17802. element.name = this.data.fieldName;
  17803. if (this.data.fieldValue === this.data.buttonValue) {
  17804. element.setAttribute('checked', true);
  17805. }
  17806. this.container.appendChild(element);
  17807. return this.container;
  17808. }
  17809. }]);
  17810. return RadioButtonWidgetAnnotationElement;
  17811. }(WidgetAnnotationElement);
  17812. var PushButtonWidgetAnnotationElement =
  17813. /*#__PURE__*/
  17814. function (_LinkAnnotationElemen) {
  17815. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  17816. function PushButtonWidgetAnnotationElement() {
  17817. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  17818. return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
  17819. }
  17820. _createClass(PushButtonWidgetAnnotationElement, [{
  17821. key: "render",
  17822. value: function render() {
  17823. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  17824. container.className = 'buttonWidgetAnnotation pushButton';
  17825. return container;
  17826. }
  17827. }]);
  17828. return PushButtonWidgetAnnotationElement;
  17829. }(LinkAnnotationElement);
  17830. var ChoiceWidgetAnnotationElement =
  17831. /*#__PURE__*/
  17832. function (_WidgetAnnotationElem4) {
  17833. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  17834. function ChoiceWidgetAnnotationElement(parameters) {
  17835. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  17836. return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  17837. }
  17838. _createClass(ChoiceWidgetAnnotationElement, [{
  17839. key: "render",
  17840. value: function render() {
  17841. this.container.className = 'choiceWidgetAnnotation';
  17842. var selectElement = document.createElement('select');
  17843. selectElement.disabled = this.data.readOnly;
  17844. if (!this.data.combo) {
  17845. selectElement.size = this.data.options.length;
  17846. if (this.data.multiSelect) {
  17847. selectElement.multiple = true;
  17848. }
  17849. }
  17850. var _iteratorNormalCompletion = true;
  17851. var _didIteratorError = false;
  17852. var _iteratorError = undefined;
  17853. try {
  17854. for (var _iterator = this.data.options[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  17855. var option = _step.value;
  17856. var optionElement = document.createElement('option');
  17857. optionElement.textContent = option.displayValue;
  17858. optionElement.value = option.exportValue;
  17859. if (this.data.fieldValue.includes(option.displayValue)) {
  17860. optionElement.setAttribute('selected', true);
  17861. }
  17862. selectElement.appendChild(optionElement);
  17863. }
  17864. } catch (err) {
  17865. _didIteratorError = true;
  17866. _iteratorError = err;
  17867. } finally {
  17868. try {
  17869. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  17870. _iterator["return"]();
  17871. }
  17872. } finally {
  17873. if (_didIteratorError) {
  17874. throw _iteratorError;
  17875. }
  17876. }
  17877. }
  17878. this.container.appendChild(selectElement);
  17879. return this.container;
  17880. }
  17881. }]);
  17882. return ChoiceWidgetAnnotationElement;
  17883. }(WidgetAnnotationElement);
  17884. var PopupAnnotationElement =
  17885. /*#__PURE__*/
  17886. function (_AnnotationElement4) {
  17887. _inherits(PopupAnnotationElement, _AnnotationElement4);
  17888. function PopupAnnotationElement(parameters) {
  17889. _classCallCheck(this, PopupAnnotationElement);
  17890. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  17891. return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
  17892. }
  17893. _createClass(PopupAnnotationElement, [{
  17894. key: "render",
  17895. value: function render() {
  17896. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  17897. this.container.className = 'popupAnnotation';
  17898. if (IGNORE_TYPES.includes(this.data.parentType)) {
  17899. return this.container;
  17900. }
  17901. var selector = "[data-annotation-id=\"".concat(this.data.parentId, "\"]");
  17902. var parentElement = this.layer.querySelector(selector);
  17903. if (!parentElement) {
  17904. return this.container;
  17905. }
  17906. var popup = new PopupElement({
  17907. container: this.container,
  17908. trigger: parentElement,
  17909. color: this.data.color,
  17910. title: this.data.title,
  17911. modificationDate: this.data.modificationDate,
  17912. contents: this.data.contents
  17913. });
  17914. var parentLeft = parseFloat(parentElement.style.left);
  17915. var parentWidth = parseFloat(parentElement.style.width);
  17916. this.container.style.transformOrigin = "-".concat(parentLeft + parentWidth, "px -").concat(parentElement.style.top);
  17917. this.container.style.left = "".concat(parentLeft + parentWidth, "px");
  17918. this.container.appendChild(popup.render());
  17919. return this.container;
  17920. }
  17921. }]);
  17922. return PopupAnnotationElement;
  17923. }(AnnotationElement);
  17924. var PopupElement =
  17925. /*#__PURE__*/
  17926. function () {
  17927. function PopupElement(parameters) {
  17928. _classCallCheck(this, PopupElement);
  17929. this.container = parameters.container;
  17930. this.trigger = parameters.trigger;
  17931. this.color = parameters.color;
  17932. this.title = parameters.title;
  17933. this.modificationDate = parameters.modificationDate;
  17934. this.contents = parameters.contents;
  17935. this.hideWrapper = parameters.hideWrapper || false;
  17936. this.pinned = false;
  17937. }
  17938. _createClass(PopupElement, [{
  17939. key: "render",
  17940. value: function render() {
  17941. var BACKGROUND_ENLIGHT = 0.7;
  17942. var wrapper = document.createElement('div');
  17943. wrapper.className = 'popupWrapper';
  17944. this.hideElement = this.hideWrapper ? wrapper : this.container;
  17945. this.hideElement.setAttribute('hidden', true);
  17946. var popup = document.createElement('div');
  17947. popup.className = 'popup';
  17948. var color = this.color;
  17949. if (color) {
  17950. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  17951. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  17952. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  17953. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  17954. }
  17955. var title = document.createElement('h1');
  17956. title.textContent = this.title;
  17957. popup.appendChild(title);
  17958. var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
  17959. if (dateObject) {
  17960. var modificationDate = document.createElement('span');
  17961. modificationDate.textContent = '{{date}}, {{time}}';
  17962. modificationDate.dataset.l10nId = 'annotation_date_string';
  17963. modificationDate.dataset.l10nArgs = JSON.stringify({
  17964. date: dateObject.toLocaleDateString(),
  17965. time: dateObject.toLocaleTimeString()
  17966. });
  17967. popup.appendChild(modificationDate);
  17968. }
  17969. var contents = this._formatContents(this.contents);
  17970. popup.appendChild(contents);
  17971. this.trigger.addEventListener('click', this._toggle.bind(this));
  17972. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  17973. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  17974. popup.addEventListener('click', this._hide.bind(this, true));
  17975. wrapper.appendChild(popup);
  17976. return wrapper;
  17977. }
  17978. }, {
  17979. key: "_formatContents",
  17980. value: function _formatContents(contents) {
  17981. var p = document.createElement('p');
  17982. var lines = contents.split(/(?:\r\n?|\n)/);
  17983. for (var i = 0, ii = lines.length; i < ii; ++i) {
  17984. var line = lines[i];
  17985. p.appendChild(document.createTextNode(line));
  17986. if (i < ii - 1) {
  17987. p.appendChild(document.createElement('br'));
  17988. }
  17989. }
  17990. return p;
  17991. }
  17992. }, {
  17993. key: "_toggle",
  17994. value: function _toggle() {
  17995. if (this.pinned) {
  17996. this._hide(true);
  17997. } else {
  17998. this._show(true);
  17999. }
  18000. }
  18001. }, {
  18002. key: "_show",
  18003. value: function _show() {
  18004. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18005. if (pin) {
  18006. this.pinned = true;
  18007. }
  18008. if (this.hideElement.hasAttribute('hidden')) {
  18009. this.hideElement.removeAttribute('hidden');
  18010. this.container.style.zIndex += 1;
  18011. }
  18012. }
  18013. }, {
  18014. key: "_hide",
  18015. value: function _hide() {
  18016. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  18017. if (unpin) {
  18018. this.pinned = false;
  18019. }
  18020. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18021. this.hideElement.setAttribute('hidden', true);
  18022. this.container.style.zIndex -= 1;
  18023. }
  18024. }
  18025. }]);
  18026. return PopupElement;
  18027. }();
  18028. var FreeTextAnnotationElement =
  18029. /*#__PURE__*/
  18030. function (_AnnotationElement5) {
  18031. _inherits(FreeTextAnnotationElement, _AnnotationElement5);
  18032. function FreeTextAnnotationElement(parameters) {
  18033. _classCallCheck(this, FreeTextAnnotationElement);
  18034. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18035. return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));
  18036. }
  18037. _createClass(FreeTextAnnotationElement, [{
  18038. key: "render",
  18039. value: function render() {
  18040. this.container.className = 'freeTextAnnotation';
  18041. if (!this.data.hasPopup) {
  18042. this._createPopup(this.container, null, this.data);
  18043. }
  18044. return this.container;
  18045. }
  18046. }]);
  18047. return FreeTextAnnotationElement;
  18048. }(AnnotationElement);
  18049. var LineAnnotationElement =
  18050. /*#__PURE__*/
  18051. function (_AnnotationElement6) {
  18052. _inherits(LineAnnotationElement, _AnnotationElement6);
  18053. function LineAnnotationElement(parameters) {
  18054. _classCallCheck(this, LineAnnotationElement);
  18055. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18056. return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
  18057. }
  18058. _createClass(LineAnnotationElement, [{
  18059. key: "render",
  18060. value: function render() {
  18061. this.container.className = 'lineAnnotation';
  18062. var data = this.data;
  18063. var width = data.rect[2] - data.rect[0];
  18064. var height = data.rect[3] - data.rect[1];
  18065. var svg = this.svgFactory.create(width, height);
  18066. var line = this.svgFactory.createElement('svg:line');
  18067. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  18068. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  18069. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  18070. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  18071. line.setAttribute('stroke-width', data.borderStyle.width);
  18072. line.setAttribute('stroke', 'transparent');
  18073. svg.appendChild(line);
  18074. this.container.append(svg);
  18075. this._createPopup(this.container, line, data);
  18076. return this.container;
  18077. }
  18078. }]);
  18079. return LineAnnotationElement;
  18080. }(AnnotationElement);
  18081. var SquareAnnotationElement =
  18082. /*#__PURE__*/
  18083. function (_AnnotationElement7) {
  18084. _inherits(SquareAnnotationElement, _AnnotationElement7);
  18085. function SquareAnnotationElement(parameters) {
  18086. _classCallCheck(this, SquareAnnotationElement);
  18087. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18088. return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
  18089. }
  18090. _createClass(SquareAnnotationElement, [{
  18091. key: "render",
  18092. value: function render() {
  18093. this.container.className = 'squareAnnotation';
  18094. var data = this.data;
  18095. var width = data.rect[2] - data.rect[0];
  18096. var height = data.rect[3] - data.rect[1];
  18097. var svg = this.svgFactory.create(width, height);
  18098. var borderWidth = data.borderStyle.width;
  18099. var square = this.svgFactory.createElement('svg:rect');
  18100. square.setAttribute('x', borderWidth / 2);
  18101. square.setAttribute('y', borderWidth / 2);
  18102. square.setAttribute('width', width - borderWidth);
  18103. square.setAttribute('height', height - borderWidth);
  18104. square.setAttribute('stroke-width', borderWidth);
  18105. square.setAttribute('stroke', 'transparent');
  18106. square.setAttribute('fill', 'none');
  18107. svg.appendChild(square);
  18108. this.container.append(svg);
  18109. this._createPopup(this.container, square, data);
  18110. return this.container;
  18111. }
  18112. }]);
  18113. return SquareAnnotationElement;
  18114. }(AnnotationElement);
  18115. var CircleAnnotationElement =
  18116. /*#__PURE__*/
  18117. function (_AnnotationElement8) {
  18118. _inherits(CircleAnnotationElement, _AnnotationElement8);
  18119. function CircleAnnotationElement(parameters) {
  18120. _classCallCheck(this, CircleAnnotationElement);
  18121. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18122. return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
  18123. }
  18124. _createClass(CircleAnnotationElement, [{
  18125. key: "render",
  18126. value: function render() {
  18127. this.container.className = 'circleAnnotation';
  18128. var data = this.data;
  18129. var width = data.rect[2] - data.rect[0];
  18130. var height = data.rect[3] - data.rect[1];
  18131. var svg = this.svgFactory.create(width, height);
  18132. var borderWidth = data.borderStyle.width;
  18133. var circle = this.svgFactory.createElement('svg:ellipse');
  18134. circle.setAttribute('cx', width / 2);
  18135. circle.setAttribute('cy', height / 2);
  18136. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  18137. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  18138. circle.setAttribute('stroke-width', borderWidth);
  18139. circle.setAttribute('stroke', 'transparent');
  18140. circle.setAttribute('fill', 'none');
  18141. svg.appendChild(circle);
  18142. this.container.append(svg);
  18143. this._createPopup(this.container, circle, data);
  18144. return this.container;
  18145. }
  18146. }]);
  18147. return CircleAnnotationElement;
  18148. }(AnnotationElement);
  18149. var PolylineAnnotationElement =
  18150. /*#__PURE__*/
  18151. function (_AnnotationElement9) {
  18152. _inherits(PolylineAnnotationElement, _AnnotationElement9);
  18153. function PolylineAnnotationElement(parameters) {
  18154. var _this3;
  18155. _classCallCheck(this, PolylineAnnotationElement);
  18156. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18157. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
  18158. _this3.containerClassName = 'polylineAnnotation';
  18159. _this3.svgElementName = 'svg:polyline';
  18160. return _this3;
  18161. }
  18162. _createClass(PolylineAnnotationElement, [{
  18163. key: "render",
  18164. value: function render() {
  18165. this.container.className = this.containerClassName;
  18166. var data = this.data;
  18167. var width = data.rect[2] - data.rect[0];
  18168. var height = data.rect[3] - data.rect[1];
  18169. var svg = this.svgFactory.create(width, height);
  18170. var points = [];
  18171. var _iteratorNormalCompletion2 = true;
  18172. var _didIteratorError2 = false;
  18173. var _iteratorError2 = undefined;
  18174. try {
  18175. for (var _iterator2 = data.vertices[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  18176. var coordinate = _step2.value;
  18177. var x = coordinate.x - data.rect[0];
  18178. var y = data.rect[3] - coordinate.y;
  18179. points.push(x + ',' + y);
  18180. }
  18181. } catch (err) {
  18182. _didIteratorError2 = true;
  18183. _iteratorError2 = err;
  18184. } finally {
  18185. try {
  18186. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  18187. _iterator2["return"]();
  18188. }
  18189. } finally {
  18190. if (_didIteratorError2) {
  18191. throw _iteratorError2;
  18192. }
  18193. }
  18194. }
  18195. points = points.join(' ');
  18196. var polyline = this.svgFactory.createElement(this.svgElementName);
  18197. polyline.setAttribute('points', points);
  18198. polyline.setAttribute('stroke-width', data.borderStyle.width);
  18199. polyline.setAttribute('stroke', 'transparent');
  18200. polyline.setAttribute('fill', 'none');
  18201. svg.appendChild(polyline);
  18202. this.container.append(svg);
  18203. this._createPopup(this.container, polyline, data);
  18204. return this.container;
  18205. }
  18206. }]);
  18207. return PolylineAnnotationElement;
  18208. }(AnnotationElement);
  18209. var PolygonAnnotationElement =
  18210. /*#__PURE__*/
  18211. function (_PolylineAnnotationEl) {
  18212. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  18213. function PolygonAnnotationElement(parameters) {
  18214. var _this4;
  18215. _classCallCheck(this, PolygonAnnotationElement);
  18216. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
  18217. _this4.containerClassName = 'polygonAnnotation';
  18218. _this4.svgElementName = 'svg:polygon';
  18219. return _this4;
  18220. }
  18221. return PolygonAnnotationElement;
  18222. }(PolylineAnnotationElement);
  18223. var CaretAnnotationElement =
  18224. /*#__PURE__*/
  18225. function (_AnnotationElement10) {
  18226. _inherits(CaretAnnotationElement, _AnnotationElement10);
  18227. function CaretAnnotationElement(parameters) {
  18228. _classCallCheck(this, CaretAnnotationElement);
  18229. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18230. return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));
  18231. }
  18232. _createClass(CaretAnnotationElement, [{
  18233. key: "render",
  18234. value: function render() {
  18235. this.container.className = 'caretAnnotation';
  18236. if (!this.data.hasPopup) {
  18237. this._createPopup(this.container, null, this.data);
  18238. }
  18239. return this.container;
  18240. }
  18241. }]);
  18242. return CaretAnnotationElement;
  18243. }(AnnotationElement);
  18244. var InkAnnotationElement =
  18245. /*#__PURE__*/
  18246. function (_AnnotationElement11) {
  18247. _inherits(InkAnnotationElement, _AnnotationElement11);
  18248. function InkAnnotationElement(parameters) {
  18249. var _this5;
  18250. _classCallCheck(this, InkAnnotationElement);
  18251. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18252. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
  18253. _this5.containerClassName = 'inkAnnotation';
  18254. _this5.svgElementName = 'svg:polyline';
  18255. return _this5;
  18256. }
  18257. _createClass(InkAnnotationElement, [{
  18258. key: "render",
  18259. value: function render() {
  18260. this.container.className = this.containerClassName;
  18261. var data = this.data;
  18262. var width = data.rect[2] - data.rect[0];
  18263. var height = data.rect[3] - data.rect[1];
  18264. var svg = this.svgFactory.create(width, height);
  18265. var _iteratorNormalCompletion3 = true;
  18266. var _didIteratorError3 = false;
  18267. var _iteratorError3 = undefined;
  18268. try {
  18269. for (var _iterator3 = data.inkLists[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  18270. var inkList = _step3.value;
  18271. var points = [];
  18272. var _iteratorNormalCompletion4 = true;
  18273. var _didIteratorError4 = false;
  18274. var _iteratorError4 = undefined;
  18275. try {
  18276. for (var _iterator4 = inkList[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  18277. var coordinate = _step4.value;
  18278. var x = coordinate.x - data.rect[0];
  18279. var y = data.rect[3] - coordinate.y;
  18280. points.push("".concat(x, ",").concat(y));
  18281. }
  18282. } catch (err) {
  18283. _didIteratorError4 = true;
  18284. _iteratorError4 = err;
  18285. } finally {
  18286. try {
  18287. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  18288. _iterator4["return"]();
  18289. }
  18290. } finally {
  18291. if (_didIteratorError4) {
  18292. throw _iteratorError4;
  18293. }
  18294. }
  18295. }
  18296. points = points.join(' ');
  18297. var polyline = this.svgFactory.createElement(this.svgElementName);
  18298. polyline.setAttribute('points', points);
  18299. polyline.setAttribute('stroke-width', data.borderStyle.width);
  18300. polyline.setAttribute('stroke', 'transparent');
  18301. polyline.setAttribute('fill', 'none');
  18302. this._createPopup(this.container, polyline, data);
  18303. svg.appendChild(polyline);
  18304. }
  18305. } catch (err) {
  18306. _didIteratorError3 = true;
  18307. _iteratorError3 = err;
  18308. } finally {
  18309. try {
  18310. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  18311. _iterator3["return"]();
  18312. }
  18313. } finally {
  18314. if (_didIteratorError3) {
  18315. throw _iteratorError3;
  18316. }
  18317. }
  18318. }
  18319. this.container.append(svg);
  18320. return this.container;
  18321. }
  18322. }]);
  18323. return InkAnnotationElement;
  18324. }(AnnotationElement);
  18325. var HighlightAnnotationElement =
  18326. /*#__PURE__*/
  18327. function (_AnnotationElement12) {
  18328. _inherits(HighlightAnnotationElement, _AnnotationElement12);
  18329. function HighlightAnnotationElement(parameters) {
  18330. _classCallCheck(this, HighlightAnnotationElement);
  18331. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18332. return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
  18333. }
  18334. _createClass(HighlightAnnotationElement, [{
  18335. key: "render",
  18336. value: function render() {
  18337. this.container.className = 'highlightAnnotation';
  18338. if (!this.data.hasPopup) {
  18339. this._createPopup(this.container, null, this.data);
  18340. }
  18341. return this.container;
  18342. }
  18343. }]);
  18344. return HighlightAnnotationElement;
  18345. }(AnnotationElement);
  18346. var UnderlineAnnotationElement =
  18347. /*#__PURE__*/
  18348. function (_AnnotationElement13) {
  18349. _inherits(UnderlineAnnotationElement, _AnnotationElement13);
  18350. function UnderlineAnnotationElement(parameters) {
  18351. _classCallCheck(this, UnderlineAnnotationElement);
  18352. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18353. return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
  18354. }
  18355. _createClass(UnderlineAnnotationElement, [{
  18356. key: "render",
  18357. value: function render() {
  18358. this.container.className = 'underlineAnnotation';
  18359. if (!this.data.hasPopup) {
  18360. this._createPopup(this.container, null, this.data);
  18361. }
  18362. return this.container;
  18363. }
  18364. }]);
  18365. return UnderlineAnnotationElement;
  18366. }(AnnotationElement);
  18367. var SquigglyAnnotationElement =
  18368. /*#__PURE__*/
  18369. function (_AnnotationElement14) {
  18370. _inherits(SquigglyAnnotationElement, _AnnotationElement14);
  18371. function SquigglyAnnotationElement(parameters) {
  18372. _classCallCheck(this, SquigglyAnnotationElement);
  18373. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18374. return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
  18375. }
  18376. _createClass(SquigglyAnnotationElement, [{
  18377. key: "render",
  18378. value: function render() {
  18379. this.container.className = 'squigglyAnnotation';
  18380. if (!this.data.hasPopup) {
  18381. this._createPopup(this.container, null, this.data);
  18382. }
  18383. return this.container;
  18384. }
  18385. }]);
  18386. return SquigglyAnnotationElement;
  18387. }(AnnotationElement);
  18388. var StrikeOutAnnotationElement =
  18389. /*#__PURE__*/
  18390. function (_AnnotationElement15) {
  18391. _inherits(StrikeOutAnnotationElement, _AnnotationElement15);
  18392. function StrikeOutAnnotationElement(parameters) {
  18393. _classCallCheck(this, StrikeOutAnnotationElement);
  18394. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18395. return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
  18396. }
  18397. _createClass(StrikeOutAnnotationElement, [{
  18398. key: "render",
  18399. value: function render() {
  18400. this.container.className = 'strikeoutAnnotation';
  18401. if (!this.data.hasPopup) {
  18402. this._createPopup(this.container, null, this.data);
  18403. }
  18404. return this.container;
  18405. }
  18406. }]);
  18407. return StrikeOutAnnotationElement;
  18408. }(AnnotationElement);
  18409. var StampAnnotationElement =
  18410. /*#__PURE__*/
  18411. function (_AnnotationElement16) {
  18412. _inherits(StampAnnotationElement, _AnnotationElement16);
  18413. function StampAnnotationElement(parameters) {
  18414. _classCallCheck(this, StampAnnotationElement);
  18415. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18416. return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
  18417. }
  18418. _createClass(StampAnnotationElement, [{
  18419. key: "render",
  18420. value: function render() {
  18421. this.container.className = 'stampAnnotation';
  18422. if (!this.data.hasPopup) {
  18423. this._createPopup(this.container, null, this.data);
  18424. }
  18425. return this.container;
  18426. }
  18427. }]);
  18428. return StampAnnotationElement;
  18429. }(AnnotationElement);
  18430. var FileAttachmentAnnotationElement =
  18431. /*#__PURE__*/
  18432. function (_AnnotationElement17) {
  18433. _inherits(FileAttachmentAnnotationElement, _AnnotationElement17);
  18434. function FileAttachmentAnnotationElement(parameters) {
  18435. var _this6;
  18436. _classCallCheck(this, FileAttachmentAnnotationElement);
  18437. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
  18438. var _this6$data$file = _this6.data.file,
  18439. filename = _this6$data$file.filename,
  18440. content = _this6$data$file.content;
  18441. _this6.filename = (0, _display_utils.getFilenameFromUrl)(filename);
  18442. _this6.content = content;
  18443. if (_this6.linkService.eventBus) {
  18444. _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
  18445. source: _assertThisInitialized(_this6),
  18446. id: (0, _util.stringToPDFString)(filename),
  18447. filename: filename,
  18448. content: content
  18449. });
  18450. }
  18451. return _this6;
  18452. }
  18453. _createClass(FileAttachmentAnnotationElement, [{
  18454. key: "render",
  18455. value: function render() {
  18456. this.container.className = 'fileAttachmentAnnotation';
  18457. var trigger = document.createElement('div');
  18458. trigger.style.height = this.container.style.height;
  18459. trigger.style.width = this.container.style.width;
  18460. trigger.addEventListener('dblclick', this._download.bind(this));
  18461. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18462. this._createPopup(this.container, trigger, this.data);
  18463. }
  18464. this.container.appendChild(trigger);
  18465. return this.container;
  18466. }
  18467. }, {
  18468. key: "_download",
  18469. value: function _download() {
  18470. if (!this.downloadManager) {
  18471. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  18472. return;
  18473. }
  18474. this.downloadManager.downloadData(this.content, this.filename, '');
  18475. }
  18476. }]);
  18477. return FileAttachmentAnnotationElement;
  18478. }(AnnotationElement);
  18479. var AnnotationLayer =
  18480. /*#__PURE__*/
  18481. function () {
  18482. function AnnotationLayer() {
  18483. _classCallCheck(this, AnnotationLayer);
  18484. }
  18485. _createClass(AnnotationLayer, null, [{
  18486. key: "render",
  18487. value: function render(parameters) {
  18488. var _iteratorNormalCompletion5 = true;
  18489. var _didIteratorError5 = false;
  18490. var _iteratorError5 = undefined;
  18491. try {
  18492. for (var _iterator5 = parameters.annotations[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  18493. var data = _step5.value;
  18494. if (!data) {
  18495. continue;
  18496. }
  18497. var element = AnnotationElementFactory.create({
  18498. data: data,
  18499. layer: parameters.div,
  18500. page: parameters.page,
  18501. viewport: parameters.viewport,
  18502. linkService: parameters.linkService,
  18503. downloadManager: parameters.downloadManager,
  18504. imageResourcesPath: parameters.imageResourcesPath || '',
  18505. renderInteractiveForms: parameters.renderInteractiveForms || false,
  18506. svgFactory: new _display_utils.DOMSVGFactory()
  18507. });
  18508. if (element.isRenderable) {
  18509. parameters.div.appendChild(element.render());
  18510. }
  18511. }
  18512. } catch (err) {
  18513. _didIteratorError5 = true;
  18514. _iteratorError5 = err;
  18515. } finally {
  18516. try {
  18517. if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
  18518. _iterator5["return"]();
  18519. }
  18520. } finally {
  18521. if (_didIteratorError5) {
  18522. throw _iteratorError5;
  18523. }
  18524. }
  18525. }
  18526. }
  18527. }, {
  18528. key: "update",
  18529. value: function update(parameters) {
  18530. var _iteratorNormalCompletion6 = true;
  18531. var _didIteratorError6 = false;
  18532. var _iteratorError6 = undefined;
  18533. try {
  18534. for (var _iterator6 = parameters.annotations[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  18535. var data = _step6.value;
  18536. var element = parameters.div.querySelector("[data-annotation-id=\"".concat(data.id, "\"]"));
  18537. if (element) {
  18538. element.style.transform = "matrix(".concat(parameters.viewport.transform.join(','), ")");
  18539. }
  18540. }
  18541. } catch (err) {
  18542. _didIteratorError6 = true;
  18543. _iteratorError6 = err;
  18544. } finally {
  18545. try {
  18546. if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
  18547. _iterator6["return"]();
  18548. }
  18549. } finally {
  18550. if (_didIteratorError6) {
  18551. throw _iteratorError6;
  18552. }
  18553. }
  18554. }
  18555. parameters.div.removeAttribute('hidden');
  18556. }
  18557. }]);
  18558. return AnnotationLayer;
  18559. }();
  18560. exports.AnnotationLayer = AnnotationLayer;
  18561. /***/ }),
  18562. /* 196 */
  18563. /***/ (function(module, exports, __w_pdfjs_require__) {
  18564. "use strict";
  18565. Object.defineProperty(exports, "__esModule", {
  18566. value: true
  18567. });
  18568. exports.SVGGraphics = void 0;
  18569. var _util = __w_pdfjs_require__(1);
  18570. var _display_utils = __w_pdfjs_require__(183);
  18571. var _is_node = _interopRequireDefault(__w_pdfjs_require__(4));
  18572. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  18573. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  18574. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  18575. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  18576. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  18577. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  18578. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  18579. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  18580. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  18581. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18582. 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); } }
  18583. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18584. var SVGGraphics = function SVGGraphics() {
  18585. throw new Error('Not implemented: SVGGraphics');
  18586. };
  18587. exports.SVGGraphics = SVGGraphics;
  18588. {
  18589. var opListToTree = function opListToTree(opList) {
  18590. var opTree = [];
  18591. var tmp = [];
  18592. var _iteratorNormalCompletion = true;
  18593. var _didIteratorError = false;
  18594. var _iteratorError = undefined;
  18595. try {
  18596. for (var _iterator = opList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  18597. var opListElement = _step.value;
  18598. if (opListElement.fn === 'save') {
  18599. opTree.push({
  18600. 'fnId': 92,
  18601. 'fn': 'group',
  18602. 'items': []
  18603. });
  18604. tmp.push(opTree);
  18605. opTree = opTree[opTree.length - 1].items;
  18606. continue;
  18607. }
  18608. if (opListElement.fn === 'restore') {
  18609. opTree = tmp.pop();
  18610. } else {
  18611. opTree.push(opListElement);
  18612. }
  18613. }
  18614. } catch (err) {
  18615. _didIteratorError = true;
  18616. _iteratorError = err;
  18617. } finally {
  18618. try {
  18619. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  18620. _iterator["return"]();
  18621. }
  18622. } finally {
  18623. if (_didIteratorError) {
  18624. throw _iteratorError;
  18625. }
  18626. }
  18627. }
  18628. return opTree;
  18629. };
  18630. var pf = function pf(value) {
  18631. if (Number.isInteger(value)) {
  18632. return value.toString();
  18633. }
  18634. var s = value.toFixed(10);
  18635. var i = s.length - 1;
  18636. if (s[i] !== '0') {
  18637. return s;
  18638. }
  18639. do {
  18640. i--;
  18641. } while (s[i] === '0');
  18642. return s.substring(0, s[i] === '.' ? i : i + 1);
  18643. };
  18644. var pm = function pm(m) {
  18645. if (m[4] === 0 && m[5] === 0) {
  18646. if (m[1] === 0 && m[2] === 0) {
  18647. if (m[0] === 1 && m[3] === 1) {
  18648. return '';
  18649. }
  18650. return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")");
  18651. }
  18652. if (m[0] === m[3] && m[1] === -m[2]) {
  18653. var a = Math.acos(m[0]) * 180 / Math.PI;
  18654. return "rotate(".concat(pf(a), ")");
  18655. }
  18656. } else {
  18657. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  18658. return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")");
  18659. }
  18660. }
  18661. return "matrix(".concat(pf(m[0]), " ").concat(pf(m[1]), " ").concat(pf(m[2]), " ").concat(pf(m[3]), " ").concat(pf(m[4]), " ") + "".concat(pf(m[5]), ")");
  18662. };
  18663. var SVG_DEFAULTS = {
  18664. fontStyle: 'normal',
  18665. fontWeight: 'normal',
  18666. fillColor: '#000000'
  18667. };
  18668. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  18669. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  18670. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  18671. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  18672. var convertImgDataToPng = function () {
  18673. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  18674. var CHUNK_WRAPPER_SIZE = 12;
  18675. var crcTable = new Int32Array(256);
  18676. for (var i = 0; i < 256; i++) {
  18677. var c = i;
  18678. for (var h = 0; h < 8; h++) {
  18679. if (c & 1) {
  18680. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  18681. } else {
  18682. c = c >> 1 & 0x7fffffff;
  18683. }
  18684. }
  18685. crcTable[i] = c;
  18686. }
  18687. function crc32(data, start, end) {
  18688. var crc = -1;
  18689. for (var _i = start; _i < end; _i++) {
  18690. var a = (crc ^ data[_i]) & 0xff;
  18691. var b = crcTable[a];
  18692. crc = crc >>> 8 ^ b;
  18693. }
  18694. return crc ^ -1;
  18695. }
  18696. function writePngChunk(type, body, data, offset) {
  18697. var p = offset;
  18698. var len = body.length;
  18699. data[p] = len >> 24 & 0xff;
  18700. data[p + 1] = len >> 16 & 0xff;
  18701. data[p + 2] = len >> 8 & 0xff;
  18702. data[p + 3] = len & 0xff;
  18703. p += 4;
  18704. data[p] = type.charCodeAt(0) & 0xff;
  18705. data[p + 1] = type.charCodeAt(1) & 0xff;
  18706. data[p + 2] = type.charCodeAt(2) & 0xff;
  18707. data[p + 3] = type.charCodeAt(3) & 0xff;
  18708. p += 4;
  18709. data.set(body, p);
  18710. p += body.length;
  18711. var crc = crc32(data, offset + 4, p);
  18712. data[p] = crc >> 24 & 0xff;
  18713. data[p + 1] = crc >> 16 & 0xff;
  18714. data[p + 2] = crc >> 8 & 0xff;
  18715. data[p + 3] = crc & 0xff;
  18716. }
  18717. function adler32(data, start, end) {
  18718. var a = 1;
  18719. var b = 0;
  18720. for (var _i2 = start; _i2 < end; ++_i2) {
  18721. a = (a + (data[_i2] & 0xff)) % 65521;
  18722. b = (b + a) % 65521;
  18723. }
  18724. return b << 16 | a;
  18725. }
  18726. function deflateSync(literals) {
  18727. if (!(0, _is_node["default"])()) {
  18728. return deflateSyncUncompressed(literals);
  18729. }
  18730. try {
  18731. var input;
  18732. if (parseInt(process.versions.node) >= 8) {
  18733. input = literals;
  18734. } else {
  18735. input = new Buffer(literals);
  18736. }
  18737. var output = require('zlib').deflateSync(input, {
  18738. level: 9
  18739. });
  18740. return output instanceof Uint8Array ? output : new Uint8Array(output);
  18741. } catch (e) {
  18742. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  18743. }
  18744. return deflateSyncUncompressed(literals);
  18745. }
  18746. function deflateSyncUncompressed(literals) {
  18747. var len = literals.length;
  18748. var maxBlockLength = 0xFFFF;
  18749. var deflateBlocks = Math.ceil(len / maxBlockLength);
  18750. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  18751. var pi = 0;
  18752. idat[pi++] = 0x78;
  18753. idat[pi++] = 0x9c;
  18754. var pos = 0;
  18755. while (len > maxBlockLength) {
  18756. idat[pi++] = 0x00;
  18757. idat[pi++] = 0xff;
  18758. idat[pi++] = 0xff;
  18759. idat[pi++] = 0x00;
  18760. idat[pi++] = 0x00;
  18761. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  18762. pi += maxBlockLength;
  18763. pos += maxBlockLength;
  18764. len -= maxBlockLength;
  18765. }
  18766. idat[pi++] = 0x01;
  18767. idat[pi++] = len & 0xff;
  18768. idat[pi++] = len >> 8 & 0xff;
  18769. idat[pi++] = ~len & 0xffff & 0xff;
  18770. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  18771. idat.set(literals.subarray(pos), pi);
  18772. pi += literals.length - pos;
  18773. var adler = adler32(literals, 0, literals.length);
  18774. idat[pi++] = adler >> 24 & 0xff;
  18775. idat[pi++] = adler >> 16 & 0xff;
  18776. idat[pi++] = adler >> 8 & 0xff;
  18777. idat[pi++] = adler & 0xff;
  18778. return idat;
  18779. }
  18780. function encode(imgData, kind, forceDataSchema, isMask) {
  18781. var width = imgData.width;
  18782. var height = imgData.height;
  18783. var bitDepth, colorType, lineSize;
  18784. var bytes = imgData.data;
  18785. switch (kind) {
  18786. case _util.ImageKind.GRAYSCALE_1BPP:
  18787. colorType = 0;
  18788. bitDepth = 1;
  18789. lineSize = width + 7 >> 3;
  18790. break;
  18791. case _util.ImageKind.RGB_24BPP:
  18792. colorType = 2;
  18793. bitDepth = 8;
  18794. lineSize = width * 3;
  18795. break;
  18796. case _util.ImageKind.RGBA_32BPP:
  18797. colorType = 6;
  18798. bitDepth = 8;
  18799. lineSize = width * 4;
  18800. break;
  18801. default:
  18802. throw new Error('invalid format');
  18803. }
  18804. var literals = new Uint8Array((1 + lineSize) * height);
  18805. var offsetLiterals = 0,
  18806. offsetBytes = 0;
  18807. for (var y = 0; y < height; ++y) {
  18808. literals[offsetLiterals++] = 0;
  18809. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  18810. offsetBytes += lineSize;
  18811. offsetLiterals += lineSize;
  18812. }
  18813. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  18814. offsetLiterals = 0;
  18815. for (var _y = 0; _y < height; _y++) {
  18816. offsetLiterals++;
  18817. for (var _i3 = 0; _i3 < lineSize; _i3++) {
  18818. literals[offsetLiterals++] ^= 0xFF;
  18819. }
  18820. }
  18821. }
  18822. 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]);
  18823. var idat = deflateSync(literals);
  18824. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  18825. var data = new Uint8Array(pngLength);
  18826. var offset = 0;
  18827. data.set(PNG_HEADER, offset);
  18828. offset += PNG_HEADER.length;
  18829. writePngChunk('IHDR', ihdr, data, offset);
  18830. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  18831. writePngChunk('IDATA', idat, data, offset);
  18832. offset += CHUNK_WRAPPER_SIZE + idat.length;
  18833. writePngChunk('IEND', new Uint8Array(0), data, offset);
  18834. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  18835. }
  18836. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  18837. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  18838. return encode(imgData, kind, forceDataSchema, isMask);
  18839. };
  18840. }();
  18841. var SVGExtraState =
  18842. /*#__PURE__*/
  18843. function () {
  18844. function SVGExtraState() {
  18845. _classCallCheck(this, SVGExtraState);
  18846. this.fontSizeScale = 1;
  18847. this.fontWeight = SVG_DEFAULTS.fontWeight;
  18848. this.fontSize = 0;
  18849. this.textMatrix = _util.IDENTITY_MATRIX;
  18850. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  18851. this.leading = 0;
  18852. this.textRenderingMode = _util.TextRenderingMode.FILL;
  18853. this.textMatrixScale = 1;
  18854. this.x = 0;
  18855. this.y = 0;
  18856. this.lineX = 0;
  18857. this.lineY = 0;
  18858. this.charSpacing = 0;
  18859. this.wordSpacing = 0;
  18860. this.textHScale = 1;
  18861. this.textRise = 0;
  18862. this.fillColor = SVG_DEFAULTS.fillColor;
  18863. this.strokeColor = '#000000';
  18864. this.fillAlpha = 1;
  18865. this.strokeAlpha = 1;
  18866. this.lineWidth = 1;
  18867. this.lineJoin = '';
  18868. this.lineCap = '';
  18869. this.miterLimit = 0;
  18870. this.dashArray = [];
  18871. this.dashPhase = 0;
  18872. this.dependencies = [];
  18873. this.activeClipUrl = null;
  18874. this.clipGroup = null;
  18875. this.maskId = '';
  18876. }
  18877. _createClass(SVGExtraState, [{
  18878. key: "clone",
  18879. value: function clone() {
  18880. return Object.create(this);
  18881. }
  18882. }, {
  18883. key: "setCurrentPoint",
  18884. value: function setCurrentPoint(x, y) {
  18885. this.x = x;
  18886. this.y = y;
  18887. }
  18888. }]);
  18889. return SVGExtraState;
  18890. }();
  18891. var clipCount = 0;
  18892. var maskCount = 0;
  18893. var shadingCount = 0;
  18894. exports.SVGGraphics = SVGGraphics =
  18895. /*#__PURE__*/
  18896. function () {
  18897. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  18898. _classCallCheck(this, SVGGraphics);
  18899. this.svgFactory = new _display_utils.DOMSVGFactory();
  18900. this.current = new SVGExtraState();
  18901. this.transformMatrix = _util.IDENTITY_MATRIX;
  18902. this.transformStack = [];
  18903. this.extraStack = [];
  18904. this.commonObjs = commonObjs;
  18905. this.objs = objs;
  18906. this.pendingClip = null;
  18907. this.pendingEOFill = false;
  18908. this.embedFonts = false;
  18909. this.embeddedFonts = Object.create(null);
  18910. this.cssStyle = null;
  18911. this.forceDataSchema = !!forceDataSchema;
  18912. this._operatorIdMapping = [];
  18913. for (var op in _util.OPS) {
  18914. this._operatorIdMapping[_util.OPS[op]] = op;
  18915. }
  18916. }
  18917. _createClass(SVGGraphics, [{
  18918. key: "save",
  18919. value: function save() {
  18920. this.transformStack.push(this.transformMatrix);
  18921. var old = this.current;
  18922. this.extraStack.push(old);
  18923. this.current = old.clone();
  18924. }
  18925. }, {
  18926. key: "restore",
  18927. value: function restore() {
  18928. this.transformMatrix = this.transformStack.pop();
  18929. this.current = this.extraStack.pop();
  18930. this.pendingClip = null;
  18931. this.tgrp = null;
  18932. }
  18933. }, {
  18934. key: "group",
  18935. value: function group(items) {
  18936. this.save();
  18937. this.executeOpTree(items);
  18938. this.restore();
  18939. }
  18940. }, {
  18941. key: "loadDependencies",
  18942. value: function loadDependencies(operatorList) {
  18943. var _this = this;
  18944. var fnArray = operatorList.fnArray;
  18945. var argsArray = operatorList.argsArray;
  18946. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  18947. if (fnArray[i] !== _util.OPS.dependency) {
  18948. continue;
  18949. }
  18950. var _iteratorNormalCompletion2 = true;
  18951. var _didIteratorError2 = false;
  18952. var _iteratorError2 = undefined;
  18953. try {
  18954. var _loop = function _loop() {
  18955. var obj = _step2.value;
  18956. var objsPool = obj.startsWith('g_') ? _this.commonObjs : _this.objs;
  18957. var promise = new Promise(function (resolve) {
  18958. objsPool.get(obj, resolve);
  18959. });
  18960. _this.current.dependencies.push(promise);
  18961. };
  18962. for (var _iterator2 = argsArray[i][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  18963. _loop();
  18964. }
  18965. } catch (err) {
  18966. _didIteratorError2 = true;
  18967. _iteratorError2 = err;
  18968. } finally {
  18969. try {
  18970. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  18971. _iterator2["return"]();
  18972. }
  18973. } finally {
  18974. if (_didIteratorError2) {
  18975. throw _iteratorError2;
  18976. }
  18977. }
  18978. }
  18979. }
  18980. return Promise.all(this.current.dependencies);
  18981. }
  18982. }, {
  18983. key: "transform",
  18984. value: function transform(a, b, c, d, e, f) {
  18985. var transformMatrix = [a, b, c, d, e, f];
  18986. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  18987. this.tgrp = null;
  18988. }
  18989. }, {
  18990. key: "getSVG",
  18991. value: function getSVG(operatorList, viewport) {
  18992. var _this2 = this;
  18993. this.viewport = viewport;
  18994. var svgElement = this._initialize(viewport);
  18995. return this.loadDependencies(operatorList).then(function () {
  18996. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  18997. _this2.executeOpTree(_this2.convertOpList(operatorList));
  18998. return svgElement;
  18999. });
  19000. }
  19001. }, {
  19002. key: "convertOpList",
  19003. value: function convertOpList(operatorList) {
  19004. var operatorIdMapping = this._operatorIdMapping;
  19005. var argsArray = operatorList.argsArray;
  19006. var fnArray = operatorList.fnArray;
  19007. var opList = [];
  19008. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  19009. var fnId = fnArray[i];
  19010. opList.push({
  19011. 'fnId': fnId,
  19012. 'fn': operatorIdMapping[fnId],
  19013. 'args': argsArray[i]
  19014. });
  19015. }
  19016. return opListToTree(opList);
  19017. }
  19018. }, {
  19019. key: "executeOpTree",
  19020. value: function executeOpTree(opTree) {
  19021. var _iteratorNormalCompletion3 = true;
  19022. var _didIteratorError3 = false;
  19023. var _iteratorError3 = undefined;
  19024. try {
  19025. for (var _iterator3 = opTree[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  19026. var opTreeElement = _step3.value;
  19027. var fn = opTreeElement.fn;
  19028. var fnId = opTreeElement.fnId;
  19029. var args = opTreeElement.args;
  19030. switch (fnId | 0) {
  19031. case _util.OPS.beginText:
  19032. this.beginText();
  19033. break;
  19034. case _util.OPS.dependency:
  19035. break;
  19036. case _util.OPS.setLeading:
  19037. this.setLeading(args);
  19038. break;
  19039. case _util.OPS.setLeadingMoveText:
  19040. this.setLeadingMoveText(args[0], args[1]);
  19041. break;
  19042. case _util.OPS.setFont:
  19043. this.setFont(args);
  19044. break;
  19045. case _util.OPS.showText:
  19046. this.showText(args[0]);
  19047. break;
  19048. case _util.OPS.showSpacedText:
  19049. this.showText(args[0]);
  19050. break;
  19051. case _util.OPS.endText:
  19052. this.endText();
  19053. break;
  19054. case _util.OPS.moveText:
  19055. this.moveText(args[0], args[1]);
  19056. break;
  19057. case _util.OPS.setCharSpacing:
  19058. this.setCharSpacing(args[0]);
  19059. break;
  19060. case _util.OPS.setWordSpacing:
  19061. this.setWordSpacing(args[0]);
  19062. break;
  19063. case _util.OPS.setHScale:
  19064. this.setHScale(args[0]);
  19065. break;
  19066. case _util.OPS.setTextMatrix:
  19067. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  19068. break;
  19069. case _util.OPS.setTextRise:
  19070. this.setTextRise(args[0]);
  19071. break;
  19072. case _util.OPS.setTextRenderingMode:
  19073. this.setTextRenderingMode(args[0]);
  19074. break;
  19075. case _util.OPS.setLineWidth:
  19076. this.setLineWidth(args[0]);
  19077. break;
  19078. case _util.OPS.setLineJoin:
  19079. this.setLineJoin(args[0]);
  19080. break;
  19081. case _util.OPS.setLineCap:
  19082. this.setLineCap(args[0]);
  19083. break;
  19084. case _util.OPS.setMiterLimit:
  19085. this.setMiterLimit(args[0]);
  19086. break;
  19087. case _util.OPS.setFillRGBColor:
  19088. this.setFillRGBColor(args[0], args[1], args[2]);
  19089. break;
  19090. case _util.OPS.setStrokeRGBColor:
  19091. this.setStrokeRGBColor(args[0], args[1], args[2]);
  19092. break;
  19093. case _util.OPS.setStrokeColorN:
  19094. this.setStrokeColorN(args);
  19095. break;
  19096. case _util.OPS.setFillColorN:
  19097. this.setFillColorN(args);
  19098. break;
  19099. case _util.OPS.shadingFill:
  19100. this.shadingFill(args[0]);
  19101. break;
  19102. case _util.OPS.setDash:
  19103. this.setDash(args[0], args[1]);
  19104. break;
  19105. case _util.OPS.setRenderingIntent:
  19106. this.setRenderingIntent(args[0]);
  19107. break;
  19108. case _util.OPS.setFlatness:
  19109. this.setFlatness(args[0]);
  19110. break;
  19111. case _util.OPS.setGState:
  19112. this.setGState(args[0]);
  19113. break;
  19114. case _util.OPS.fill:
  19115. this.fill();
  19116. break;
  19117. case _util.OPS.eoFill:
  19118. this.eoFill();
  19119. break;
  19120. case _util.OPS.stroke:
  19121. this.stroke();
  19122. break;
  19123. case _util.OPS.fillStroke:
  19124. this.fillStroke();
  19125. break;
  19126. case _util.OPS.eoFillStroke:
  19127. this.eoFillStroke();
  19128. break;
  19129. case _util.OPS.clip:
  19130. this.clip('nonzero');
  19131. break;
  19132. case _util.OPS.eoClip:
  19133. this.clip('evenodd');
  19134. break;
  19135. case _util.OPS.paintSolidColorImageMask:
  19136. this.paintSolidColorImageMask();
  19137. break;
  19138. case _util.OPS.paintJpegXObject:
  19139. this.paintJpegXObject(args[0], args[1], args[2]);
  19140. break;
  19141. case _util.OPS.paintImageXObject:
  19142. this.paintImageXObject(args[0]);
  19143. break;
  19144. case _util.OPS.paintInlineImageXObject:
  19145. this.paintInlineImageXObject(args[0]);
  19146. break;
  19147. case _util.OPS.paintImageMaskXObject:
  19148. this.paintImageMaskXObject(args[0]);
  19149. break;
  19150. case _util.OPS.paintFormXObjectBegin:
  19151. this.paintFormXObjectBegin(args[0], args[1]);
  19152. break;
  19153. case _util.OPS.paintFormXObjectEnd:
  19154. this.paintFormXObjectEnd();
  19155. break;
  19156. case _util.OPS.closePath:
  19157. this.closePath();
  19158. break;
  19159. case _util.OPS.closeStroke:
  19160. this.closeStroke();
  19161. break;
  19162. case _util.OPS.closeFillStroke:
  19163. this.closeFillStroke();
  19164. break;
  19165. case _util.OPS.closeEOFillStroke:
  19166. this.closeEOFillStroke();
  19167. break;
  19168. case _util.OPS.nextLine:
  19169. this.nextLine();
  19170. break;
  19171. case _util.OPS.transform:
  19172. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  19173. break;
  19174. case _util.OPS.constructPath:
  19175. this.constructPath(args[0], args[1]);
  19176. break;
  19177. case _util.OPS.endPath:
  19178. this.endPath();
  19179. break;
  19180. case 92:
  19181. this.group(opTreeElement.items);
  19182. break;
  19183. default:
  19184. (0, _util.warn)("Unimplemented operator ".concat(fn));
  19185. break;
  19186. }
  19187. }
  19188. } catch (err) {
  19189. _didIteratorError3 = true;
  19190. _iteratorError3 = err;
  19191. } finally {
  19192. try {
  19193. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  19194. _iterator3["return"]();
  19195. }
  19196. } finally {
  19197. if (_didIteratorError3) {
  19198. throw _iteratorError3;
  19199. }
  19200. }
  19201. }
  19202. }
  19203. }, {
  19204. key: "setWordSpacing",
  19205. value: function setWordSpacing(wordSpacing) {
  19206. this.current.wordSpacing = wordSpacing;
  19207. }
  19208. }, {
  19209. key: "setCharSpacing",
  19210. value: function setCharSpacing(charSpacing) {
  19211. this.current.charSpacing = charSpacing;
  19212. }
  19213. }, {
  19214. key: "nextLine",
  19215. value: function nextLine() {
  19216. this.moveText(0, this.current.leading);
  19217. }
  19218. }, {
  19219. key: "setTextMatrix",
  19220. value: function setTextMatrix(a, b, c, d, e, f) {
  19221. var current = this.current;
  19222. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  19223. current.textMatrixScale = Math.sqrt(a * a + b * b);
  19224. current.x = current.lineX = 0;
  19225. current.y = current.lineY = 0;
  19226. current.xcoords = [];
  19227. current.tspan = this.svgFactory.createElement('svg:tspan');
  19228. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  19229. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  19230. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  19231. current.txtElement = this.svgFactory.createElement('svg:text');
  19232. current.txtElement.appendChild(current.tspan);
  19233. }
  19234. }, {
  19235. key: "beginText",
  19236. value: function beginText() {
  19237. var current = this.current;
  19238. current.x = current.lineX = 0;
  19239. current.y = current.lineY = 0;
  19240. current.textMatrix = _util.IDENTITY_MATRIX;
  19241. current.lineMatrix = _util.IDENTITY_MATRIX;
  19242. current.textMatrixScale = 1;
  19243. current.tspan = this.svgFactory.createElement('svg:tspan');
  19244. current.txtElement = this.svgFactory.createElement('svg:text');
  19245. current.txtgrp = this.svgFactory.createElement('svg:g');
  19246. current.xcoords = [];
  19247. }
  19248. }, {
  19249. key: "moveText",
  19250. value: function moveText(x, y) {
  19251. var current = this.current;
  19252. current.x = current.lineX += x;
  19253. current.y = current.lineY += y;
  19254. current.xcoords = [];
  19255. current.tspan = this.svgFactory.createElement('svg:tspan');
  19256. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  19257. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  19258. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  19259. }
  19260. }, {
  19261. key: "showText",
  19262. value: function showText(glyphs) {
  19263. var current = this.current;
  19264. var font = current.font;
  19265. var fontSize = current.fontSize;
  19266. if (fontSize === 0) {
  19267. return;
  19268. }
  19269. var charSpacing = current.charSpacing;
  19270. var wordSpacing = current.wordSpacing;
  19271. var fontDirection = current.fontDirection;
  19272. var textHScale = current.textHScale * fontDirection;
  19273. var vertical = font.vertical;
  19274. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  19275. var x = 0;
  19276. var _iteratorNormalCompletion4 = true;
  19277. var _didIteratorError4 = false;
  19278. var _iteratorError4 = undefined;
  19279. try {
  19280. for (var _iterator4 = glyphs[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  19281. var glyph = _step4.value;
  19282. if (glyph === null) {
  19283. x += fontDirection * wordSpacing;
  19284. continue;
  19285. } else if ((0, _util.isNum)(glyph)) {
  19286. x += -glyph * fontSize * 0.001;
  19287. continue;
  19288. }
  19289. var width = glyph.width;
  19290. var character = glyph.fontChar;
  19291. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  19292. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  19293. if (!glyph.isInFont && !font.missingFile) {
  19294. x += charWidth;
  19295. continue;
  19296. }
  19297. current.xcoords.push(current.x + x * textHScale);
  19298. current.tspan.textContent += character;
  19299. x += charWidth;
  19300. }
  19301. } catch (err) {
  19302. _didIteratorError4 = true;
  19303. _iteratorError4 = err;
  19304. } finally {
  19305. try {
  19306. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  19307. _iterator4["return"]();
  19308. }
  19309. } finally {
  19310. if (_didIteratorError4) {
  19311. throw _iteratorError4;
  19312. }
  19313. }
  19314. }
  19315. if (vertical) {
  19316. current.y -= x * textHScale;
  19317. } else {
  19318. current.x += x * textHScale;
  19319. }
  19320. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  19321. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  19322. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  19323. current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
  19324. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  19325. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  19326. }
  19327. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  19328. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  19329. }
  19330. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  19331. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  19332. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  19333. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  19334. }
  19335. if (current.fillAlpha < 1) {
  19336. current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  19337. }
  19338. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  19339. current.tspan.setAttributeNS(null, 'fill', 'transparent');
  19340. } else {
  19341. current.tspan.setAttributeNS(null, 'fill', 'none');
  19342. }
  19343. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  19344. var lineWidthScale = 1 / (current.textMatrixScale || 1);
  19345. this._setStrokeAttributes(current.tspan, lineWidthScale);
  19346. }
  19347. var textMatrix = current.textMatrix;
  19348. if (current.textRise !== 0) {
  19349. textMatrix = textMatrix.slice();
  19350. textMatrix[5] += current.textRise;
  19351. }
  19352. current.txtElement.setAttributeNS(null, 'transform', "".concat(pm(textMatrix), " scale(1, -1)"));
  19353. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  19354. current.txtElement.appendChild(current.tspan);
  19355. current.txtgrp.appendChild(current.txtElement);
  19356. this._ensureTransformGroup().appendChild(current.txtElement);
  19357. }
  19358. }, {
  19359. key: "setLeadingMoveText",
  19360. value: function setLeadingMoveText(x, y) {
  19361. this.setLeading(-y);
  19362. this.moveText(x, y);
  19363. }
  19364. }, {
  19365. key: "addFontStyle",
  19366. value: function addFontStyle(fontObj) {
  19367. if (!this.cssStyle) {
  19368. this.cssStyle = this.svgFactory.createElement('svg:style');
  19369. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  19370. this.defs.appendChild(this.cssStyle);
  19371. }
  19372. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  19373. this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
  19374. }
  19375. }, {
  19376. key: "setFont",
  19377. value: function setFont(details) {
  19378. var current = this.current;
  19379. var fontObj = this.commonObjs.get(details[0]);
  19380. var size = details[1];
  19381. current.font = fontObj;
  19382. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  19383. this.addFontStyle(fontObj);
  19384. this.embeddedFonts[fontObj.loadedName] = fontObj;
  19385. }
  19386. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  19387. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  19388. var italic = fontObj.italic ? 'italic' : 'normal';
  19389. if (size < 0) {
  19390. size = -size;
  19391. current.fontDirection = -1;
  19392. } else {
  19393. current.fontDirection = 1;
  19394. }
  19395. current.fontSize = size;
  19396. current.fontFamily = fontObj.loadedName;
  19397. current.fontWeight = bold;
  19398. current.fontStyle = italic;
  19399. current.tspan = this.svgFactory.createElement('svg:tspan');
  19400. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  19401. current.xcoords = [];
  19402. }
  19403. }, {
  19404. key: "endText",
  19405. value: function endText() {
  19406. var current = this.current;
  19407. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
  19408. current.element = current.txtElement;
  19409. this.clip('nonzero');
  19410. this.endPath();
  19411. }
  19412. }
  19413. }, {
  19414. key: "setLineWidth",
  19415. value: function setLineWidth(width) {
  19416. if (width > 0) {
  19417. this.current.lineWidth = width;
  19418. }
  19419. }
  19420. }, {
  19421. key: "setLineCap",
  19422. value: function setLineCap(style) {
  19423. this.current.lineCap = LINE_CAP_STYLES[style];
  19424. }
  19425. }, {
  19426. key: "setLineJoin",
  19427. value: function setLineJoin(style) {
  19428. this.current.lineJoin = LINE_JOIN_STYLES[style];
  19429. }
  19430. }, {
  19431. key: "setMiterLimit",
  19432. value: function setMiterLimit(limit) {
  19433. this.current.miterLimit = limit;
  19434. }
  19435. }, {
  19436. key: "setStrokeAlpha",
  19437. value: function setStrokeAlpha(strokeAlpha) {
  19438. this.current.strokeAlpha = strokeAlpha;
  19439. }
  19440. }, {
  19441. key: "setStrokeRGBColor",
  19442. value: function setStrokeRGBColor(r, g, b) {
  19443. this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
  19444. }
  19445. }, {
  19446. key: "setFillAlpha",
  19447. value: function setFillAlpha(fillAlpha) {
  19448. this.current.fillAlpha = fillAlpha;
  19449. }
  19450. }, {
  19451. key: "setFillRGBColor",
  19452. value: function setFillRGBColor(r, g, b) {
  19453. this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
  19454. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  19455. this.current.xcoords = [];
  19456. }
  19457. }, {
  19458. key: "setStrokeColorN",
  19459. value: function setStrokeColorN(args) {
  19460. this.current.strokeColor = this._makeColorN_Pattern(args);
  19461. }
  19462. }, {
  19463. key: "setFillColorN",
  19464. value: function setFillColorN(args) {
  19465. this.current.fillColor = this._makeColorN_Pattern(args);
  19466. }
  19467. }, {
  19468. key: "shadingFill",
  19469. value: function shadingFill(args) {
  19470. var width = this.viewport.width;
  19471. var height = this.viewport.height;
  19472. var inv = _util.Util.inverseTransform(this.transformMatrix);
  19473. var bl = _util.Util.applyTransform([0, 0], inv);
  19474. var br = _util.Util.applyTransform([0, height], inv);
  19475. var ul = _util.Util.applyTransform([width, 0], inv);
  19476. var ur = _util.Util.applyTransform([width, height], inv);
  19477. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  19478. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  19479. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  19480. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  19481. var rect = this.svgFactory.createElement('svg:rect');
  19482. rect.setAttributeNS(null, 'x', x0);
  19483. rect.setAttributeNS(null, 'y', y0);
  19484. rect.setAttributeNS(null, 'width', x1 - x0);
  19485. rect.setAttributeNS(null, 'height', y1 - y0);
  19486. rect.setAttributeNS(null, 'fill', this._makeShadingPattern(args));
  19487. this._ensureTransformGroup().appendChild(rect);
  19488. }
  19489. }, {
  19490. key: "_makeColorN_Pattern",
  19491. value: function _makeColorN_Pattern(args) {
  19492. if (args[0] === 'TilingPattern') {
  19493. return this._makeTilingPattern(args);
  19494. }
  19495. return this._makeShadingPattern(args);
  19496. }
  19497. }, {
  19498. key: "_makeTilingPattern",
  19499. value: function _makeTilingPattern(args) {
  19500. var color = args[1];
  19501. var operatorList = args[2];
  19502. var matrix = args[3] || _util.IDENTITY_MATRIX;
  19503. var _args$ = _slicedToArray(args[4], 4),
  19504. x0 = _args$[0],
  19505. y0 = _args$[1],
  19506. x1 = _args$[2],
  19507. y1 = _args$[3];
  19508. var xstep = args[5];
  19509. var ystep = args[6];
  19510. var paintType = args[7];
  19511. var tilingId = "shading".concat(shadingCount++);
  19512. var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix),
  19513. _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2),
  19514. tx0 = _Util$applyTransform2[0],
  19515. ty0 = _Util$applyTransform2[1];
  19516. var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix),
  19517. _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2),
  19518. tx1 = _Util$applyTransform4[0],
  19519. ty1 = _Util$applyTransform4[1];
  19520. var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix),
  19521. _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2),
  19522. xscale = _Util$singularValueDe2[0],
  19523. yscale = _Util$singularValueDe2[1];
  19524. var txstep = xstep * xscale;
  19525. var tystep = ystep * yscale;
  19526. var tiling = this.svgFactory.createElement('svg:pattern');
  19527. tiling.setAttributeNS(null, 'id', tilingId);
  19528. tiling.setAttributeNS(null, 'patternUnits', 'userSpaceOnUse');
  19529. tiling.setAttributeNS(null, 'width', txstep);
  19530. tiling.setAttributeNS(null, 'height', tystep);
  19531. tiling.setAttributeNS(null, 'x', "".concat(tx0));
  19532. tiling.setAttributeNS(null, 'y', "".concat(ty0));
  19533. var svg = this.svg;
  19534. var transformMatrix = this.transformMatrix;
  19535. var fillColor = this.current.fillColor;
  19536. var strokeColor = this.current.strokeColor;
  19537. var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  19538. this.svg = bbox;
  19539. this.transformMatrix = matrix;
  19540. if (paintType === 2) {
  19541. var cssColor = _util.Util.makeCssRgb.apply(_util.Util, _toConsumableArray(color));
  19542. this.current.fillColor = cssColor;
  19543. this.current.strokeColor = cssColor;
  19544. }
  19545. this.executeOpTree(this.convertOpList(operatorList));
  19546. this.svg = svg;
  19547. this.transformMatrix = transformMatrix;
  19548. this.current.fillColor = fillColor;
  19549. this.current.strokeColor = strokeColor;
  19550. tiling.appendChild(bbox.childNodes[0]);
  19551. this.defs.appendChild(tiling);
  19552. return "url(#".concat(tilingId, ")");
  19553. }
  19554. }, {
  19555. key: "_makeShadingPattern",
  19556. value: function _makeShadingPattern(args) {
  19557. switch (args[0]) {
  19558. case 'RadialAxial':
  19559. var shadingId = "shading".concat(shadingCount++);
  19560. var colorStops = args[2];
  19561. var gradient;
  19562. switch (args[1]) {
  19563. case 'axial':
  19564. var point0 = args[3];
  19565. var point1 = args[4];
  19566. gradient = this.svgFactory.createElement('svg:linearGradient');
  19567. gradient.setAttributeNS(null, 'id', shadingId);
  19568. gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
  19569. gradient.setAttributeNS(null, 'x1', point0[0]);
  19570. gradient.setAttributeNS(null, 'y1', point0[1]);
  19571. gradient.setAttributeNS(null, 'x2', point1[0]);
  19572. gradient.setAttributeNS(null, 'y2', point1[1]);
  19573. break;
  19574. case 'radial':
  19575. var focalPoint = args[3];
  19576. var circlePoint = args[4];
  19577. var focalRadius = args[5];
  19578. var circleRadius = args[6];
  19579. gradient = this.svgFactory.createElement('svg:radialGradient');
  19580. gradient.setAttributeNS(null, 'id', shadingId);
  19581. gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
  19582. gradient.setAttributeNS(null, 'cx', circlePoint[0]);
  19583. gradient.setAttributeNS(null, 'cy', circlePoint[1]);
  19584. gradient.setAttributeNS(null, 'r', circleRadius);
  19585. gradient.setAttributeNS(null, 'fx', focalPoint[0]);
  19586. gradient.setAttributeNS(null, 'fy', focalPoint[1]);
  19587. gradient.setAttributeNS(null, 'fr', focalRadius);
  19588. break;
  19589. default:
  19590. throw new Error("Unknown RadialAxial type: ".concat(args[1]));
  19591. }
  19592. var _iteratorNormalCompletion5 = true;
  19593. var _didIteratorError5 = false;
  19594. var _iteratorError5 = undefined;
  19595. try {
  19596. for (var _iterator5 = colorStops[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  19597. var colorStop = _step5.value;
  19598. var stop = this.svgFactory.createElement('svg:stop');
  19599. stop.setAttributeNS(null, 'offset', colorStop[0]);
  19600. stop.setAttributeNS(null, 'stop-color', colorStop[1]);
  19601. gradient.appendChild(stop);
  19602. }
  19603. } catch (err) {
  19604. _didIteratorError5 = true;
  19605. _iteratorError5 = err;
  19606. } finally {
  19607. try {
  19608. if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
  19609. _iterator5["return"]();
  19610. }
  19611. } finally {
  19612. if (_didIteratorError5) {
  19613. throw _iteratorError5;
  19614. }
  19615. }
  19616. }
  19617. this.defs.appendChild(gradient);
  19618. return "url(#".concat(shadingId, ")");
  19619. case 'Mesh':
  19620. (0, _util.warn)('Unimplemented pattern Mesh');
  19621. return null;
  19622. case 'Dummy':
  19623. return 'hotpink';
  19624. default:
  19625. throw new Error("Unknown IR type: ".concat(args[0]));
  19626. }
  19627. }
  19628. }, {
  19629. key: "setDash",
  19630. value: function setDash(dashArray, dashPhase) {
  19631. this.current.dashArray = dashArray;
  19632. this.current.dashPhase = dashPhase;
  19633. }
  19634. }, {
  19635. key: "constructPath",
  19636. value: function constructPath(ops, args) {
  19637. var current = this.current;
  19638. var x = current.x,
  19639. y = current.y;
  19640. var d = [];
  19641. var j = 0;
  19642. var _iteratorNormalCompletion6 = true;
  19643. var _didIteratorError6 = false;
  19644. var _iteratorError6 = undefined;
  19645. try {
  19646. for (var _iterator6 = ops[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  19647. var op = _step6.value;
  19648. switch (op | 0) {
  19649. case _util.OPS.rectangle:
  19650. x = args[j++];
  19651. y = args[j++];
  19652. var width = args[j++];
  19653. var height = args[j++];
  19654. var xw = x + width;
  19655. var yh = y + height;
  19656. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  19657. break;
  19658. case _util.OPS.moveTo:
  19659. x = args[j++];
  19660. y = args[j++];
  19661. d.push('M', pf(x), pf(y));
  19662. break;
  19663. case _util.OPS.lineTo:
  19664. x = args[j++];
  19665. y = args[j++];
  19666. d.push('L', pf(x), pf(y));
  19667. break;
  19668. case _util.OPS.curveTo:
  19669. x = args[j + 4];
  19670. y = args[j + 5];
  19671. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  19672. j += 6;
  19673. break;
  19674. case _util.OPS.curveTo2:
  19675. x = args[j + 2];
  19676. y = args[j + 3];
  19677. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  19678. j += 4;
  19679. break;
  19680. case _util.OPS.curveTo3:
  19681. x = args[j + 2];
  19682. y = args[j + 3];
  19683. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  19684. j += 4;
  19685. break;
  19686. case _util.OPS.closePath:
  19687. d.push('Z');
  19688. break;
  19689. }
  19690. }
  19691. } catch (err) {
  19692. _didIteratorError6 = true;
  19693. _iteratorError6 = err;
  19694. } finally {
  19695. try {
  19696. if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
  19697. _iterator6["return"]();
  19698. }
  19699. } finally {
  19700. if (_didIteratorError6) {
  19701. throw _iteratorError6;
  19702. }
  19703. }
  19704. }
  19705. d = d.join(' ');
  19706. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  19707. d = current.path.getAttributeNS(null, 'd') + d;
  19708. } else {
  19709. current.path = this.svgFactory.createElement('svg:path');
  19710. this._ensureTransformGroup().appendChild(current.path);
  19711. }
  19712. current.path.setAttributeNS(null, 'd', d);
  19713. current.path.setAttributeNS(null, 'fill', 'none');
  19714. current.element = current.path;
  19715. current.setCurrentPoint(x, y);
  19716. }
  19717. }, {
  19718. key: "endPath",
  19719. value: function endPath() {
  19720. var current = this.current;
  19721. current.path = null;
  19722. if (!this.pendingClip) {
  19723. return;
  19724. }
  19725. if (!current.element) {
  19726. this.pendingClip = null;
  19727. return;
  19728. }
  19729. var clipId = "clippath".concat(clipCount++);
  19730. var clipPath = this.svgFactory.createElement('svg:clipPath');
  19731. clipPath.setAttributeNS(null, 'id', clipId);
  19732. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  19733. var clipElement = current.element.cloneNode(true);
  19734. if (this.pendingClip === 'evenodd') {
  19735. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  19736. } else {
  19737. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  19738. }
  19739. this.pendingClip = null;
  19740. clipPath.appendChild(clipElement);
  19741. this.defs.appendChild(clipPath);
  19742. if (current.activeClipUrl) {
  19743. current.clipGroup = null;
  19744. this.extraStack.forEach(function (prev) {
  19745. prev.clipGroup = null;
  19746. });
  19747. clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
  19748. }
  19749. current.activeClipUrl = "url(#".concat(clipId, ")");
  19750. this.tgrp = null;
  19751. }
  19752. }, {
  19753. key: "clip",
  19754. value: function clip(type) {
  19755. this.pendingClip = type;
  19756. }
  19757. }, {
  19758. key: "closePath",
  19759. value: function closePath() {
  19760. var current = this.current;
  19761. if (current.path) {
  19762. var d = "".concat(current.path.getAttributeNS(null, 'd'), "Z");
  19763. current.path.setAttributeNS(null, 'd', d);
  19764. }
  19765. }
  19766. }, {
  19767. key: "setLeading",
  19768. value: function setLeading(leading) {
  19769. this.current.leading = -leading;
  19770. }
  19771. }, {
  19772. key: "setTextRise",
  19773. value: function setTextRise(textRise) {
  19774. this.current.textRise = textRise;
  19775. }
  19776. }, {
  19777. key: "setTextRenderingMode",
  19778. value: function setTextRenderingMode(textRenderingMode) {
  19779. this.current.textRenderingMode = textRenderingMode;
  19780. }
  19781. }, {
  19782. key: "setHScale",
  19783. value: function setHScale(scale) {
  19784. this.current.textHScale = scale / 100;
  19785. }
  19786. }, {
  19787. key: "setRenderingIntent",
  19788. value: function setRenderingIntent(intent) {}
  19789. }, {
  19790. key: "setFlatness",
  19791. value: function setFlatness(flatness) {}
  19792. }, {
  19793. key: "setGState",
  19794. value: function setGState(states) {
  19795. var _iteratorNormalCompletion7 = true;
  19796. var _didIteratorError7 = false;
  19797. var _iteratorError7 = undefined;
  19798. try {
  19799. for (var _iterator7 = states[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  19800. var _step7$value = _slicedToArray(_step7.value, 2),
  19801. key = _step7$value[0],
  19802. value = _step7$value[1];
  19803. switch (key) {
  19804. case 'LW':
  19805. this.setLineWidth(value);
  19806. break;
  19807. case 'LC':
  19808. this.setLineCap(value);
  19809. break;
  19810. case 'LJ':
  19811. this.setLineJoin(value);
  19812. break;
  19813. case 'ML':
  19814. this.setMiterLimit(value);
  19815. break;
  19816. case 'D':
  19817. this.setDash(value[0], value[1]);
  19818. break;
  19819. case 'RI':
  19820. this.setRenderingIntent(value);
  19821. break;
  19822. case 'FL':
  19823. this.setFlatness(value);
  19824. break;
  19825. case 'Font':
  19826. this.setFont(value);
  19827. break;
  19828. case 'CA':
  19829. this.setStrokeAlpha(value);
  19830. break;
  19831. case 'ca':
  19832. this.setFillAlpha(value);
  19833. break;
  19834. default:
  19835. (0, _util.warn)("Unimplemented graphic state operator ".concat(key));
  19836. break;
  19837. }
  19838. }
  19839. } catch (err) {
  19840. _didIteratorError7 = true;
  19841. _iteratorError7 = err;
  19842. } finally {
  19843. try {
  19844. if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) {
  19845. _iterator7["return"]();
  19846. }
  19847. } finally {
  19848. if (_didIteratorError7) {
  19849. throw _iteratorError7;
  19850. }
  19851. }
  19852. }
  19853. }
  19854. }, {
  19855. key: "fill",
  19856. value: function fill() {
  19857. var current = this.current;
  19858. if (current.element) {
  19859. current.element.setAttributeNS(null, 'fill', current.fillColor);
  19860. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  19861. this.endPath();
  19862. }
  19863. }
  19864. }, {
  19865. key: "stroke",
  19866. value: function stroke() {
  19867. var current = this.current;
  19868. if (current.element) {
  19869. this._setStrokeAttributes(current.element);
  19870. current.element.setAttributeNS(null, 'fill', 'none');
  19871. this.endPath();
  19872. }
  19873. }
  19874. }, {
  19875. key: "_setStrokeAttributes",
  19876. value: function _setStrokeAttributes(element) {
  19877. var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  19878. var current = this.current;
  19879. var dashArray = current.dashArray;
  19880. if (lineWidthScale !== 1 && dashArray.length > 0) {
  19881. dashArray = dashArray.map(function (value) {
  19882. return lineWidthScale * value;
  19883. });
  19884. }
  19885. element.setAttributeNS(null, 'stroke', current.strokeColor);
  19886. element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  19887. element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  19888. element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  19889. element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  19890. element.setAttributeNS(null, 'stroke-width', pf(lineWidthScale * current.lineWidth) + 'px');
  19891. element.setAttributeNS(null, 'stroke-dasharray', dashArray.map(pf).join(' '));
  19892. element.setAttributeNS(null, 'stroke-dashoffset', pf(lineWidthScale * current.dashPhase) + 'px');
  19893. }
  19894. }, {
  19895. key: "eoFill",
  19896. value: function eoFill() {
  19897. if (this.current.element) {
  19898. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  19899. }
  19900. this.fill();
  19901. }
  19902. }, {
  19903. key: "fillStroke",
  19904. value: function fillStroke() {
  19905. this.stroke();
  19906. this.fill();
  19907. }
  19908. }, {
  19909. key: "eoFillStroke",
  19910. value: function eoFillStroke() {
  19911. if (this.current.element) {
  19912. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  19913. }
  19914. this.fillStroke();
  19915. }
  19916. }, {
  19917. key: "closeStroke",
  19918. value: function closeStroke() {
  19919. this.closePath();
  19920. this.stroke();
  19921. }
  19922. }, {
  19923. key: "closeFillStroke",
  19924. value: function closeFillStroke() {
  19925. this.closePath();
  19926. this.fillStroke();
  19927. }
  19928. }, {
  19929. key: "closeEOFillStroke",
  19930. value: function closeEOFillStroke() {
  19931. this.closePath();
  19932. this.eoFillStroke();
  19933. }
  19934. }, {
  19935. key: "paintSolidColorImageMask",
  19936. value: function paintSolidColorImageMask() {
  19937. var rect = this.svgFactory.createElement('svg:rect');
  19938. rect.setAttributeNS(null, 'x', '0');
  19939. rect.setAttributeNS(null, 'y', '0');
  19940. rect.setAttributeNS(null, 'width', '1px');
  19941. rect.setAttributeNS(null, 'height', '1px');
  19942. rect.setAttributeNS(null, 'fill', this.current.fillColor);
  19943. this._ensureTransformGroup().appendChild(rect);
  19944. }
  19945. }, {
  19946. key: "paintJpegXObject",
  19947. value: function paintJpegXObject(objId, w, h) {
  19948. var imgObj = this.objs.get(objId);
  19949. var imgEl = this.svgFactory.createElement('svg:image');
  19950. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  19951. imgEl.setAttributeNS(null, 'width', pf(w));
  19952. imgEl.setAttributeNS(null, 'height', pf(h));
  19953. imgEl.setAttributeNS(null, 'x', '0');
  19954. imgEl.setAttributeNS(null, 'y', pf(-h));
  19955. imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / w), " ").concat(pf(-1 / h), ")"));
  19956. this._ensureTransformGroup().appendChild(imgEl);
  19957. }
  19958. }, {
  19959. key: "paintImageXObject",
  19960. value: function paintImageXObject(objId) {
  19961. var imgData = this.objs.get(objId);
  19962. if (!imgData) {
  19963. (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
  19964. return;
  19965. }
  19966. this.paintInlineImageXObject(imgData);
  19967. }
  19968. }, {
  19969. key: "paintInlineImageXObject",
  19970. value: function paintInlineImageXObject(imgData, mask) {
  19971. var width = imgData.width;
  19972. var height = imgData.height;
  19973. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  19974. var cliprect = this.svgFactory.createElement('svg:rect');
  19975. cliprect.setAttributeNS(null, 'x', '0');
  19976. cliprect.setAttributeNS(null, 'y', '0');
  19977. cliprect.setAttributeNS(null, 'width', pf(width));
  19978. cliprect.setAttributeNS(null, 'height', pf(height));
  19979. this.current.element = cliprect;
  19980. this.clip('nonzero');
  19981. var imgEl = this.svgFactory.createElement('svg:image');
  19982. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  19983. imgEl.setAttributeNS(null, 'x', '0');
  19984. imgEl.setAttributeNS(null, 'y', pf(-height));
  19985. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  19986. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  19987. imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
  19988. if (mask) {
  19989. mask.appendChild(imgEl);
  19990. } else {
  19991. this._ensureTransformGroup().appendChild(imgEl);
  19992. }
  19993. }
  19994. }, {
  19995. key: "paintImageMaskXObject",
  19996. value: function paintImageMaskXObject(imgData) {
  19997. var current = this.current;
  19998. var width = imgData.width;
  19999. var height = imgData.height;
  20000. var fillColor = current.fillColor;
  20001. current.maskId = "mask".concat(maskCount++);
  20002. var mask = this.svgFactory.createElement('svg:mask');
  20003. mask.setAttributeNS(null, 'id', current.maskId);
  20004. var rect = this.svgFactory.createElement('svg:rect');
  20005. rect.setAttributeNS(null, 'x', '0');
  20006. rect.setAttributeNS(null, 'y', '0');
  20007. rect.setAttributeNS(null, 'width', pf(width));
  20008. rect.setAttributeNS(null, 'height', pf(height));
  20009. rect.setAttributeNS(null, 'fill', fillColor);
  20010. rect.setAttributeNS(null, 'mask', "url(#".concat(current.maskId, ")"));
  20011. this.defs.appendChild(mask);
  20012. this._ensureTransformGroup().appendChild(rect);
  20013. this.paintInlineImageXObject(imgData, mask);
  20014. }
  20015. }, {
  20016. key: "paintFormXObjectBegin",
  20017. value: function paintFormXObjectBegin(matrix, bbox) {
  20018. if (Array.isArray(matrix) && matrix.length === 6) {
  20019. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20020. }
  20021. if (bbox) {
  20022. var width = bbox[2] - bbox[0];
  20023. var height = bbox[3] - bbox[1];
  20024. var cliprect = this.svgFactory.createElement('svg:rect');
  20025. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20026. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20027. cliprect.setAttributeNS(null, 'width', pf(width));
  20028. cliprect.setAttributeNS(null, 'height', pf(height));
  20029. this.current.element = cliprect;
  20030. this.clip('nonzero');
  20031. this.endPath();
  20032. }
  20033. }
  20034. }, {
  20035. key: "paintFormXObjectEnd",
  20036. value: function paintFormXObjectEnd() {}
  20037. }, {
  20038. key: "_initialize",
  20039. value: function _initialize(viewport) {
  20040. var svg = this.svgFactory.create(viewport.width, viewport.height);
  20041. var definitions = this.svgFactory.createElement('svg:defs');
  20042. svg.appendChild(definitions);
  20043. this.defs = definitions;
  20044. var rootGroup = this.svgFactory.createElement('svg:g');
  20045. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20046. svg.appendChild(rootGroup);
  20047. this.svg = rootGroup;
  20048. return svg;
  20049. }
  20050. }, {
  20051. key: "_ensureClipGroup",
  20052. value: function _ensureClipGroup() {
  20053. if (!this.current.clipGroup) {
  20054. var clipGroup = this.svgFactory.createElement('svg:g');
  20055. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20056. this.svg.appendChild(clipGroup);
  20057. this.current.clipGroup = clipGroup;
  20058. }
  20059. return this.current.clipGroup;
  20060. }
  20061. }, {
  20062. key: "_ensureTransformGroup",
  20063. value: function _ensureTransformGroup() {
  20064. if (!this.tgrp) {
  20065. this.tgrp = this.svgFactory.createElement('svg:g');
  20066. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20067. if (this.current.activeClipUrl) {
  20068. this._ensureClipGroup().appendChild(this.tgrp);
  20069. } else {
  20070. this.svg.appendChild(this.tgrp);
  20071. }
  20072. }
  20073. return this.tgrp;
  20074. }
  20075. }]);
  20076. return SVGGraphics;
  20077. }();
  20078. }
  20079. /***/ }),
  20080. /* 197 */
  20081. /***/ (function(module, exports, __w_pdfjs_require__) {
  20082. "use strict";
  20083. Object.defineProperty(exports, "__esModule", {
  20084. value: true
  20085. });
  20086. exports.PDFNodeStream = void 0;
  20087. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  20088. var _util = __w_pdfjs_require__(1);
  20089. var _network_utils = __w_pdfjs_require__(198);
  20090. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  20091. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  20092. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  20093. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  20094. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  20095. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  20096. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  20097. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  20098. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  20099. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20100. 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); } }
  20101. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20102. var fs = require('fs');
  20103. var http = require('http');
  20104. var https = require('https');
  20105. var url = require('url');
  20106. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  20107. function parseUrl(sourceUrl) {
  20108. var parsedUrl = url.parse(sourceUrl);
  20109. if (parsedUrl.protocol === 'file:' || parsedUrl.host) {
  20110. return parsedUrl;
  20111. }
  20112. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  20113. return url.parse("file:///".concat(sourceUrl));
  20114. }
  20115. if (!parsedUrl.host) {
  20116. parsedUrl.protocol = 'file:';
  20117. }
  20118. return parsedUrl;
  20119. }
  20120. var PDFNodeStream =
  20121. /*#__PURE__*/
  20122. function () {
  20123. function PDFNodeStream(source) {
  20124. _classCallCheck(this, PDFNodeStream);
  20125. this.source = source;
  20126. this.url = parseUrl(source.url);
  20127. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  20128. this.isFsUrl = this.url.protocol === 'file:';
  20129. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  20130. this._fullRequestReader = null;
  20131. this._rangeRequestReaders = [];
  20132. }
  20133. _createClass(PDFNodeStream, [{
  20134. key: "getFullReader",
  20135. value: function getFullReader() {
  20136. (0, _util.assert)(!this._fullRequestReader);
  20137. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  20138. return this._fullRequestReader;
  20139. }
  20140. }, {
  20141. key: "getRangeReader",
  20142. value: function getRangeReader(start, end) {
  20143. if (end <= this._progressiveDataLength) {
  20144. return null;
  20145. }
  20146. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  20147. this._rangeRequestReaders.push(rangeReader);
  20148. return rangeReader;
  20149. }
  20150. }, {
  20151. key: "cancelAllRequests",
  20152. value: function cancelAllRequests(reason) {
  20153. if (this._fullRequestReader) {
  20154. this._fullRequestReader.cancel(reason);
  20155. }
  20156. var readers = this._rangeRequestReaders.slice(0);
  20157. readers.forEach(function (reader) {
  20158. reader.cancel(reason);
  20159. });
  20160. }
  20161. }, {
  20162. key: "_progressiveDataLength",
  20163. get: function get() {
  20164. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  20165. }
  20166. }]);
  20167. return PDFNodeStream;
  20168. }();
  20169. exports.PDFNodeStream = PDFNodeStream;
  20170. var BaseFullReader =
  20171. /*#__PURE__*/
  20172. function () {
  20173. function BaseFullReader(stream) {
  20174. _classCallCheck(this, BaseFullReader);
  20175. this._url = stream.url;
  20176. this._done = false;
  20177. this._storedError = null;
  20178. this.onProgress = null;
  20179. var source = stream.source;
  20180. this._contentLength = source.length;
  20181. this._loaded = 0;
  20182. this._filename = null;
  20183. this._disableRange = source.disableRange || false;
  20184. this._rangeChunkSize = source.rangeChunkSize;
  20185. if (!this._rangeChunkSize && !this._disableRange) {
  20186. this._disableRange = true;
  20187. }
  20188. this._isStreamingSupported = !source.disableStream;
  20189. this._isRangeSupported = !source.disableRange;
  20190. this._readableStream = null;
  20191. this._readCapability = (0, _util.createPromiseCapability)();
  20192. this._headersCapability = (0, _util.createPromiseCapability)();
  20193. }
  20194. _createClass(BaseFullReader, [{
  20195. key: "read",
  20196. value: function () {
  20197. var _read = _asyncToGenerator(
  20198. /*#__PURE__*/
  20199. _regenerator["default"].mark(function _callee() {
  20200. var chunk, buffer;
  20201. return _regenerator["default"].wrap(function _callee$(_context) {
  20202. while (1) {
  20203. switch (_context.prev = _context.next) {
  20204. case 0:
  20205. _context.next = 2;
  20206. return this._readCapability.promise;
  20207. case 2:
  20208. if (!this._done) {
  20209. _context.next = 4;
  20210. break;
  20211. }
  20212. return _context.abrupt("return", {
  20213. value: undefined,
  20214. done: true
  20215. });
  20216. case 4:
  20217. if (!this._storedError) {
  20218. _context.next = 6;
  20219. break;
  20220. }
  20221. throw this._storedError;
  20222. case 6:
  20223. chunk = this._readableStream.read();
  20224. if (!(chunk === null)) {
  20225. _context.next = 10;
  20226. break;
  20227. }
  20228. this._readCapability = (0, _util.createPromiseCapability)();
  20229. return _context.abrupt("return", this.read());
  20230. case 10:
  20231. this._loaded += chunk.length;
  20232. if (this.onProgress) {
  20233. this.onProgress({
  20234. loaded: this._loaded,
  20235. total: this._contentLength
  20236. });
  20237. }
  20238. buffer = new Uint8Array(chunk).buffer;
  20239. return _context.abrupt("return", {
  20240. value: buffer,
  20241. done: false
  20242. });
  20243. case 14:
  20244. case "end":
  20245. return _context.stop();
  20246. }
  20247. }
  20248. }, _callee, this);
  20249. }));
  20250. function read() {
  20251. return _read.apply(this, arguments);
  20252. }
  20253. return read;
  20254. }()
  20255. }, {
  20256. key: "cancel",
  20257. value: function cancel(reason) {
  20258. if (!this._readableStream) {
  20259. this._error(reason);
  20260. return;
  20261. }
  20262. this._readableStream.destroy(reason);
  20263. }
  20264. }, {
  20265. key: "_error",
  20266. value: function _error(reason) {
  20267. this._storedError = reason;
  20268. this._readCapability.resolve();
  20269. }
  20270. }, {
  20271. key: "_setReadableStream",
  20272. value: function _setReadableStream(readableStream) {
  20273. var _this = this;
  20274. this._readableStream = readableStream;
  20275. readableStream.on('readable', function () {
  20276. _this._readCapability.resolve();
  20277. });
  20278. readableStream.on('end', function () {
  20279. readableStream.destroy();
  20280. _this._done = true;
  20281. _this._readCapability.resolve();
  20282. });
  20283. readableStream.on('error', function (reason) {
  20284. _this._error(reason);
  20285. });
  20286. if (!this._isStreamingSupported && this._isRangeSupported) {
  20287. this._error(new _util.AbortException('streaming is disabled'));
  20288. }
  20289. if (this._storedError) {
  20290. this._readableStream.destroy(this._storedError);
  20291. }
  20292. }
  20293. }, {
  20294. key: "headersReady",
  20295. get: function get() {
  20296. return this._headersCapability.promise;
  20297. }
  20298. }, {
  20299. key: "filename",
  20300. get: function get() {
  20301. return this._filename;
  20302. }
  20303. }, {
  20304. key: "contentLength",
  20305. get: function get() {
  20306. return this._contentLength;
  20307. }
  20308. }, {
  20309. key: "isRangeSupported",
  20310. get: function get() {
  20311. return this._isRangeSupported;
  20312. }
  20313. }, {
  20314. key: "isStreamingSupported",
  20315. get: function get() {
  20316. return this._isStreamingSupported;
  20317. }
  20318. }]);
  20319. return BaseFullReader;
  20320. }();
  20321. var BaseRangeReader =
  20322. /*#__PURE__*/
  20323. function () {
  20324. function BaseRangeReader(stream) {
  20325. _classCallCheck(this, BaseRangeReader);
  20326. this._url = stream.url;
  20327. this._done = false;
  20328. this._storedError = null;
  20329. this.onProgress = null;
  20330. this._loaded = 0;
  20331. this._readableStream = null;
  20332. this._readCapability = (0, _util.createPromiseCapability)();
  20333. var source = stream.source;
  20334. this._isStreamingSupported = !source.disableStream;
  20335. }
  20336. _createClass(BaseRangeReader, [{
  20337. key: "read",
  20338. value: function () {
  20339. var _read2 = _asyncToGenerator(
  20340. /*#__PURE__*/
  20341. _regenerator["default"].mark(function _callee2() {
  20342. var chunk, buffer;
  20343. return _regenerator["default"].wrap(function _callee2$(_context2) {
  20344. while (1) {
  20345. switch (_context2.prev = _context2.next) {
  20346. case 0:
  20347. _context2.next = 2;
  20348. return this._readCapability.promise;
  20349. case 2:
  20350. if (!this._done) {
  20351. _context2.next = 4;
  20352. break;
  20353. }
  20354. return _context2.abrupt("return", {
  20355. value: undefined,
  20356. done: true
  20357. });
  20358. case 4:
  20359. if (!this._storedError) {
  20360. _context2.next = 6;
  20361. break;
  20362. }
  20363. throw this._storedError;
  20364. case 6:
  20365. chunk = this._readableStream.read();
  20366. if (!(chunk === null)) {
  20367. _context2.next = 10;
  20368. break;
  20369. }
  20370. this._readCapability = (0, _util.createPromiseCapability)();
  20371. return _context2.abrupt("return", this.read());
  20372. case 10:
  20373. this._loaded += chunk.length;
  20374. if (this.onProgress) {
  20375. this.onProgress({
  20376. loaded: this._loaded
  20377. });
  20378. }
  20379. buffer = new Uint8Array(chunk).buffer;
  20380. return _context2.abrupt("return", {
  20381. value: buffer,
  20382. done: false
  20383. });
  20384. case 14:
  20385. case "end":
  20386. return _context2.stop();
  20387. }
  20388. }
  20389. }, _callee2, this);
  20390. }));
  20391. function read() {
  20392. return _read2.apply(this, arguments);
  20393. }
  20394. return read;
  20395. }()
  20396. }, {
  20397. key: "cancel",
  20398. value: function cancel(reason) {
  20399. if (!this._readableStream) {
  20400. this._error(reason);
  20401. return;
  20402. }
  20403. this._readableStream.destroy(reason);
  20404. }
  20405. }, {
  20406. key: "_error",
  20407. value: function _error(reason) {
  20408. this._storedError = reason;
  20409. this._readCapability.resolve();
  20410. }
  20411. }, {
  20412. key: "_setReadableStream",
  20413. value: function _setReadableStream(readableStream) {
  20414. var _this2 = this;
  20415. this._readableStream = readableStream;
  20416. readableStream.on('readable', function () {
  20417. _this2._readCapability.resolve();
  20418. });
  20419. readableStream.on('end', function () {
  20420. readableStream.destroy();
  20421. _this2._done = true;
  20422. _this2._readCapability.resolve();
  20423. });
  20424. readableStream.on('error', function (reason) {
  20425. _this2._error(reason);
  20426. });
  20427. if (this._storedError) {
  20428. this._readableStream.destroy(this._storedError);
  20429. }
  20430. }
  20431. }, {
  20432. key: "isStreamingSupported",
  20433. get: function get() {
  20434. return this._isStreamingSupported;
  20435. }
  20436. }]);
  20437. return BaseRangeReader;
  20438. }();
  20439. function createRequestOptions(url, headers) {
  20440. return {
  20441. protocol: url.protocol,
  20442. auth: url.auth,
  20443. host: url.hostname,
  20444. port: url.port,
  20445. path: url.path,
  20446. method: 'GET',
  20447. headers: headers
  20448. };
  20449. }
  20450. var PDFNodeStreamFullReader =
  20451. /*#__PURE__*/
  20452. function (_BaseFullReader) {
  20453. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  20454. function PDFNodeStreamFullReader(stream) {
  20455. var _this3;
  20456. _classCallCheck(this, PDFNodeStreamFullReader);
  20457. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFullReader).call(this, stream));
  20458. var handleResponse = function handleResponse(response) {
  20459. if (response.statusCode === 404) {
  20460. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
  20461. _this3._storedError = error;
  20462. _this3._headersCapability.reject(error);
  20463. return;
  20464. }
  20465. _this3._headersCapability.resolve();
  20466. _this3._setReadableStream(response);
  20467. var getResponseHeader = function getResponseHeader(name) {
  20468. return _this3._readableStream.headers[name.toLowerCase()];
  20469. };
  20470. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  20471. getResponseHeader: getResponseHeader,
  20472. isHttp: stream.isHttp,
  20473. rangeChunkSize: _this3._rangeChunkSize,
  20474. disableRange: _this3._disableRange
  20475. }),
  20476. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  20477. suggestedLength = _validateRangeRequest.suggestedLength;
  20478. _this3._isRangeSupported = allowRangeRequests;
  20479. _this3._contentLength = suggestedLength || _this3._contentLength;
  20480. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  20481. };
  20482. _this3._request = null;
  20483. if (_this3._url.protocol === 'http:') {
  20484. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  20485. } else {
  20486. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  20487. }
  20488. _this3._request.on('error', function (reason) {
  20489. _this3._storedError = reason;
  20490. _this3._headersCapability.reject(reason);
  20491. });
  20492. _this3._request.end();
  20493. return _this3;
  20494. }
  20495. return PDFNodeStreamFullReader;
  20496. }(BaseFullReader);
  20497. var PDFNodeStreamRangeReader =
  20498. /*#__PURE__*/
  20499. function (_BaseRangeReader) {
  20500. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  20501. function PDFNodeStreamRangeReader(stream, start, end) {
  20502. var _this4;
  20503. _classCallCheck(this, PDFNodeStreamRangeReader);
  20504. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamRangeReader).call(this, stream));
  20505. _this4._httpHeaders = {};
  20506. for (var property in stream.httpHeaders) {
  20507. var value = stream.httpHeaders[property];
  20508. if (typeof value === 'undefined') {
  20509. continue;
  20510. }
  20511. _this4._httpHeaders[property] = value;
  20512. }
  20513. _this4._httpHeaders['Range'] = "bytes=".concat(start, "-").concat(end - 1);
  20514. var handleResponse = function handleResponse(response) {
  20515. if (response.statusCode === 404) {
  20516. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
  20517. _this4._storedError = error;
  20518. return;
  20519. }
  20520. _this4._setReadableStream(response);
  20521. };
  20522. _this4._request = null;
  20523. if (_this4._url.protocol === 'http:') {
  20524. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  20525. } else {
  20526. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  20527. }
  20528. _this4._request.on('error', function (reason) {
  20529. _this4._storedError = reason;
  20530. });
  20531. _this4._request.end();
  20532. return _this4;
  20533. }
  20534. return PDFNodeStreamRangeReader;
  20535. }(BaseRangeReader);
  20536. var PDFNodeStreamFsFullReader =
  20537. /*#__PURE__*/
  20538. function (_BaseFullReader2) {
  20539. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  20540. function PDFNodeStreamFsFullReader(stream) {
  20541. var _this5;
  20542. _classCallCheck(this, PDFNodeStreamFsFullReader);
  20543. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsFullReader).call(this, stream));
  20544. var path = decodeURIComponent(_this5._url.path);
  20545. if (fileUriRegex.test(_this5._url.href)) {
  20546. path = path.replace(/^\//, '');
  20547. }
  20548. fs.lstat(path, function (error, stat) {
  20549. if (error) {
  20550. if (error.code === 'ENOENT') {
  20551. error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
  20552. }
  20553. _this5._storedError = error;
  20554. _this5._headersCapability.reject(error);
  20555. return;
  20556. }
  20557. _this5._contentLength = stat.size;
  20558. _this5._setReadableStream(fs.createReadStream(path));
  20559. _this5._headersCapability.resolve();
  20560. });
  20561. return _this5;
  20562. }
  20563. return PDFNodeStreamFsFullReader;
  20564. }(BaseFullReader);
  20565. var PDFNodeStreamFsRangeReader =
  20566. /*#__PURE__*/
  20567. function (_BaseRangeReader2) {
  20568. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  20569. function PDFNodeStreamFsRangeReader(stream, start, end) {
  20570. var _this6;
  20571. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  20572. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsRangeReader).call(this, stream));
  20573. var path = decodeURIComponent(_this6._url.path);
  20574. if (fileUriRegex.test(_this6._url.href)) {
  20575. path = path.replace(/^\//, '');
  20576. }
  20577. _this6._setReadableStream(fs.createReadStream(path, {
  20578. start: start,
  20579. end: end - 1
  20580. }));
  20581. return _this6;
  20582. }
  20583. return PDFNodeStreamFsRangeReader;
  20584. }(BaseRangeReader);
  20585. /***/ }),
  20586. /* 198 */
  20587. /***/ (function(module, exports, __w_pdfjs_require__) {
  20588. "use strict";
  20589. Object.defineProperty(exports, "__esModule", {
  20590. value: true
  20591. });
  20592. exports.createResponseStatusError = createResponseStatusError;
  20593. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  20594. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  20595. exports.validateResponseStatus = validateResponseStatus;
  20596. var _util = __w_pdfjs_require__(1);
  20597. var _content_disposition = __w_pdfjs_require__(199);
  20598. function validateRangeRequestCapabilities(_ref) {
  20599. var getResponseHeader = _ref.getResponseHeader,
  20600. isHttp = _ref.isHttp,
  20601. rangeChunkSize = _ref.rangeChunkSize,
  20602. disableRange = _ref.disableRange;
  20603. (0, _util.assert)(rangeChunkSize > 0, 'Range chunk size must be larger than zero');
  20604. var returnValues = {
  20605. allowRangeRequests: false,
  20606. suggestedLength: undefined
  20607. };
  20608. var length = parseInt(getResponseHeader('Content-Length'), 10);
  20609. if (!Number.isInteger(length)) {
  20610. return returnValues;
  20611. }
  20612. returnValues.suggestedLength = length;
  20613. if (length <= 2 * rangeChunkSize) {
  20614. return returnValues;
  20615. }
  20616. if (disableRange || !isHttp) {
  20617. return returnValues;
  20618. }
  20619. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  20620. return returnValues;
  20621. }
  20622. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  20623. if (contentEncoding !== 'identity') {
  20624. return returnValues;
  20625. }
  20626. returnValues.allowRangeRequests = true;
  20627. return returnValues;
  20628. }
  20629. function extractFilenameFromHeader(getResponseHeader) {
  20630. var contentDisposition = getResponseHeader('Content-Disposition');
  20631. if (contentDisposition) {
  20632. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  20633. if (filename.includes('%')) {
  20634. try {
  20635. filename = decodeURIComponent(filename);
  20636. } catch (ex) {}
  20637. }
  20638. if (/\.pdf$/i.test(filename)) {
  20639. return filename;
  20640. }
  20641. }
  20642. return null;
  20643. }
  20644. function createResponseStatusError(status, url) {
  20645. if (status === 404 || status === 0 && /^file:/.test(url)) {
  20646. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  20647. }
  20648. return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  20649. }
  20650. function validateResponseStatus(status) {
  20651. return status === 200 || status === 206;
  20652. }
  20653. /***/ }),
  20654. /* 199 */
  20655. /***/ (function(module, exports, __w_pdfjs_require__) {
  20656. "use strict";
  20657. Object.defineProperty(exports, "__esModule", {
  20658. value: true
  20659. });
  20660. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  20661. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  20662. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  20663. function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  20664. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  20665. function getFilenameFromContentDispositionHeader(contentDisposition) {
  20666. var needsEncodingFixup = true;
  20667. var tmp = toParamRegExp('filename\\*', 'i').exec(contentDisposition);
  20668. if (tmp) {
  20669. tmp = tmp[1];
  20670. var filename = rfc2616unquote(tmp);
  20671. filename = unescape(filename);
  20672. filename = rfc5987decode(filename);
  20673. filename = rfc2047decode(filename);
  20674. return fixupEncoding(filename);
  20675. }
  20676. tmp = rfc2231getparam(contentDisposition);
  20677. if (tmp) {
  20678. var _filename = rfc2047decode(tmp);
  20679. return fixupEncoding(_filename);
  20680. }
  20681. tmp = toParamRegExp('filename', 'i').exec(contentDisposition);
  20682. if (tmp) {
  20683. tmp = tmp[1];
  20684. var _filename2 = rfc2616unquote(tmp);
  20685. _filename2 = rfc2047decode(_filename2);
  20686. return fixupEncoding(_filename2);
  20687. }
  20688. function toParamRegExp(attributePattern, flags) {
  20689. return new RegExp('(?:^|;)\\s*' + attributePattern + '\\s*=\\s*' + '(' + '[^";\\s][^;\\s]*' + '|' + '"(?:[^"\\\\]|\\\\"?)+"?' + ')', flags);
  20690. }
  20691. function textdecode(encoding, value) {
  20692. if (encoding) {
  20693. if (!/^[\x00-\xFF]+$/.test(value)) {
  20694. return value;
  20695. }
  20696. try {
  20697. var decoder = new TextDecoder(encoding, {
  20698. fatal: true
  20699. });
  20700. var bytes = Array.from(value, function (ch) {
  20701. return ch.charCodeAt(0) & 0xFF;
  20702. });
  20703. value = decoder.decode(new Uint8Array(bytes));
  20704. needsEncodingFixup = false;
  20705. } catch (e) {
  20706. if (/^utf-?8$/i.test(encoding)) {
  20707. try {
  20708. value = decodeURIComponent(escape(value));
  20709. needsEncodingFixup = false;
  20710. } catch (err) {}
  20711. }
  20712. }
  20713. }
  20714. return value;
  20715. }
  20716. function fixupEncoding(value) {
  20717. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  20718. value = textdecode('utf-8', value);
  20719. if (needsEncodingFixup) {
  20720. value = textdecode('iso-8859-1', value);
  20721. }
  20722. }
  20723. return value;
  20724. }
  20725. function rfc2231getparam(contentDisposition) {
  20726. var matches = [],
  20727. match;
  20728. var iter = toParamRegExp('filename\\*((?!0\\d)\\d+)(\\*?)', 'ig');
  20729. while ((match = iter.exec(contentDisposition)) !== null) {
  20730. var _match = match,
  20731. _match2 = _slicedToArray(_match, 4),
  20732. n = _match2[1],
  20733. quot = _match2[2],
  20734. part = _match2[3];
  20735. n = parseInt(n, 10);
  20736. if (n in matches) {
  20737. if (n === 0) {
  20738. break;
  20739. }
  20740. continue;
  20741. }
  20742. matches[n] = [quot, part];
  20743. }
  20744. var parts = [];
  20745. for (var n = 0; n < matches.length; ++n) {
  20746. if (!(n in matches)) {
  20747. break;
  20748. }
  20749. var _matches$n = _slicedToArray(matches[n], 2),
  20750. quot = _matches$n[0],
  20751. part = _matches$n[1];
  20752. part = rfc2616unquote(part);
  20753. if (quot) {
  20754. part = unescape(part);
  20755. if (n === 0) {
  20756. part = rfc5987decode(part);
  20757. }
  20758. }
  20759. parts.push(part);
  20760. }
  20761. return parts.join('');
  20762. }
  20763. function rfc2616unquote(value) {
  20764. if (value.startsWith('"')) {
  20765. var parts = value.slice(1).split('\\"');
  20766. for (var i = 0; i < parts.length; ++i) {
  20767. var quotindex = parts[i].indexOf('"');
  20768. if (quotindex !== -1) {
  20769. parts[i] = parts[i].slice(0, quotindex);
  20770. parts.length = i + 1;
  20771. }
  20772. parts[i] = parts[i].replace(/\\(.)/g, '$1');
  20773. }
  20774. value = parts.join('"');
  20775. }
  20776. return value;
  20777. }
  20778. function rfc5987decode(extvalue) {
  20779. var encodingend = extvalue.indexOf('\'');
  20780. if (encodingend === -1) {
  20781. return extvalue;
  20782. }
  20783. var encoding = extvalue.slice(0, encodingend);
  20784. var langvalue = extvalue.slice(encodingend + 1);
  20785. var value = langvalue.replace(/^[^']*'/, '');
  20786. return textdecode(encoding, value);
  20787. }
  20788. function rfc2047decode(value) {
  20789. if (!value.startsWith('=?') || /[\x00-\x19\x80-\xff]/.test(value)) {
  20790. return value;
  20791. }
  20792. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (_, charset, encoding, text) {
  20793. if (encoding === 'q' || encoding === 'Q') {
  20794. text = text.replace(/_/g, ' ');
  20795. text = text.replace(/=([0-9a-fA-F]{2})/g, function (_, hex) {
  20796. return String.fromCharCode(parseInt(hex, 16));
  20797. });
  20798. return textdecode(charset, text);
  20799. }
  20800. try {
  20801. text = atob(text);
  20802. } catch (e) {}
  20803. return textdecode(charset, text);
  20804. });
  20805. }
  20806. return '';
  20807. }
  20808. /***/ }),
  20809. /* 200 */
  20810. /***/ (function(module, exports, __w_pdfjs_require__) {
  20811. "use strict";
  20812. Object.defineProperty(exports, "__esModule", {
  20813. value: true
  20814. });
  20815. exports.PDFNetworkStream = void 0;
  20816. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  20817. var _util = __w_pdfjs_require__(1);
  20818. var _network_utils = __w_pdfjs_require__(198);
  20819. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20820. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  20821. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  20822. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20823. 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); } }
  20824. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20825. ;
  20826. var OK_RESPONSE = 200;
  20827. var PARTIAL_CONTENT_RESPONSE = 206;
  20828. function getArrayBuffer(xhr) {
  20829. var data = xhr.response;
  20830. if (typeof data !== 'string') {
  20831. return data;
  20832. }
  20833. var array = (0, _util.stringToBytes)(data);
  20834. return array.buffer;
  20835. }
  20836. var NetworkManager =
  20837. /*#__PURE__*/
  20838. function () {
  20839. function NetworkManager(url, args) {
  20840. _classCallCheck(this, NetworkManager);
  20841. this.url = url;
  20842. args = args || {};
  20843. this.isHttp = /^https?:/i.test(url);
  20844. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  20845. this.withCredentials = args.withCredentials || false;
  20846. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  20847. return new XMLHttpRequest();
  20848. };
  20849. this.currXhrId = 0;
  20850. this.pendingRequests = Object.create(null);
  20851. }
  20852. _createClass(NetworkManager, [{
  20853. key: "requestRange",
  20854. value: function requestRange(begin, end, listeners) {
  20855. var args = {
  20856. begin: begin,
  20857. end: end
  20858. };
  20859. for (var prop in listeners) {
  20860. args[prop] = listeners[prop];
  20861. }
  20862. return this.request(args);
  20863. }
  20864. }, {
  20865. key: "requestFull",
  20866. value: function requestFull(listeners) {
  20867. return this.request(listeners);
  20868. }
  20869. }, {
  20870. key: "request",
  20871. value: function request(args) {
  20872. var xhr = this.getXhr();
  20873. var xhrId = this.currXhrId++;
  20874. var pendingRequest = this.pendingRequests[xhrId] = {
  20875. xhr: xhr
  20876. };
  20877. xhr.open('GET', this.url);
  20878. xhr.withCredentials = this.withCredentials;
  20879. for (var property in this.httpHeaders) {
  20880. var value = this.httpHeaders[property];
  20881. if (typeof value === 'undefined') {
  20882. continue;
  20883. }
  20884. xhr.setRequestHeader(property, value);
  20885. }
  20886. if (this.isHttp && 'begin' in args && 'end' in args) {
  20887. xhr.setRequestHeader('Range', "bytes=".concat(args.begin, "-").concat(args.end - 1));
  20888. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  20889. } else {
  20890. pendingRequest.expectedStatus = OK_RESPONSE;
  20891. }
  20892. xhr.responseType = 'arraybuffer';
  20893. if (args.onError) {
  20894. xhr.onerror = function (evt) {
  20895. args.onError(xhr.status);
  20896. };
  20897. }
  20898. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  20899. xhr.onprogress = this.onProgress.bind(this, xhrId);
  20900. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  20901. pendingRequest.onDone = args.onDone;
  20902. pendingRequest.onError = args.onError;
  20903. pendingRequest.onProgress = args.onProgress;
  20904. xhr.send(null);
  20905. return xhrId;
  20906. }
  20907. }, {
  20908. key: "onProgress",
  20909. value: function onProgress(xhrId, evt) {
  20910. var pendingRequest = this.pendingRequests[xhrId];
  20911. if (!pendingRequest) {
  20912. return;
  20913. }
  20914. if (pendingRequest.onProgress) {
  20915. pendingRequest.onProgress(evt);
  20916. }
  20917. }
  20918. }, {
  20919. key: "onStateChange",
  20920. value: function onStateChange(xhrId, evt) {
  20921. var pendingRequest = this.pendingRequests[xhrId];
  20922. if (!pendingRequest) {
  20923. return;
  20924. }
  20925. var xhr = pendingRequest.xhr;
  20926. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  20927. pendingRequest.onHeadersReceived();
  20928. delete pendingRequest.onHeadersReceived;
  20929. }
  20930. if (xhr.readyState !== 4) {
  20931. return;
  20932. }
  20933. if (!(xhrId in this.pendingRequests)) {
  20934. return;
  20935. }
  20936. delete this.pendingRequests[xhrId];
  20937. if (xhr.status === 0 && this.isHttp) {
  20938. if (pendingRequest.onError) {
  20939. pendingRequest.onError(xhr.status);
  20940. }
  20941. return;
  20942. }
  20943. var xhrStatus = xhr.status || OK_RESPONSE;
  20944. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  20945. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  20946. if (pendingRequest.onError) {
  20947. pendingRequest.onError(xhr.status);
  20948. }
  20949. return;
  20950. }
  20951. var chunk = getArrayBuffer(xhr);
  20952. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  20953. var rangeHeader = xhr.getResponseHeader('Content-Range');
  20954. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  20955. pendingRequest.onDone({
  20956. begin: parseInt(matches[1], 10),
  20957. chunk: chunk
  20958. });
  20959. } else if (chunk) {
  20960. pendingRequest.onDone({
  20961. begin: 0,
  20962. chunk: chunk
  20963. });
  20964. } else if (pendingRequest.onError) {
  20965. pendingRequest.onError(xhr.status);
  20966. }
  20967. }
  20968. }, {
  20969. key: "hasPendingRequests",
  20970. value: function hasPendingRequests() {
  20971. for (var xhrId in this.pendingRequests) {
  20972. return true;
  20973. }
  20974. return false;
  20975. }
  20976. }, {
  20977. key: "getRequestXhr",
  20978. value: function getRequestXhr(xhrId) {
  20979. return this.pendingRequests[xhrId].xhr;
  20980. }
  20981. }, {
  20982. key: "isPendingRequest",
  20983. value: function isPendingRequest(xhrId) {
  20984. return xhrId in this.pendingRequests;
  20985. }
  20986. }, {
  20987. key: "abortAllRequests",
  20988. value: function abortAllRequests() {
  20989. for (var xhrId in this.pendingRequests) {
  20990. this.abortRequest(xhrId | 0);
  20991. }
  20992. }
  20993. }, {
  20994. key: "abortRequest",
  20995. value: function abortRequest(xhrId) {
  20996. var xhr = this.pendingRequests[xhrId].xhr;
  20997. delete this.pendingRequests[xhrId];
  20998. xhr.abort();
  20999. }
  21000. }]);
  21001. return NetworkManager;
  21002. }();
  21003. var PDFNetworkStream =
  21004. /*#__PURE__*/
  21005. function () {
  21006. function PDFNetworkStream(source) {
  21007. _classCallCheck(this, PDFNetworkStream);
  21008. this._source = source;
  21009. this._manager = new NetworkManager(source.url, {
  21010. httpHeaders: source.httpHeaders,
  21011. withCredentials: source.withCredentials
  21012. });
  21013. this._rangeChunkSize = source.rangeChunkSize;
  21014. this._fullRequestReader = null;
  21015. this._rangeRequestReaders = [];
  21016. }
  21017. _createClass(PDFNetworkStream, [{
  21018. key: "_onRangeRequestReaderClosed",
  21019. value: function _onRangeRequestReaderClosed(reader) {
  21020. var i = this._rangeRequestReaders.indexOf(reader);
  21021. if (i >= 0) {
  21022. this._rangeRequestReaders.splice(i, 1);
  21023. }
  21024. }
  21025. }, {
  21026. key: "getFullReader",
  21027. value: function getFullReader() {
  21028. (0, _util.assert)(!this._fullRequestReader);
  21029. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  21030. return this._fullRequestReader;
  21031. }
  21032. }, {
  21033. key: "getRangeReader",
  21034. value: function getRangeReader(begin, end) {
  21035. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  21036. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  21037. this._rangeRequestReaders.push(reader);
  21038. return reader;
  21039. }
  21040. }, {
  21041. key: "cancelAllRequests",
  21042. value: function cancelAllRequests(reason) {
  21043. if (this._fullRequestReader) {
  21044. this._fullRequestReader.cancel(reason);
  21045. }
  21046. var readers = this._rangeRequestReaders.slice(0);
  21047. readers.forEach(function (reader) {
  21048. reader.cancel(reason);
  21049. });
  21050. }
  21051. }]);
  21052. return PDFNetworkStream;
  21053. }();
  21054. exports.PDFNetworkStream = PDFNetworkStream;
  21055. var PDFNetworkStreamFullRequestReader =
  21056. /*#__PURE__*/
  21057. function () {
  21058. function PDFNetworkStreamFullRequestReader(manager, source) {
  21059. _classCallCheck(this, PDFNetworkStreamFullRequestReader);
  21060. this._manager = manager;
  21061. var args = {
  21062. onHeadersReceived: this._onHeadersReceived.bind(this),
  21063. onDone: this._onDone.bind(this),
  21064. onError: this._onError.bind(this),
  21065. onProgress: this._onProgress.bind(this)
  21066. };
  21067. this._url = source.url;
  21068. this._fullRequestId = manager.requestFull(args);
  21069. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  21070. this._disableRange = source.disableRange || false;
  21071. this._contentLength = source.length;
  21072. this._rangeChunkSize = source.rangeChunkSize;
  21073. if (!this._rangeChunkSize && !this._disableRange) {
  21074. this._disableRange = true;
  21075. }
  21076. this._isStreamingSupported = false;
  21077. this._isRangeSupported = false;
  21078. this._cachedChunks = [];
  21079. this._requests = [];
  21080. this._done = false;
  21081. this._storedError = undefined;
  21082. this._filename = null;
  21083. this.onProgress = null;
  21084. }
  21085. _createClass(PDFNetworkStreamFullRequestReader, [{
  21086. key: "_onHeadersReceived",
  21087. value: function _onHeadersReceived() {
  21088. var fullRequestXhrId = this._fullRequestId;
  21089. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  21090. var getResponseHeader = function getResponseHeader(name) {
  21091. return fullRequestXhr.getResponseHeader(name);
  21092. };
  21093. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  21094. getResponseHeader: getResponseHeader,
  21095. isHttp: this._manager.isHttp,
  21096. rangeChunkSize: this._rangeChunkSize,
  21097. disableRange: this._disableRange
  21098. }),
  21099. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  21100. suggestedLength = _validateRangeRequest.suggestedLength;
  21101. if (allowRangeRequests) {
  21102. this._isRangeSupported = true;
  21103. }
  21104. this._contentLength = suggestedLength || this._contentLength;
  21105. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  21106. if (this._isRangeSupported) {
  21107. this._manager.abortRequest(fullRequestXhrId);
  21108. }
  21109. this._headersReceivedCapability.resolve();
  21110. }
  21111. }, {
  21112. key: "_onDone",
  21113. value: function _onDone(args) {
  21114. if (args) {
  21115. if (this._requests.length > 0) {
  21116. var requestCapability = this._requests.shift();
  21117. requestCapability.resolve({
  21118. value: args.chunk,
  21119. done: false
  21120. });
  21121. } else {
  21122. this._cachedChunks.push(args.chunk);
  21123. }
  21124. }
  21125. this._done = true;
  21126. if (this._cachedChunks.length > 0) {
  21127. return;
  21128. }
  21129. this._requests.forEach(function (requestCapability) {
  21130. requestCapability.resolve({
  21131. value: undefined,
  21132. done: true
  21133. });
  21134. });
  21135. this._requests = [];
  21136. }
  21137. }, {
  21138. key: "_onError",
  21139. value: function _onError(status) {
  21140. var url = this._url;
  21141. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  21142. this._storedError = exception;
  21143. this._headersReceivedCapability.reject(exception);
  21144. this._requests.forEach(function (requestCapability) {
  21145. requestCapability.reject(exception);
  21146. });
  21147. this._requests = [];
  21148. this._cachedChunks = [];
  21149. }
  21150. }, {
  21151. key: "_onProgress",
  21152. value: function _onProgress(data) {
  21153. if (this.onProgress) {
  21154. this.onProgress({
  21155. loaded: data.loaded,
  21156. total: data.lengthComputable ? data.total : this._contentLength
  21157. });
  21158. }
  21159. }
  21160. }, {
  21161. key: "read",
  21162. value: function () {
  21163. var _read = _asyncToGenerator(
  21164. /*#__PURE__*/
  21165. _regenerator["default"].mark(function _callee() {
  21166. var chunk, requestCapability;
  21167. return _regenerator["default"].wrap(function _callee$(_context) {
  21168. while (1) {
  21169. switch (_context.prev = _context.next) {
  21170. case 0:
  21171. if (!this._storedError) {
  21172. _context.next = 2;
  21173. break;
  21174. }
  21175. throw this._storedError;
  21176. case 2:
  21177. if (!(this._cachedChunks.length > 0)) {
  21178. _context.next = 5;
  21179. break;
  21180. }
  21181. chunk = this._cachedChunks.shift();
  21182. return _context.abrupt("return", {
  21183. value: chunk,
  21184. done: false
  21185. });
  21186. case 5:
  21187. if (!this._done) {
  21188. _context.next = 7;
  21189. break;
  21190. }
  21191. return _context.abrupt("return", {
  21192. value: undefined,
  21193. done: true
  21194. });
  21195. case 7:
  21196. requestCapability = (0, _util.createPromiseCapability)();
  21197. this._requests.push(requestCapability);
  21198. return _context.abrupt("return", requestCapability.promise);
  21199. case 10:
  21200. case "end":
  21201. return _context.stop();
  21202. }
  21203. }
  21204. }, _callee, this);
  21205. }));
  21206. function read() {
  21207. return _read.apply(this, arguments);
  21208. }
  21209. return read;
  21210. }()
  21211. }, {
  21212. key: "cancel",
  21213. value: function cancel(reason) {
  21214. this._done = true;
  21215. this._headersReceivedCapability.reject(reason);
  21216. this._requests.forEach(function (requestCapability) {
  21217. requestCapability.resolve({
  21218. value: undefined,
  21219. done: true
  21220. });
  21221. });
  21222. this._requests = [];
  21223. if (this._manager.isPendingRequest(this._fullRequestId)) {
  21224. this._manager.abortRequest(this._fullRequestId);
  21225. }
  21226. this._fullRequestReader = null;
  21227. }
  21228. }, {
  21229. key: "filename",
  21230. get: function get() {
  21231. return this._filename;
  21232. }
  21233. }, {
  21234. key: "isRangeSupported",
  21235. get: function get() {
  21236. return this._isRangeSupported;
  21237. }
  21238. }, {
  21239. key: "isStreamingSupported",
  21240. get: function get() {
  21241. return this._isStreamingSupported;
  21242. }
  21243. }, {
  21244. key: "contentLength",
  21245. get: function get() {
  21246. return this._contentLength;
  21247. }
  21248. }, {
  21249. key: "headersReady",
  21250. get: function get() {
  21251. return this._headersReceivedCapability.promise;
  21252. }
  21253. }]);
  21254. return PDFNetworkStreamFullRequestReader;
  21255. }();
  21256. var PDFNetworkStreamRangeRequestReader =
  21257. /*#__PURE__*/
  21258. function () {
  21259. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  21260. _classCallCheck(this, PDFNetworkStreamRangeRequestReader);
  21261. this._manager = manager;
  21262. var args = {
  21263. onDone: this._onDone.bind(this),
  21264. onProgress: this._onProgress.bind(this)
  21265. };
  21266. this._requestId = manager.requestRange(begin, end, args);
  21267. this._requests = [];
  21268. this._queuedChunk = null;
  21269. this._done = false;
  21270. this.onProgress = null;
  21271. this.onClosed = null;
  21272. }
  21273. _createClass(PDFNetworkStreamRangeRequestReader, [{
  21274. key: "_close",
  21275. value: function _close() {
  21276. if (this.onClosed) {
  21277. this.onClosed(this);
  21278. }
  21279. }
  21280. }, {
  21281. key: "_onDone",
  21282. value: function _onDone(data) {
  21283. var chunk = data.chunk;
  21284. if (this._requests.length > 0) {
  21285. var requestCapability = this._requests.shift();
  21286. requestCapability.resolve({
  21287. value: chunk,
  21288. done: false
  21289. });
  21290. } else {
  21291. this._queuedChunk = chunk;
  21292. }
  21293. this._done = true;
  21294. this._requests.forEach(function (requestCapability) {
  21295. requestCapability.resolve({
  21296. value: undefined,
  21297. done: true
  21298. });
  21299. });
  21300. this._requests = [];
  21301. this._close();
  21302. }
  21303. }, {
  21304. key: "_onProgress",
  21305. value: function _onProgress(evt) {
  21306. if (!this.isStreamingSupported && this.onProgress) {
  21307. this.onProgress({
  21308. loaded: evt.loaded
  21309. });
  21310. }
  21311. }
  21312. }, {
  21313. key: "read",
  21314. value: function () {
  21315. var _read2 = _asyncToGenerator(
  21316. /*#__PURE__*/
  21317. _regenerator["default"].mark(function _callee2() {
  21318. var chunk, requestCapability;
  21319. return _regenerator["default"].wrap(function _callee2$(_context2) {
  21320. while (1) {
  21321. switch (_context2.prev = _context2.next) {
  21322. case 0:
  21323. if (!(this._queuedChunk !== null)) {
  21324. _context2.next = 4;
  21325. break;
  21326. }
  21327. chunk = this._queuedChunk;
  21328. this._queuedChunk = null;
  21329. return _context2.abrupt("return", {
  21330. value: chunk,
  21331. done: false
  21332. });
  21333. case 4:
  21334. if (!this._done) {
  21335. _context2.next = 6;
  21336. break;
  21337. }
  21338. return _context2.abrupt("return", {
  21339. value: undefined,
  21340. done: true
  21341. });
  21342. case 6:
  21343. requestCapability = (0, _util.createPromiseCapability)();
  21344. this._requests.push(requestCapability);
  21345. return _context2.abrupt("return", requestCapability.promise);
  21346. case 9:
  21347. case "end":
  21348. return _context2.stop();
  21349. }
  21350. }
  21351. }, _callee2, this);
  21352. }));
  21353. function read() {
  21354. return _read2.apply(this, arguments);
  21355. }
  21356. return read;
  21357. }()
  21358. }, {
  21359. key: "cancel",
  21360. value: function cancel(reason) {
  21361. this._done = true;
  21362. this._requests.forEach(function (requestCapability) {
  21363. requestCapability.resolve({
  21364. value: undefined,
  21365. done: true
  21366. });
  21367. });
  21368. this._requests = [];
  21369. if (this._manager.isPendingRequest(this._requestId)) {
  21370. this._manager.abortRequest(this._requestId);
  21371. }
  21372. this._close();
  21373. }
  21374. }, {
  21375. key: "isStreamingSupported",
  21376. get: function get() {
  21377. return false;
  21378. }
  21379. }]);
  21380. return PDFNetworkStreamRangeRequestReader;
  21381. }();
  21382. /***/ }),
  21383. /* 201 */
  21384. /***/ (function(module, exports, __w_pdfjs_require__) {
  21385. "use strict";
  21386. Object.defineProperty(exports, "__esModule", {
  21387. value: true
  21388. });
  21389. exports.PDFFetchStream = void 0;
  21390. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(180));
  21391. var _util = __w_pdfjs_require__(1);
  21392. var _network_utils = __w_pdfjs_require__(198);
  21393. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21394. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  21395. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  21396. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21397. 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); } }
  21398. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  21399. function createFetchOptions(headers, withCredentials, abortController) {
  21400. return {
  21401. method: 'GET',
  21402. headers: headers,
  21403. signal: abortController && abortController.signal,
  21404. mode: 'cors',
  21405. credentials: withCredentials ? 'include' : 'same-origin',
  21406. redirect: 'follow'
  21407. };
  21408. }
  21409. var PDFFetchStream =
  21410. /*#__PURE__*/
  21411. function () {
  21412. function PDFFetchStream(source) {
  21413. _classCallCheck(this, PDFFetchStream);
  21414. this.source = source;
  21415. this.isHttp = /^https?:/i.test(source.url);
  21416. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  21417. this._fullRequestReader = null;
  21418. this._rangeRequestReaders = [];
  21419. }
  21420. _createClass(PDFFetchStream, [{
  21421. key: "getFullReader",
  21422. value: function getFullReader() {
  21423. (0, _util.assert)(!this._fullRequestReader);
  21424. this._fullRequestReader = new PDFFetchStreamReader(this);
  21425. return this._fullRequestReader;
  21426. }
  21427. }, {
  21428. key: "getRangeReader",
  21429. value: function getRangeReader(begin, end) {
  21430. if (end <= this._progressiveDataLength) {
  21431. return null;
  21432. }
  21433. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  21434. this._rangeRequestReaders.push(reader);
  21435. return reader;
  21436. }
  21437. }, {
  21438. key: "cancelAllRequests",
  21439. value: function cancelAllRequests(reason) {
  21440. if (this._fullRequestReader) {
  21441. this._fullRequestReader.cancel(reason);
  21442. }
  21443. var readers = this._rangeRequestReaders.slice(0);
  21444. readers.forEach(function (reader) {
  21445. reader.cancel(reason);
  21446. });
  21447. }
  21448. }, {
  21449. key: "_progressiveDataLength",
  21450. get: function get() {
  21451. return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
  21452. }
  21453. }]);
  21454. return PDFFetchStream;
  21455. }();
  21456. exports.PDFFetchStream = PDFFetchStream;
  21457. var PDFFetchStreamReader =
  21458. /*#__PURE__*/
  21459. function () {
  21460. function PDFFetchStreamReader(stream) {
  21461. var _this = this;
  21462. _classCallCheck(this, PDFFetchStreamReader);
  21463. this._stream = stream;
  21464. this._reader = null;
  21465. this._loaded = 0;
  21466. this._filename = null;
  21467. var source = stream.source;
  21468. this._withCredentials = source.withCredentials || false;
  21469. this._contentLength = source.length;
  21470. this._headersCapability = (0, _util.createPromiseCapability)();
  21471. this._disableRange = source.disableRange || false;
  21472. this._rangeChunkSize = source.rangeChunkSize;
  21473. if (!this._rangeChunkSize && !this._disableRange) {
  21474. this._disableRange = true;
  21475. }
  21476. if (typeof AbortController !== 'undefined') {
  21477. this._abortController = new AbortController();
  21478. }
  21479. this._isStreamingSupported = !source.disableStream;
  21480. this._isRangeSupported = !source.disableRange;
  21481. this._headers = new Headers();
  21482. for (var property in this._stream.httpHeaders) {
  21483. var value = this._stream.httpHeaders[property];
  21484. if (typeof value === 'undefined') {
  21485. continue;
  21486. }
  21487. this._headers.append(property, value);
  21488. }
  21489. var url = source.url;
  21490. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  21491. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  21492. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  21493. }
  21494. _this._reader = response.body.getReader();
  21495. _this._headersCapability.resolve();
  21496. var getResponseHeader = function getResponseHeader(name) {
  21497. return response.headers.get(name);
  21498. };
  21499. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  21500. getResponseHeader: getResponseHeader,
  21501. isHttp: _this._stream.isHttp,
  21502. rangeChunkSize: _this._rangeChunkSize,
  21503. disableRange: _this._disableRange
  21504. }),
  21505. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  21506. suggestedLength = _validateRangeRequest.suggestedLength;
  21507. _this._isRangeSupported = allowRangeRequests;
  21508. _this._contentLength = suggestedLength || _this._contentLength;
  21509. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  21510. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  21511. _this.cancel(new _util.AbortException('Streaming is disabled.'));
  21512. }
  21513. })["catch"](this._headersCapability.reject);
  21514. this.onProgress = null;
  21515. }
  21516. _createClass(PDFFetchStreamReader, [{
  21517. key: "read",
  21518. value: function () {
  21519. var _read = _asyncToGenerator(
  21520. /*#__PURE__*/
  21521. _regenerator["default"].mark(function _callee() {
  21522. var _ref, value, done, buffer;
  21523. return _regenerator["default"].wrap(function _callee$(_context) {
  21524. while (1) {
  21525. switch (_context.prev = _context.next) {
  21526. case 0:
  21527. _context.next = 2;
  21528. return this._headersCapability.promise;
  21529. case 2:
  21530. _context.next = 4;
  21531. return this._reader.read();
  21532. case 4:
  21533. _ref = _context.sent;
  21534. value = _ref.value;
  21535. done = _ref.done;
  21536. if (!done) {
  21537. _context.next = 9;
  21538. break;
  21539. }
  21540. return _context.abrupt("return", {
  21541. value: value,
  21542. done: done
  21543. });
  21544. case 9:
  21545. this._loaded += value.byteLength;
  21546. if (this.onProgress) {
  21547. this.onProgress({
  21548. loaded: this._loaded,
  21549. total: this._contentLength
  21550. });
  21551. }
  21552. buffer = new Uint8Array(value).buffer;
  21553. return _context.abrupt("return", {
  21554. value: buffer,
  21555. done: false
  21556. });
  21557. case 13:
  21558. case "end":
  21559. return _context.stop();
  21560. }
  21561. }
  21562. }, _callee, this);
  21563. }));
  21564. function read() {
  21565. return _read.apply(this, arguments);
  21566. }
  21567. return read;
  21568. }()
  21569. }, {
  21570. key: "cancel",
  21571. value: function cancel(reason) {
  21572. if (this._reader) {
  21573. this._reader.cancel(reason);
  21574. }
  21575. if (this._abortController) {
  21576. this._abortController.abort();
  21577. }
  21578. }
  21579. }, {
  21580. key: "headersReady",
  21581. get: function get() {
  21582. return this._headersCapability.promise;
  21583. }
  21584. }, {
  21585. key: "filename",
  21586. get: function get() {
  21587. return this._filename;
  21588. }
  21589. }, {
  21590. key: "contentLength",
  21591. get: function get() {
  21592. return this._contentLength;
  21593. }
  21594. }, {
  21595. key: "isRangeSupported",
  21596. get: function get() {
  21597. return this._isRangeSupported;
  21598. }
  21599. }, {
  21600. key: "isStreamingSupported",
  21601. get: function get() {
  21602. return this._isStreamingSupported;
  21603. }
  21604. }]);
  21605. return PDFFetchStreamReader;
  21606. }();
  21607. var PDFFetchStreamRangeReader =
  21608. /*#__PURE__*/
  21609. function () {
  21610. function PDFFetchStreamRangeReader(stream, begin, end) {
  21611. var _this2 = this;
  21612. _classCallCheck(this, PDFFetchStreamRangeReader);
  21613. this._stream = stream;
  21614. this._reader = null;
  21615. this._loaded = 0;
  21616. var source = stream.source;
  21617. this._withCredentials = source.withCredentials || false;
  21618. this._readCapability = (0, _util.createPromiseCapability)();
  21619. this._isStreamingSupported = !source.disableStream;
  21620. if (typeof AbortController !== 'undefined') {
  21621. this._abortController = new AbortController();
  21622. }
  21623. this._headers = new Headers();
  21624. for (var property in this._stream.httpHeaders) {
  21625. var value = this._stream.httpHeaders[property];
  21626. if (typeof value === 'undefined') {
  21627. continue;
  21628. }
  21629. this._headers.append(property, value);
  21630. }
  21631. this._headers.append('Range', "bytes=".concat(begin, "-").concat(end - 1));
  21632. var url = source.url;
  21633. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  21634. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  21635. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  21636. }
  21637. _this2._readCapability.resolve();
  21638. _this2._reader = response.body.getReader();
  21639. });
  21640. this.onProgress = null;
  21641. }
  21642. _createClass(PDFFetchStreamRangeReader, [{
  21643. key: "read",
  21644. value: function () {
  21645. var _read2 = _asyncToGenerator(
  21646. /*#__PURE__*/
  21647. _regenerator["default"].mark(function _callee2() {
  21648. var _ref2, value, done, buffer;
  21649. return _regenerator["default"].wrap(function _callee2$(_context2) {
  21650. while (1) {
  21651. switch (_context2.prev = _context2.next) {
  21652. case 0:
  21653. _context2.next = 2;
  21654. return this._readCapability.promise;
  21655. case 2:
  21656. _context2.next = 4;
  21657. return this._reader.read();
  21658. case 4:
  21659. _ref2 = _context2.sent;
  21660. value = _ref2.value;
  21661. done = _ref2.done;
  21662. if (!done) {
  21663. _context2.next = 9;
  21664. break;
  21665. }
  21666. return _context2.abrupt("return", {
  21667. value: value,
  21668. done: done
  21669. });
  21670. case 9:
  21671. this._loaded += value.byteLength;
  21672. if (this.onProgress) {
  21673. this.onProgress({
  21674. loaded: this._loaded
  21675. });
  21676. }
  21677. buffer = new Uint8Array(value).buffer;
  21678. return _context2.abrupt("return", {
  21679. value: buffer,
  21680. done: false
  21681. });
  21682. case 13:
  21683. case "end":
  21684. return _context2.stop();
  21685. }
  21686. }
  21687. }, _callee2, this);
  21688. }));
  21689. function read() {
  21690. return _read2.apply(this, arguments);
  21691. }
  21692. return read;
  21693. }()
  21694. }, {
  21695. key: "cancel",
  21696. value: function cancel(reason) {
  21697. if (this._reader) {
  21698. this._reader.cancel(reason);
  21699. }
  21700. if (this._abortController) {
  21701. this._abortController.abort();
  21702. }
  21703. }
  21704. }, {
  21705. key: "isStreamingSupported",
  21706. get: function get() {
  21707. return this._isStreamingSupported;
  21708. }
  21709. }]);
  21710. return PDFFetchStreamRangeReader;
  21711. }();
  21712. /***/ })
  21713. /******/ ]);
  21714. });
  21715. //# sourceMappingURL=pdf.js.map