pdf.js 687 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 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 = root.pdfjsLib = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], () => { return (root.pdfjsLib = factory()); });
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(globalThis, () => {
  32. return /******/ (() => { // webpackBootstrap
  33. /******/ "use strict";
  34. /******/ var __webpack_modules__ = ([
  35. /* 0 */,
  36. /* 1 */
  37. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38. Object.defineProperty(exports, "__esModule", ({
  39. value: true
  40. }));
  41. exports.VerbosityLevel = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.RenderingIntentFlag = exports.PromiseCapability = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.PageActionEventType = exports.OPS = exports.MissingPDFException = exports.MAX_IMAGE_SIZE_TO_CACHE = exports.LINE_FACTOR = exports.LINE_DESCENT_FACTOR = exports.InvalidPDFException = exports.ImageKind = exports.IDENTITY_MATRIX = exports.FormatError = exports.FeatureTest = exports.FONT_IDENTITY_MATRIX = exports.DocumentActionEventType = exports.CMapCompressionType = exports.BaseException = exports.BASELINE_FACTOR = exports.AnnotationType = exports.AnnotationReplyType = exports.AnnotationMode = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationEditorType = exports.AnnotationEditorPrefix = exports.AnnotationEditorParamsType = exports.AnnotationBorderStyleType = exports.AnnotationActionEventType = exports.AbortException = void 0;
  42. exports.assert = assert;
  43. exports.bytesToString = bytesToString;
  44. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  45. exports.getModificationDate = getModificationDate;
  46. exports.getUuid = getUuid;
  47. exports.getVerbosityLevel = getVerbosityLevel;
  48. exports.info = info;
  49. exports.isArrayBuffer = isArrayBuffer;
  50. exports.isArrayEqual = isArrayEqual;
  51. exports.isNodeJS = void 0;
  52. exports.normalizeUnicode = normalizeUnicode;
  53. exports.objectFromMap = objectFromMap;
  54. exports.objectSize = objectSize;
  55. exports.setVerbosityLevel = setVerbosityLevel;
  56. exports.shadow = shadow;
  57. exports.string32 = string32;
  58. exports.stringToBytes = stringToBytes;
  59. exports.stringToPDFString = stringToPDFString;
  60. exports.stringToUTF8String = stringToUTF8String;
  61. exports.unreachable = unreachable;
  62. exports.utf8StringToString = utf8StringToString;
  63. exports.warn = warn;
  64. __w_pdfjs_require__(2);
  65. __w_pdfjs_require__(84);
  66. __w_pdfjs_require__(86);
  67. __w_pdfjs_require__(87);
  68. __w_pdfjs_require__(89);
  69. __w_pdfjs_require__(93);
  70. __w_pdfjs_require__(101);
  71. __w_pdfjs_require__(102);
  72. __w_pdfjs_require__(105);
  73. __w_pdfjs_require__(107);
  74. __w_pdfjs_require__(109);
  75. __w_pdfjs_require__(113);
  76. __w_pdfjs_require__(116);
  77. __w_pdfjs_require__(123);
  78. const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  79. exports.isNodeJS = isNodeJS;
  80. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  81. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  82. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  83. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  84. const MAX_IMAGE_SIZE_TO_CACHE = 10e6;
  85. exports.MAX_IMAGE_SIZE_TO_CACHE = MAX_IMAGE_SIZE_TO_CACHE;
  86. const LINE_FACTOR = 1.35;
  87. exports.LINE_FACTOR = LINE_FACTOR;
  88. const LINE_DESCENT_FACTOR = 0.35;
  89. exports.LINE_DESCENT_FACTOR = LINE_DESCENT_FACTOR;
  90. const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
  91. exports.BASELINE_FACTOR = BASELINE_FACTOR;
  92. const RenderingIntentFlag = {
  93. ANY: 0x01,
  94. DISPLAY: 0x02,
  95. PRINT: 0x04,
  96. SAVE: 0x08,
  97. ANNOTATIONS_FORMS: 0x10,
  98. ANNOTATIONS_STORAGE: 0x20,
  99. ANNOTATIONS_DISABLE: 0x40,
  100. OPLIST: 0x100
  101. };
  102. exports.RenderingIntentFlag = RenderingIntentFlag;
  103. const AnnotationMode = {
  104. DISABLE: 0,
  105. ENABLE: 1,
  106. ENABLE_FORMS: 2,
  107. ENABLE_STORAGE: 3
  108. };
  109. exports.AnnotationMode = AnnotationMode;
  110. const AnnotationEditorPrefix = "pdfjs_internal_editor_";
  111. exports.AnnotationEditorPrefix = AnnotationEditorPrefix;
  112. const AnnotationEditorType = {
  113. DISABLE: -1,
  114. NONE: 0,
  115. FREETEXT: 3,
  116. STAMP: 13,
  117. INK: 15
  118. };
  119. exports.AnnotationEditorType = AnnotationEditorType;
  120. const AnnotationEditorParamsType = {
  121. RESIZE: 1,
  122. CREATE: 2,
  123. FREETEXT_SIZE: 11,
  124. FREETEXT_COLOR: 12,
  125. FREETEXT_OPACITY: 13,
  126. INK_COLOR: 21,
  127. INK_THICKNESS: 22,
  128. INK_OPACITY: 23
  129. };
  130. exports.AnnotationEditorParamsType = AnnotationEditorParamsType;
  131. const PermissionFlag = {
  132. PRINT: 0x04,
  133. MODIFY_CONTENTS: 0x08,
  134. COPY: 0x10,
  135. MODIFY_ANNOTATIONS: 0x20,
  136. FILL_INTERACTIVE_FORMS: 0x100,
  137. COPY_FOR_ACCESSIBILITY: 0x200,
  138. ASSEMBLE: 0x400,
  139. PRINT_HIGH_QUALITY: 0x800
  140. };
  141. exports.PermissionFlag = PermissionFlag;
  142. const TextRenderingMode = {
  143. FILL: 0,
  144. STROKE: 1,
  145. FILL_STROKE: 2,
  146. INVISIBLE: 3,
  147. FILL_ADD_TO_PATH: 4,
  148. STROKE_ADD_TO_PATH: 5,
  149. FILL_STROKE_ADD_TO_PATH: 6,
  150. ADD_TO_PATH: 7,
  151. FILL_STROKE_MASK: 3,
  152. ADD_TO_PATH_FLAG: 4
  153. };
  154. exports.TextRenderingMode = TextRenderingMode;
  155. const ImageKind = {
  156. GRAYSCALE_1BPP: 1,
  157. RGB_24BPP: 2,
  158. RGBA_32BPP: 3
  159. };
  160. exports.ImageKind = ImageKind;
  161. const AnnotationType = {
  162. TEXT: 1,
  163. LINK: 2,
  164. FREETEXT: 3,
  165. LINE: 4,
  166. SQUARE: 5,
  167. CIRCLE: 6,
  168. POLYGON: 7,
  169. POLYLINE: 8,
  170. HIGHLIGHT: 9,
  171. UNDERLINE: 10,
  172. SQUIGGLY: 11,
  173. STRIKEOUT: 12,
  174. STAMP: 13,
  175. CARET: 14,
  176. INK: 15,
  177. POPUP: 16,
  178. FILEATTACHMENT: 17,
  179. SOUND: 18,
  180. MOVIE: 19,
  181. WIDGET: 20,
  182. SCREEN: 21,
  183. PRINTERMARK: 22,
  184. TRAPNET: 23,
  185. WATERMARK: 24,
  186. THREED: 25,
  187. REDACT: 26
  188. };
  189. exports.AnnotationType = AnnotationType;
  190. const AnnotationReplyType = {
  191. GROUP: "Group",
  192. REPLY: "R"
  193. };
  194. exports.AnnotationReplyType = AnnotationReplyType;
  195. const AnnotationFlag = {
  196. INVISIBLE: 0x01,
  197. HIDDEN: 0x02,
  198. PRINT: 0x04,
  199. NOZOOM: 0x08,
  200. NOROTATE: 0x10,
  201. NOVIEW: 0x20,
  202. READONLY: 0x40,
  203. LOCKED: 0x80,
  204. TOGGLENOVIEW: 0x100,
  205. LOCKEDCONTENTS: 0x200
  206. };
  207. exports.AnnotationFlag = AnnotationFlag;
  208. const AnnotationFieldFlag = {
  209. READONLY: 0x0000001,
  210. REQUIRED: 0x0000002,
  211. NOEXPORT: 0x0000004,
  212. MULTILINE: 0x0001000,
  213. PASSWORD: 0x0002000,
  214. NOTOGGLETOOFF: 0x0004000,
  215. RADIO: 0x0008000,
  216. PUSHBUTTON: 0x0010000,
  217. COMBO: 0x0020000,
  218. EDIT: 0x0040000,
  219. SORT: 0x0080000,
  220. FILESELECT: 0x0100000,
  221. MULTISELECT: 0x0200000,
  222. DONOTSPELLCHECK: 0x0400000,
  223. DONOTSCROLL: 0x0800000,
  224. COMB: 0x1000000,
  225. RICHTEXT: 0x2000000,
  226. RADIOSINUNISON: 0x2000000,
  227. COMMITONSELCHANGE: 0x4000000
  228. };
  229. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  230. const AnnotationBorderStyleType = {
  231. SOLID: 1,
  232. DASHED: 2,
  233. BEVELED: 3,
  234. INSET: 4,
  235. UNDERLINE: 5
  236. };
  237. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  238. const AnnotationActionEventType = {
  239. E: "Mouse Enter",
  240. X: "Mouse Exit",
  241. D: "Mouse Down",
  242. U: "Mouse Up",
  243. Fo: "Focus",
  244. Bl: "Blur",
  245. PO: "PageOpen",
  246. PC: "PageClose",
  247. PV: "PageVisible",
  248. PI: "PageInvisible",
  249. K: "Keystroke",
  250. F: "Format",
  251. V: "Validate",
  252. C: "Calculate"
  253. };
  254. exports.AnnotationActionEventType = AnnotationActionEventType;
  255. const DocumentActionEventType = {
  256. WC: "WillClose",
  257. WS: "WillSave",
  258. DS: "DidSave",
  259. WP: "WillPrint",
  260. DP: "DidPrint"
  261. };
  262. exports.DocumentActionEventType = DocumentActionEventType;
  263. const PageActionEventType = {
  264. O: "PageOpen",
  265. C: "PageClose"
  266. };
  267. exports.PageActionEventType = PageActionEventType;
  268. const VerbosityLevel = {
  269. ERRORS: 0,
  270. WARNINGS: 1,
  271. INFOS: 5
  272. };
  273. exports.VerbosityLevel = VerbosityLevel;
  274. const CMapCompressionType = {
  275. NONE: 0,
  276. BINARY: 1
  277. };
  278. exports.CMapCompressionType = CMapCompressionType;
  279. const OPS = {
  280. dependency: 1,
  281. setLineWidth: 2,
  282. setLineCap: 3,
  283. setLineJoin: 4,
  284. setMiterLimit: 5,
  285. setDash: 6,
  286. setRenderingIntent: 7,
  287. setFlatness: 8,
  288. setGState: 9,
  289. save: 10,
  290. restore: 11,
  291. transform: 12,
  292. moveTo: 13,
  293. lineTo: 14,
  294. curveTo: 15,
  295. curveTo2: 16,
  296. curveTo3: 17,
  297. closePath: 18,
  298. rectangle: 19,
  299. stroke: 20,
  300. closeStroke: 21,
  301. fill: 22,
  302. eoFill: 23,
  303. fillStroke: 24,
  304. eoFillStroke: 25,
  305. closeFillStroke: 26,
  306. closeEOFillStroke: 27,
  307. endPath: 28,
  308. clip: 29,
  309. eoClip: 30,
  310. beginText: 31,
  311. endText: 32,
  312. setCharSpacing: 33,
  313. setWordSpacing: 34,
  314. setHScale: 35,
  315. setLeading: 36,
  316. setFont: 37,
  317. setTextRenderingMode: 38,
  318. setTextRise: 39,
  319. moveText: 40,
  320. setLeadingMoveText: 41,
  321. setTextMatrix: 42,
  322. nextLine: 43,
  323. showText: 44,
  324. showSpacedText: 45,
  325. nextLineShowText: 46,
  326. nextLineSetSpacingShowText: 47,
  327. setCharWidth: 48,
  328. setCharWidthAndBounds: 49,
  329. setStrokeColorSpace: 50,
  330. setFillColorSpace: 51,
  331. setStrokeColor: 52,
  332. setStrokeColorN: 53,
  333. setFillColor: 54,
  334. setFillColorN: 55,
  335. setStrokeGray: 56,
  336. setFillGray: 57,
  337. setStrokeRGBColor: 58,
  338. setFillRGBColor: 59,
  339. setStrokeCMYKColor: 60,
  340. setFillCMYKColor: 61,
  341. shadingFill: 62,
  342. beginInlineImage: 63,
  343. beginImageData: 64,
  344. endInlineImage: 65,
  345. paintXObject: 66,
  346. markPoint: 67,
  347. markPointProps: 68,
  348. beginMarkedContent: 69,
  349. beginMarkedContentProps: 70,
  350. endMarkedContent: 71,
  351. beginCompat: 72,
  352. endCompat: 73,
  353. paintFormXObjectBegin: 74,
  354. paintFormXObjectEnd: 75,
  355. beginGroup: 76,
  356. endGroup: 77,
  357. beginAnnotation: 80,
  358. endAnnotation: 81,
  359. paintImageMaskXObject: 83,
  360. paintImageMaskXObjectGroup: 84,
  361. paintImageXObject: 85,
  362. paintInlineImageXObject: 86,
  363. paintInlineImageXObjectGroup: 87,
  364. paintImageXObjectRepeat: 88,
  365. paintImageMaskXObjectRepeat: 89,
  366. paintSolidColorImageMask: 90,
  367. constructPath: 91
  368. };
  369. exports.OPS = OPS;
  370. const PasswordResponses = {
  371. NEED_PASSWORD: 1,
  372. INCORRECT_PASSWORD: 2
  373. };
  374. exports.PasswordResponses = PasswordResponses;
  375. let verbosity = VerbosityLevel.WARNINGS;
  376. function setVerbosityLevel(level) {
  377. if (Number.isInteger(level)) {
  378. verbosity = level;
  379. }
  380. }
  381. function getVerbosityLevel() {
  382. return verbosity;
  383. }
  384. function info(msg) {
  385. if (verbosity >= VerbosityLevel.INFOS) {
  386. console.log(`Info: ${msg}`);
  387. }
  388. }
  389. function warn(msg) {
  390. if (verbosity >= VerbosityLevel.WARNINGS) {
  391. console.log(`Warning: ${msg}`);
  392. }
  393. }
  394. function unreachable(msg) {
  395. throw new Error(msg);
  396. }
  397. function assert(cond, msg) {
  398. if (!cond) {
  399. unreachable(msg);
  400. }
  401. }
  402. function _isValidProtocol(url) {
  403. switch (url?.protocol) {
  404. case "http:":
  405. case "https:":
  406. case "ftp:":
  407. case "mailto:":
  408. case "tel:":
  409. return true;
  410. default:
  411. return false;
  412. }
  413. }
  414. function createValidAbsoluteUrl(url) {
  415. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  416. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  417. if (!url) {
  418. return null;
  419. }
  420. try {
  421. if (options && typeof url === "string") {
  422. if (options.addDefaultProtocol && url.startsWith("www.")) {
  423. const dots = url.match(/\./g);
  424. if (dots?.length >= 2) {
  425. url = `http://${url}`;
  426. }
  427. }
  428. if (options.tryConvertEncoding) {
  429. try {
  430. url = stringToUTF8String(url);
  431. } catch {}
  432. }
  433. }
  434. const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  435. if (_isValidProtocol(absoluteUrl)) {
  436. return absoluteUrl;
  437. }
  438. } catch {}
  439. return null;
  440. }
  441. function shadow(obj, prop, value) {
  442. let nonSerializable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  443. Object.defineProperty(obj, prop, {
  444. value,
  445. enumerable: !nonSerializable,
  446. configurable: true,
  447. writable: false
  448. });
  449. return value;
  450. }
  451. const BaseException = function BaseExceptionClosure() {
  452. function BaseException(message, name) {
  453. if (this.constructor === BaseException) {
  454. unreachable("Cannot initialize BaseException.");
  455. }
  456. this.message = message;
  457. this.name = name;
  458. }
  459. BaseException.prototype = new Error();
  460. BaseException.constructor = BaseException;
  461. return BaseException;
  462. }();
  463. exports.BaseException = BaseException;
  464. class PasswordException extends BaseException {
  465. constructor(msg, code) {
  466. super(msg, "PasswordException");
  467. this.code = code;
  468. }
  469. }
  470. exports.PasswordException = PasswordException;
  471. class UnknownErrorException extends BaseException {
  472. constructor(msg, details) {
  473. super(msg, "UnknownErrorException");
  474. this.details = details;
  475. }
  476. }
  477. exports.UnknownErrorException = UnknownErrorException;
  478. class InvalidPDFException extends BaseException {
  479. constructor(msg) {
  480. super(msg, "InvalidPDFException");
  481. }
  482. }
  483. exports.InvalidPDFException = InvalidPDFException;
  484. class MissingPDFException extends BaseException {
  485. constructor(msg) {
  486. super(msg, "MissingPDFException");
  487. }
  488. }
  489. exports.MissingPDFException = MissingPDFException;
  490. class UnexpectedResponseException extends BaseException {
  491. constructor(msg, status) {
  492. super(msg, "UnexpectedResponseException");
  493. this.status = status;
  494. }
  495. }
  496. exports.UnexpectedResponseException = UnexpectedResponseException;
  497. class FormatError extends BaseException {
  498. constructor(msg) {
  499. super(msg, "FormatError");
  500. }
  501. }
  502. exports.FormatError = FormatError;
  503. class AbortException extends BaseException {
  504. constructor(msg) {
  505. super(msg, "AbortException");
  506. }
  507. }
  508. exports.AbortException = AbortException;
  509. function bytesToString(bytes) {
  510. if (typeof bytes !== "object" || bytes?.length === undefined) {
  511. unreachable("Invalid argument for bytesToString");
  512. }
  513. const length = bytes.length;
  514. const MAX_ARGUMENT_COUNT = 8192;
  515. if (length < MAX_ARGUMENT_COUNT) {
  516. return String.fromCharCode.apply(null, bytes);
  517. }
  518. const strBuf = [];
  519. for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  520. const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  521. const chunk = bytes.subarray(i, chunkEnd);
  522. strBuf.push(String.fromCharCode.apply(null, chunk));
  523. }
  524. return strBuf.join("");
  525. }
  526. function stringToBytes(str) {
  527. if (typeof str !== "string") {
  528. unreachable("Invalid argument for stringToBytes");
  529. }
  530. const length = str.length;
  531. const bytes = new Uint8Array(length);
  532. for (let i = 0; i < length; ++i) {
  533. bytes[i] = str.charCodeAt(i) & 0xff;
  534. }
  535. return bytes;
  536. }
  537. function string32(value) {
  538. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  539. }
  540. function objectSize(obj) {
  541. return Object.keys(obj).length;
  542. }
  543. function objectFromMap(map) {
  544. const obj = Object.create(null);
  545. for (const [key, value] of map) {
  546. obj[key] = value;
  547. }
  548. return obj;
  549. }
  550. function isLittleEndian() {
  551. const buffer8 = new Uint8Array(4);
  552. buffer8[0] = 1;
  553. const view32 = new Uint32Array(buffer8.buffer, 0, 1);
  554. return view32[0] === 1;
  555. }
  556. function isEvalSupported() {
  557. try {
  558. new Function("");
  559. return true;
  560. } catch {
  561. return false;
  562. }
  563. }
  564. class FeatureTest {
  565. static get isLittleEndian() {
  566. return shadow(this, "isLittleEndian", isLittleEndian());
  567. }
  568. static get isEvalSupported() {
  569. return shadow(this, "isEvalSupported", isEvalSupported());
  570. }
  571. static get isOffscreenCanvasSupported() {
  572. return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
  573. }
  574. static get platform() {
  575. if (typeof navigator === "undefined") {
  576. return shadow(this, "platform", {
  577. isWin: false,
  578. isMac: false
  579. });
  580. }
  581. return shadow(this, "platform", {
  582. isWin: navigator.platform.includes("Win"),
  583. isMac: navigator.platform.includes("Mac")
  584. });
  585. }
  586. static get isCSSRoundSupported() {
  587. return shadow(this, "isCSSRoundSupported", globalThis.CSS?.supports?.("width: round(1.5px, 1px)"));
  588. }
  589. }
  590. exports.FeatureTest = FeatureTest;
  591. const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
  592. class Util {
  593. static makeHexColor(r, g, b) {
  594. return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
  595. }
  596. static scaleMinMax(transform, minMax) {
  597. let temp;
  598. if (transform[0]) {
  599. if (transform[0] < 0) {
  600. temp = minMax[0];
  601. minMax[0] = minMax[1];
  602. minMax[1] = temp;
  603. }
  604. minMax[0] *= transform[0];
  605. minMax[1] *= transform[0];
  606. if (transform[3] < 0) {
  607. temp = minMax[2];
  608. minMax[2] = minMax[3];
  609. minMax[3] = temp;
  610. }
  611. minMax[2] *= transform[3];
  612. minMax[3] *= transform[3];
  613. } else {
  614. temp = minMax[0];
  615. minMax[0] = minMax[2];
  616. minMax[2] = temp;
  617. temp = minMax[1];
  618. minMax[1] = minMax[3];
  619. minMax[3] = temp;
  620. if (transform[1] < 0) {
  621. temp = minMax[2];
  622. minMax[2] = minMax[3];
  623. minMax[3] = temp;
  624. }
  625. minMax[2] *= transform[1];
  626. minMax[3] *= transform[1];
  627. if (transform[2] < 0) {
  628. temp = minMax[0];
  629. minMax[0] = minMax[1];
  630. minMax[1] = temp;
  631. }
  632. minMax[0] *= transform[2];
  633. minMax[1] *= transform[2];
  634. }
  635. minMax[0] += transform[4];
  636. minMax[1] += transform[4];
  637. minMax[2] += transform[5];
  638. minMax[3] += transform[5];
  639. }
  640. static transform(m1, m2) {
  641. 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]];
  642. }
  643. static applyTransform(p, m) {
  644. const xt = p[0] * m[0] + p[1] * m[2] + m[4];
  645. const yt = p[0] * m[1] + p[1] * m[3] + m[5];
  646. return [xt, yt];
  647. }
  648. static applyInverseTransform(p, m) {
  649. const d = m[0] * m[3] - m[1] * m[2];
  650. const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  651. const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  652. return [xt, yt];
  653. }
  654. static getAxialAlignedBoundingBox(r, m) {
  655. const p1 = this.applyTransform(r, m);
  656. const p2 = this.applyTransform(r.slice(2, 4), m);
  657. const p3 = this.applyTransform([r[0], r[3]], m);
  658. const p4 = this.applyTransform([r[2], r[1]], m);
  659. 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])];
  660. }
  661. static inverseTransform(m) {
  662. const d = m[0] * m[3] - m[1] * m[2];
  663. 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];
  664. }
  665. static singularValueDecompose2dScale(m) {
  666. const transpose = [m[0], m[2], m[1], m[3]];
  667. const a = m[0] * transpose[0] + m[1] * transpose[2];
  668. const b = m[0] * transpose[1] + m[1] * transpose[3];
  669. const c = m[2] * transpose[0] + m[3] * transpose[2];
  670. const d = m[2] * transpose[1] + m[3] * transpose[3];
  671. const first = (a + d) / 2;
  672. const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
  673. const sx = first + second || 1;
  674. const sy = first - second || 1;
  675. return [Math.sqrt(sx), Math.sqrt(sy)];
  676. }
  677. static normalizeRect(rect) {
  678. const r = rect.slice(0);
  679. if (rect[0] > rect[2]) {
  680. r[0] = rect[2];
  681. r[2] = rect[0];
  682. }
  683. if (rect[1] > rect[3]) {
  684. r[1] = rect[3];
  685. r[3] = rect[1];
  686. }
  687. return r;
  688. }
  689. static intersect(rect1, rect2) {
  690. const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
  691. const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
  692. if (xLow > xHigh) {
  693. return null;
  694. }
  695. const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
  696. const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
  697. if (yLow > yHigh) {
  698. return null;
  699. }
  700. return [xLow, yLow, xHigh, yHigh];
  701. }
  702. static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3) {
  703. const tvalues = [],
  704. bounds = [[], []];
  705. let a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  706. for (let i = 0; i < 2; ++i) {
  707. if (i === 0) {
  708. b = 6 * x0 - 12 * x1 + 6 * x2;
  709. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  710. c = 3 * x1 - 3 * x0;
  711. } else {
  712. b = 6 * y0 - 12 * y1 + 6 * y2;
  713. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  714. c = 3 * y1 - 3 * y0;
  715. }
  716. if (Math.abs(a) < 1e-12) {
  717. if (Math.abs(b) < 1e-12) {
  718. continue;
  719. }
  720. t = -c / b;
  721. if (0 < t && t < 1) {
  722. tvalues.push(t);
  723. }
  724. continue;
  725. }
  726. b2ac = b * b - 4 * c * a;
  727. sqrtb2ac = Math.sqrt(b2ac);
  728. if (b2ac < 0) {
  729. continue;
  730. }
  731. t1 = (-b + sqrtb2ac) / (2 * a);
  732. if (0 < t1 && t1 < 1) {
  733. tvalues.push(t1);
  734. }
  735. t2 = (-b - sqrtb2ac) / (2 * a);
  736. if (0 < t2 && t2 < 1) {
  737. tvalues.push(t2);
  738. }
  739. }
  740. let j = tvalues.length,
  741. mt;
  742. const jlen = j;
  743. while (j--) {
  744. t = tvalues[j];
  745. mt = 1 - t;
  746. bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
  747. bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
  748. }
  749. bounds[0][jlen] = x0;
  750. bounds[1][jlen] = y0;
  751. bounds[0][jlen + 1] = x3;
  752. bounds[1][jlen + 1] = y3;
  753. bounds[0].length = bounds[1].length = jlen + 2;
  754. return [Math.min(...bounds[0]), Math.min(...bounds[1]), Math.max(...bounds[0]), Math.max(...bounds[1])];
  755. }
  756. }
  757. exports.Util = Util;
  758. const 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];
  759. function stringToPDFString(str) {
  760. if (str[0] >= "\xEF") {
  761. let encoding;
  762. if (str[0] === "\xFE" && str[1] === "\xFF") {
  763. encoding = "utf-16be";
  764. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  765. encoding = "utf-16le";
  766. } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
  767. encoding = "utf-8";
  768. }
  769. if (encoding) {
  770. try {
  771. const decoder = new TextDecoder(encoding, {
  772. fatal: true
  773. });
  774. const buffer = stringToBytes(str);
  775. return decoder.decode(buffer);
  776. } catch (ex) {
  777. warn(`stringToPDFString: "${ex}".`);
  778. }
  779. }
  780. }
  781. const strBuf = [];
  782. for (let i = 0, ii = str.length; i < ii; i++) {
  783. const code = PDFStringTranslateTable[str.charCodeAt(i)];
  784. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  785. }
  786. return strBuf.join("");
  787. }
  788. function stringToUTF8String(str) {
  789. return decodeURIComponent(escape(str));
  790. }
  791. function utf8StringToString(str) {
  792. return unescape(encodeURIComponent(str));
  793. }
  794. function isArrayBuffer(v) {
  795. return typeof v === "object" && v?.byteLength !== undefined;
  796. }
  797. function isArrayEqual(arr1, arr2) {
  798. if (arr1.length !== arr2.length) {
  799. return false;
  800. }
  801. for (let i = 0, ii = arr1.length; i < ii; i++) {
  802. if (arr1[i] !== arr2[i]) {
  803. return false;
  804. }
  805. }
  806. return true;
  807. }
  808. function getModificationDate() {
  809. let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
  810. const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  811. return buffer.join("");
  812. }
  813. class PromiseCapability {
  814. #settled = false;
  815. constructor() {
  816. this.promise = new Promise((resolve, reject) => {
  817. this.resolve = data => {
  818. this.#settled = true;
  819. resolve(data);
  820. };
  821. this.reject = reason => {
  822. this.#settled = true;
  823. reject(reason);
  824. };
  825. });
  826. }
  827. get settled() {
  828. return this.#settled;
  829. }
  830. }
  831. exports.PromiseCapability = PromiseCapability;
  832. let NormalizeRegex = null;
  833. let NormalizationMap = null;
  834. function normalizeUnicode(str) {
  835. if (!NormalizeRegex) {
  836. NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
  837. NormalizationMap = new Map([["ſt", "ſt"]]);
  838. }
  839. return str.replaceAll(NormalizeRegex, (_, p1, p2) => {
  840. return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2);
  841. });
  842. }
  843. function getUuid() {
  844. if (typeof crypto !== "undefined" && typeof crypto?.randomUUID === "function") {
  845. return crypto.randomUUID();
  846. }
  847. const buf = new Uint8Array(32);
  848. if (typeof crypto !== "undefined" && typeof crypto?.getRandomValues === "function") {
  849. crypto.getRandomValues(buf);
  850. } else {
  851. for (let i = 0; i < 32; i++) {
  852. buf[i] = Math.floor(Math.random() * 255);
  853. }
  854. }
  855. return bytesToString(buf);
  856. }
  857. /***/ }),
  858. /* 2 */
  859. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  860. var $ = __w_pdfjs_require__(3);
  861. var global = __w_pdfjs_require__(4);
  862. var apply = __w_pdfjs_require__(69);
  863. var wrapErrorConstructorWithCause = __w_pdfjs_require__(70);
  864. var WEB_ASSEMBLY = 'WebAssembly';
  865. var WebAssembly = global[WEB_ASSEMBLY];
  866. var FORCED = Error('e', { cause: 7 }).cause !== 7;
  867. var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  868. var O = {};
  869. O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED);
  870. $({
  871. global: true,
  872. constructor: true,
  873. arity: 1,
  874. forced: FORCED
  875. }, O);
  876. };
  877. var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) {
  878. if (WebAssembly && WebAssembly[ERROR_NAME]) {
  879. var O = {};
  880. O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED);
  881. $({
  882. target: WEB_ASSEMBLY,
  883. stat: true,
  884. constructor: true,
  885. arity: 1,
  886. forced: FORCED
  887. }, O);
  888. }
  889. };
  890. exportGlobalErrorCauseWrapper('Error', function (init) {
  891. return function Error(message) {
  892. return apply(init, this, arguments);
  893. };
  894. });
  895. exportGlobalErrorCauseWrapper('EvalError', function (init) {
  896. return function EvalError(message) {
  897. return apply(init, this, arguments);
  898. };
  899. });
  900. exportGlobalErrorCauseWrapper('RangeError', function (init) {
  901. return function RangeError(message) {
  902. return apply(init, this, arguments);
  903. };
  904. });
  905. exportGlobalErrorCauseWrapper('ReferenceError', function (init) {
  906. return function ReferenceError(message) {
  907. return apply(init, this, arguments);
  908. };
  909. });
  910. exportGlobalErrorCauseWrapper('SyntaxError', function (init) {
  911. return function SyntaxError(message) {
  912. return apply(init, this, arguments);
  913. };
  914. });
  915. exportGlobalErrorCauseWrapper('TypeError', function (init) {
  916. return function TypeError(message) {
  917. return apply(init, this, arguments);
  918. };
  919. });
  920. exportGlobalErrorCauseWrapper('URIError', function (init) {
  921. return function URIError(message) {
  922. return apply(init, this, arguments);
  923. };
  924. });
  925. exportWebAssemblyErrorCauseWrapper('CompileError', function (init) {
  926. return function CompileError(message) {
  927. return apply(init, this, arguments);
  928. };
  929. });
  930. exportWebAssemblyErrorCauseWrapper('LinkError', function (init) {
  931. return function LinkError(message) {
  932. return apply(init, this, arguments);
  933. };
  934. });
  935. exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) {
  936. return function RuntimeError(message) {
  937. return apply(init, this, arguments);
  938. };
  939. });
  940. /***/ }),
  941. /* 3 */
  942. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  943. var global = __w_pdfjs_require__(4);
  944. var getOwnPropertyDescriptor = (__w_pdfjs_require__(5).f);
  945. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  946. var defineBuiltIn = __w_pdfjs_require__(48);
  947. var defineGlobalProperty = __w_pdfjs_require__(38);
  948. var copyConstructorProperties = __w_pdfjs_require__(56);
  949. var isForced = __w_pdfjs_require__(68);
  950. module.exports = function (options, source) {
  951. var TARGET = options.target;
  952. var GLOBAL = options.global;
  953. var STATIC = options.stat;
  954. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  955. if (GLOBAL) {
  956. target = global;
  957. } else if (STATIC) {
  958. target = global[TARGET] || defineGlobalProperty(TARGET, {});
  959. } else {
  960. target = (global[TARGET] || {}).prototype;
  961. }
  962. if (target)
  963. for (key in source) {
  964. sourceProperty = source[key];
  965. if (options.dontCallGetSet) {
  966. descriptor = getOwnPropertyDescriptor(target, key);
  967. targetProperty = descriptor && descriptor.value;
  968. } else
  969. targetProperty = target[key];
  970. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  971. if (!FORCED && targetProperty !== undefined) {
  972. if (typeof sourceProperty == typeof targetProperty)
  973. continue;
  974. copyConstructorProperties(sourceProperty, targetProperty);
  975. }
  976. if (options.sham || targetProperty && targetProperty.sham) {
  977. createNonEnumerableProperty(sourceProperty, 'sham', true);
  978. }
  979. defineBuiltIn(target, key, sourceProperty, options);
  980. }
  981. };
  982. /***/ }),
  983. /* 4 */
  984. /***/ (function(module) {
  985. var check = function (it) {
  986. return it && it.Math === Math && it;
  987. };
  988. module.exports = check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || (function () {
  989. return this;
  990. }()) || this || Function('return this')();
  991. /***/ }),
  992. /* 5 */
  993. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  994. var DESCRIPTORS = __w_pdfjs_require__(6);
  995. var call = __w_pdfjs_require__(8);
  996. var propertyIsEnumerableModule = __w_pdfjs_require__(10);
  997. var createPropertyDescriptor = __w_pdfjs_require__(11);
  998. var toIndexedObject = __w_pdfjs_require__(12);
  999. var toPropertyKey = __w_pdfjs_require__(18);
  1000. var hasOwn = __w_pdfjs_require__(39);
  1001. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  1002. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1003. exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  1004. O = toIndexedObject(O);
  1005. P = toPropertyKey(P);
  1006. if (IE8_DOM_DEFINE)
  1007. try {
  1008. return $getOwnPropertyDescriptor(O, P);
  1009. } catch (error) {
  1010. }
  1011. if (hasOwn(O, P))
  1012. return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
  1013. };
  1014. /***/ }),
  1015. /* 6 */
  1016. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1017. var fails = __w_pdfjs_require__(7);
  1018. module.exports = !fails(function () {
  1019. return Object.defineProperty({}, 1, {
  1020. get: function () {
  1021. return 7;
  1022. }
  1023. })[1] !== 7;
  1024. });
  1025. /***/ }),
  1026. /* 7 */
  1027. /***/ ((module) => {
  1028. module.exports = function (exec) {
  1029. try {
  1030. return !!exec();
  1031. } catch (error) {
  1032. return true;
  1033. }
  1034. };
  1035. /***/ }),
  1036. /* 8 */
  1037. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1038. var NATIVE_BIND = __w_pdfjs_require__(9);
  1039. var call = Function.prototype.call;
  1040. module.exports = NATIVE_BIND ? call.bind(call) : function () {
  1041. return call.apply(call, arguments);
  1042. };
  1043. /***/ }),
  1044. /* 9 */
  1045. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1046. var fails = __w_pdfjs_require__(7);
  1047. module.exports = !fails(function () {
  1048. var test = function () {
  1049. }.bind();
  1050. return typeof test != 'function' || test.hasOwnProperty('prototype');
  1051. });
  1052. /***/ }),
  1053. /* 10 */
  1054. /***/ ((__unused_webpack_module, exports) => {
  1055. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  1056. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1057. var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  1058. exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  1059. var descriptor = getOwnPropertyDescriptor(this, V);
  1060. return !!descriptor && descriptor.enumerable;
  1061. } : $propertyIsEnumerable;
  1062. /***/ }),
  1063. /* 11 */
  1064. /***/ ((module) => {
  1065. module.exports = function (bitmap, value) {
  1066. return {
  1067. enumerable: !(bitmap & 1),
  1068. configurable: !(bitmap & 2),
  1069. writable: !(bitmap & 4),
  1070. value: value
  1071. };
  1072. };
  1073. /***/ }),
  1074. /* 12 */
  1075. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1076. var IndexedObject = __w_pdfjs_require__(13);
  1077. var requireObjectCoercible = __w_pdfjs_require__(16);
  1078. module.exports = function (it) {
  1079. return IndexedObject(requireObjectCoercible(it));
  1080. };
  1081. /***/ }),
  1082. /* 13 */
  1083. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1084. var uncurryThis = __w_pdfjs_require__(14);
  1085. var fails = __w_pdfjs_require__(7);
  1086. var classof = __w_pdfjs_require__(15);
  1087. var $Object = Object;
  1088. var split = uncurryThis(''.split);
  1089. module.exports = fails(function () {
  1090. return !$Object('z').propertyIsEnumerable(0);
  1091. }) ? function (it) {
  1092. return classof(it) === 'String' ? split(it, '') : $Object(it);
  1093. } : $Object;
  1094. /***/ }),
  1095. /* 14 */
  1096. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1097. var NATIVE_BIND = __w_pdfjs_require__(9);
  1098. var FunctionPrototype = Function.prototype;
  1099. var call = FunctionPrototype.call;
  1100. var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
  1101. module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
  1102. return function () {
  1103. return call.apply(fn, arguments);
  1104. };
  1105. };
  1106. /***/ }),
  1107. /* 15 */
  1108. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1109. var uncurryThis = __w_pdfjs_require__(14);
  1110. var toString = uncurryThis({}.toString);
  1111. var stringSlice = uncurryThis(''.slice);
  1112. module.exports = function (it) {
  1113. return stringSlice(toString(it), 8, -1);
  1114. };
  1115. /***/ }),
  1116. /* 16 */
  1117. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1118. var isNullOrUndefined = __w_pdfjs_require__(17);
  1119. var $TypeError = TypeError;
  1120. module.exports = function (it) {
  1121. if (isNullOrUndefined(it))
  1122. throw $TypeError("Can't call method on " + it);
  1123. return it;
  1124. };
  1125. /***/ }),
  1126. /* 17 */
  1127. /***/ ((module) => {
  1128. module.exports = function (it) {
  1129. return it === null || it === undefined;
  1130. };
  1131. /***/ }),
  1132. /* 18 */
  1133. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1134. var toPrimitive = __w_pdfjs_require__(19);
  1135. var isSymbol = __w_pdfjs_require__(23);
  1136. module.exports = function (argument) {
  1137. var key = toPrimitive(argument, 'string');
  1138. return isSymbol(key) ? key : key + '';
  1139. };
  1140. /***/ }),
  1141. /* 19 */
  1142. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1143. var call = __w_pdfjs_require__(8);
  1144. var isObject = __w_pdfjs_require__(20);
  1145. var isSymbol = __w_pdfjs_require__(23);
  1146. var getMethod = __w_pdfjs_require__(30);
  1147. var ordinaryToPrimitive = __w_pdfjs_require__(33);
  1148. var wellKnownSymbol = __w_pdfjs_require__(34);
  1149. var $TypeError = TypeError;
  1150. var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
  1151. module.exports = function (input, pref) {
  1152. if (!isObject(input) || isSymbol(input))
  1153. return input;
  1154. var exoticToPrim = getMethod(input, TO_PRIMITIVE);
  1155. var result;
  1156. if (exoticToPrim) {
  1157. if (pref === undefined)
  1158. pref = 'default';
  1159. result = call(exoticToPrim, input, pref);
  1160. if (!isObject(result) || isSymbol(result))
  1161. return result;
  1162. throw $TypeError("Can't convert object to primitive value");
  1163. }
  1164. if (pref === undefined)
  1165. pref = 'number';
  1166. return ordinaryToPrimitive(input, pref);
  1167. };
  1168. /***/ }),
  1169. /* 20 */
  1170. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1171. var isCallable = __w_pdfjs_require__(21);
  1172. var $documentAll = __w_pdfjs_require__(22);
  1173. var documentAll = $documentAll.all;
  1174. module.exports = $documentAll.IS_HTMLDDA ? function (it) {
  1175. return typeof it == 'object' ? it !== null : isCallable(it) || it === documentAll;
  1176. } : function (it) {
  1177. return typeof it == 'object' ? it !== null : isCallable(it);
  1178. };
  1179. /***/ }),
  1180. /* 21 */
  1181. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1182. var $documentAll = __w_pdfjs_require__(22);
  1183. var documentAll = $documentAll.all;
  1184. module.exports = $documentAll.IS_HTMLDDA ? function (argument) {
  1185. return typeof argument == 'function' || argument === documentAll;
  1186. } : function (argument) {
  1187. return typeof argument == 'function';
  1188. };
  1189. /***/ }),
  1190. /* 22 */
  1191. /***/ ((module) => {
  1192. var documentAll = typeof document == 'object' && document.all;
  1193. var IS_HTMLDDA = typeof documentAll == 'undefined' && documentAll !== undefined;
  1194. module.exports = {
  1195. all: documentAll,
  1196. IS_HTMLDDA: IS_HTMLDDA
  1197. };
  1198. /***/ }),
  1199. /* 23 */
  1200. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1201. var getBuiltIn = __w_pdfjs_require__(24);
  1202. var isCallable = __w_pdfjs_require__(21);
  1203. var isPrototypeOf = __w_pdfjs_require__(25);
  1204. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1205. var $Object = Object;
  1206. module.exports = USE_SYMBOL_AS_UID ? function (it) {
  1207. return typeof it == 'symbol';
  1208. } : function (it) {
  1209. var $Symbol = getBuiltIn('Symbol');
  1210. return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
  1211. };
  1212. /***/ }),
  1213. /* 24 */
  1214. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1215. var global = __w_pdfjs_require__(4);
  1216. var isCallable = __w_pdfjs_require__(21);
  1217. var aFunction = function (argument) {
  1218. return isCallable(argument) ? argument : undefined;
  1219. };
  1220. module.exports = function (namespace, method) {
  1221. return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
  1222. };
  1223. /***/ }),
  1224. /* 25 */
  1225. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1226. var uncurryThis = __w_pdfjs_require__(14);
  1227. module.exports = uncurryThis({}.isPrototypeOf);
  1228. /***/ }),
  1229. /* 26 */
  1230. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1231. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1232. module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
  1233. /***/ }),
  1234. /* 27 */
  1235. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1236. var V8_VERSION = __w_pdfjs_require__(28);
  1237. var fails = __w_pdfjs_require__(7);
  1238. var global = __w_pdfjs_require__(4);
  1239. var $String = global.String;
  1240. module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
  1241. var symbol = Symbol('symbol detection');
  1242. return !$String(symbol) || !(Object(symbol) instanceof Symbol) || !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  1243. });
  1244. /***/ }),
  1245. /* 28 */
  1246. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1247. var global = __w_pdfjs_require__(4);
  1248. var userAgent = __w_pdfjs_require__(29);
  1249. var process = global.process;
  1250. var Deno = global.Deno;
  1251. var versions = process && process.versions || Deno && Deno.version;
  1252. var v8 = versions && versions.v8;
  1253. var match, version;
  1254. if (v8) {
  1255. match = v8.split('.');
  1256. version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
  1257. }
  1258. if (!version && userAgent) {
  1259. match = userAgent.match(/Edge\/(\d+)/);
  1260. if (!match || match[1] >= 74) {
  1261. match = userAgent.match(/Chrome\/(\d+)/);
  1262. if (match)
  1263. version = +match[1];
  1264. }
  1265. }
  1266. module.exports = version;
  1267. /***/ }),
  1268. /* 29 */
  1269. /***/ ((module) => {
  1270. module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
  1271. /***/ }),
  1272. /* 30 */
  1273. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1274. var aCallable = __w_pdfjs_require__(31);
  1275. var isNullOrUndefined = __w_pdfjs_require__(17);
  1276. module.exports = function (V, P) {
  1277. var func = V[P];
  1278. return isNullOrUndefined(func) ? undefined : aCallable(func);
  1279. };
  1280. /***/ }),
  1281. /* 31 */
  1282. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1283. var isCallable = __w_pdfjs_require__(21);
  1284. var tryToString = __w_pdfjs_require__(32);
  1285. var $TypeError = TypeError;
  1286. module.exports = function (argument) {
  1287. if (isCallable(argument))
  1288. return argument;
  1289. throw $TypeError(tryToString(argument) + ' is not a function');
  1290. };
  1291. /***/ }),
  1292. /* 32 */
  1293. /***/ ((module) => {
  1294. var $String = String;
  1295. module.exports = function (argument) {
  1296. try {
  1297. return $String(argument);
  1298. } catch (error) {
  1299. return 'Object';
  1300. }
  1301. };
  1302. /***/ }),
  1303. /* 33 */
  1304. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1305. var call = __w_pdfjs_require__(8);
  1306. var isCallable = __w_pdfjs_require__(21);
  1307. var isObject = __w_pdfjs_require__(20);
  1308. var $TypeError = TypeError;
  1309. module.exports = function (input, pref) {
  1310. var fn, val;
  1311. if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1312. return val;
  1313. if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input)))
  1314. return val;
  1315. if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input)))
  1316. return val;
  1317. throw $TypeError("Can't convert object to primitive value");
  1318. };
  1319. /***/ }),
  1320. /* 34 */
  1321. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1322. var global = __w_pdfjs_require__(4);
  1323. var shared = __w_pdfjs_require__(35);
  1324. var hasOwn = __w_pdfjs_require__(39);
  1325. var uid = __w_pdfjs_require__(41);
  1326. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  1327. var USE_SYMBOL_AS_UID = __w_pdfjs_require__(26);
  1328. var Symbol = global.Symbol;
  1329. var WellKnownSymbolsStore = shared('wks');
  1330. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
  1331. module.exports = function (name) {
  1332. if (!hasOwn(WellKnownSymbolsStore, name)) {
  1333. WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) ? Symbol[name] : createWellKnownSymbol('Symbol.' + name);
  1334. }
  1335. return WellKnownSymbolsStore[name];
  1336. };
  1337. /***/ }),
  1338. /* 35 */
  1339. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1340. var IS_PURE = __w_pdfjs_require__(36);
  1341. var store = __w_pdfjs_require__(37);
  1342. (module.exports = function (key, value) {
  1343. return store[key] || (store[key] = value !== undefined ? value : {});
  1344. })('versions', []).push({
  1345. version: '3.32.1',
  1346. mode: IS_PURE ? 'pure' : 'global',
  1347. copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
  1348. license: 'https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE',
  1349. source: 'https://github.com/zloirock/core-js'
  1350. });
  1351. /***/ }),
  1352. /* 36 */
  1353. /***/ ((module) => {
  1354. module.exports = false;
  1355. /***/ }),
  1356. /* 37 */
  1357. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1358. var global = __w_pdfjs_require__(4);
  1359. var defineGlobalProperty = __w_pdfjs_require__(38);
  1360. var SHARED = '__core-js_shared__';
  1361. var store = global[SHARED] || defineGlobalProperty(SHARED, {});
  1362. module.exports = store;
  1363. /***/ }),
  1364. /* 38 */
  1365. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1366. var global = __w_pdfjs_require__(4);
  1367. var defineProperty = Object.defineProperty;
  1368. module.exports = function (key, value) {
  1369. try {
  1370. defineProperty(global, key, {
  1371. value: value,
  1372. configurable: true,
  1373. writable: true
  1374. });
  1375. } catch (error) {
  1376. global[key] = value;
  1377. }
  1378. return value;
  1379. };
  1380. /***/ }),
  1381. /* 39 */
  1382. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1383. var uncurryThis = __w_pdfjs_require__(14);
  1384. var toObject = __w_pdfjs_require__(40);
  1385. var hasOwnProperty = uncurryThis({}.hasOwnProperty);
  1386. module.exports = Object.hasOwn || function hasOwn(it, key) {
  1387. return hasOwnProperty(toObject(it), key);
  1388. };
  1389. /***/ }),
  1390. /* 40 */
  1391. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1392. var requireObjectCoercible = __w_pdfjs_require__(16);
  1393. var $Object = Object;
  1394. module.exports = function (argument) {
  1395. return $Object(requireObjectCoercible(argument));
  1396. };
  1397. /***/ }),
  1398. /* 41 */
  1399. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1400. var uncurryThis = __w_pdfjs_require__(14);
  1401. var id = 0;
  1402. var postfix = Math.random();
  1403. var toString = uncurryThis(1.0.toString);
  1404. module.exports = function (key) {
  1405. return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
  1406. };
  1407. /***/ }),
  1408. /* 42 */
  1409. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1410. var DESCRIPTORS = __w_pdfjs_require__(6);
  1411. var fails = __w_pdfjs_require__(7);
  1412. var createElement = __w_pdfjs_require__(43);
  1413. module.exports = !DESCRIPTORS && !fails(function () {
  1414. return Object.defineProperty(createElement('div'), 'a', {
  1415. get: function () {
  1416. return 7;
  1417. }
  1418. }).a !== 7;
  1419. });
  1420. /***/ }),
  1421. /* 43 */
  1422. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1423. var global = __w_pdfjs_require__(4);
  1424. var isObject = __w_pdfjs_require__(20);
  1425. var document = global.document;
  1426. var EXISTS = isObject(document) && isObject(document.createElement);
  1427. module.exports = function (it) {
  1428. return EXISTS ? document.createElement(it) : {};
  1429. };
  1430. /***/ }),
  1431. /* 44 */
  1432. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1433. var DESCRIPTORS = __w_pdfjs_require__(6);
  1434. var definePropertyModule = __w_pdfjs_require__(45);
  1435. var createPropertyDescriptor = __w_pdfjs_require__(11);
  1436. module.exports = DESCRIPTORS ? function (object, key, value) {
  1437. return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
  1438. } : function (object, key, value) {
  1439. object[key] = value;
  1440. return object;
  1441. };
  1442. /***/ }),
  1443. /* 45 */
  1444. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1445. var DESCRIPTORS = __w_pdfjs_require__(6);
  1446. var IE8_DOM_DEFINE = __w_pdfjs_require__(42);
  1447. var V8_PROTOTYPE_DEFINE_BUG = __w_pdfjs_require__(46);
  1448. var anObject = __w_pdfjs_require__(47);
  1449. var toPropertyKey = __w_pdfjs_require__(18);
  1450. var $TypeError = TypeError;
  1451. var $defineProperty = Object.defineProperty;
  1452. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1453. var ENUMERABLE = 'enumerable';
  1454. var CONFIGURABLE = 'configurable';
  1455. var WRITABLE = 'writable';
  1456. exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
  1457. anObject(O);
  1458. P = toPropertyKey(P);
  1459. anObject(Attributes);
  1460. if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
  1461. var current = $getOwnPropertyDescriptor(O, P);
  1462. if (current && current[WRITABLE]) {
  1463. O[P] = Attributes.value;
  1464. Attributes = {
  1465. configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
  1466. enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
  1467. writable: false
  1468. };
  1469. }
  1470. }
  1471. return $defineProperty(O, P, Attributes);
  1472. } : $defineProperty : function defineProperty(O, P, Attributes) {
  1473. anObject(O);
  1474. P = toPropertyKey(P);
  1475. anObject(Attributes);
  1476. if (IE8_DOM_DEFINE)
  1477. try {
  1478. return $defineProperty(O, P, Attributes);
  1479. } catch (error) {
  1480. }
  1481. if ('get' in Attributes || 'set' in Attributes)
  1482. throw $TypeError('Accessors not supported');
  1483. if ('value' in Attributes)
  1484. O[P] = Attributes.value;
  1485. return O;
  1486. };
  1487. /***/ }),
  1488. /* 46 */
  1489. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1490. var DESCRIPTORS = __w_pdfjs_require__(6);
  1491. var fails = __w_pdfjs_require__(7);
  1492. module.exports = DESCRIPTORS && fails(function () {
  1493. return Object.defineProperty(function () {
  1494. }, 'prototype', {
  1495. value: 42,
  1496. writable: false
  1497. }).prototype !== 42;
  1498. });
  1499. /***/ }),
  1500. /* 47 */
  1501. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1502. var isObject = __w_pdfjs_require__(20);
  1503. var $String = String;
  1504. var $TypeError = TypeError;
  1505. module.exports = function (argument) {
  1506. if (isObject(argument))
  1507. return argument;
  1508. throw $TypeError($String(argument) + ' is not an object');
  1509. };
  1510. /***/ }),
  1511. /* 48 */
  1512. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1513. var isCallable = __w_pdfjs_require__(21);
  1514. var definePropertyModule = __w_pdfjs_require__(45);
  1515. var makeBuiltIn = __w_pdfjs_require__(49);
  1516. var defineGlobalProperty = __w_pdfjs_require__(38);
  1517. module.exports = function (O, key, value, options) {
  1518. if (!options)
  1519. options = {};
  1520. var simple = options.enumerable;
  1521. var name = options.name !== undefined ? options.name : key;
  1522. if (isCallable(value))
  1523. makeBuiltIn(value, name, options);
  1524. if (options.global) {
  1525. if (simple)
  1526. O[key] = value;
  1527. else
  1528. defineGlobalProperty(key, value);
  1529. } else {
  1530. try {
  1531. if (!options.unsafe)
  1532. delete O[key];
  1533. else if (O[key])
  1534. simple = true;
  1535. } catch (error) {
  1536. }
  1537. if (simple)
  1538. O[key] = value;
  1539. else
  1540. definePropertyModule.f(O, key, {
  1541. value: value,
  1542. enumerable: false,
  1543. configurable: !options.nonConfigurable,
  1544. writable: !options.nonWritable
  1545. });
  1546. }
  1547. return O;
  1548. };
  1549. /***/ }),
  1550. /* 49 */
  1551. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1552. var uncurryThis = __w_pdfjs_require__(14);
  1553. var fails = __w_pdfjs_require__(7);
  1554. var isCallable = __w_pdfjs_require__(21);
  1555. var hasOwn = __w_pdfjs_require__(39);
  1556. var DESCRIPTORS = __w_pdfjs_require__(6);
  1557. var CONFIGURABLE_FUNCTION_NAME = (__w_pdfjs_require__(50).CONFIGURABLE);
  1558. var inspectSource = __w_pdfjs_require__(51);
  1559. var InternalStateModule = __w_pdfjs_require__(52);
  1560. var enforceInternalState = InternalStateModule.enforce;
  1561. var getInternalState = InternalStateModule.get;
  1562. var $String = String;
  1563. var defineProperty = Object.defineProperty;
  1564. var stringSlice = uncurryThis(''.slice);
  1565. var replace = uncurryThis(''.replace);
  1566. var join = uncurryThis([].join);
  1567. var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
  1568. return defineProperty(function () {
  1569. }, 'length', { value: 8 }).length !== 8;
  1570. });
  1571. var TEMPLATE = String(String).split('String');
  1572. var makeBuiltIn = module.exports = function (value, name, options) {
  1573. if (stringSlice($String(name), 0, 7) === 'Symbol(') {
  1574. name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']';
  1575. }
  1576. if (options && options.getter)
  1577. name = 'get ' + name;
  1578. if (options && options.setter)
  1579. name = 'set ' + name;
  1580. if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
  1581. if (DESCRIPTORS)
  1582. defineProperty(value, 'name', {
  1583. value: name,
  1584. configurable: true
  1585. });
  1586. else
  1587. value.name = name;
  1588. }
  1589. if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
  1590. defineProperty(value, 'length', { value: options.arity });
  1591. }
  1592. try {
  1593. if (options && hasOwn(options, 'constructor') && options.constructor) {
  1594. if (DESCRIPTORS)
  1595. defineProperty(value, 'prototype', { writable: false });
  1596. } else if (value.prototype)
  1597. value.prototype = undefined;
  1598. } catch (error) {
  1599. }
  1600. var state = enforceInternalState(value);
  1601. if (!hasOwn(state, 'source')) {
  1602. state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
  1603. }
  1604. return value;
  1605. };
  1606. Function.prototype.toString = makeBuiltIn(function toString() {
  1607. return isCallable(this) && getInternalState(this).source || inspectSource(this);
  1608. }, 'toString');
  1609. /***/ }),
  1610. /* 50 */
  1611. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1612. var DESCRIPTORS = __w_pdfjs_require__(6);
  1613. var hasOwn = __w_pdfjs_require__(39);
  1614. var FunctionPrototype = Function.prototype;
  1615. var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
  1616. var EXISTS = hasOwn(FunctionPrototype, 'name');
  1617. var PROPER = EXISTS && function something() {
  1618. }.name === 'something';
  1619. var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
  1620. module.exports = {
  1621. EXISTS: EXISTS,
  1622. PROPER: PROPER,
  1623. CONFIGURABLE: CONFIGURABLE
  1624. };
  1625. /***/ }),
  1626. /* 51 */
  1627. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1628. var uncurryThis = __w_pdfjs_require__(14);
  1629. var isCallable = __w_pdfjs_require__(21);
  1630. var store = __w_pdfjs_require__(37);
  1631. var functionToString = uncurryThis(Function.toString);
  1632. if (!isCallable(store.inspectSource)) {
  1633. store.inspectSource = function (it) {
  1634. return functionToString(it);
  1635. };
  1636. }
  1637. module.exports = store.inspectSource;
  1638. /***/ }),
  1639. /* 52 */
  1640. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1641. var NATIVE_WEAK_MAP = __w_pdfjs_require__(53);
  1642. var global = __w_pdfjs_require__(4);
  1643. var isObject = __w_pdfjs_require__(20);
  1644. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1645. var hasOwn = __w_pdfjs_require__(39);
  1646. var shared = __w_pdfjs_require__(37);
  1647. var sharedKey = __w_pdfjs_require__(54);
  1648. var hiddenKeys = __w_pdfjs_require__(55);
  1649. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  1650. var TypeError = global.TypeError;
  1651. var WeakMap = global.WeakMap;
  1652. var set, get, has;
  1653. var enforce = function (it) {
  1654. return has(it) ? get(it) : set(it, {});
  1655. };
  1656. var getterFor = function (TYPE) {
  1657. return function (it) {
  1658. var state;
  1659. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  1660. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  1661. }
  1662. return state;
  1663. };
  1664. };
  1665. if (NATIVE_WEAK_MAP || shared.state) {
  1666. var store = shared.state || (shared.state = new WeakMap());
  1667. store.get = store.get;
  1668. store.has = store.has;
  1669. store.set = store.set;
  1670. set = function (it, metadata) {
  1671. if (store.has(it))
  1672. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1673. metadata.facade = it;
  1674. store.set(it, metadata);
  1675. return metadata;
  1676. };
  1677. get = function (it) {
  1678. return store.get(it) || {};
  1679. };
  1680. has = function (it) {
  1681. return store.has(it);
  1682. };
  1683. } else {
  1684. var STATE = sharedKey('state');
  1685. hiddenKeys[STATE] = true;
  1686. set = function (it, metadata) {
  1687. if (hasOwn(it, STATE))
  1688. throw TypeError(OBJECT_ALREADY_INITIALIZED);
  1689. metadata.facade = it;
  1690. createNonEnumerableProperty(it, STATE, metadata);
  1691. return metadata;
  1692. };
  1693. get = function (it) {
  1694. return hasOwn(it, STATE) ? it[STATE] : {};
  1695. };
  1696. has = function (it) {
  1697. return hasOwn(it, STATE);
  1698. };
  1699. }
  1700. module.exports = {
  1701. set: set,
  1702. get: get,
  1703. has: has,
  1704. enforce: enforce,
  1705. getterFor: getterFor
  1706. };
  1707. /***/ }),
  1708. /* 53 */
  1709. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1710. var global = __w_pdfjs_require__(4);
  1711. var isCallable = __w_pdfjs_require__(21);
  1712. var WeakMap = global.WeakMap;
  1713. module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap));
  1714. /***/ }),
  1715. /* 54 */
  1716. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1717. var shared = __w_pdfjs_require__(35);
  1718. var uid = __w_pdfjs_require__(41);
  1719. var keys = shared('keys');
  1720. module.exports = function (key) {
  1721. return keys[key] || (keys[key] = uid(key));
  1722. };
  1723. /***/ }),
  1724. /* 55 */
  1725. /***/ ((module) => {
  1726. module.exports = {};
  1727. /***/ }),
  1728. /* 56 */
  1729. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1730. var hasOwn = __w_pdfjs_require__(39);
  1731. var ownKeys = __w_pdfjs_require__(57);
  1732. var getOwnPropertyDescriptorModule = __w_pdfjs_require__(5);
  1733. var definePropertyModule = __w_pdfjs_require__(45);
  1734. module.exports = function (target, source, exceptions) {
  1735. var keys = ownKeys(source);
  1736. var defineProperty = definePropertyModule.f;
  1737. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  1738. for (var i = 0; i < keys.length; i++) {
  1739. var key = keys[i];
  1740. if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
  1741. defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  1742. }
  1743. }
  1744. };
  1745. /***/ }),
  1746. /* 57 */
  1747. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1748. var getBuiltIn = __w_pdfjs_require__(24);
  1749. var uncurryThis = __w_pdfjs_require__(14);
  1750. var getOwnPropertyNamesModule = __w_pdfjs_require__(58);
  1751. var getOwnPropertySymbolsModule = __w_pdfjs_require__(67);
  1752. var anObject = __w_pdfjs_require__(47);
  1753. var concat = uncurryThis([].concat);
  1754. module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
  1755. var keys = getOwnPropertyNamesModule.f(anObject(it));
  1756. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  1757. return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
  1758. };
  1759. /***/ }),
  1760. /* 58 */
  1761. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  1762. var internalObjectKeys = __w_pdfjs_require__(59);
  1763. var enumBugKeys = __w_pdfjs_require__(66);
  1764. var hiddenKeys = enumBugKeys.concat('length', 'prototype');
  1765. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  1766. return internalObjectKeys(O, hiddenKeys);
  1767. };
  1768. /***/ }),
  1769. /* 59 */
  1770. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1771. var uncurryThis = __w_pdfjs_require__(14);
  1772. var hasOwn = __w_pdfjs_require__(39);
  1773. var toIndexedObject = __w_pdfjs_require__(12);
  1774. var indexOf = (__w_pdfjs_require__(60).indexOf);
  1775. var hiddenKeys = __w_pdfjs_require__(55);
  1776. var push = uncurryThis([].push);
  1777. module.exports = function (object, names) {
  1778. var O = toIndexedObject(object);
  1779. var i = 0;
  1780. var result = [];
  1781. var key;
  1782. for (key in O)
  1783. !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
  1784. while (names.length > i)
  1785. if (hasOwn(O, key = names[i++])) {
  1786. ~indexOf(result, key) || push(result, key);
  1787. }
  1788. return result;
  1789. };
  1790. /***/ }),
  1791. /* 60 */
  1792. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1793. var toIndexedObject = __w_pdfjs_require__(12);
  1794. var toAbsoluteIndex = __w_pdfjs_require__(61);
  1795. var lengthOfArrayLike = __w_pdfjs_require__(64);
  1796. var createMethod = function (IS_INCLUDES) {
  1797. return function ($this, el, fromIndex) {
  1798. var O = toIndexedObject($this);
  1799. var length = lengthOfArrayLike(O);
  1800. var index = toAbsoluteIndex(fromIndex, length);
  1801. var value;
  1802. if (IS_INCLUDES && el !== el)
  1803. while (length > index) {
  1804. value = O[index++];
  1805. if (value !== value)
  1806. return true;
  1807. }
  1808. else
  1809. for (; length > index; index++) {
  1810. if ((IS_INCLUDES || index in O) && O[index] === el)
  1811. return IS_INCLUDES || index || 0;
  1812. }
  1813. return !IS_INCLUDES && -1;
  1814. };
  1815. };
  1816. module.exports = {
  1817. includes: createMethod(true),
  1818. indexOf: createMethod(false)
  1819. };
  1820. /***/ }),
  1821. /* 61 */
  1822. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1823. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  1824. var max = Math.max;
  1825. var min = Math.min;
  1826. module.exports = function (index, length) {
  1827. var integer = toIntegerOrInfinity(index);
  1828. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  1829. };
  1830. /***/ }),
  1831. /* 62 */
  1832. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1833. var trunc = __w_pdfjs_require__(63);
  1834. module.exports = function (argument) {
  1835. var number = +argument;
  1836. return number !== number || number === 0 ? 0 : trunc(number);
  1837. };
  1838. /***/ }),
  1839. /* 63 */
  1840. /***/ ((module) => {
  1841. var ceil = Math.ceil;
  1842. var floor = Math.floor;
  1843. module.exports = Math.trunc || function trunc(x) {
  1844. var n = +x;
  1845. return (n > 0 ? floor : ceil)(n);
  1846. };
  1847. /***/ }),
  1848. /* 64 */
  1849. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1850. var toLength = __w_pdfjs_require__(65);
  1851. module.exports = function (obj) {
  1852. return toLength(obj.length);
  1853. };
  1854. /***/ }),
  1855. /* 65 */
  1856. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1857. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  1858. var min = Math.min;
  1859. module.exports = function (argument) {
  1860. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0;
  1861. };
  1862. /***/ }),
  1863. /* 66 */
  1864. /***/ ((module) => {
  1865. module.exports = [
  1866. 'constructor',
  1867. 'hasOwnProperty',
  1868. 'isPrototypeOf',
  1869. 'propertyIsEnumerable',
  1870. 'toLocaleString',
  1871. 'toString',
  1872. 'valueOf'
  1873. ];
  1874. /***/ }),
  1875. /* 67 */
  1876. /***/ ((__unused_webpack_module, exports) => {
  1877. exports.f = Object.getOwnPropertySymbols;
  1878. /***/ }),
  1879. /* 68 */
  1880. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1881. var fails = __w_pdfjs_require__(7);
  1882. var isCallable = __w_pdfjs_require__(21);
  1883. var replacement = /#|\.prototype\./;
  1884. var isForced = function (feature, detection) {
  1885. var value = data[normalize(feature)];
  1886. return value === POLYFILL ? true : value === NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
  1887. };
  1888. var normalize = isForced.normalize = function (string) {
  1889. return String(string).replace(replacement, '.').toLowerCase();
  1890. };
  1891. var data = isForced.data = {};
  1892. var NATIVE = isForced.NATIVE = 'N';
  1893. var POLYFILL = isForced.POLYFILL = 'P';
  1894. module.exports = isForced;
  1895. /***/ }),
  1896. /* 69 */
  1897. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1898. var NATIVE_BIND = __w_pdfjs_require__(9);
  1899. var FunctionPrototype = Function.prototype;
  1900. var apply = FunctionPrototype.apply;
  1901. var call = FunctionPrototype.call;
  1902. module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
  1903. return call.apply(apply, arguments);
  1904. });
  1905. /***/ }),
  1906. /* 70 */
  1907. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1908. var getBuiltIn = __w_pdfjs_require__(24);
  1909. var hasOwn = __w_pdfjs_require__(39);
  1910. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  1911. var isPrototypeOf = __w_pdfjs_require__(25);
  1912. var setPrototypeOf = __w_pdfjs_require__(71);
  1913. var copyConstructorProperties = __w_pdfjs_require__(56);
  1914. var proxyAccessor = __w_pdfjs_require__(74);
  1915. var inheritIfRequired = __w_pdfjs_require__(75);
  1916. var normalizeStringArgument = __w_pdfjs_require__(76);
  1917. var installErrorCause = __w_pdfjs_require__(80);
  1918. var installErrorStack = __w_pdfjs_require__(81);
  1919. var DESCRIPTORS = __w_pdfjs_require__(6);
  1920. var IS_PURE = __w_pdfjs_require__(36);
  1921. module.exports = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) {
  1922. var STACK_TRACE_LIMIT = 'stackTraceLimit';
  1923. var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1;
  1924. var path = FULL_NAME.split('.');
  1925. var ERROR_NAME = path[path.length - 1];
  1926. var OriginalError = getBuiltIn.apply(null, path);
  1927. if (!OriginalError)
  1928. return;
  1929. var OriginalErrorPrototype = OriginalError.prototype;
  1930. if (!IS_PURE && hasOwn(OriginalErrorPrototype, 'cause'))
  1931. delete OriginalErrorPrototype.cause;
  1932. if (!FORCED)
  1933. return OriginalError;
  1934. var BaseError = getBuiltIn('Error');
  1935. var WrappedError = wrapper(function (a, b) {
  1936. var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined);
  1937. var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError();
  1938. if (message !== undefined)
  1939. createNonEnumerableProperty(result, 'message', message);
  1940. installErrorStack(result, WrappedError, result.stack, 2);
  1941. if (this && isPrototypeOf(OriginalErrorPrototype, this))
  1942. inheritIfRequired(result, this, WrappedError);
  1943. if (arguments.length > OPTIONS_POSITION)
  1944. installErrorCause(result, arguments[OPTIONS_POSITION]);
  1945. return result;
  1946. });
  1947. WrappedError.prototype = OriginalErrorPrototype;
  1948. if (ERROR_NAME !== 'Error') {
  1949. if (setPrototypeOf)
  1950. setPrototypeOf(WrappedError, BaseError);
  1951. else
  1952. copyConstructorProperties(WrappedError, BaseError, { name: true });
  1953. } else if (DESCRIPTORS && STACK_TRACE_LIMIT in OriginalError) {
  1954. proxyAccessor(WrappedError, OriginalError, STACK_TRACE_LIMIT);
  1955. proxyAccessor(WrappedError, OriginalError, 'prepareStackTrace');
  1956. }
  1957. copyConstructorProperties(WrappedError, OriginalError);
  1958. if (!IS_PURE)
  1959. try {
  1960. if (OriginalErrorPrototype.name !== ERROR_NAME) {
  1961. createNonEnumerableProperty(OriginalErrorPrototype, 'name', ERROR_NAME);
  1962. }
  1963. OriginalErrorPrototype.constructor = WrappedError;
  1964. } catch (error) {
  1965. }
  1966. return WrappedError;
  1967. };
  1968. /***/ }),
  1969. /* 71 */
  1970. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1971. var uncurryThisAccessor = __w_pdfjs_require__(72);
  1972. var anObject = __w_pdfjs_require__(47);
  1973. var aPossiblePrototype = __w_pdfjs_require__(73);
  1974. module.exports = Object.setPrototypeOf || ('__proto__' in {} ? (function () {
  1975. var CORRECT_SETTER = false;
  1976. var test = {};
  1977. var setter;
  1978. try {
  1979. setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
  1980. setter(test, []);
  1981. CORRECT_SETTER = test instanceof Array;
  1982. } catch (error) {
  1983. }
  1984. return function setPrototypeOf(O, proto) {
  1985. anObject(O);
  1986. aPossiblePrototype(proto);
  1987. if (CORRECT_SETTER)
  1988. setter(O, proto);
  1989. else
  1990. O.__proto__ = proto;
  1991. return O;
  1992. };
  1993. }()) : undefined);
  1994. /***/ }),
  1995. /* 72 */
  1996. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  1997. var uncurryThis = __w_pdfjs_require__(14);
  1998. var aCallable = __w_pdfjs_require__(31);
  1999. module.exports = function (object, key, method) {
  2000. try {
  2001. return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
  2002. } catch (error) {
  2003. }
  2004. };
  2005. /***/ }),
  2006. /* 73 */
  2007. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2008. var isCallable = __w_pdfjs_require__(21);
  2009. var $String = String;
  2010. var $TypeError = TypeError;
  2011. module.exports = function (argument) {
  2012. if (typeof argument == 'object' || isCallable(argument))
  2013. return argument;
  2014. throw $TypeError("Can't set " + $String(argument) + ' as a prototype');
  2015. };
  2016. /***/ }),
  2017. /* 74 */
  2018. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2019. var defineProperty = (__w_pdfjs_require__(45).f);
  2020. module.exports = function (Target, Source, key) {
  2021. key in Target || defineProperty(Target, key, {
  2022. configurable: true,
  2023. get: function () {
  2024. return Source[key];
  2025. },
  2026. set: function (it) {
  2027. Source[key] = it;
  2028. }
  2029. });
  2030. };
  2031. /***/ }),
  2032. /* 75 */
  2033. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2034. var isCallable = __w_pdfjs_require__(21);
  2035. var isObject = __w_pdfjs_require__(20);
  2036. var setPrototypeOf = __w_pdfjs_require__(71);
  2037. module.exports = function ($this, dummy, Wrapper) {
  2038. var NewTarget, NewTargetPrototype;
  2039. if (setPrototypeOf && isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype)
  2040. setPrototypeOf($this, NewTargetPrototype);
  2041. return $this;
  2042. };
  2043. /***/ }),
  2044. /* 76 */
  2045. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2046. var toString = __w_pdfjs_require__(77);
  2047. module.exports = function (argument, $default) {
  2048. return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
  2049. };
  2050. /***/ }),
  2051. /* 77 */
  2052. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2053. var classof = __w_pdfjs_require__(78);
  2054. var $String = String;
  2055. module.exports = function (argument) {
  2056. if (classof(argument) === 'Symbol')
  2057. throw TypeError('Cannot convert a Symbol value to a string');
  2058. return $String(argument);
  2059. };
  2060. /***/ }),
  2061. /* 78 */
  2062. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2063. var TO_STRING_TAG_SUPPORT = __w_pdfjs_require__(79);
  2064. var isCallable = __w_pdfjs_require__(21);
  2065. var classofRaw = __w_pdfjs_require__(15);
  2066. var wellKnownSymbol = __w_pdfjs_require__(34);
  2067. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2068. var $Object = Object;
  2069. var CORRECT_ARGUMENTS = classofRaw((function () {
  2070. return arguments;
  2071. }())) === 'Arguments';
  2072. var tryGet = function (it, key) {
  2073. try {
  2074. return it[key];
  2075. } catch (error) {
  2076. }
  2077. };
  2078. module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  2079. var O, tag, result;
  2080. 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' && isCallable(O.callee) ? 'Arguments' : result;
  2081. };
  2082. /***/ }),
  2083. /* 79 */
  2084. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2085. var wellKnownSymbol = __w_pdfjs_require__(34);
  2086. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2087. var test = {};
  2088. test[TO_STRING_TAG] = 'z';
  2089. module.exports = String(test) === '[object z]';
  2090. /***/ }),
  2091. /* 80 */
  2092. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2093. var isObject = __w_pdfjs_require__(20);
  2094. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  2095. module.exports = function (O, options) {
  2096. if (isObject(options) && 'cause' in options) {
  2097. createNonEnumerableProperty(O, 'cause', options.cause);
  2098. }
  2099. };
  2100. /***/ }),
  2101. /* 81 */
  2102. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2103. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  2104. var clearErrorStack = __w_pdfjs_require__(82);
  2105. var ERROR_STACK_INSTALLABLE = __w_pdfjs_require__(83);
  2106. var captureStackTrace = Error.captureStackTrace;
  2107. module.exports = function (error, C, stack, dropEntries) {
  2108. if (ERROR_STACK_INSTALLABLE) {
  2109. if (captureStackTrace)
  2110. captureStackTrace(error, C);
  2111. else
  2112. createNonEnumerableProperty(error, 'stack', clearErrorStack(stack, dropEntries));
  2113. }
  2114. };
  2115. /***/ }),
  2116. /* 82 */
  2117. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2118. var uncurryThis = __w_pdfjs_require__(14);
  2119. var $Error = Error;
  2120. var replace = uncurryThis(''.replace);
  2121. var TEST = function (arg) {
  2122. return String($Error(arg).stack);
  2123. }('zxcasd');
  2124. var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
  2125. var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
  2126. module.exports = function (stack, dropEntries) {
  2127. if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) {
  2128. while (dropEntries--)
  2129. stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
  2130. }
  2131. return stack;
  2132. };
  2133. /***/ }),
  2134. /* 83 */
  2135. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2136. var fails = __w_pdfjs_require__(7);
  2137. var createPropertyDescriptor = __w_pdfjs_require__(11);
  2138. module.exports = !fails(function () {
  2139. var error = Error('a');
  2140. if (!('stack' in error))
  2141. return true;
  2142. Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
  2143. return error.stack !== 7;
  2144. });
  2145. /***/ }),
  2146. /* 84 */
  2147. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2148. var defineBuiltIn = __w_pdfjs_require__(48);
  2149. var uncurryThis = __w_pdfjs_require__(14);
  2150. var toString = __w_pdfjs_require__(77);
  2151. var validateArgumentsLength = __w_pdfjs_require__(85);
  2152. var $URLSearchParams = URLSearchParams;
  2153. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  2154. var append = uncurryThis(URLSearchParamsPrototype.append);
  2155. var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
  2156. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  2157. var push = uncurryThis([].push);
  2158. var params = new $URLSearchParams('a=1&a=2&b=3');
  2159. params['delete']('a', 1);
  2160. params['delete']('b', undefined);
  2161. if (params + '' !== 'a=2') {
  2162. defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name) {
  2163. var length = arguments.length;
  2164. var $value = length < 2 ? undefined : arguments[1];
  2165. if (length && $value === undefined)
  2166. return $delete(this, name);
  2167. var entries = [];
  2168. forEach(this, function (v, k) {
  2169. push(entries, {
  2170. key: k,
  2171. value: v
  2172. });
  2173. });
  2174. validateArgumentsLength(length, 1);
  2175. var key = toString(name);
  2176. var value = toString($value);
  2177. var index = 0;
  2178. var dindex = 0;
  2179. var found = false;
  2180. var entriesLength = entries.length;
  2181. var entry;
  2182. while (index < entriesLength) {
  2183. entry = entries[index++];
  2184. if (found || entry.key === key) {
  2185. found = true;
  2186. $delete(this, entry.key);
  2187. } else
  2188. dindex++;
  2189. }
  2190. while (dindex < entriesLength) {
  2191. entry = entries[dindex++];
  2192. if (!(entry.key === key && entry.value === value))
  2193. append(this, entry.key, entry.value);
  2194. }
  2195. }, {
  2196. enumerable: true,
  2197. unsafe: true
  2198. });
  2199. }
  2200. /***/ }),
  2201. /* 85 */
  2202. /***/ ((module) => {
  2203. var $TypeError = TypeError;
  2204. module.exports = function (passed, required) {
  2205. if (passed < required)
  2206. throw $TypeError('Not enough arguments');
  2207. return passed;
  2208. };
  2209. /***/ }),
  2210. /* 86 */
  2211. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2212. var defineBuiltIn = __w_pdfjs_require__(48);
  2213. var uncurryThis = __w_pdfjs_require__(14);
  2214. var toString = __w_pdfjs_require__(77);
  2215. var validateArgumentsLength = __w_pdfjs_require__(85);
  2216. var $URLSearchParams = URLSearchParams;
  2217. var URLSearchParamsPrototype = $URLSearchParams.prototype;
  2218. var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
  2219. var $has = uncurryThis(URLSearchParamsPrototype.has);
  2220. var params = new $URLSearchParams('a=1');
  2221. if (params.has('a', 2) || !params.has('a', undefined)) {
  2222. defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name) {
  2223. var length = arguments.length;
  2224. var $value = length < 2 ? undefined : arguments[1];
  2225. if (length && $value === undefined)
  2226. return $has(this, name);
  2227. var values = getAll(this, name);
  2228. validateArgumentsLength(length, 1);
  2229. var value = toString($value);
  2230. var index = 0;
  2231. while (index < values.length) {
  2232. if (values[index++] === value)
  2233. return true;
  2234. }
  2235. return false;
  2236. }, {
  2237. enumerable: true,
  2238. unsafe: true
  2239. });
  2240. }
  2241. /***/ }),
  2242. /* 87 */
  2243. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2244. var DESCRIPTORS = __w_pdfjs_require__(6);
  2245. var uncurryThis = __w_pdfjs_require__(14);
  2246. var defineBuiltInAccessor = __w_pdfjs_require__(88);
  2247. var URLSearchParamsPrototype = URLSearchParams.prototype;
  2248. var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
  2249. if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
  2250. defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
  2251. get: function size() {
  2252. var count = 0;
  2253. forEach(this, function () {
  2254. count++;
  2255. });
  2256. return count;
  2257. },
  2258. configurable: true,
  2259. enumerable: true
  2260. });
  2261. }
  2262. /***/ }),
  2263. /* 88 */
  2264. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2265. var makeBuiltIn = __w_pdfjs_require__(49);
  2266. var defineProperty = __w_pdfjs_require__(45);
  2267. module.exports = function (target, name, descriptor) {
  2268. if (descriptor.get)
  2269. makeBuiltIn(descriptor.get, name, { getter: true });
  2270. if (descriptor.set)
  2271. makeBuiltIn(descriptor.set, name, { setter: true });
  2272. return defineProperty.f(target, name, descriptor);
  2273. };
  2274. /***/ }),
  2275. /* 89 */
  2276. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2277. var $ = __w_pdfjs_require__(3);
  2278. var toObject = __w_pdfjs_require__(40);
  2279. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2280. var setArrayLength = __w_pdfjs_require__(90);
  2281. var doesNotExceedSafeInteger = __w_pdfjs_require__(92);
  2282. var fails = __w_pdfjs_require__(7);
  2283. var INCORRECT_TO_LENGTH = fails(function () {
  2284. return [].push.call({ length: 0x100000000 }, 1) !== 4294967297;
  2285. });
  2286. var properErrorOnNonWritableLength = function () {
  2287. try {
  2288. Object.defineProperty([], 'length', { writable: false }).push();
  2289. } catch (error) {
  2290. return error instanceof TypeError;
  2291. }
  2292. };
  2293. var FORCED = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
  2294. $({
  2295. target: 'Array',
  2296. proto: true,
  2297. arity: 1,
  2298. forced: FORCED
  2299. }, {
  2300. push: function push(item) {
  2301. var O = toObject(this);
  2302. var len = lengthOfArrayLike(O);
  2303. var argCount = arguments.length;
  2304. doesNotExceedSafeInteger(len + argCount);
  2305. for (var i = 0; i < argCount; i++) {
  2306. O[len] = arguments[i];
  2307. len++;
  2308. }
  2309. setArrayLength(O, len);
  2310. return len;
  2311. }
  2312. });
  2313. /***/ }),
  2314. /* 90 */
  2315. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2316. var DESCRIPTORS = __w_pdfjs_require__(6);
  2317. var isArray = __w_pdfjs_require__(91);
  2318. var $TypeError = TypeError;
  2319. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2320. var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !(function () {
  2321. if (this !== undefined)
  2322. return true;
  2323. try {
  2324. Object.defineProperty([], 'length', { writable: false }).length = 1;
  2325. } catch (error) {
  2326. return error instanceof TypeError;
  2327. }
  2328. }());
  2329. module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
  2330. if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
  2331. throw $TypeError('Cannot set read only .length');
  2332. }
  2333. return O.length = length;
  2334. } : function (O, length) {
  2335. return O.length = length;
  2336. };
  2337. /***/ }),
  2338. /* 91 */
  2339. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2340. var classof = __w_pdfjs_require__(15);
  2341. module.exports = Array.isArray || function isArray(argument) {
  2342. return classof(argument) === 'Array';
  2343. };
  2344. /***/ }),
  2345. /* 92 */
  2346. /***/ ((module) => {
  2347. var $TypeError = TypeError;
  2348. var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
  2349. module.exports = function (it) {
  2350. if (it > MAX_SAFE_INTEGER)
  2351. throw $TypeError('Maximum allowed index exceeded');
  2352. return it;
  2353. };
  2354. /***/ }),
  2355. /* 93 */
  2356. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2357. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2358. var $findLast = (__w_pdfjs_require__(98).findLast);
  2359. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2360. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2361. exportTypedArrayMethod('findLast', function findLast(predicate) {
  2362. return $findLast(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  2363. });
  2364. /***/ }),
  2365. /* 94 */
  2366. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2367. var NATIVE_ARRAY_BUFFER = __w_pdfjs_require__(95);
  2368. var DESCRIPTORS = __w_pdfjs_require__(6);
  2369. var global = __w_pdfjs_require__(4);
  2370. var isCallable = __w_pdfjs_require__(21);
  2371. var isObject = __w_pdfjs_require__(20);
  2372. var hasOwn = __w_pdfjs_require__(39);
  2373. var classof = __w_pdfjs_require__(78);
  2374. var tryToString = __w_pdfjs_require__(32);
  2375. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  2376. var defineBuiltIn = __w_pdfjs_require__(48);
  2377. var defineBuiltInAccessor = __w_pdfjs_require__(88);
  2378. var isPrototypeOf = __w_pdfjs_require__(25);
  2379. var getPrototypeOf = __w_pdfjs_require__(96);
  2380. var setPrototypeOf = __w_pdfjs_require__(71);
  2381. var wellKnownSymbol = __w_pdfjs_require__(34);
  2382. var uid = __w_pdfjs_require__(41);
  2383. var InternalStateModule = __w_pdfjs_require__(52);
  2384. var enforceInternalState = InternalStateModule.enforce;
  2385. var getInternalState = InternalStateModule.get;
  2386. var Int8Array = global.Int8Array;
  2387. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  2388. var Uint8ClampedArray = global.Uint8ClampedArray;
  2389. var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
  2390. var TypedArray = Int8Array && getPrototypeOf(Int8Array);
  2391. var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
  2392. var ObjectPrototype = Object.prototype;
  2393. var TypeError = global.TypeError;
  2394. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  2395. var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
  2396. var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
  2397. var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
  2398. var TYPED_ARRAY_TAG_REQUIRED = false;
  2399. var NAME, Constructor, Prototype;
  2400. var TypedArrayConstructorsList = {
  2401. Int8Array: 1,
  2402. Uint8Array: 1,
  2403. Uint8ClampedArray: 1,
  2404. Int16Array: 2,
  2405. Uint16Array: 2,
  2406. Int32Array: 4,
  2407. Uint32Array: 4,
  2408. Float32Array: 4,
  2409. Float64Array: 8
  2410. };
  2411. var BigIntArrayConstructorsList = {
  2412. BigInt64Array: 8,
  2413. BigUint64Array: 8
  2414. };
  2415. var isView = function isView(it) {
  2416. if (!isObject(it))
  2417. return false;
  2418. var klass = classof(it);
  2419. return klass === 'DataView' || hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2420. };
  2421. var getTypedArrayConstructor = function (it) {
  2422. var proto = getPrototypeOf(it);
  2423. if (!isObject(proto))
  2424. return;
  2425. var state = getInternalState(proto);
  2426. return state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);
  2427. };
  2428. var isTypedArray = function (it) {
  2429. if (!isObject(it))
  2430. return false;
  2431. var klass = classof(it);
  2432. return hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
  2433. };
  2434. var aTypedArray = function (it) {
  2435. if (isTypedArray(it))
  2436. return it;
  2437. throw TypeError('Target is not a typed array');
  2438. };
  2439. var aTypedArrayConstructor = function (C) {
  2440. if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C)))
  2441. return C;
  2442. throw TypeError(tryToString(C) + ' is not a typed array constructor');
  2443. };
  2444. var exportTypedArrayMethod = function (KEY, property, forced, options) {
  2445. if (!DESCRIPTORS)
  2446. return;
  2447. if (forced)
  2448. for (var ARRAY in TypedArrayConstructorsList) {
  2449. var TypedArrayConstructor = global[ARRAY];
  2450. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY))
  2451. try {
  2452. delete TypedArrayConstructor.prototype[KEY];
  2453. } catch (error) {
  2454. try {
  2455. TypedArrayConstructor.prototype[KEY] = property;
  2456. } catch (error2) {
  2457. }
  2458. }
  2459. }
  2460. if (!TypedArrayPrototype[KEY] || forced) {
  2461. defineBuiltIn(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options);
  2462. }
  2463. };
  2464. var exportTypedArrayStaticMethod = function (KEY, property, forced) {
  2465. var ARRAY, TypedArrayConstructor;
  2466. if (!DESCRIPTORS)
  2467. return;
  2468. if (setPrototypeOf) {
  2469. if (forced)
  2470. for (ARRAY in TypedArrayConstructorsList) {
  2471. TypedArrayConstructor = global[ARRAY];
  2472. if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY))
  2473. try {
  2474. delete TypedArrayConstructor[KEY];
  2475. } catch (error) {
  2476. }
  2477. }
  2478. if (!TypedArray[KEY] || forced) {
  2479. try {
  2480. return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
  2481. } catch (error) {
  2482. }
  2483. } else
  2484. return;
  2485. }
  2486. for (ARRAY in TypedArrayConstructorsList) {
  2487. TypedArrayConstructor = global[ARRAY];
  2488. if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
  2489. defineBuiltIn(TypedArrayConstructor, KEY, property);
  2490. }
  2491. }
  2492. };
  2493. for (NAME in TypedArrayConstructorsList) {
  2494. Constructor = global[NAME];
  2495. Prototype = Constructor && Constructor.prototype;
  2496. if (Prototype)
  2497. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2498. else
  2499. NATIVE_ARRAY_BUFFER_VIEWS = false;
  2500. }
  2501. for (NAME in BigIntArrayConstructorsList) {
  2502. Constructor = global[NAME];
  2503. Prototype = Constructor && Constructor.prototype;
  2504. if (Prototype)
  2505. enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
  2506. }
  2507. if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) {
  2508. TypedArray = function TypedArray() {
  2509. throw TypeError('Incorrect invocation');
  2510. };
  2511. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2512. for (NAME in TypedArrayConstructorsList) {
  2513. if (global[NAME])
  2514. setPrototypeOf(global[NAME], TypedArray);
  2515. }
  2516. }
  2517. if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
  2518. TypedArrayPrototype = TypedArray.prototype;
  2519. if (NATIVE_ARRAY_BUFFER_VIEWS)
  2520. for (NAME in TypedArrayConstructorsList) {
  2521. if (global[NAME])
  2522. setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
  2523. }
  2524. }
  2525. if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
  2526. setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
  2527. }
  2528. if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
  2529. TYPED_ARRAY_TAG_REQUIRED = true;
  2530. defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, {
  2531. configurable: true,
  2532. get: function () {
  2533. return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
  2534. }
  2535. });
  2536. for (NAME in TypedArrayConstructorsList)
  2537. if (global[NAME]) {
  2538. createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
  2539. }
  2540. }
  2541. module.exports = {
  2542. NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
  2543. TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG,
  2544. aTypedArray: aTypedArray,
  2545. aTypedArrayConstructor: aTypedArrayConstructor,
  2546. exportTypedArrayMethod: exportTypedArrayMethod,
  2547. exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
  2548. getTypedArrayConstructor: getTypedArrayConstructor,
  2549. isView: isView,
  2550. isTypedArray: isTypedArray,
  2551. TypedArray: TypedArray,
  2552. TypedArrayPrototype: TypedArrayPrototype
  2553. };
  2554. /***/ }),
  2555. /* 95 */
  2556. /***/ ((module) => {
  2557. module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined';
  2558. /***/ }),
  2559. /* 96 */
  2560. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2561. var hasOwn = __w_pdfjs_require__(39);
  2562. var isCallable = __w_pdfjs_require__(21);
  2563. var toObject = __w_pdfjs_require__(40);
  2564. var sharedKey = __w_pdfjs_require__(54);
  2565. var CORRECT_PROTOTYPE_GETTER = __w_pdfjs_require__(97);
  2566. var IE_PROTO = sharedKey('IE_PROTO');
  2567. var $Object = Object;
  2568. var ObjectPrototype = $Object.prototype;
  2569. module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
  2570. var object = toObject(O);
  2571. if (hasOwn(object, IE_PROTO))
  2572. return object[IE_PROTO];
  2573. var constructor = object.constructor;
  2574. if (isCallable(constructor) && object instanceof constructor) {
  2575. return constructor.prototype;
  2576. }
  2577. return object instanceof $Object ? ObjectPrototype : null;
  2578. };
  2579. /***/ }),
  2580. /* 97 */
  2581. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2582. var fails = __w_pdfjs_require__(7);
  2583. module.exports = !fails(function () {
  2584. function F() {
  2585. }
  2586. F.prototype.constructor = null;
  2587. return Object.getPrototypeOf(new F()) !== F.prototype;
  2588. });
  2589. /***/ }),
  2590. /* 98 */
  2591. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2592. var bind = __w_pdfjs_require__(99);
  2593. var IndexedObject = __w_pdfjs_require__(13);
  2594. var toObject = __w_pdfjs_require__(40);
  2595. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2596. var createMethod = function (TYPE) {
  2597. var IS_FIND_LAST_INDEX = TYPE === 1;
  2598. return function ($this, callbackfn, that) {
  2599. var O = toObject($this);
  2600. var self = IndexedObject(O);
  2601. var boundFunction = bind(callbackfn, that);
  2602. var index = lengthOfArrayLike(self);
  2603. var value, result;
  2604. while (index-- > 0) {
  2605. value = self[index];
  2606. result = boundFunction(value, index, O);
  2607. if (result)
  2608. switch (TYPE) {
  2609. case 0:
  2610. return value;
  2611. case 1:
  2612. return index;
  2613. }
  2614. }
  2615. return IS_FIND_LAST_INDEX ? -1 : undefined;
  2616. };
  2617. };
  2618. module.exports = {
  2619. findLast: createMethod(0),
  2620. findLastIndex: createMethod(1)
  2621. };
  2622. /***/ }),
  2623. /* 99 */
  2624. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2625. var uncurryThis = __w_pdfjs_require__(100);
  2626. var aCallable = __w_pdfjs_require__(31);
  2627. var NATIVE_BIND = __w_pdfjs_require__(9);
  2628. var bind = uncurryThis(uncurryThis.bind);
  2629. module.exports = function (fn, that) {
  2630. aCallable(fn);
  2631. return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function () {
  2632. return fn.apply(that, arguments);
  2633. };
  2634. };
  2635. /***/ }),
  2636. /* 100 */
  2637. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2638. var classofRaw = __w_pdfjs_require__(15);
  2639. var uncurryThis = __w_pdfjs_require__(14);
  2640. module.exports = function (fn) {
  2641. if (classofRaw(fn) === 'Function')
  2642. return uncurryThis(fn);
  2643. };
  2644. /***/ }),
  2645. /* 101 */
  2646. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2647. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2648. var $findLastIndex = (__w_pdfjs_require__(98).findLastIndex);
  2649. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2650. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2651. exportTypedArrayMethod('findLastIndex', function findLastIndex(predicate) {
  2652. return $findLastIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  2653. });
  2654. /***/ }),
  2655. /* 102 */
  2656. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2657. var global = __w_pdfjs_require__(4);
  2658. var call = __w_pdfjs_require__(8);
  2659. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2660. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2661. var toOffset = __w_pdfjs_require__(103);
  2662. var toIndexedObject = __w_pdfjs_require__(40);
  2663. var fails = __w_pdfjs_require__(7);
  2664. var RangeError = global.RangeError;
  2665. var Int8Array = global.Int8Array;
  2666. var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
  2667. var $set = Int8ArrayPrototype && Int8ArrayPrototype.set;
  2668. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2669. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2670. var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () {
  2671. var array = new Uint8ClampedArray(2);
  2672. call($set, array, {
  2673. length: 1,
  2674. 0: 3
  2675. }, 1);
  2676. return array[1] !== 3;
  2677. });
  2678. var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () {
  2679. var array = new Int8Array(2);
  2680. array.set(1);
  2681. array.set('2', 1);
  2682. return array[0] !== 0 || array[1] !== 2;
  2683. });
  2684. exportTypedArrayMethod('set', function set(arrayLike) {
  2685. aTypedArray(this);
  2686. var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
  2687. var src = toIndexedObject(arrayLike);
  2688. if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS)
  2689. return call($set, this, src, offset);
  2690. var length = this.length;
  2691. var len = lengthOfArrayLike(src);
  2692. var index = 0;
  2693. if (len + offset > length)
  2694. throw RangeError('Wrong length');
  2695. while (index < len)
  2696. this[offset + index] = src[index++];
  2697. }, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG);
  2698. /***/ }),
  2699. /* 103 */
  2700. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2701. var toPositiveInteger = __w_pdfjs_require__(104);
  2702. var $RangeError = RangeError;
  2703. module.exports = function (it, BYTES) {
  2704. var offset = toPositiveInteger(it);
  2705. if (offset % BYTES)
  2706. throw $RangeError('Wrong offset');
  2707. return offset;
  2708. };
  2709. /***/ }),
  2710. /* 104 */
  2711. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2712. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2713. var $RangeError = RangeError;
  2714. module.exports = function (it) {
  2715. var result = toIntegerOrInfinity(it);
  2716. if (result < 0)
  2717. throw $RangeError("The argument can't be less than 0");
  2718. return result;
  2719. };
  2720. /***/ }),
  2721. /* 105 */
  2722. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2723. var arrayToReversed = __w_pdfjs_require__(106);
  2724. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2725. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2726. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2727. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2728. exportTypedArrayMethod('toReversed', function toReversed() {
  2729. return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this));
  2730. });
  2731. /***/ }),
  2732. /* 106 */
  2733. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2734. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2735. module.exports = function (O, C) {
  2736. var len = lengthOfArrayLike(O);
  2737. var A = new C(len);
  2738. var k = 0;
  2739. for (; k < len; k++)
  2740. A[k] = O[len - k - 1];
  2741. return A;
  2742. };
  2743. /***/ }),
  2744. /* 107 */
  2745. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2746. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2747. var uncurryThis = __w_pdfjs_require__(14);
  2748. var aCallable = __w_pdfjs_require__(31);
  2749. var arrayFromConstructorAndList = __w_pdfjs_require__(108);
  2750. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2751. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2752. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2753. var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
  2754. exportTypedArrayMethod('toSorted', function toSorted(compareFn) {
  2755. if (compareFn !== undefined)
  2756. aCallable(compareFn);
  2757. var O = aTypedArray(this);
  2758. var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O);
  2759. return sort(A, compareFn);
  2760. });
  2761. /***/ }),
  2762. /* 108 */
  2763. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2764. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2765. module.exports = function (Constructor, list) {
  2766. var index = 0;
  2767. var length = lengthOfArrayLike(list);
  2768. var result = new Constructor(length);
  2769. while (length > index)
  2770. result[index] = list[index++];
  2771. return result;
  2772. };
  2773. /***/ }),
  2774. /* 109 */
  2775. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2776. var arrayWith = __w_pdfjs_require__(110);
  2777. var ArrayBufferViewCore = __w_pdfjs_require__(94);
  2778. var isBigIntArray = __w_pdfjs_require__(111);
  2779. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2780. var toBigInt = __w_pdfjs_require__(112);
  2781. var aTypedArray = ArrayBufferViewCore.aTypedArray;
  2782. var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
  2783. var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
  2784. var PROPER_ORDER = !!(function () {
  2785. try {
  2786. new Int8Array(1)['with'](2, {
  2787. valueOf: function () {
  2788. throw 8;
  2789. }
  2790. });
  2791. } catch (error) {
  2792. return error === 8;
  2793. }
  2794. }());
  2795. exportTypedArrayMethod('with', {
  2796. 'with': function (index, value) {
  2797. var O = aTypedArray(this);
  2798. var relativeIndex = toIntegerOrInfinity(index);
  2799. var actualValue = isBigIntArray(O) ? toBigInt(value) : +value;
  2800. return arrayWith(O, getTypedArrayConstructor(O), relativeIndex, actualValue);
  2801. }
  2802. }['with'], !PROPER_ORDER);
  2803. /***/ }),
  2804. /* 110 */
  2805. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2806. var lengthOfArrayLike = __w_pdfjs_require__(64);
  2807. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2808. var $RangeError = RangeError;
  2809. module.exports = function (O, C, index, value) {
  2810. var len = lengthOfArrayLike(O);
  2811. var relativeIndex = toIntegerOrInfinity(index);
  2812. var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex;
  2813. if (actualIndex >= len || actualIndex < 0)
  2814. throw $RangeError('Incorrect index');
  2815. var A = new C(len);
  2816. var k = 0;
  2817. for (; k < len; k++)
  2818. A[k] = k === actualIndex ? value : O[k];
  2819. return A;
  2820. };
  2821. /***/ }),
  2822. /* 111 */
  2823. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2824. var classof = __w_pdfjs_require__(78);
  2825. module.exports = function (it) {
  2826. var klass = classof(it);
  2827. return klass === 'BigInt64Array' || klass === 'BigUint64Array';
  2828. };
  2829. /***/ }),
  2830. /* 112 */
  2831. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2832. var toPrimitive = __w_pdfjs_require__(19);
  2833. var $TypeError = TypeError;
  2834. module.exports = function (argument) {
  2835. var prim = toPrimitive(argument, 'number');
  2836. if (typeof prim == 'number')
  2837. throw $TypeError("Can't convert number to bigint");
  2838. return BigInt(prim);
  2839. };
  2840. /***/ }),
  2841. /* 113 */
  2842. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2843. var DESCRIPTORS = __w_pdfjs_require__(6);
  2844. var defineBuiltInAccessor = __w_pdfjs_require__(88);
  2845. var isDetached = __w_pdfjs_require__(114);
  2846. var ArrayBufferPrototype = ArrayBuffer.prototype;
  2847. if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) {
  2848. defineBuiltInAccessor(ArrayBufferPrototype, 'detached', {
  2849. configurable: true,
  2850. get: function detached() {
  2851. return isDetached(this);
  2852. }
  2853. });
  2854. }
  2855. /***/ }),
  2856. /* 114 */
  2857. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2858. var uncurryThis = __w_pdfjs_require__(14);
  2859. var arrayBufferByteLength = __w_pdfjs_require__(115);
  2860. var slice = uncurryThis(ArrayBuffer.prototype.slice);
  2861. module.exports = function (O) {
  2862. if (arrayBufferByteLength(O) !== 0)
  2863. return false;
  2864. try {
  2865. slice(O, 0, 0);
  2866. return false;
  2867. } catch (error) {
  2868. return true;
  2869. }
  2870. };
  2871. /***/ }),
  2872. /* 115 */
  2873. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2874. var uncurryThisAccessor = __w_pdfjs_require__(72);
  2875. var classof = __w_pdfjs_require__(15);
  2876. var $TypeError = TypeError;
  2877. module.exports = uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) {
  2878. if (classof(O) !== 'ArrayBuffer')
  2879. throw $TypeError('ArrayBuffer expected');
  2880. return O.byteLength;
  2881. };
  2882. /***/ }),
  2883. /* 116 */
  2884. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2885. var $ = __w_pdfjs_require__(3);
  2886. var $transfer = __w_pdfjs_require__(117);
  2887. if ($transfer)
  2888. $({
  2889. target: 'ArrayBuffer',
  2890. proto: true
  2891. }, {
  2892. transfer: function transfer() {
  2893. return $transfer(this, arguments.length ? arguments[0] : undefined, true);
  2894. }
  2895. });
  2896. /***/ }),
  2897. /* 117 */
  2898. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2899. var global = __w_pdfjs_require__(4);
  2900. var uncurryThis = __w_pdfjs_require__(14);
  2901. var uncurryThisAccessor = __w_pdfjs_require__(72);
  2902. var toIndex = __w_pdfjs_require__(118);
  2903. var isDetached = __w_pdfjs_require__(114);
  2904. var arrayBufferByteLength = __w_pdfjs_require__(115);
  2905. var PROPER_TRANSFER = __w_pdfjs_require__(119);
  2906. var TypeError = global.TypeError;
  2907. var structuredClone = global.structuredClone;
  2908. var ArrayBuffer = global.ArrayBuffer;
  2909. var DataView = global.DataView;
  2910. var min = Math.min;
  2911. var ArrayBufferPrototype = ArrayBuffer.prototype;
  2912. var DataViewPrototype = DataView.prototype;
  2913. var slice = uncurryThis(ArrayBufferPrototype.slice);
  2914. var isResizable = uncurryThisAccessor(ArrayBufferPrototype, 'resizable', 'get');
  2915. var maxByteLength = uncurryThisAccessor(ArrayBufferPrototype, 'maxByteLength', 'get');
  2916. var getInt8 = uncurryThis(DataViewPrototype.getInt8);
  2917. var setInt8 = uncurryThis(DataViewPrototype.setInt8);
  2918. module.exports = PROPER_TRANSFER && function (arrayBuffer, newLength, preserveResizability) {
  2919. var byteLength = arrayBufferByteLength(arrayBuffer);
  2920. var newByteLength = newLength === undefined ? byteLength : toIndex(newLength);
  2921. var fixedLength = !isResizable || !isResizable(arrayBuffer);
  2922. if (isDetached(arrayBuffer))
  2923. throw TypeError('ArrayBuffer is detached');
  2924. var newBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] });
  2925. if (byteLength === newByteLength && (preserveResizability || fixedLength))
  2926. return newBuffer;
  2927. if (byteLength >= newByteLength && (!preserveResizability || fixedLength))
  2928. return slice(newBuffer, 0, newByteLength);
  2929. var options = preserveResizability && !fixedLength && maxByteLength ? { maxByteLength: maxByteLength(newBuffer) } : undefined;
  2930. var newNewBuffer = new ArrayBuffer(newByteLength, options);
  2931. var a = new DataView(newBuffer);
  2932. var b = new DataView(newNewBuffer);
  2933. var copyLength = min(newByteLength, byteLength);
  2934. for (var i = 0; i < copyLength; i++)
  2935. setInt8(b, i, getInt8(a, i));
  2936. return newNewBuffer;
  2937. };
  2938. /***/ }),
  2939. /* 118 */
  2940. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2941. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  2942. var toLength = __w_pdfjs_require__(65);
  2943. var $RangeError = RangeError;
  2944. module.exports = function (it) {
  2945. if (it === undefined)
  2946. return 0;
  2947. var number = toIntegerOrInfinity(it);
  2948. var length = toLength(number);
  2949. if (number !== length)
  2950. throw $RangeError('Wrong length or index');
  2951. return length;
  2952. };
  2953. /***/ }),
  2954. /* 119 */
  2955. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2956. var global = __w_pdfjs_require__(4);
  2957. var fails = __w_pdfjs_require__(7);
  2958. var V8 = __w_pdfjs_require__(28);
  2959. var IS_BROWSER = __w_pdfjs_require__(120);
  2960. var IS_DENO = __w_pdfjs_require__(121);
  2961. var IS_NODE = __w_pdfjs_require__(122);
  2962. var structuredClone = global.structuredClone;
  2963. module.exports = !!structuredClone && !fails(function () {
  2964. if (IS_DENO && V8 > 92 || IS_NODE && V8 > 94 || IS_BROWSER && V8 > 97)
  2965. return false;
  2966. var buffer = new ArrayBuffer(8);
  2967. var clone = structuredClone(buffer, { transfer: [buffer] });
  2968. return buffer.byteLength !== 0 || clone.byteLength !== 8;
  2969. });
  2970. /***/ }),
  2971. /* 120 */
  2972. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2973. var IS_DENO = __w_pdfjs_require__(121);
  2974. var IS_NODE = __w_pdfjs_require__(122);
  2975. module.exports = !IS_DENO && !IS_NODE && typeof window == 'object' && typeof document == 'object';
  2976. /***/ }),
  2977. /* 121 */
  2978. /***/ ((module) => {
  2979. module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object';
  2980. /***/ }),
  2981. /* 122 */
  2982. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2983. var global = __w_pdfjs_require__(4);
  2984. var classof = __w_pdfjs_require__(15);
  2985. module.exports = classof(global.process) === 'process';
  2986. /***/ }),
  2987. /* 123 */
  2988. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  2989. var $ = __w_pdfjs_require__(3);
  2990. var $transfer = __w_pdfjs_require__(117);
  2991. if ($transfer)
  2992. $({
  2993. target: 'ArrayBuffer',
  2994. proto: true
  2995. }, {
  2996. transferToFixedLength: function transferToFixedLength() {
  2997. return $transfer(this, arguments.length ? arguments[0] : undefined, false);
  2998. }
  2999. });
  3000. /***/ }),
  3001. /* 124 */
  3002. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3003. Object.defineProperty(exports, "__esModule", ({
  3004. value: true
  3005. }));
  3006. exports.RenderTask = exports.PDFWorkerUtil = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDocumentLoadingTask = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultStandardFontDataFactory = exports.DefaultFilterFactory = exports.DefaultCanvasFactory = exports.DefaultCMapReaderFactory = void 0;
  3007. Object.defineProperty(exports, "SVGGraphics", ({
  3008. enumerable: true,
  3009. get: function () {
  3010. return _displaySvg.SVGGraphics;
  3011. }
  3012. }));
  3013. exports.build = void 0;
  3014. exports.getDocument = getDocument;
  3015. exports.version = void 0;
  3016. __w_pdfjs_require__(84);
  3017. __w_pdfjs_require__(86);
  3018. __w_pdfjs_require__(87);
  3019. __w_pdfjs_require__(2);
  3020. __w_pdfjs_require__(93);
  3021. __w_pdfjs_require__(101);
  3022. __w_pdfjs_require__(102);
  3023. __w_pdfjs_require__(105);
  3024. __w_pdfjs_require__(107);
  3025. __w_pdfjs_require__(109);
  3026. __w_pdfjs_require__(113);
  3027. __w_pdfjs_require__(116);
  3028. __w_pdfjs_require__(123);
  3029. __w_pdfjs_require__(89);
  3030. __w_pdfjs_require__(125);
  3031. __w_pdfjs_require__(136);
  3032. __w_pdfjs_require__(138);
  3033. __w_pdfjs_require__(141);
  3034. __w_pdfjs_require__(143);
  3035. __w_pdfjs_require__(145);
  3036. __w_pdfjs_require__(147);
  3037. __w_pdfjs_require__(149);
  3038. __w_pdfjs_require__(152);
  3039. var _util = __w_pdfjs_require__(1);
  3040. var _annotation_storage = __w_pdfjs_require__(163);
  3041. var _display_utils = __w_pdfjs_require__(168);
  3042. var _font_loader = __w_pdfjs_require__(171);
  3043. var _displayNode_utils = __w_pdfjs_require__(172);
  3044. var _canvas = __w_pdfjs_require__(173);
  3045. var _worker_options = __w_pdfjs_require__(176);
  3046. var _message_handler = __w_pdfjs_require__(177);
  3047. var _metadata = __w_pdfjs_require__(178);
  3048. var _optional_content_config = __w_pdfjs_require__(179);
  3049. var _transport_stream = __w_pdfjs_require__(180);
  3050. var _displayFetch_stream = __w_pdfjs_require__(181);
  3051. var _displayNetwork = __w_pdfjs_require__(184);
  3052. var _displayNode_stream = __w_pdfjs_require__(185);
  3053. var _displaySvg = __w_pdfjs_require__(186);
  3054. var _xfa_text = __w_pdfjs_require__(194);
  3055. const DEFAULT_RANGE_CHUNK_SIZE = 65536;
  3056. const RENDERING_CANCELLED_TIMEOUT = 100;
  3057. const DELAYED_CLEANUP_TIMEOUT = 5000;
  3058. const DefaultCanvasFactory = _util.isNodeJS ? _displayNode_utils.NodeCanvasFactory : _display_utils.DOMCanvasFactory;
  3059. exports.DefaultCanvasFactory = DefaultCanvasFactory;
  3060. const DefaultCMapReaderFactory = _util.isNodeJS ? _displayNode_utils.NodeCMapReaderFactory : _display_utils.DOMCMapReaderFactory;
  3061. exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory;
  3062. const DefaultFilterFactory = _util.isNodeJS ? _displayNode_utils.NodeFilterFactory : _display_utils.DOMFilterFactory;
  3063. exports.DefaultFilterFactory = DefaultFilterFactory;
  3064. const DefaultStandardFontDataFactory = _util.isNodeJS ? _displayNode_utils.NodeStandardFontDataFactory : _display_utils.DOMStandardFontDataFactory;
  3065. exports.DefaultStandardFontDataFactory = DefaultStandardFontDataFactory;
  3066. function getDocument(src) {
  3067. if (typeof src === "string" || src instanceof URL) {
  3068. src = {
  3069. url: src
  3070. };
  3071. } else if ((0, _util.isArrayBuffer)(src)) {
  3072. src = {
  3073. data: src
  3074. };
  3075. }
  3076. if (typeof src !== "object") {
  3077. throw new Error("Invalid parameter in getDocument, need parameter object.");
  3078. }
  3079. if (!src.url && !src.data && !src.range) {
  3080. throw new Error("Invalid parameter object: need either .data, .range or .url");
  3081. }
  3082. const task = new PDFDocumentLoadingTask();
  3083. const {
  3084. docId
  3085. } = task;
  3086. const url = src.url ? getUrlProp(src.url) : null;
  3087. const data = src.data ? getDataProp(src.data) : null;
  3088. const httpHeaders = src.httpHeaders || null;
  3089. const withCredentials = src.withCredentials === true;
  3090. const password = src.password ?? null;
  3091. const rangeTransport = src.range instanceof PDFDataRangeTransport ? src.range : null;
  3092. const rangeChunkSize = Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0 ? src.rangeChunkSize : DEFAULT_RANGE_CHUNK_SIZE;
  3093. let worker = src.worker instanceof PDFWorker ? src.worker : null;
  3094. const verbosity = src.verbosity;
  3095. const docBaseUrl = typeof src.docBaseUrl === "string" && !(0, _display_utils.isDataScheme)(src.docBaseUrl) ? src.docBaseUrl : null;
  3096. const cMapUrl = typeof src.cMapUrl === "string" ? src.cMapUrl : null;
  3097. const cMapPacked = src.cMapPacked !== false;
  3098. const CMapReaderFactory = src.CMapReaderFactory || DefaultCMapReaderFactory;
  3099. const standardFontDataUrl = typeof src.standardFontDataUrl === "string" ? src.standardFontDataUrl : null;
  3100. const StandardFontDataFactory = src.StandardFontDataFactory || DefaultStandardFontDataFactory;
  3101. const ignoreErrors = src.stopAtErrors !== true;
  3102. const maxImageSize = Number.isInteger(src.maxImageSize) && src.maxImageSize > -1 ? src.maxImageSize : -1;
  3103. const isEvalSupported = src.isEvalSupported !== false;
  3104. const isOffscreenCanvasSupported = typeof src.isOffscreenCanvasSupported === "boolean" ? src.isOffscreenCanvasSupported : !_util.isNodeJS;
  3105. const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes) ? src.canvasMaxAreaInBytes : -1;
  3106. const disableFontFace = typeof src.disableFontFace === "boolean" ? src.disableFontFace : _util.isNodeJS;
  3107. const fontExtraProperties = src.fontExtraProperties === true;
  3108. const enableXfa = src.enableXfa === true;
  3109. const ownerDocument = src.ownerDocument || globalThis.document;
  3110. const disableRange = src.disableRange === true;
  3111. const disableStream = src.disableStream === true;
  3112. const disableAutoFetch = src.disableAutoFetch === true;
  3113. const pdfBug = src.pdfBug === true;
  3114. const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
  3115. const useSystemFonts = typeof src.useSystemFonts === "boolean" ? src.useSystemFonts : !_util.isNodeJS && !disableFontFace;
  3116. const useWorkerFetch = typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : CMapReaderFactory === _display_utils.DOMCMapReaderFactory && StandardFontDataFactory === _display_utils.DOMStandardFontDataFactory && cMapUrl && standardFontDataUrl && (0, _display_utils.isValidFetchUrl)(cMapUrl, document.baseURI) && (0, _display_utils.isValidFetchUrl)(standardFontDataUrl, document.baseURI);
  3117. const canvasFactory = src.canvasFactory || new DefaultCanvasFactory({
  3118. ownerDocument
  3119. });
  3120. const filterFactory = src.filterFactory || new DefaultFilterFactory({
  3121. docId,
  3122. ownerDocument
  3123. });
  3124. const styleElement = null;
  3125. (0, _util.setVerbosityLevel)(verbosity);
  3126. const transportFactory = {
  3127. canvasFactory,
  3128. filterFactory
  3129. };
  3130. if (!useWorkerFetch) {
  3131. transportFactory.cMapReaderFactory = new CMapReaderFactory({
  3132. baseUrl: cMapUrl,
  3133. isCompressed: cMapPacked
  3134. });
  3135. transportFactory.standardFontDataFactory = new StandardFontDataFactory({
  3136. baseUrl: standardFontDataUrl
  3137. });
  3138. }
  3139. if (!worker) {
  3140. const workerParams = {
  3141. verbosity,
  3142. port: _worker_options.GlobalWorkerOptions.workerPort
  3143. };
  3144. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  3145. task._worker = worker;
  3146. }
  3147. const fetchDocParams = {
  3148. docId,
  3149. apiVersion: '3.10.111',
  3150. data,
  3151. password,
  3152. disableAutoFetch,
  3153. rangeChunkSize,
  3154. length,
  3155. docBaseUrl,
  3156. enableXfa,
  3157. evaluatorOptions: {
  3158. maxImageSize,
  3159. disableFontFace,
  3160. ignoreErrors,
  3161. isEvalSupported,
  3162. isOffscreenCanvasSupported,
  3163. canvasMaxAreaInBytes,
  3164. fontExtraProperties,
  3165. useSystemFonts,
  3166. cMapUrl: useWorkerFetch ? cMapUrl : null,
  3167. standardFontDataUrl: useWorkerFetch ? standardFontDataUrl : null
  3168. }
  3169. };
  3170. const transportParams = {
  3171. ignoreErrors,
  3172. isEvalSupported,
  3173. disableFontFace,
  3174. fontExtraProperties,
  3175. enableXfa,
  3176. ownerDocument,
  3177. disableAutoFetch,
  3178. pdfBug,
  3179. styleElement
  3180. };
  3181. worker.promise.then(function () {
  3182. if (task.destroyed) {
  3183. throw new Error("Loading aborted");
  3184. }
  3185. const workerIdPromise = _fetchDocument(worker, fetchDocParams);
  3186. const networkStreamPromise = new Promise(function (resolve) {
  3187. let networkStream;
  3188. if (rangeTransport) {
  3189. networkStream = new _transport_stream.PDFDataTransportStream({
  3190. length,
  3191. initialData: rangeTransport.initialData,
  3192. progressiveDone: rangeTransport.progressiveDone,
  3193. contentDispositionFilename: rangeTransport.contentDispositionFilename,
  3194. disableRange,
  3195. disableStream
  3196. }, rangeTransport);
  3197. } else if (!data) {
  3198. const createPDFNetworkStream = params => {
  3199. if (_util.isNodeJS) {
  3200. return new _displayNode_stream.PDFNodeStream(params);
  3201. }
  3202. return (0, _display_utils.isValidFetchUrl)(params.url) ? new _displayFetch_stream.PDFFetchStream(params) : new _displayNetwork.PDFNetworkStream(params);
  3203. };
  3204. networkStream = createPDFNetworkStream({
  3205. url,
  3206. length,
  3207. httpHeaders,
  3208. withCredentials,
  3209. rangeChunkSize,
  3210. disableRange,
  3211. disableStream
  3212. });
  3213. }
  3214. resolve(networkStream);
  3215. });
  3216. return Promise.all([workerIdPromise, networkStreamPromise]).then(function (_ref) {
  3217. let [workerId, networkStream] = _ref;
  3218. if (task.destroyed) {
  3219. throw new Error("Loading aborted");
  3220. }
  3221. const messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  3222. const transport = new WorkerTransport(messageHandler, task, networkStream, transportParams, transportFactory);
  3223. task._transport = transport;
  3224. messageHandler.send("Ready", null);
  3225. });
  3226. }).catch(task._capability.reject);
  3227. return task;
  3228. }
  3229. async function _fetchDocument(worker, source) {
  3230. if (worker.destroyed) {
  3231. throw new Error("Worker was destroyed");
  3232. }
  3233. const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", source, source.data ? [source.data.buffer] : null);
  3234. if (worker.destroyed) {
  3235. throw new Error("Worker was destroyed");
  3236. }
  3237. return workerId;
  3238. }
  3239. function getUrlProp(val) {
  3240. if (val instanceof URL) {
  3241. return val.href;
  3242. }
  3243. try {
  3244. return new URL(val, window.location).href;
  3245. } catch {
  3246. if (_util.isNodeJS && typeof val === "string") {
  3247. return val;
  3248. }
  3249. }
  3250. throw new Error("Invalid PDF url data: " + "either string or URL-object is expected in the url property.");
  3251. }
  3252. function getDataProp(val) {
  3253. if (_util.isNodeJS && typeof Buffer !== "undefined" && val instanceof Buffer) {
  3254. throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");
  3255. }
  3256. if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
  3257. return val;
  3258. }
  3259. if (typeof val === "string") {
  3260. return (0, _util.stringToBytes)(val);
  3261. }
  3262. if (typeof val === "object" && !isNaN(val?.length) || (0, _util.isArrayBuffer)(val)) {
  3263. return new Uint8Array(val);
  3264. }
  3265. throw new Error("Invalid PDF binary data: either TypedArray, " + "string, or array-like object is expected in the data property.");
  3266. }
  3267. class PDFDocumentLoadingTask {
  3268. static #docId = 0;
  3269. constructor() {
  3270. this._capability = new _util.PromiseCapability();
  3271. this._transport = null;
  3272. this._worker = null;
  3273. this.docId = `d${PDFDocumentLoadingTask.#docId++}`;
  3274. this.destroyed = false;
  3275. this.onPassword = null;
  3276. this.onProgress = null;
  3277. }
  3278. get promise() {
  3279. return this._capability.promise;
  3280. }
  3281. async destroy() {
  3282. this.destroyed = true;
  3283. try {
  3284. if (this._worker?.port) {
  3285. this._worker._pendingDestroy = true;
  3286. }
  3287. await this._transport?.destroy();
  3288. } catch (ex) {
  3289. if (this._worker?.port) {
  3290. delete this._worker._pendingDestroy;
  3291. }
  3292. throw ex;
  3293. }
  3294. this._transport = null;
  3295. if (this._worker) {
  3296. this._worker.destroy();
  3297. this._worker = null;
  3298. }
  3299. }
  3300. }
  3301. exports.PDFDocumentLoadingTask = PDFDocumentLoadingTask;
  3302. class PDFDataRangeTransport {
  3303. constructor(length, initialData) {
  3304. let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3305. let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  3306. this.length = length;
  3307. this.initialData = initialData;
  3308. this.progressiveDone = progressiveDone;
  3309. this.contentDispositionFilename = contentDispositionFilename;
  3310. this._rangeListeners = [];
  3311. this._progressListeners = [];
  3312. this._progressiveReadListeners = [];
  3313. this._progressiveDoneListeners = [];
  3314. this._readyCapability = new _util.PromiseCapability();
  3315. }
  3316. addRangeListener(listener) {
  3317. this._rangeListeners.push(listener);
  3318. }
  3319. addProgressListener(listener) {
  3320. this._progressListeners.push(listener);
  3321. }
  3322. addProgressiveReadListener(listener) {
  3323. this._progressiveReadListeners.push(listener);
  3324. }
  3325. addProgressiveDoneListener(listener) {
  3326. this._progressiveDoneListeners.push(listener);
  3327. }
  3328. onDataRange(begin, chunk) {
  3329. for (const listener of this._rangeListeners) {
  3330. listener(begin, chunk);
  3331. }
  3332. }
  3333. onDataProgress(loaded, total) {
  3334. this._readyCapability.promise.then(() => {
  3335. for (const listener of this._progressListeners) {
  3336. listener(loaded, total);
  3337. }
  3338. });
  3339. }
  3340. onDataProgressiveRead(chunk) {
  3341. this._readyCapability.promise.then(() => {
  3342. for (const listener of this._progressiveReadListeners) {
  3343. listener(chunk);
  3344. }
  3345. });
  3346. }
  3347. onDataProgressiveDone() {
  3348. this._readyCapability.promise.then(() => {
  3349. for (const listener of this._progressiveDoneListeners) {
  3350. listener();
  3351. }
  3352. });
  3353. }
  3354. transportReady() {
  3355. this._readyCapability.resolve();
  3356. }
  3357. requestDataRange(begin, end) {
  3358. (0, _util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange");
  3359. }
  3360. abort() {}
  3361. }
  3362. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  3363. class PDFDocumentProxy {
  3364. constructor(pdfInfo, transport) {
  3365. this._pdfInfo = pdfInfo;
  3366. this._transport = transport;
  3367. Object.defineProperty(this, "getJavaScript", {
  3368. value: () => {
  3369. (0, _display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, " + "please use `PDFDocumentProxy.getJSActions` instead.");
  3370. return this.getJSActions().then(js => {
  3371. if (!js) {
  3372. return js;
  3373. }
  3374. const jsArr = [];
  3375. for (const name in js) {
  3376. jsArr.push(...js[name]);
  3377. }
  3378. return jsArr;
  3379. });
  3380. }
  3381. });
  3382. }
  3383. get annotationStorage() {
  3384. return this._transport.annotationStorage;
  3385. }
  3386. get filterFactory() {
  3387. return this._transport.filterFactory;
  3388. }
  3389. get numPages() {
  3390. return this._pdfInfo.numPages;
  3391. }
  3392. get fingerprints() {
  3393. return this._pdfInfo.fingerprints;
  3394. }
  3395. get isPureXfa() {
  3396. return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
  3397. }
  3398. get allXfaHtml() {
  3399. return this._transport._htmlForXfa;
  3400. }
  3401. getPage(pageNumber) {
  3402. return this._transport.getPage(pageNumber);
  3403. }
  3404. getPageIndex(ref) {
  3405. return this._transport.getPageIndex(ref);
  3406. }
  3407. getDestinations() {
  3408. return this._transport.getDestinations();
  3409. }
  3410. getDestination(id) {
  3411. return this._transport.getDestination(id);
  3412. }
  3413. getPageLabels() {
  3414. return this._transport.getPageLabels();
  3415. }
  3416. getPageLayout() {
  3417. return this._transport.getPageLayout();
  3418. }
  3419. getPageMode() {
  3420. return this._transport.getPageMode();
  3421. }
  3422. getViewerPreferences() {
  3423. return this._transport.getViewerPreferences();
  3424. }
  3425. getOpenAction() {
  3426. return this._transport.getOpenAction();
  3427. }
  3428. getAttachments() {
  3429. return this._transport.getAttachments();
  3430. }
  3431. getJSActions() {
  3432. return this._transport.getDocJSActions();
  3433. }
  3434. getOutline() {
  3435. return this._transport.getOutline();
  3436. }
  3437. getOptionalContentConfig() {
  3438. return this._transport.getOptionalContentConfig();
  3439. }
  3440. getPermissions() {
  3441. return this._transport.getPermissions();
  3442. }
  3443. getMetadata() {
  3444. return this._transport.getMetadata();
  3445. }
  3446. getMarkInfo() {
  3447. return this._transport.getMarkInfo();
  3448. }
  3449. getData() {
  3450. return this._transport.getData();
  3451. }
  3452. saveDocument() {
  3453. return this._transport.saveDocument();
  3454. }
  3455. getDownloadInfo() {
  3456. return this._transport.downloadInfoCapability.promise;
  3457. }
  3458. cleanup() {
  3459. let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3460. return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
  3461. }
  3462. destroy() {
  3463. return this.loadingTask.destroy();
  3464. }
  3465. get loadingParams() {
  3466. return this._transport.loadingParams;
  3467. }
  3468. get loadingTask() {
  3469. return this._transport.loadingTask;
  3470. }
  3471. getFieldObjects() {
  3472. return this._transport.getFieldObjects();
  3473. }
  3474. hasJSActions() {
  3475. return this._transport.hasJSActions();
  3476. }
  3477. getCalculationOrderIds() {
  3478. return this._transport.getCalculationOrderIds();
  3479. }
  3480. }
  3481. exports.PDFDocumentProxy = PDFDocumentProxy;
  3482. class PDFPageProxy {
  3483. #delayedCleanupTimeout = null;
  3484. #pendingCleanup = false;
  3485. constructor(pageIndex, pageInfo, transport) {
  3486. let pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3487. this._pageIndex = pageIndex;
  3488. this._pageInfo = pageInfo;
  3489. this._transport = transport;
  3490. this._stats = pdfBug ? new _display_utils.StatTimer() : null;
  3491. this._pdfBug = pdfBug;
  3492. this.commonObjs = transport.commonObjs;
  3493. this.objs = new PDFObjects();
  3494. this._maybeCleanupAfterRender = false;
  3495. this._intentStates = new Map();
  3496. this.destroyed = false;
  3497. }
  3498. get pageNumber() {
  3499. return this._pageIndex + 1;
  3500. }
  3501. get rotate() {
  3502. return this._pageInfo.rotate;
  3503. }
  3504. get ref() {
  3505. return this._pageInfo.ref;
  3506. }
  3507. get userUnit() {
  3508. return this._pageInfo.userUnit;
  3509. }
  3510. get view() {
  3511. return this._pageInfo.view;
  3512. }
  3513. getViewport() {
  3514. let {
  3515. scale,
  3516. rotation = this.rotate,
  3517. offsetX = 0,
  3518. offsetY = 0,
  3519. dontFlip = false
  3520. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3521. return new _display_utils.PageViewport({
  3522. viewBox: this.view,
  3523. scale,
  3524. rotation,
  3525. offsetX,
  3526. offsetY,
  3527. dontFlip
  3528. });
  3529. }
  3530. getAnnotations() {
  3531. let {
  3532. intent = "display"
  3533. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3534. const intentArgs = this._transport.getRenderingIntent(intent);
  3535. return this._transport.getAnnotations(this._pageIndex, intentArgs.renderingIntent);
  3536. }
  3537. getJSActions() {
  3538. return this._transport.getPageJSActions(this._pageIndex);
  3539. }
  3540. get filterFactory() {
  3541. return this._transport.filterFactory;
  3542. }
  3543. get isPureXfa() {
  3544. return (0, _util.shadow)(this, "isPureXfa", !!this._transport._htmlForXfa);
  3545. }
  3546. async getXfa() {
  3547. return this._transport._htmlForXfa?.children[this._pageIndex] || null;
  3548. }
  3549. render(_ref2) {
  3550. let {
  3551. canvasContext,
  3552. viewport,
  3553. intent = "display",
  3554. annotationMode = _util.AnnotationMode.ENABLE,
  3555. transform = null,
  3556. background = null,
  3557. optionalContentConfigPromise = null,
  3558. annotationCanvasMap = null,
  3559. pageColors = null,
  3560. printAnnotationStorage = null
  3561. } = _ref2;
  3562. this._stats?.time("Overall");
  3563. const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage);
  3564. this.#pendingCleanup = false;
  3565. this.#abortDelayedCleanup();
  3566. if (!optionalContentConfigPromise) {
  3567. optionalContentConfigPromise = this._transport.getOptionalContentConfig();
  3568. }
  3569. let intentState = this._intentStates.get(intentArgs.cacheKey);
  3570. if (!intentState) {
  3571. intentState = Object.create(null);
  3572. this._intentStates.set(intentArgs.cacheKey, intentState);
  3573. }
  3574. if (intentState.streamReaderCancelTimeout) {
  3575. clearTimeout(intentState.streamReaderCancelTimeout);
  3576. intentState.streamReaderCancelTimeout = null;
  3577. }
  3578. const intentPrint = !!(intentArgs.renderingIntent & _util.RenderingIntentFlag.PRINT);
  3579. if (!intentState.displayReadyCapability) {
  3580. intentState.displayReadyCapability = new _util.PromiseCapability();
  3581. intentState.operatorList = {
  3582. fnArray: [],
  3583. argsArray: [],
  3584. lastChunk: false,
  3585. separateAnnots: null
  3586. };
  3587. this._stats?.time("Page Request");
  3588. this._pumpOperatorList(intentArgs);
  3589. }
  3590. const complete = error => {
  3591. intentState.renderTasks.delete(internalRenderTask);
  3592. if (this._maybeCleanupAfterRender || intentPrint) {
  3593. this.#pendingCleanup = true;
  3594. }
  3595. this.#tryCleanup(!intentPrint);
  3596. if (error) {
  3597. internalRenderTask.capability.reject(error);
  3598. this._abortOperatorList({
  3599. intentState,
  3600. reason: error instanceof Error ? error : new Error(error)
  3601. });
  3602. } else {
  3603. internalRenderTask.capability.resolve();
  3604. }
  3605. this._stats?.timeEnd("Rendering");
  3606. this._stats?.timeEnd("Overall");
  3607. };
  3608. const internalRenderTask = new InternalRenderTask({
  3609. callback: complete,
  3610. params: {
  3611. canvasContext,
  3612. viewport,
  3613. transform,
  3614. background
  3615. },
  3616. objs: this.objs,
  3617. commonObjs: this.commonObjs,
  3618. annotationCanvasMap,
  3619. operatorList: intentState.operatorList,
  3620. pageIndex: this._pageIndex,
  3621. canvasFactory: this._transport.canvasFactory,
  3622. filterFactory: this._transport.filterFactory,
  3623. useRequestAnimationFrame: !intentPrint,
  3624. pdfBug: this._pdfBug,
  3625. pageColors
  3626. });
  3627. (intentState.renderTasks ||= new Set()).add(internalRenderTask);
  3628. const renderTask = internalRenderTask.task;
  3629. Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(_ref3 => {
  3630. let [transparency, optionalContentConfig] = _ref3;
  3631. if (this.destroyed) {
  3632. complete();
  3633. return;
  3634. }
  3635. this._stats?.time("Rendering");
  3636. internalRenderTask.initializeGraphics({
  3637. transparency,
  3638. optionalContentConfig
  3639. });
  3640. internalRenderTask.operatorListChanged();
  3641. }).catch(complete);
  3642. return renderTask;
  3643. }
  3644. getOperatorList() {
  3645. let {
  3646. intent = "display",
  3647. annotationMode = _util.AnnotationMode.ENABLE,
  3648. printAnnotationStorage = null
  3649. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3650. function operatorListChanged() {
  3651. if (intentState.operatorList.lastChunk) {
  3652. intentState.opListReadCapability.resolve(intentState.operatorList);
  3653. intentState.renderTasks.delete(opListTask);
  3654. }
  3655. }
  3656. const intentArgs = this._transport.getRenderingIntent(intent, annotationMode, printAnnotationStorage, true);
  3657. let intentState = this._intentStates.get(intentArgs.cacheKey);
  3658. if (!intentState) {
  3659. intentState = Object.create(null);
  3660. this._intentStates.set(intentArgs.cacheKey, intentState);
  3661. }
  3662. let opListTask;
  3663. if (!intentState.opListReadCapability) {
  3664. opListTask = Object.create(null);
  3665. opListTask.operatorListChanged = operatorListChanged;
  3666. intentState.opListReadCapability = new _util.PromiseCapability();
  3667. (intentState.renderTasks ||= new Set()).add(opListTask);
  3668. intentState.operatorList = {
  3669. fnArray: [],
  3670. argsArray: [],
  3671. lastChunk: false,
  3672. separateAnnots: null
  3673. };
  3674. this._stats?.time("Page Request");
  3675. this._pumpOperatorList(intentArgs);
  3676. }
  3677. return intentState.opListReadCapability.promise;
  3678. }
  3679. streamTextContent() {
  3680. let {
  3681. includeMarkedContent = false,
  3682. disableNormalization = false
  3683. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3684. const TEXT_CONTENT_CHUNK_SIZE = 100;
  3685. return this._transport.messageHandler.sendWithStream("GetTextContent", {
  3686. pageIndex: this._pageIndex,
  3687. includeMarkedContent: includeMarkedContent === true,
  3688. disableNormalization: disableNormalization === true
  3689. }, {
  3690. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  3691. size(textContent) {
  3692. return textContent.items.length;
  3693. }
  3694. });
  3695. }
  3696. getTextContent() {
  3697. let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3698. if (this._transport._htmlForXfa) {
  3699. return this.getXfa().then(xfa => {
  3700. return _xfa_text.XfaText.textContent(xfa);
  3701. });
  3702. }
  3703. const readableStream = this.streamTextContent(params);
  3704. return new Promise(function (resolve, reject) {
  3705. function pump() {
  3706. reader.read().then(function (_ref4) {
  3707. let {
  3708. value,
  3709. done
  3710. } = _ref4;
  3711. if (done) {
  3712. resolve(textContent);
  3713. return;
  3714. }
  3715. Object.assign(textContent.styles, value.styles);
  3716. textContent.items.push(...value.items);
  3717. pump();
  3718. }, reject);
  3719. }
  3720. const reader = readableStream.getReader();
  3721. const textContent = {
  3722. items: [],
  3723. styles: Object.create(null)
  3724. };
  3725. pump();
  3726. });
  3727. }
  3728. getStructTree() {
  3729. return this._transport.getStructTree(this._pageIndex);
  3730. }
  3731. _destroy() {
  3732. this.destroyed = true;
  3733. const waitOn = [];
  3734. for (const intentState of this._intentStates.values()) {
  3735. this._abortOperatorList({
  3736. intentState,
  3737. reason: new Error("Page was destroyed."),
  3738. force: true
  3739. });
  3740. if (intentState.opListReadCapability) {
  3741. continue;
  3742. }
  3743. for (const internalRenderTask of intentState.renderTasks) {
  3744. waitOn.push(internalRenderTask.completed);
  3745. internalRenderTask.cancel();
  3746. }
  3747. }
  3748. this.objs.clear();
  3749. this.#pendingCleanup = false;
  3750. this.#abortDelayedCleanup();
  3751. return Promise.all(waitOn);
  3752. }
  3753. cleanup() {
  3754. let resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3755. this.#pendingCleanup = true;
  3756. const success = this.#tryCleanup(false);
  3757. if (resetStats && success) {
  3758. this._stats &&= new _display_utils.StatTimer();
  3759. }
  3760. return success;
  3761. }
  3762. #tryCleanup() {
  3763. let delayed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3764. this.#abortDelayedCleanup();
  3765. if (!this.#pendingCleanup || this.destroyed) {
  3766. return false;
  3767. }
  3768. if (delayed) {
  3769. this.#delayedCleanupTimeout = setTimeout(() => {
  3770. this.#delayedCleanupTimeout = null;
  3771. this.#tryCleanup(false);
  3772. }, DELAYED_CLEANUP_TIMEOUT);
  3773. return false;
  3774. }
  3775. for (const {
  3776. renderTasks,
  3777. operatorList
  3778. } of this._intentStates.values()) {
  3779. if (renderTasks.size > 0 || !operatorList.lastChunk) {
  3780. return false;
  3781. }
  3782. }
  3783. this._intentStates.clear();
  3784. this.objs.clear();
  3785. this.#pendingCleanup = false;
  3786. return true;
  3787. }
  3788. #abortDelayedCleanup() {
  3789. if (this.#delayedCleanupTimeout) {
  3790. clearTimeout(this.#delayedCleanupTimeout);
  3791. this.#delayedCleanupTimeout = null;
  3792. }
  3793. }
  3794. _startRenderPage(transparency, cacheKey) {
  3795. const intentState = this._intentStates.get(cacheKey);
  3796. if (!intentState) {
  3797. return;
  3798. }
  3799. this._stats?.timeEnd("Page Request");
  3800. intentState.displayReadyCapability?.resolve(transparency);
  3801. }
  3802. _renderPageChunk(operatorListChunk, intentState) {
  3803. for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {
  3804. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  3805. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  3806. }
  3807. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  3808. intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;
  3809. for (const internalRenderTask of intentState.renderTasks) {
  3810. internalRenderTask.operatorListChanged();
  3811. }
  3812. if (operatorListChunk.lastChunk) {
  3813. this.#tryCleanup(true);
  3814. }
  3815. }
  3816. _pumpOperatorList(_ref5) {
  3817. let {
  3818. renderingIntent,
  3819. cacheKey,
  3820. annotationStorageSerializable
  3821. } = _ref5;
  3822. const {
  3823. map,
  3824. transfers
  3825. } = annotationStorageSerializable;
  3826. const readableStream = this._transport.messageHandler.sendWithStream("GetOperatorList", {
  3827. pageIndex: this._pageIndex,
  3828. intent: renderingIntent,
  3829. cacheKey,
  3830. annotationStorage: map
  3831. }, transfers);
  3832. const reader = readableStream.getReader();
  3833. const intentState = this._intentStates.get(cacheKey);
  3834. intentState.streamReader = reader;
  3835. const pump = () => {
  3836. reader.read().then(_ref6 => {
  3837. let {
  3838. value,
  3839. done
  3840. } = _ref6;
  3841. if (done) {
  3842. intentState.streamReader = null;
  3843. return;
  3844. }
  3845. if (this._transport.destroyed) {
  3846. return;
  3847. }
  3848. this._renderPageChunk(value, intentState);
  3849. pump();
  3850. }, reason => {
  3851. intentState.streamReader = null;
  3852. if (this._transport.destroyed) {
  3853. return;
  3854. }
  3855. if (intentState.operatorList) {
  3856. intentState.operatorList.lastChunk = true;
  3857. for (const internalRenderTask of intentState.renderTasks) {
  3858. internalRenderTask.operatorListChanged();
  3859. }
  3860. this.#tryCleanup(true);
  3861. }
  3862. if (intentState.displayReadyCapability) {
  3863. intentState.displayReadyCapability.reject(reason);
  3864. } else if (intentState.opListReadCapability) {
  3865. intentState.opListReadCapability.reject(reason);
  3866. } else {
  3867. throw reason;
  3868. }
  3869. });
  3870. };
  3871. pump();
  3872. }
  3873. _abortOperatorList(_ref7) {
  3874. let {
  3875. intentState,
  3876. reason,
  3877. force = false
  3878. } = _ref7;
  3879. if (!intentState.streamReader) {
  3880. return;
  3881. }
  3882. if (intentState.streamReaderCancelTimeout) {
  3883. clearTimeout(intentState.streamReaderCancelTimeout);
  3884. intentState.streamReaderCancelTimeout = null;
  3885. }
  3886. if (!force) {
  3887. if (intentState.renderTasks.size > 0) {
  3888. return;
  3889. }
  3890. if (reason instanceof _display_utils.RenderingCancelledException) {
  3891. let delay = RENDERING_CANCELLED_TIMEOUT;
  3892. if (reason.extraDelay > 0 && reason.extraDelay < 1000) {
  3893. delay += reason.extraDelay;
  3894. }
  3895. intentState.streamReaderCancelTimeout = setTimeout(() => {
  3896. intentState.streamReaderCancelTimeout = null;
  3897. this._abortOperatorList({
  3898. intentState,
  3899. reason,
  3900. force: true
  3901. });
  3902. }, delay);
  3903. return;
  3904. }
  3905. }
  3906. intentState.streamReader.cancel(new _util.AbortException(reason.message)).catch(() => {});
  3907. intentState.streamReader = null;
  3908. if (this._transport.destroyed) {
  3909. return;
  3910. }
  3911. for (const [curCacheKey, curIntentState] of this._intentStates) {
  3912. if (curIntentState === intentState) {
  3913. this._intentStates.delete(curCacheKey);
  3914. break;
  3915. }
  3916. }
  3917. this.cleanup();
  3918. }
  3919. get stats() {
  3920. return this._stats;
  3921. }
  3922. }
  3923. exports.PDFPageProxy = PDFPageProxy;
  3924. class LoopbackPort {
  3925. #listeners = new Set();
  3926. #deferred = Promise.resolve();
  3927. postMessage(obj, transfer) {
  3928. const event = {
  3929. data: structuredClone(obj, null)
  3930. };
  3931. this.#deferred.then(() => {
  3932. for (const listener of this.#listeners) {
  3933. listener.call(this, event);
  3934. }
  3935. });
  3936. }
  3937. addEventListener(name, listener) {
  3938. this.#listeners.add(listener);
  3939. }
  3940. removeEventListener(name, listener) {
  3941. this.#listeners.delete(listener);
  3942. }
  3943. terminate() {
  3944. this.#listeners.clear();
  3945. }
  3946. }
  3947. exports.LoopbackPort = LoopbackPort;
  3948. const PDFWorkerUtil = {
  3949. isWorkerDisabled: false,
  3950. fallbackWorkerSrc: null,
  3951. fakeWorkerId: 0
  3952. };
  3953. exports.PDFWorkerUtil = PDFWorkerUtil;
  3954. {
  3955. if (_util.isNodeJS && typeof require === "function") {
  3956. PDFWorkerUtil.isWorkerDisabled = true;
  3957. PDFWorkerUtil.fallbackWorkerSrc = "./pdf.worker.js";
  3958. } else if (typeof document === "object") {
  3959. const pdfjsFilePath = document?.currentScript?.src;
  3960. if (pdfjsFilePath) {
  3961. PDFWorkerUtil.fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, ".worker$1$2");
  3962. }
  3963. }
  3964. PDFWorkerUtil.isSameOrigin = function (baseUrl, otherUrl) {
  3965. let base;
  3966. try {
  3967. base = new URL(baseUrl);
  3968. if (!base.origin || base.origin === "null") {
  3969. return false;
  3970. }
  3971. } catch {
  3972. return false;
  3973. }
  3974. const other = new URL(otherUrl, base);
  3975. return base.origin === other.origin;
  3976. };
  3977. PDFWorkerUtil.createCDNWrapper = function (url) {
  3978. const wrapper = `importScripts("${url}");`;
  3979. return URL.createObjectURL(new Blob([wrapper]));
  3980. };
  3981. }
  3982. class PDFWorker {
  3983. static #workerPorts;
  3984. constructor() {
  3985. let {
  3986. name = null,
  3987. port = null,
  3988. verbosity = (0, _util.getVerbosityLevel)()
  3989. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3990. this.name = name;
  3991. this.destroyed = false;
  3992. this.verbosity = verbosity;
  3993. this._readyCapability = new _util.PromiseCapability();
  3994. this._port = null;
  3995. this._webWorker = null;
  3996. this._messageHandler = null;
  3997. if (port) {
  3998. if (PDFWorker.#workerPorts?.has(port)) {
  3999. throw new Error("Cannot use more than one PDFWorker per port.");
  4000. }
  4001. (PDFWorker.#workerPorts ||= new WeakMap()).set(port, this);
  4002. this._initializeFromPort(port);
  4003. return;
  4004. }
  4005. this._initialize();
  4006. }
  4007. get promise() {
  4008. return this._readyCapability.promise;
  4009. }
  4010. get port() {
  4011. return this._port;
  4012. }
  4013. get messageHandler() {
  4014. return this._messageHandler;
  4015. }
  4016. _initializeFromPort(port) {
  4017. this._port = port;
  4018. this._messageHandler = new _message_handler.MessageHandler("main", "worker", port);
  4019. this._messageHandler.on("ready", function () {});
  4020. this._readyCapability.resolve();
  4021. this._messageHandler.send("configure", {
  4022. verbosity: this.verbosity
  4023. });
  4024. }
  4025. _initialize() {
  4026. if (!PDFWorkerUtil.isWorkerDisabled && !PDFWorker._mainThreadWorkerMessageHandler) {
  4027. let {
  4028. workerSrc
  4029. } = PDFWorker;
  4030. try {
  4031. if (!PDFWorkerUtil.isSameOrigin(window.location.href, workerSrc)) {
  4032. workerSrc = PDFWorkerUtil.createCDNWrapper(new URL(workerSrc, window.location).href);
  4033. }
  4034. const worker = new Worker(workerSrc);
  4035. const messageHandler = new _message_handler.MessageHandler("main", "worker", worker);
  4036. const terminateEarly = () => {
  4037. worker.removeEventListener("error", onWorkerError);
  4038. messageHandler.destroy();
  4039. worker.terminate();
  4040. if (this.destroyed) {
  4041. this._readyCapability.reject(new Error("Worker was destroyed"));
  4042. } else {
  4043. this._setupFakeWorker();
  4044. }
  4045. };
  4046. const onWorkerError = () => {
  4047. if (!this._webWorker) {
  4048. terminateEarly();
  4049. }
  4050. };
  4051. worker.addEventListener("error", onWorkerError);
  4052. messageHandler.on("test", data => {
  4053. worker.removeEventListener("error", onWorkerError);
  4054. if (this.destroyed) {
  4055. terminateEarly();
  4056. return;
  4057. }
  4058. if (data) {
  4059. this._messageHandler = messageHandler;
  4060. this._port = worker;
  4061. this._webWorker = worker;
  4062. this._readyCapability.resolve();
  4063. messageHandler.send("configure", {
  4064. verbosity: this.verbosity
  4065. });
  4066. } else {
  4067. this._setupFakeWorker();
  4068. messageHandler.destroy();
  4069. worker.terminate();
  4070. }
  4071. });
  4072. messageHandler.on("ready", data => {
  4073. worker.removeEventListener("error", onWorkerError);
  4074. if (this.destroyed) {
  4075. terminateEarly();
  4076. return;
  4077. }
  4078. try {
  4079. sendTest();
  4080. } catch {
  4081. this._setupFakeWorker();
  4082. }
  4083. });
  4084. const sendTest = () => {
  4085. const testObj = new Uint8Array();
  4086. messageHandler.send("test", testObj, [testObj.buffer]);
  4087. };
  4088. sendTest();
  4089. return;
  4090. } catch {
  4091. (0, _util.info)("The worker has been disabled.");
  4092. }
  4093. }
  4094. this._setupFakeWorker();
  4095. }
  4096. _setupFakeWorker() {
  4097. if (!PDFWorkerUtil.isWorkerDisabled) {
  4098. (0, _util.warn)("Setting up fake worker.");
  4099. PDFWorkerUtil.isWorkerDisabled = true;
  4100. }
  4101. PDFWorker._setupFakeWorkerGlobal.then(WorkerMessageHandler => {
  4102. if (this.destroyed) {
  4103. this._readyCapability.reject(new Error("Worker was destroyed"));
  4104. return;
  4105. }
  4106. const port = new LoopbackPort();
  4107. this._port = port;
  4108. const id = `fake${PDFWorkerUtil.fakeWorkerId++}`;
  4109. const workerHandler = new _message_handler.MessageHandler(id + "_worker", id, port);
  4110. WorkerMessageHandler.setup(workerHandler, port);
  4111. const messageHandler = new _message_handler.MessageHandler(id, id + "_worker", port);
  4112. this._messageHandler = messageHandler;
  4113. this._readyCapability.resolve();
  4114. messageHandler.send("configure", {
  4115. verbosity: this.verbosity
  4116. });
  4117. }).catch(reason => {
  4118. this._readyCapability.reject(new Error(`Setting up fake worker failed: "${reason.message}".`));
  4119. });
  4120. }
  4121. destroy() {
  4122. this.destroyed = true;
  4123. if (this._webWorker) {
  4124. this._webWorker.terminate();
  4125. this._webWorker = null;
  4126. }
  4127. PDFWorker.#workerPorts?.delete(this._port);
  4128. this._port = null;
  4129. if (this._messageHandler) {
  4130. this._messageHandler.destroy();
  4131. this._messageHandler = null;
  4132. }
  4133. }
  4134. static fromPort(params) {
  4135. if (!params?.port) {
  4136. throw new Error("PDFWorker.fromPort - invalid method signature.");
  4137. }
  4138. const cachedPort = this.#workerPorts?.get(params.port);
  4139. if (cachedPort) {
  4140. if (cachedPort._pendingDestroy) {
  4141. throw new Error("PDFWorker.fromPort - the worker is being destroyed.\n" + "Please remember to await `PDFDocumentLoadingTask.destroy()`-calls.");
  4142. }
  4143. return cachedPort;
  4144. }
  4145. return new PDFWorker(params);
  4146. }
  4147. static get workerSrc() {
  4148. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  4149. return _worker_options.GlobalWorkerOptions.workerSrc;
  4150. }
  4151. if (PDFWorkerUtil.fallbackWorkerSrc !== null) {
  4152. if (!_util.isNodeJS) {
  4153. (0, _display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');
  4154. }
  4155. return PDFWorkerUtil.fallbackWorkerSrc;
  4156. }
  4157. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  4158. }
  4159. static get _mainThreadWorkerMessageHandler() {
  4160. try {
  4161. return globalThis.pdfjsWorker?.WorkerMessageHandler || null;
  4162. } catch {
  4163. return null;
  4164. }
  4165. }
  4166. static get _setupFakeWorkerGlobal() {
  4167. const loader = async () => {
  4168. const mainWorkerMessageHandler = this._mainThreadWorkerMessageHandler;
  4169. if (mainWorkerMessageHandler) {
  4170. return mainWorkerMessageHandler;
  4171. }
  4172. if (_util.isNodeJS && typeof require === "function") {
  4173. const worker = eval("require")(this.workerSrc);
  4174. return worker.WorkerMessageHandler;
  4175. }
  4176. await (0, _display_utils.loadScript)(this.workerSrc);
  4177. return window.pdfjsWorker.WorkerMessageHandler;
  4178. };
  4179. return (0, _util.shadow)(this, "_setupFakeWorkerGlobal", loader());
  4180. }
  4181. }
  4182. exports.PDFWorker = PDFWorker;
  4183. class WorkerTransport {
  4184. #methodPromises = new Map();
  4185. #pageCache = new Map();
  4186. #pagePromises = new Map();
  4187. #passwordCapability = null;
  4188. constructor(messageHandler, loadingTask, networkStream, params, factory) {
  4189. this.messageHandler = messageHandler;
  4190. this.loadingTask = loadingTask;
  4191. this.commonObjs = new PDFObjects();
  4192. this.fontLoader = new _font_loader.FontLoader({
  4193. ownerDocument: params.ownerDocument,
  4194. styleElement: params.styleElement
  4195. });
  4196. this._params = params;
  4197. this.canvasFactory = factory.canvasFactory;
  4198. this.filterFactory = factory.filterFactory;
  4199. this.cMapReaderFactory = factory.cMapReaderFactory;
  4200. this.standardFontDataFactory = factory.standardFontDataFactory;
  4201. this.destroyed = false;
  4202. this.destroyCapability = null;
  4203. this._networkStream = networkStream;
  4204. this._fullReader = null;
  4205. this._lastProgress = null;
  4206. this.downloadInfoCapability = new _util.PromiseCapability();
  4207. this.setupMessageHandler();
  4208. }
  4209. #cacheSimpleMethod(name) {
  4210. let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4211. const cachedPromise = this.#methodPromises.get(name);
  4212. if (cachedPromise) {
  4213. return cachedPromise;
  4214. }
  4215. const promise = this.messageHandler.sendWithPromise(name, data);
  4216. this.#methodPromises.set(name, promise);
  4217. return promise;
  4218. }
  4219. get annotationStorage() {
  4220. return (0, _util.shadow)(this, "annotationStorage", new _annotation_storage.AnnotationStorage());
  4221. }
  4222. getRenderingIntent(intent) {
  4223. let annotationMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _util.AnnotationMode.ENABLE;
  4224. let printAnnotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4225. let isOpList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4226. let renderingIntent = _util.RenderingIntentFlag.DISPLAY;
  4227. let annotationStorageSerializable = _annotation_storage.SerializableEmpty;
  4228. switch (intent) {
  4229. case "any":
  4230. renderingIntent = _util.RenderingIntentFlag.ANY;
  4231. break;
  4232. case "display":
  4233. break;
  4234. case "print":
  4235. renderingIntent = _util.RenderingIntentFlag.PRINT;
  4236. break;
  4237. default:
  4238. (0, _util.warn)(`getRenderingIntent - invalid intent: ${intent}`);
  4239. }
  4240. switch (annotationMode) {
  4241. case _util.AnnotationMode.DISABLE:
  4242. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_DISABLE;
  4243. break;
  4244. case _util.AnnotationMode.ENABLE:
  4245. break;
  4246. case _util.AnnotationMode.ENABLE_FORMS:
  4247. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_FORMS;
  4248. break;
  4249. case _util.AnnotationMode.ENABLE_STORAGE:
  4250. renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_STORAGE;
  4251. const annotationStorage = renderingIntent & _util.RenderingIntentFlag.PRINT && printAnnotationStorage instanceof _annotation_storage.PrintAnnotationStorage ? printAnnotationStorage : this.annotationStorage;
  4252. annotationStorageSerializable = annotationStorage.serializable;
  4253. break;
  4254. default:
  4255. (0, _util.warn)(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
  4256. }
  4257. if (isOpList) {
  4258. renderingIntent += _util.RenderingIntentFlag.OPLIST;
  4259. }
  4260. return {
  4261. renderingIntent,
  4262. cacheKey: `${renderingIntent}_${annotationStorageSerializable.hash}`,
  4263. annotationStorageSerializable
  4264. };
  4265. }
  4266. destroy() {
  4267. if (this.destroyCapability) {
  4268. return this.destroyCapability.promise;
  4269. }
  4270. this.destroyed = true;
  4271. this.destroyCapability = new _util.PromiseCapability();
  4272. this.#passwordCapability?.reject(new Error("Worker was destroyed during onPassword callback"));
  4273. const waitOn = [];
  4274. for (const page of this.#pageCache.values()) {
  4275. waitOn.push(page._destroy());
  4276. }
  4277. this.#pageCache.clear();
  4278. this.#pagePromises.clear();
  4279. if (this.hasOwnProperty("annotationStorage")) {
  4280. this.annotationStorage.resetModified();
  4281. }
  4282. const terminated = this.messageHandler.sendWithPromise("Terminate", null);
  4283. waitOn.push(terminated);
  4284. Promise.all(waitOn).then(() => {
  4285. this.commonObjs.clear();
  4286. this.fontLoader.clear();
  4287. this.#methodPromises.clear();
  4288. this.filterFactory.destroy();
  4289. this._networkStream?.cancelAllRequests(new _util.AbortException("Worker was terminated."));
  4290. if (this.messageHandler) {
  4291. this.messageHandler.destroy();
  4292. this.messageHandler = null;
  4293. }
  4294. this.destroyCapability.resolve();
  4295. }, this.destroyCapability.reject);
  4296. return this.destroyCapability.promise;
  4297. }
  4298. setupMessageHandler() {
  4299. const {
  4300. messageHandler,
  4301. loadingTask
  4302. } = this;
  4303. messageHandler.on("GetReader", (data, sink) => {
  4304. (0, _util.assert)(this._networkStream, "GetReader - no `IPDFStream` instance available.");
  4305. this._fullReader = this._networkStream.getFullReader();
  4306. this._fullReader.onProgress = evt => {
  4307. this._lastProgress = {
  4308. loaded: evt.loaded,
  4309. total: evt.total
  4310. };
  4311. };
  4312. sink.onPull = () => {
  4313. this._fullReader.read().then(function (_ref8) {
  4314. let {
  4315. value,
  4316. done
  4317. } = _ref8;
  4318. if (done) {
  4319. sink.close();
  4320. return;
  4321. }
  4322. (0, _util.assert)(value instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer.");
  4323. sink.enqueue(new Uint8Array(value), 1, [value]);
  4324. }).catch(reason => {
  4325. sink.error(reason);
  4326. });
  4327. };
  4328. sink.onCancel = reason => {
  4329. this._fullReader.cancel(reason);
  4330. sink.ready.catch(readyReason => {
  4331. if (this.destroyed) {
  4332. return;
  4333. }
  4334. throw readyReason;
  4335. });
  4336. };
  4337. });
  4338. messageHandler.on("ReaderHeadersReady", data => {
  4339. const headersCapability = new _util.PromiseCapability();
  4340. const fullReader = this._fullReader;
  4341. fullReader.headersReady.then(() => {
  4342. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  4343. if (this._lastProgress) {
  4344. loadingTask.onProgress?.(this._lastProgress);
  4345. }
  4346. fullReader.onProgress = evt => {
  4347. loadingTask.onProgress?.({
  4348. loaded: evt.loaded,
  4349. total: evt.total
  4350. });
  4351. };
  4352. }
  4353. headersCapability.resolve({
  4354. isStreamingSupported: fullReader.isStreamingSupported,
  4355. isRangeSupported: fullReader.isRangeSupported,
  4356. contentLength: fullReader.contentLength
  4357. });
  4358. }, headersCapability.reject);
  4359. return headersCapability.promise;
  4360. });
  4361. messageHandler.on("GetRangeReader", (data, sink) => {
  4362. (0, _util.assert)(this._networkStream, "GetRangeReader - no `IPDFStream` instance available.");
  4363. const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  4364. if (!rangeReader) {
  4365. sink.close();
  4366. return;
  4367. }
  4368. sink.onPull = () => {
  4369. rangeReader.read().then(function (_ref9) {
  4370. let {
  4371. value,
  4372. done
  4373. } = _ref9;
  4374. if (done) {
  4375. sink.close();
  4376. return;
  4377. }
  4378. (0, _util.assert)(value instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer.");
  4379. sink.enqueue(new Uint8Array(value), 1, [value]);
  4380. }).catch(reason => {
  4381. sink.error(reason);
  4382. });
  4383. };
  4384. sink.onCancel = reason => {
  4385. rangeReader.cancel(reason);
  4386. sink.ready.catch(readyReason => {
  4387. if (this.destroyed) {
  4388. return;
  4389. }
  4390. throw readyReason;
  4391. });
  4392. };
  4393. });
  4394. messageHandler.on("GetDoc", _ref10 => {
  4395. let {
  4396. pdfInfo
  4397. } = _ref10;
  4398. this._numPages = pdfInfo.numPages;
  4399. this._htmlForXfa = pdfInfo.htmlForXfa;
  4400. delete pdfInfo.htmlForXfa;
  4401. loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
  4402. });
  4403. messageHandler.on("DocException", function (ex) {
  4404. let reason;
  4405. switch (ex.name) {
  4406. case "PasswordException":
  4407. reason = new _util.PasswordException(ex.message, ex.code);
  4408. break;
  4409. case "InvalidPDFException":
  4410. reason = new _util.InvalidPDFException(ex.message);
  4411. break;
  4412. case "MissingPDFException":
  4413. reason = new _util.MissingPDFException(ex.message);
  4414. break;
  4415. case "UnexpectedResponseException":
  4416. reason = new _util.UnexpectedResponseException(ex.message, ex.status);
  4417. break;
  4418. case "UnknownErrorException":
  4419. reason = new _util.UnknownErrorException(ex.message, ex.details);
  4420. break;
  4421. default:
  4422. (0, _util.unreachable)("DocException - expected a valid Error.");
  4423. }
  4424. loadingTask._capability.reject(reason);
  4425. });
  4426. messageHandler.on("PasswordRequest", exception => {
  4427. this.#passwordCapability = new _util.PromiseCapability();
  4428. if (loadingTask.onPassword) {
  4429. const updatePassword = password => {
  4430. if (password instanceof Error) {
  4431. this.#passwordCapability.reject(password);
  4432. } else {
  4433. this.#passwordCapability.resolve({
  4434. password
  4435. });
  4436. }
  4437. };
  4438. try {
  4439. loadingTask.onPassword(updatePassword, exception.code);
  4440. } catch (ex) {
  4441. this.#passwordCapability.reject(ex);
  4442. }
  4443. } else {
  4444. this.#passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  4445. }
  4446. return this.#passwordCapability.promise;
  4447. });
  4448. messageHandler.on("DataLoaded", data => {
  4449. loadingTask.onProgress?.({
  4450. loaded: data.length,
  4451. total: data.length
  4452. });
  4453. this.downloadInfoCapability.resolve(data);
  4454. });
  4455. messageHandler.on("StartRenderPage", data => {
  4456. if (this.destroyed) {
  4457. return;
  4458. }
  4459. const page = this.#pageCache.get(data.pageIndex);
  4460. page._startRenderPage(data.transparency, data.cacheKey);
  4461. });
  4462. messageHandler.on("commonobj", _ref11 => {
  4463. let [id, type, exportedData] = _ref11;
  4464. if (this.destroyed) {
  4465. return;
  4466. }
  4467. if (this.commonObjs.has(id)) {
  4468. return;
  4469. }
  4470. switch (type) {
  4471. case "Font":
  4472. const params = this._params;
  4473. if ("error" in exportedData) {
  4474. const exportedError = exportedData.error;
  4475. (0, _util.warn)(`Error during font loading: ${exportedError}`);
  4476. this.commonObjs.resolve(id, exportedError);
  4477. break;
  4478. }
  4479. const inspectFont = params.pdfBug && globalThis.FontInspector?.enabled ? (font, url) => globalThis.FontInspector.fontAdded(font, url) : null;
  4480. const font = new _font_loader.FontFaceObject(exportedData, {
  4481. isEvalSupported: params.isEvalSupported,
  4482. disableFontFace: params.disableFontFace,
  4483. ignoreErrors: params.ignoreErrors,
  4484. inspectFont
  4485. });
  4486. this.fontLoader.bind(font).catch(reason => {
  4487. return messageHandler.sendWithPromise("FontFallback", {
  4488. id
  4489. });
  4490. }).finally(() => {
  4491. if (!params.fontExtraProperties && font.data) {
  4492. font.data = null;
  4493. }
  4494. this.commonObjs.resolve(id, font);
  4495. });
  4496. break;
  4497. case "FontPath":
  4498. case "Image":
  4499. case "Pattern":
  4500. this.commonObjs.resolve(id, exportedData);
  4501. break;
  4502. default:
  4503. throw new Error(`Got unknown common object type ${type}`);
  4504. }
  4505. });
  4506. messageHandler.on("obj", _ref12 => {
  4507. let [id, pageIndex, type, imageData] = _ref12;
  4508. if (this.destroyed) {
  4509. return;
  4510. }
  4511. const pageProxy = this.#pageCache.get(pageIndex);
  4512. if (pageProxy.objs.has(id)) {
  4513. return;
  4514. }
  4515. switch (type) {
  4516. case "Image":
  4517. pageProxy.objs.resolve(id, imageData);
  4518. if (imageData) {
  4519. let length;
  4520. if (imageData.bitmap) {
  4521. const {
  4522. width,
  4523. height
  4524. } = imageData;
  4525. length = width * height * 4;
  4526. } else {
  4527. length = imageData.data?.length || 0;
  4528. }
  4529. if (length > _util.MAX_IMAGE_SIZE_TO_CACHE) {
  4530. pageProxy._maybeCleanupAfterRender = true;
  4531. }
  4532. }
  4533. break;
  4534. case "Pattern":
  4535. pageProxy.objs.resolve(id, imageData);
  4536. break;
  4537. default:
  4538. throw new Error(`Got unknown object type ${type}`);
  4539. }
  4540. });
  4541. messageHandler.on("DocProgress", data => {
  4542. if (this.destroyed) {
  4543. return;
  4544. }
  4545. loadingTask.onProgress?.({
  4546. loaded: data.loaded,
  4547. total: data.total
  4548. });
  4549. });
  4550. messageHandler.on("FetchBuiltInCMap", data => {
  4551. if (this.destroyed) {
  4552. return Promise.reject(new Error("Worker was destroyed."));
  4553. }
  4554. if (!this.cMapReaderFactory) {
  4555. return Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."));
  4556. }
  4557. return this.cMapReaderFactory.fetch(data);
  4558. });
  4559. messageHandler.on("FetchStandardFontData", data => {
  4560. if (this.destroyed) {
  4561. return Promise.reject(new Error("Worker was destroyed."));
  4562. }
  4563. if (!this.standardFontDataFactory) {
  4564. return Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."));
  4565. }
  4566. return this.standardFontDataFactory.fetch(data);
  4567. });
  4568. }
  4569. getData() {
  4570. return this.messageHandler.sendWithPromise("GetData", null);
  4571. }
  4572. saveDocument() {
  4573. if (this.annotationStorage.size <= 0) {
  4574. (0, _util.warn)("saveDocument called while `annotationStorage` is empty, " + "please use the getData-method instead.");
  4575. }
  4576. const {
  4577. map,
  4578. transfers
  4579. } = this.annotationStorage.serializable;
  4580. return this.messageHandler.sendWithPromise("SaveDocument", {
  4581. isPureXfa: !!this._htmlForXfa,
  4582. numPages: this._numPages,
  4583. annotationStorage: map,
  4584. filename: this._fullReader?.filename ?? null
  4585. }, transfers).finally(() => {
  4586. this.annotationStorage.resetModified();
  4587. });
  4588. }
  4589. getPage(pageNumber) {
  4590. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this._numPages) {
  4591. return Promise.reject(new Error("Invalid page request."));
  4592. }
  4593. const pageIndex = pageNumber - 1,
  4594. cachedPromise = this.#pagePromises.get(pageIndex);
  4595. if (cachedPromise) {
  4596. return cachedPromise;
  4597. }
  4598. const promise = this.messageHandler.sendWithPromise("GetPage", {
  4599. pageIndex
  4600. }).then(pageInfo => {
  4601. if (this.destroyed) {
  4602. throw new Error("Transport destroyed");
  4603. }
  4604. const page = new PDFPageProxy(pageIndex, pageInfo, this, this._params.pdfBug);
  4605. this.#pageCache.set(pageIndex, page);
  4606. return page;
  4607. });
  4608. this.#pagePromises.set(pageIndex, promise);
  4609. return promise;
  4610. }
  4611. getPageIndex(ref) {
  4612. if (typeof ref !== "object" || ref === null || !Number.isInteger(ref.num) || ref.num < 0 || !Number.isInteger(ref.gen) || ref.gen < 0) {
  4613. return Promise.reject(new Error("Invalid pageIndex request."));
  4614. }
  4615. return this.messageHandler.sendWithPromise("GetPageIndex", {
  4616. num: ref.num,
  4617. gen: ref.gen
  4618. });
  4619. }
  4620. getAnnotations(pageIndex, intent) {
  4621. return this.messageHandler.sendWithPromise("GetAnnotations", {
  4622. pageIndex,
  4623. intent
  4624. });
  4625. }
  4626. getFieldObjects() {
  4627. return this.#cacheSimpleMethod("GetFieldObjects");
  4628. }
  4629. hasJSActions() {
  4630. return this.#cacheSimpleMethod("HasJSActions");
  4631. }
  4632. getCalculationOrderIds() {
  4633. return this.messageHandler.sendWithPromise("GetCalculationOrderIds", null);
  4634. }
  4635. getDestinations() {
  4636. return this.messageHandler.sendWithPromise("GetDestinations", null);
  4637. }
  4638. getDestination(id) {
  4639. if (typeof id !== "string") {
  4640. return Promise.reject(new Error("Invalid destination request."));
  4641. }
  4642. return this.messageHandler.sendWithPromise("GetDestination", {
  4643. id
  4644. });
  4645. }
  4646. getPageLabels() {
  4647. return this.messageHandler.sendWithPromise("GetPageLabels", null);
  4648. }
  4649. getPageLayout() {
  4650. return this.messageHandler.sendWithPromise("GetPageLayout", null);
  4651. }
  4652. getPageMode() {
  4653. return this.messageHandler.sendWithPromise("GetPageMode", null);
  4654. }
  4655. getViewerPreferences() {
  4656. return this.messageHandler.sendWithPromise("GetViewerPreferences", null);
  4657. }
  4658. getOpenAction() {
  4659. return this.messageHandler.sendWithPromise("GetOpenAction", null);
  4660. }
  4661. getAttachments() {
  4662. return this.messageHandler.sendWithPromise("GetAttachments", null);
  4663. }
  4664. getDocJSActions() {
  4665. return this.#cacheSimpleMethod("GetDocJSActions");
  4666. }
  4667. getPageJSActions(pageIndex) {
  4668. return this.messageHandler.sendWithPromise("GetPageJSActions", {
  4669. pageIndex
  4670. });
  4671. }
  4672. getStructTree(pageIndex) {
  4673. return this.messageHandler.sendWithPromise("GetStructTree", {
  4674. pageIndex
  4675. });
  4676. }
  4677. getOutline() {
  4678. return this.messageHandler.sendWithPromise("GetOutline", null);
  4679. }
  4680. getOptionalContentConfig() {
  4681. return this.messageHandler.sendWithPromise("GetOptionalContentConfig", null).then(results => {
  4682. return new _optional_content_config.OptionalContentConfig(results);
  4683. });
  4684. }
  4685. getPermissions() {
  4686. return this.messageHandler.sendWithPromise("GetPermissions", null);
  4687. }
  4688. getMetadata() {
  4689. const name = "GetMetadata",
  4690. cachedPromise = this.#methodPromises.get(name);
  4691. if (cachedPromise) {
  4692. return cachedPromise;
  4693. }
  4694. const promise = this.messageHandler.sendWithPromise(name, null).then(results => {
  4695. return {
  4696. info: results[0],
  4697. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  4698. contentDispositionFilename: this._fullReader?.filename ?? null,
  4699. contentLength: this._fullReader?.contentLength ?? null
  4700. };
  4701. });
  4702. this.#methodPromises.set(name, promise);
  4703. return promise;
  4704. }
  4705. getMarkInfo() {
  4706. return this.messageHandler.sendWithPromise("GetMarkInfo", null);
  4707. }
  4708. async startCleanup() {
  4709. let keepLoadedFonts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4710. if (this.destroyed) {
  4711. return;
  4712. }
  4713. await this.messageHandler.sendWithPromise("Cleanup", null);
  4714. for (const page of this.#pageCache.values()) {
  4715. const cleanupSuccessful = page.cleanup();
  4716. if (!cleanupSuccessful) {
  4717. throw new Error(`startCleanup: Page ${page.pageNumber} is currently rendering.`);
  4718. }
  4719. }
  4720. this.commonObjs.clear();
  4721. if (!keepLoadedFonts) {
  4722. this.fontLoader.clear();
  4723. }
  4724. this.#methodPromises.clear();
  4725. this.filterFactory.destroy(true);
  4726. }
  4727. get loadingParams() {
  4728. const {
  4729. disableAutoFetch,
  4730. enableXfa
  4731. } = this._params;
  4732. return (0, _util.shadow)(this, "loadingParams", {
  4733. disableAutoFetch,
  4734. enableXfa
  4735. });
  4736. }
  4737. }
  4738. class PDFObjects {
  4739. #objs = Object.create(null);
  4740. #ensureObj(objId) {
  4741. return this.#objs[objId] ||= {
  4742. capability: new _util.PromiseCapability(),
  4743. data: null
  4744. };
  4745. }
  4746. get(objId) {
  4747. let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4748. if (callback) {
  4749. const obj = this.#ensureObj(objId);
  4750. obj.capability.promise.then(() => callback(obj.data));
  4751. return null;
  4752. }
  4753. const obj = this.#objs[objId];
  4754. if (!obj?.capability.settled) {
  4755. throw new Error(`Requesting object that isn't resolved yet ${objId}.`);
  4756. }
  4757. return obj.data;
  4758. }
  4759. has(objId) {
  4760. const obj = this.#objs[objId];
  4761. return obj?.capability.settled || false;
  4762. }
  4763. resolve(objId) {
  4764. let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4765. const obj = this.#ensureObj(objId);
  4766. obj.data = data;
  4767. obj.capability.resolve();
  4768. }
  4769. clear() {
  4770. for (const objId in this.#objs) {
  4771. const {
  4772. data
  4773. } = this.#objs[objId];
  4774. data?.bitmap?.close();
  4775. }
  4776. this.#objs = Object.create(null);
  4777. }
  4778. }
  4779. class RenderTask {
  4780. #internalRenderTask = null;
  4781. constructor(internalRenderTask) {
  4782. this.#internalRenderTask = internalRenderTask;
  4783. this.onContinue = null;
  4784. }
  4785. get promise() {
  4786. return this.#internalRenderTask.capability.promise;
  4787. }
  4788. cancel() {
  4789. let extraDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  4790. this.#internalRenderTask.cancel(null, extraDelay);
  4791. }
  4792. get separateAnnots() {
  4793. const {
  4794. separateAnnots
  4795. } = this.#internalRenderTask.operatorList;
  4796. if (!separateAnnots) {
  4797. return false;
  4798. }
  4799. const {
  4800. annotationCanvasMap
  4801. } = this.#internalRenderTask;
  4802. return separateAnnots.form || separateAnnots.canvas && annotationCanvasMap?.size > 0;
  4803. }
  4804. }
  4805. exports.RenderTask = RenderTask;
  4806. class InternalRenderTask {
  4807. static #canvasInUse = new WeakSet();
  4808. constructor(_ref13) {
  4809. let {
  4810. callback,
  4811. params,
  4812. objs,
  4813. commonObjs,
  4814. annotationCanvasMap,
  4815. operatorList,
  4816. pageIndex,
  4817. canvasFactory,
  4818. filterFactory,
  4819. useRequestAnimationFrame = false,
  4820. pdfBug = false,
  4821. pageColors = null
  4822. } = _ref13;
  4823. this.callback = callback;
  4824. this.params = params;
  4825. this.objs = objs;
  4826. this.commonObjs = commonObjs;
  4827. this.annotationCanvasMap = annotationCanvasMap;
  4828. this.operatorListIdx = null;
  4829. this.operatorList = operatorList;
  4830. this._pageIndex = pageIndex;
  4831. this.canvasFactory = canvasFactory;
  4832. this.filterFactory = filterFactory;
  4833. this._pdfBug = pdfBug;
  4834. this.pageColors = pageColors;
  4835. this.running = false;
  4836. this.graphicsReadyCallback = null;
  4837. this.graphicsReady = false;
  4838. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
  4839. this.cancelled = false;
  4840. this.capability = new _util.PromiseCapability();
  4841. this.task = new RenderTask(this);
  4842. this._cancelBound = this.cancel.bind(this);
  4843. this._continueBound = this._continue.bind(this);
  4844. this._scheduleNextBound = this._scheduleNext.bind(this);
  4845. this._nextBound = this._next.bind(this);
  4846. this._canvas = params.canvasContext.canvas;
  4847. }
  4848. get completed() {
  4849. return this.capability.promise.catch(function () {});
  4850. }
  4851. initializeGraphics(_ref14) {
  4852. let {
  4853. transparency = false,
  4854. optionalContentConfig
  4855. } = _ref14;
  4856. if (this.cancelled) {
  4857. return;
  4858. }
  4859. if (this._canvas) {
  4860. if (InternalRenderTask.#canvasInUse.has(this._canvas)) {
  4861. throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed.");
  4862. }
  4863. InternalRenderTask.#canvasInUse.add(this._canvas);
  4864. }
  4865. if (this._pdfBug && globalThis.StepperManager?.enabled) {
  4866. this.stepper = globalThis.StepperManager.create(this._pageIndex);
  4867. this.stepper.init(this.operatorList);
  4868. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  4869. }
  4870. const {
  4871. canvasContext,
  4872. viewport,
  4873. transform,
  4874. background
  4875. } = this.params;
  4876. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
  4877. optionalContentConfig
  4878. }, this.annotationCanvasMap, this.pageColors);
  4879. this.gfx.beginDrawing({
  4880. transform,
  4881. viewport,
  4882. transparency,
  4883. background
  4884. });
  4885. this.operatorListIdx = 0;
  4886. this.graphicsReady = true;
  4887. this.graphicsReadyCallback?.();
  4888. }
  4889. cancel() {
  4890. let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4891. let extraDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  4892. this.running = false;
  4893. this.cancelled = true;
  4894. this.gfx?.endDrawing();
  4895. if (this._canvas) {
  4896. InternalRenderTask.#canvasInUse.delete(this._canvas);
  4897. }
  4898. this.callback(error || new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, extraDelay));
  4899. }
  4900. operatorListChanged() {
  4901. if (!this.graphicsReady) {
  4902. this.graphicsReadyCallback ||= this._continueBound;
  4903. return;
  4904. }
  4905. this.stepper?.updateOperatorList(this.operatorList);
  4906. if (this.running) {
  4907. return;
  4908. }
  4909. this._continue();
  4910. }
  4911. _continue() {
  4912. this.running = true;
  4913. if (this.cancelled) {
  4914. return;
  4915. }
  4916. if (this.task.onContinue) {
  4917. this.task.onContinue(this._scheduleNextBound);
  4918. } else {
  4919. this._scheduleNext();
  4920. }
  4921. }
  4922. _scheduleNext() {
  4923. if (this._useRequestAnimationFrame) {
  4924. window.requestAnimationFrame(() => {
  4925. this._nextBound().catch(this._cancelBound);
  4926. });
  4927. } else {
  4928. Promise.resolve().then(this._nextBound).catch(this._cancelBound);
  4929. }
  4930. }
  4931. async _next() {
  4932. if (this.cancelled) {
  4933. return;
  4934. }
  4935. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  4936. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  4937. this.running = false;
  4938. if (this.operatorList.lastChunk) {
  4939. this.gfx.endDrawing(this.pageColors);
  4940. if (this._canvas) {
  4941. InternalRenderTask.#canvasInUse.delete(this._canvas);
  4942. }
  4943. this.callback();
  4944. }
  4945. }
  4946. }
  4947. }
  4948. const version = '3.10.111';
  4949. exports.version = version;
  4950. const build = 'e142baecb';
  4951. exports.build = build;
  4952. /***/ }),
  4953. /* 125 */
  4954. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4955. var $ = __w_pdfjs_require__(3);
  4956. var difference = __w_pdfjs_require__(126);
  4957. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  4958. $({
  4959. target: 'Set',
  4960. proto: true,
  4961. real: true,
  4962. forced: !setMethodAcceptSetLike('difference')
  4963. }, { difference: difference });
  4964. /***/ }),
  4965. /* 126 */
  4966. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4967. var aSet = __w_pdfjs_require__(127);
  4968. var SetHelpers = __w_pdfjs_require__(128);
  4969. var clone = __w_pdfjs_require__(129);
  4970. var size = __w_pdfjs_require__(132);
  4971. var getSetRecord = __w_pdfjs_require__(133);
  4972. var iterateSet = __w_pdfjs_require__(130);
  4973. var iterateSimple = __w_pdfjs_require__(131);
  4974. var has = SetHelpers.has;
  4975. var remove = SetHelpers.remove;
  4976. module.exports = function difference(other) {
  4977. var O = aSet(this);
  4978. var otherRec = getSetRecord(other);
  4979. var result = clone(O);
  4980. if (size(O) <= otherRec.size)
  4981. iterateSet(O, function (e) {
  4982. if (otherRec.includes(e))
  4983. remove(result, e);
  4984. });
  4985. else
  4986. iterateSimple(otherRec.getIterator(), function (e) {
  4987. if (has(O, e))
  4988. remove(result, e);
  4989. });
  4990. return result;
  4991. };
  4992. /***/ }),
  4993. /* 127 */
  4994. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  4995. var has = (__w_pdfjs_require__(128).has);
  4996. module.exports = function (it) {
  4997. has(it);
  4998. return it;
  4999. };
  5000. /***/ }),
  5001. /* 128 */
  5002. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5003. var uncurryThis = __w_pdfjs_require__(14);
  5004. var SetPrototype = Set.prototype;
  5005. module.exports = {
  5006. Set: Set,
  5007. add: uncurryThis(SetPrototype.add),
  5008. has: uncurryThis(SetPrototype.has),
  5009. remove: uncurryThis(SetPrototype['delete']),
  5010. proto: SetPrototype
  5011. };
  5012. /***/ }),
  5013. /* 129 */
  5014. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5015. var SetHelpers = __w_pdfjs_require__(128);
  5016. var iterate = __w_pdfjs_require__(130);
  5017. var Set = SetHelpers.Set;
  5018. var add = SetHelpers.add;
  5019. module.exports = function (set) {
  5020. var result = new Set();
  5021. iterate(set, function (it) {
  5022. add(result, it);
  5023. });
  5024. return result;
  5025. };
  5026. /***/ }),
  5027. /* 130 */
  5028. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5029. var uncurryThis = __w_pdfjs_require__(14);
  5030. var iterateSimple = __w_pdfjs_require__(131);
  5031. var SetHelpers = __w_pdfjs_require__(128);
  5032. var Set = SetHelpers.Set;
  5033. var SetPrototype = SetHelpers.proto;
  5034. var forEach = uncurryThis(SetPrototype.forEach);
  5035. var keys = uncurryThis(SetPrototype.keys);
  5036. var next = keys(new Set()).next;
  5037. module.exports = function (set, fn, interruptible) {
  5038. return interruptible ? iterateSimple({
  5039. iterator: keys(set),
  5040. next: next
  5041. }, fn) : forEach(set, fn);
  5042. };
  5043. /***/ }),
  5044. /* 131 */
  5045. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5046. var call = __w_pdfjs_require__(8);
  5047. module.exports = function (record, fn, ITERATOR_INSTEAD_OF_RECORD) {
  5048. var iterator = ITERATOR_INSTEAD_OF_RECORD ? record : record.iterator;
  5049. var next = record.next;
  5050. var step, result;
  5051. while (!(step = call(next, iterator)).done) {
  5052. result = fn(step.value);
  5053. if (result !== undefined)
  5054. return result;
  5055. }
  5056. };
  5057. /***/ }),
  5058. /* 132 */
  5059. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5060. var uncurryThisAccessor = __w_pdfjs_require__(72);
  5061. var SetHelpers = __w_pdfjs_require__(128);
  5062. module.exports = uncurryThisAccessor(SetHelpers.proto, 'size', 'get') || function (set) {
  5063. return set.size;
  5064. };
  5065. /***/ }),
  5066. /* 133 */
  5067. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5068. var aCallable = __w_pdfjs_require__(31);
  5069. var anObject = __w_pdfjs_require__(47);
  5070. var call = __w_pdfjs_require__(8);
  5071. var toIntegerOrInfinity = __w_pdfjs_require__(62);
  5072. var getIteratorDirect = __w_pdfjs_require__(134);
  5073. var INVALID_SIZE = 'Invalid size';
  5074. var $RangeError = RangeError;
  5075. var $TypeError = TypeError;
  5076. var max = Math.max;
  5077. var SetRecord = function (set, size, has, keys) {
  5078. this.set = set;
  5079. this.size = size;
  5080. this.has = has;
  5081. this.keys = keys;
  5082. };
  5083. SetRecord.prototype = {
  5084. getIterator: function () {
  5085. return getIteratorDirect(anObject(call(this.keys, this.set)));
  5086. },
  5087. includes: function (it) {
  5088. return call(this.has, this.set, it);
  5089. }
  5090. };
  5091. module.exports = function (obj) {
  5092. anObject(obj);
  5093. var numSize = +obj.size;
  5094. if (numSize !== numSize)
  5095. throw $TypeError(INVALID_SIZE);
  5096. var intSize = toIntegerOrInfinity(numSize);
  5097. if (intSize < 0)
  5098. throw $RangeError(INVALID_SIZE);
  5099. return new SetRecord(obj, max(intSize, 0), aCallable(obj.has), aCallable(obj.keys));
  5100. };
  5101. /***/ }),
  5102. /* 134 */
  5103. /***/ ((module) => {
  5104. module.exports = function (obj) {
  5105. return {
  5106. iterator: obj,
  5107. next: obj.next,
  5108. done: false
  5109. };
  5110. };
  5111. /***/ }),
  5112. /* 135 */
  5113. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5114. var getBuiltIn = __w_pdfjs_require__(24);
  5115. var createSetLike = function (size) {
  5116. return {
  5117. size: size,
  5118. has: function () {
  5119. return false;
  5120. },
  5121. keys: function () {
  5122. return {
  5123. next: function () {
  5124. return { done: true };
  5125. }
  5126. };
  5127. }
  5128. };
  5129. };
  5130. module.exports = function (name) {
  5131. var Set = getBuiltIn('Set');
  5132. try {
  5133. new Set()[name](createSetLike(0));
  5134. try {
  5135. new Set()[name](createSetLike(-1));
  5136. return false;
  5137. } catch (error2) {
  5138. return true;
  5139. }
  5140. } catch (error) {
  5141. return false;
  5142. }
  5143. };
  5144. /***/ }),
  5145. /* 136 */
  5146. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5147. var $ = __w_pdfjs_require__(3);
  5148. var fails = __w_pdfjs_require__(7);
  5149. var intersection = __w_pdfjs_require__(137);
  5150. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5151. var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () {
  5152. return Array.from(new Set([
  5153. 1,
  5154. 2,
  5155. 3
  5156. ]).intersection(new Set([
  5157. 3,
  5158. 2
  5159. ]))) !== '3,2';
  5160. });
  5161. $({
  5162. target: 'Set',
  5163. proto: true,
  5164. real: true,
  5165. forced: INCORRECT
  5166. }, { intersection: intersection });
  5167. /***/ }),
  5168. /* 137 */
  5169. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5170. var aSet = __w_pdfjs_require__(127);
  5171. var SetHelpers = __w_pdfjs_require__(128);
  5172. var size = __w_pdfjs_require__(132);
  5173. var getSetRecord = __w_pdfjs_require__(133);
  5174. var iterateSet = __w_pdfjs_require__(130);
  5175. var iterateSimple = __w_pdfjs_require__(131);
  5176. var Set = SetHelpers.Set;
  5177. var add = SetHelpers.add;
  5178. var has = SetHelpers.has;
  5179. module.exports = function intersection(other) {
  5180. var O = aSet(this);
  5181. var otherRec = getSetRecord(other);
  5182. var result = new Set();
  5183. if (size(O) > otherRec.size) {
  5184. iterateSimple(otherRec.getIterator(), function (e) {
  5185. if (has(O, e))
  5186. add(result, e);
  5187. });
  5188. } else {
  5189. iterateSet(O, function (e) {
  5190. if (otherRec.includes(e))
  5191. add(result, e);
  5192. });
  5193. }
  5194. return result;
  5195. };
  5196. /***/ }),
  5197. /* 138 */
  5198. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5199. var $ = __w_pdfjs_require__(3);
  5200. var isDisjointFrom = __w_pdfjs_require__(139);
  5201. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5202. $({
  5203. target: 'Set',
  5204. proto: true,
  5205. real: true,
  5206. forced: !setMethodAcceptSetLike('isDisjointFrom')
  5207. }, { isDisjointFrom: isDisjointFrom });
  5208. /***/ }),
  5209. /* 139 */
  5210. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5211. var aSet = __w_pdfjs_require__(127);
  5212. var has = (__w_pdfjs_require__(128).has);
  5213. var size = __w_pdfjs_require__(132);
  5214. var getSetRecord = __w_pdfjs_require__(133);
  5215. var iterateSet = __w_pdfjs_require__(130);
  5216. var iterateSimple = __w_pdfjs_require__(131);
  5217. var iteratorClose = __w_pdfjs_require__(140);
  5218. module.exports = function isDisjointFrom(other) {
  5219. var O = aSet(this);
  5220. var otherRec = getSetRecord(other);
  5221. if (size(O) <= otherRec.size)
  5222. return iterateSet(O, function (e) {
  5223. if (otherRec.includes(e))
  5224. return false;
  5225. }, true) !== false;
  5226. var iterator = otherRec.getIterator();
  5227. return iterateSimple(iterator, function (e) {
  5228. if (has(O, e))
  5229. return iteratorClose(iterator, 'normal', false);
  5230. }) !== false;
  5231. };
  5232. /***/ }),
  5233. /* 140 */
  5234. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5235. var call = __w_pdfjs_require__(8);
  5236. var anObject = __w_pdfjs_require__(47);
  5237. var getMethod = __w_pdfjs_require__(30);
  5238. module.exports = function (iterator, kind, value) {
  5239. var innerResult, innerError;
  5240. anObject(iterator);
  5241. try {
  5242. innerResult = getMethod(iterator, 'return');
  5243. if (!innerResult) {
  5244. if (kind === 'throw')
  5245. throw value;
  5246. return value;
  5247. }
  5248. innerResult = call(innerResult, iterator);
  5249. } catch (error) {
  5250. innerError = true;
  5251. innerResult = error;
  5252. }
  5253. if (kind === 'throw')
  5254. throw value;
  5255. if (innerError)
  5256. throw innerResult;
  5257. anObject(innerResult);
  5258. return value;
  5259. };
  5260. /***/ }),
  5261. /* 141 */
  5262. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5263. var $ = __w_pdfjs_require__(3);
  5264. var isSubsetOf = __w_pdfjs_require__(142);
  5265. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5266. $({
  5267. target: 'Set',
  5268. proto: true,
  5269. real: true,
  5270. forced: !setMethodAcceptSetLike('isSubsetOf')
  5271. }, { isSubsetOf: isSubsetOf });
  5272. /***/ }),
  5273. /* 142 */
  5274. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5275. var aSet = __w_pdfjs_require__(127);
  5276. var size = __w_pdfjs_require__(132);
  5277. var iterate = __w_pdfjs_require__(130);
  5278. var getSetRecord = __w_pdfjs_require__(133);
  5279. module.exports = function isSubsetOf(other) {
  5280. var O = aSet(this);
  5281. var otherRec = getSetRecord(other);
  5282. if (size(O) > otherRec.size)
  5283. return false;
  5284. return iterate(O, function (e) {
  5285. if (!otherRec.includes(e))
  5286. return false;
  5287. }, true) !== false;
  5288. };
  5289. /***/ }),
  5290. /* 143 */
  5291. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5292. var $ = __w_pdfjs_require__(3);
  5293. var isSupersetOf = __w_pdfjs_require__(144);
  5294. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5295. $({
  5296. target: 'Set',
  5297. proto: true,
  5298. real: true,
  5299. forced: !setMethodAcceptSetLike('isSupersetOf')
  5300. }, { isSupersetOf: isSupersetOf });
  5301. /***/ }),
  5302. /* 144 */
  5303. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5304. var aSet = __w_pdfjs_require__(127);
  5305. var has = (__w_pdfjs_require__(128).has);
  5306. var size = __w_pdfjs_require__(132);
  5307. var getSetRecord = __w_pdfjs_require__(133);
  5308. var iterateSimple = __w_pdfjs_require__(131);
  5309. var iteratorClose = __w_pdfjs_require__(140);
  5310. module.exports = function isSupersetOf(other) {
  5311. var O = aSet(this);
  5312. var otherRec = getSetRecord(other);
  5313. if (size(O) < otherRec.size)
  5314. return false;
  5315. var iterator = otherRec.getIterator();
  5316. return iterateSimple(iterator, function (e) {
  5317. if (!has(O, e))
  5318. return iteratorClose(iterator, 'normal', false);
  5319. }) !== false;
  5320. };
  5321. /***/ }),
  5322. /* 145 */
  5323. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5324. var $ = __w_pdfjs_require__(3);
  5325. var symmetricDifference = __w_pdfjs_require__(146);
  5326. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5327. $({
  5328. target: 'Set',
  5329. proto: true,
  5330. real: true,
  5331. forced: !setMethodAcceptSetLike('symmetricDifference')
  5332. }, { symmetricDifference: symmetricDifference });
  5333. /***/ }),
  5334. /* 146 */
  5335. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5336. var aSet = __w_pdfjs_require__(127);
  5337. var SetHelpers = __w_pdfjs_require__(128);
  5338. var clone = __w_pdfjs_require__(129);
  5339. var getSetRecord = __w_pdfjs_require__(133);
  5340. var iterateSimple = __w_pdfjs_require__(131);
  5341. var add = SetHelpers.add;
  5342. var has = SetHelpers.has;
  5343. var remove = SetHelpers.remove;
  5344. module.exports = function symmetricDifference(other) {
  5345. var O = aSet(this);
  5346. var keysIter = getSetRecord(other).getIterator();
  5347. var result = clone(O);
  5348. iterateSimple(keysIter, function (e) {
  5349. if (has(O, e))
  5350. remove(result, e);
  5351. else
  5352. add(result, e);
  5353. });
  5354. return result;
  5355. };
  5356. /***/ }),
  5357. /* 147 */
  5358. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5359. var $ = __w_pdfjs_require__(3);
  5360. var union = __w_pdfjs_require__(148);
  5361. var setMethodAcceptSetLike = __w_pdfjs_require__(135);
  5362. $({
  5363. target: 'Set',
  5364. proto: true,
  5365. real: true,
  5366. forced: !setMethodAcceptSetLike('union')
  5367. }, { union: union });
  5368. /***/ }),
  5369. /* 148 */
  5370. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5371. var aSet = __w_pdfjs_require__(127);
  5372. var add = (__w_pdfjs_require__(128).add);
  5373. var clone = __w_pdfjs_require__(129);
  5374. var getSetRecord = __w_pdfjs_require__(133);
  5375. var iterateSimple = __w_pdfjs_require__(131);
  5376. module.exports = function union(other) {
  5377. var O = aSet(this);
  5378. var keysIter = getSetRecord(other).getIterator();
  5379. var result = clone(O);
  5380. iterateSimple(keysIter, function (it) {
  5381. add(result, it);
  5382. });
  5383. return result;
  5384. };
  5385. /***/ }),
  5386. /* 149 */
  5387. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5388. var $ = __w_pdfjs_require__(3);
  5389. var global = __w_pdfjs_require__(4);
  5390. var getBuiltIn = __w_pdfjs_require__(24);
  5391. var createPropertyDescriptor = __w_pdfjs_require__(11);
  5392. var defineProperty = (__w_pdfjs_require__(45).f);
  5393. var hasOwn = __w_pdfjs_require__(39);
  5394. var anInstance = __w_pdfjs_require__(150);
  5395. var inheritIfRequired = __w_pdfjs_require__(75);
  5396. var normalizeStringArgument = __w_pdfjs_require__(76);
  5397. var DOMExceptionConstants = __w_pdfjs_require__(151);
  5398. var clearErrorStack = __w_pdfjs_require__(82);
  5399. var DESCRIPTORS = __w_pdfjs_require__(6);
  5400. var IS_PURE = __w_pdfjs_require__(36);
  5401. var DOM_EXCEPTION = 'DOMException';
  5402. var Error = getBuiltIn('Error');
  5403. var NativeDOMException = getBuiltIn(DOM_EXCEPTION);
  5404. var $DOMException = function DOMException() {
  5405. anInstance(this, DOMExceptionPrototype);
  5406. var argumentsLength = arguments.length;
  5407. var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]);
  5408. var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error');
  5409. var that = new NativeDOMException(message, name);
  5410. var error = Error(message);
  5411. error.name = DOM_EXCEPTION;
  5412. defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1)));
  5413. inheritIfRequired(that, this, $DOMException);
  5414. return that;
  5415. };
  5416. var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype;
  5417. var ERROR_HAS_STACK = 'stack' in Error(DOM_EXCEPTION);
  5418. var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2);
  5419. var descriptor = NativeDOMException && DESCRIPTORS && Object.getOwnPropertyDescriptor(global, DOM_EXCEPTION);
  5420. var BUGGY_DESCRIPTOR = !!descriptor && !(descriptor.writable && descriptor.configurable);
  5421. var FORCED_CONSTRUCTOR = ERROR_HAS_STACK && !BUGGY_DESCRIPTOR && !DOM_EXCEPTION_HAS_STACK;
  5422. $({
  5423. global: true,
  5424. constructor: true,
  5425. forced: IS_PURE || FORCED_CONSTRUCTOR
  5426. }, { DOMException: FORCED_CONSTRUCTOR ? $DOMException : NativeDOMException });
  5427. var PolyfilledDOMException = getBuiltIn(DOM_EXCEPTION);
  5428. var PolyfilledDOMExceptionPrototype = PolyfilledDOMException.prototype;
  5429. if (PolyfilledDOMExceptionPrototype.constructor !== PolyfilledDOMException) {
  5430. if (!IS_PURE) {
  5431. defineProperty(PolyfilledDOMExceptionPrototype, 'constructor', createPropertyDescriptor(1, PolyfilledDOMException));
  5432. }
  5433. for (var key in DOMExceptionConstants)
  5434. if (hasOwn(DOMExceptionConstants, key)) {
  5435. var constant = DOMExceptionConstants[key];
  5436. var constantName = constant.s;
  5437. if (!hasOwn(PolyfilledDOMException, constantName)) {
  5438. defineProperty(PolyfilledDOMException, constantName, createPropertyDescriptor(6, constant.c));
  5439. }
  5440. }
  5441. }
  5442. /***/ }),
  5443. /* 150 */
  5444. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5445. var isPrototypeOf = __w_pdfjs_require__(25);
  5446. var $TypeError = TypeError;
  5447. module.exports = function (it, Prototype) {
  5448. if (isPrototypeOf(Prototype, it))
  5449. return it;
  5450. throw $TypeError('Incorrect invocation');
  5451. };
  5452. /***/ }),
  5453. /* 151 */
  5454. /***/ ((module) => {
  5455. module.exports = {
  5456. IndexSizeError: {
  5457. s: 'INDEX_SIZE_ERR',
  5458. c: 1,
  5459. m: 1
  5460. },
  5461. DOMStringSizeError: {
  5462. s: 'DOMSTRING_SIZE_ERR',
  5463. c: 2,
  5464. m: 0
  5465. },
  5466. HierarchyRequestError: {
  5467. s: 'HIERARCHY_REQUEST_ERR',
  5468. c: 3,
  5469. m: 1
  5470. },
  5471. WrongDocumentError: {
  5472. s: 'WRONG_DOCUMENT_ERR',
  5473. c: 4,
  5474. m: 1
  5475. },
  5476. InvalidCharacterError: {
  5477. s: 'INVALID_CHARACTER_ERR',
  5478. c: 5,
  5479. m: 1
  5480. },
  5481. NoDataAllowedError: {
  5482. s: 'NO_DATA_ALLOWED_ERR',
  5483. c: 6,
  5484. m: 0
  5485. },
  5486. NoModificationAllowedError: {
  5487. s: 'NO_MODIFICATION_ALLOWED_ERR',
  5488. c: 7,
  5489. m: 1
  5490. },
  5491. NotFoundError: {
  5492. s: 'NOT_FOUND_ERR',
  5493. c: 8,
  5494. m: 1
  5495. },
  5496. NotSupportedError: {
  5497. s: 'NOT_SUPPORTED_ERR',
  5498. c: 9,
  5499. m: 1
  5500. },
  5501. InUseAttributeError: {
  5502. s: 'INUSE_ATTRIBUTE_ERR',
  5503. c: 10,
  5504. m: 1
  5505. },
  5506. InvalidStateError: {
  5507. s: 'INVALID_STATE_ERR',
  5508. c: 11,
  5509. m: 1
  5510. },
  5511. SyntaxError: {
  5512. s: 'SYNTAX_ERR',
  5513. c: 12,
  5514. m: 1
  5515. },
  5516. InvalidModificationError: {
  5517. s: 'INVALID_MODIFICATION_ERR',
  5518. c: 13,
  5519. m: 1
  5520. },
  5521. NamespaceError: {
  5522. s: 'NAMESPACE_ERR',
  5523. c: 14,
  5524. m: 1
  5525. },
  5526. InvalidAccessError: {
  5527. s: 'INVALID_ACCESS_ERR',
  5528. c: 15,
  5529. m: 1
  5530. },
  5531. ValidationError: {
  5532. s: 'VALIDATION_ERR',
  5533. c: 16,
  5534. m: 0
  5535. },
  5536. TypeMismatchError: {
  5537. s: 'TYPE_MISMATCH_ERR',
  5538. c: 17,
  5539. m: 1
  5540. },
  5541. SecurityError: {
  5542. s: 'SECURITY_ERR',
  5543. c: 18,
  5544. m: 1
  5545. },
  5546. NetworkError: {
  5547. s: 'NETWORK_ERR',
  5548. c: 19,
  5549. m: 1
  5550. },
  5551. AbortError: {
  5552. s: 'ABORT_ERR',
  5553. c: 20,
  5554. m: 1
  5555. },
  5556. URLMismatchError: {
  5557. s: 'URL_MISMATCH_ERR',
  5558. c: 21,
  5559. m: 1
  5560. },
  5561. QuotaExceededError: {
  5562. s: 'QUOTA_EXCEEDED_ERR',
  5563. c: 22,
  5564. m: 1
  5565. },
  5566. TimeoutError: {
  5567. s: 'TIMEOUT_ERR',
  5568. c: 23,
  5569. m: 1
  5570. },
  5571. InvalidNodeTypeError: {
  5572. s: 'INVALID_NODE_TYPE_ERR',
  5573. c: 24,
  5574. m: 1
  5575. },
  5576. DataCloneError: {
  5577. s: 'DATA_CLONE_ERR',
  5578. c: 25,
  5579. m: 1
  5580. }
  5581. };
  5582. /***/ }),
  5583. /* 152 */
  5584. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  5585. var IS_PURE = __w_pdfjs_require__(36);
  5586. var $ = __w_pdfjs_require__(3);
  5587. var global = __w_pdfjs_require__(4);
  5588. var getBuiltin = __w_pdfjs_require__(24);
  5589. var uncurryThis = __w_pdfjs_require__(14);
  5590. var fails = __w_pdfjs_require__(7);
  5591. var uid = __w_pdfjs_require__(41);
  5592. var isCallable = __w_pdfjs_require__(21);
  5593. var isConstructor = __w_pdfjs_require__(153);
  5594. var isNullOrUndefined = __w_pdfjs_require__(17);
  5595. var isObject = __w_pdfjs_require__(20);
  5596. var isSymbol = __w_pdfjs_require__(23);
  5597. var iterate = __w_pdfjs_require__(154);
  5598. var anObject = __w_pdfjs_require__(47);
  5599. var classof = __w_pdfjs_require__(78);
  5600. var hasOwn = __w_pdfjs_require__(39);
  5601. var createProperty = __w_pdfjs_require__(159);
  5602. var createNonEnumerableProperty = __w_pdfjs_require__(44);
  5603. var lengthOfArrayLike = __w_pdfjs_require__(64);
  5604. var validateArgumentsLength = __w_pdfjs_require__(85);
  5605. var getRegExpFlags = __w_pdfjs_require__(160);
  5606. var MapHelpers = __w_pdfjs_require__(162);
  5607. var SetHelpers = __w_pdfjs_require__(128);
  5608. var ERROR_STACK_INSTALLABLE = __w_pdfjs_require__(83);
  5609. var PROPER_TRANSFER = __w_pdfjs_require__(119);
  5610. var Object = global.Object;
  5611. var Array = global.Array;
  5612. var Date = global.Date;
  5613. var Error = global.Error;
  5614. var EvalError = global.EvalError;
  5615. var RangeError = global.RangeError;
  5616. var ReferenceError = global.ReferenceError;
  5617. var SyntaxError = global.SyntaxError;
  5618. var TypeError = global.TypeError;
  5619. var URIError = global.URIError;
  5620. var PerformanceMark = global.PerformanceMark;
  5621. var WebAssembly = global.WebAssembly;
  5622. var CompileError = WebAssembly && WebAssembly.CompileError || Error;
  5623. var LinkError = WebAssembly && WebAssembly.LinkError || Error;
  5624. var RuntimeError = WebAssembly && WebAssembly.RuntimeError || Error;
  5625. var DOMException = getBuiltin('DOMException');
  5626. var Map = MapHelpers.Map;
  5627. var mapHas = MapHelpers.has;
  5628. var mapGet = MapHelpers.get;
  5629. var mapSet = MapHelpers.set;
  5630. var Set = SetHelpers.Set;
  5631. var setAdd = SetHelpers.add;
  5632. var objectKeys = getBuiltin('Object', 'keys');
  5633. var push = uncurryThis([].push);
  5634. var thisBooleanValue = uncurryThis(true.valueOf);
  5635. var thisNumberValue = uncurryThis(1.0.valueOf);
  5636. var thisStringValue = uncurryThis(''.valueOf);
  5637. var thisTimeValue = uncurryThis(Date.prototype.getTime);
  5638. var PERFORMANCE_MARK = uid('structuredClone');
  5639. var DATA_CLONE_ERROR = 'DataCloneError';
  5640. var TRANSFERRING = 'Transferring';
  5641. var checkBasicSemantic = function (structuredCloneImplementation) {
  5642. return !fails(function () {
  5643. var set1 = new global.Set([7]);
  5644. var set2 = structuredCloneImplementation(set1);
  5645. var number = structuredCloneImplementation(Object(7));
  5646. return set2 === set1 || !set2.has(7) || typeof number != 'object' || number !== 7;
  5647. }) && structuredCloneImplementation;
  5648. };
  5649. var checkErrorsCloning = function (structuredCloneImplementation, $Error) {
  5650. return !fails(function () {
  5651. var error = new $Error();
  5652. var test = structuredCloneImplementation({
  5653. a: error,
  5654. b: error
  5655. });
  5656. return !(test && test.a === test.b && test.a instanceof $Error && test.a.stack === error.stack);
  5657. });
  5658. };
  5659. var checkNewErrorsCloningSemantic = function (structuredCloneImplementation) {
  5660. return !fails(function () {
  5661. var test = structuredCloneImplementation(new global.AggregateError([1], PERFORMANCE_MARK, { cause: 3 }));
  5662. return test.name !== 'AggregateError' || test.errors[0] !== 1 || test.message !== PERFORMANCE_MARK || test.cause !== 3;
  5663. });
  5664. };
  5665. var nativeStructuredClone = global.structuredClone;
  5666. var FORCED_REPLACEMENT = IS_PURE || !checkErrorsCloning(nativeStructuredClone, Error) || !checkErrorsCloning(nativeStructuredClone, DOMException) || !checkNewErrorsCloningSemantic(nativeStructuredClone);
  5667. var structuredCloneFromMark = !nativeStructuredClone && checkBasicSemantic(function (value) {
  5668. return new PerformanceMark(PERFORMANCE_MARK, { detail: value }).detail;
  5669. });
  5670. var nativeRestrictedStructuredClone = checkBasicSemantic(nativeStructuredClone) || structuredCloneFromMark;
  5671. var throwUncloneable = function (type) {
  5672. throw new DOMException('Uncloneable type: ' + type, DATA_CLONE_ERROR);
  5673. };
  5674. var throwUnpolyfillable = function (type, action) {
  5675. throw new DOMException((action || 'Cloning') + ' of ' + type + ' cannot be properly polyfilled in this engine', DATA_CLONE_ERROR);
  5676. };
  5677. var tryNativeRestrictedStructuredClone = function (value, type) {
  5678. if (!nativeRestrictedStructuredClone)
  5679. throwUnpolyfillable(type);
  5680. return nativeRestrictedStructuredClone(value);
  5681. };
  5682. var createDataTransfer = function () {
  5683. var dataTransfer;
  5684. try {
  5685. dataTransfer = new global.DataTransfer();
  5686. } catch (error) {
  5687. try {
  5688. dataTransfer = new global.ClipboardEvent('').clipboardData;
  5689. } catch (error2) {
  5690. }
  5691. }
  5692. return dataTransfer && dataTransfer.items && dataTransfer.files ? dataTransfer : null;
  5693. };
  5694. var cloneBuffer = function (value, map, $type) {
  5695. if (mapHas(map, value))
  5696. return mapGet(map, value);
  5697. var type = $type || classof(value);
  5698. var clone, length, options, source, target, i;
  5699. if (type === 'SharedArrayBuffer') {
  5700. if (nativeRestrictedStructuredClone)
  5701. clone = nativeRestrictedStructuredClone(value);
  5702. else
  5703. clone = value;
  5704. } else {
  5705. var DataView = global.DataView;
  5706. if (!DataView && typeof value.slice != 'function')
  5707. throwUnpolyfillable('ArrayBuffer');
  5708. try {
  5709. if (typeof value.slice == 'function' && !value.resizable) {
  5710. clone = value.slice(0);
  5711. } else {
  5712. length = value.byteLength;
  5713. options = 'maxByteLength' in value ? { maxByteLength: value.maxByteLength } : undefined;
  5714. clone = new ArrayBuffer(length, options);
  5715. source = new DataView(value);
  5716. target = new DataView(clone);
  5717. for (i = 0; i < length; i++) {
  5718. target.setUint8(i, source.getUint8(i));
  5719. }
  5720. }
  5721. } catch (error) {
  5722. throw new DOMException('ArrayBuffer is detached', DATA_CLONE_ERROR);
  5723. }
  5724. }
  5725. mapSet(map, value, clone);
  5726. return clone;
  5727. };
  5728. var cloneView = function (value, type, offset, length, map) {
  5729. var C = global[type];
  5730. if (!isObject(C))
  5731. throwUnpolyfillable(type);
  5732. return new C(cloneBuffer(value.buffer, map), offset, length);
  5733. };
  5734. var Placeholder = function (object, type, metadata) {
  5735. this.object = object;
  5736. this.type = type;
  5737. this.metadata = metadata;
  5738. };
  5739. var structuredCloneInternal = function (value, map, transferredBuffers) {
  5740. if (isSymbol(value))
  5741. throwUncloneable('Symbol');
  5742. if (!isObject(value))
  5743. return value;
  5744. if (map) {
  5745. if (mapHas(map, value))
  5746. return mapGet(map, value);
  5747. } else
  5748. map = new Map();
  5749. var type = classof(value);
  5750. var C, name, cloned, dataTransfer, i, length, keys, key;
  5751. switch (type) {
  5752. case 'Array':
  5753. cloned = Array(lengthOfArrayLike(value));
  5754. break;
  5755. case 'Object':
  5756. cloned = {};
  5757. break;
  5758. case 'Map':
  5759. cloned = new Map();
  5760. break;
  5761. case 'Set':
  5762. cloned = new Set();
  5763. break;
  5764. case 'RegExp':
  5765. cloned = new RegExp(value.source, getRegExpFlags(value));
  5766. break;
  5767. case 'Error':
  5768. name = value.name;
  5769. switch (name) {
  5770. case 'AggregateError':
  5771. cloned = getBuiltin('AggregateError')([]);
  5772. break;
  5773. case 'EvalError':
  5774. cloned = EvalError();
  5775. break;
  5776. case 'RangeError':
  5777. cloned = RangeError();
  5778. break;
  5779. case 'ReferenceError':
  5780. cloned = ReferenceError();
  5781. break;
  5782. case 'SyntaxError':
  5783. cloned = SyntaxError();
  5784. break;
  5785. case 'TypeError':
  5786. cloned = TypeError();
  5787. break;
  5788. case 'URIError':
  5789. cloned = URIError();
  5790. break;
  5791. case 'CompileError':
  5792. cloned = CompileError();
  5793. break;
  5794. case 'LinkError':
  5795. cloned = LinkError();
  5796. break;
  5797. case 'RuntimeError':
  5798. cloned = RuntimeError();
  5799. break;
  5800. default:
  5801. cloned = Error();
  5802. }
  5803. break;
  5804. case 'DOMException':
  5805. cloned = new DOMException(value.message, value.name);
  5806. break;
  5807. case 'ArrayBuffer':
  5808. case 'SharedArrayBuffer':
  5809. cloned = transferredBuffers ? new Placeholder(value, type) : cloneBuffer(value, map, type);
  5810. break;
  5811. case 'DataView':
  5812. case 'Int8Array':
  5813. case 'Uint8Array':
  5814. case 'Uint8ClampedArray':
  5815. case 'Int16Array':
  5816. case 'Uint16Array':
  5817. case 'Int32Array':
  5818. case 'Uint32Array':
  5819. case 'Float16Array':
  5820. case 'Float32Array':
  5821. case 'Float64Array':
  5822. case 'BigInt64Array':
  5823. case 'BigUint64Array':
  5824. length = type === 'DataView' ? value.byteLength : value.length;
  5825. cloned = transferredBuffers ? new Placeholder(value, type, {
  5826. offset: value.byteOffset,
  5827. length: length
  5828. }) : cloneView(value, type, value.byteOffset, length, map);
  5829. break;
  5830. case 'DOMQuad':
  5831. try {
  5832. cloned = new DOMQuad(structuredCloneInternal(value.p1, map, transferredBuffers), structuredCloneInternal(value.p2, map, transferredBuffers), structuredCloneInternal(value.p3, map, transferredBuffers), structuredCloneInternal(value.p4, map, transferredBuffers));
  5833. } catch (error) {
  5834. cloned = tryNativeRestrictedStructuredClone(value, type);
  5835. }
  5836. break;
  5837. case 'File':
  5838. if (nativeRestrictedStructuredClone)
  5839. try {
  5840. cloned = nativeRestrictedStructuredClone(value);
  5841. if (classof(cloned) !== type)
  5842. cloned = undefined;
  5843. } catch (error) {
  5844. }
  5845. if (!cloned)
  5846. try {
  5847. cloned = new File([value], value.name, value);
  5848. } catch (error) {
  5849. }
  5850. if (!cloned)
  5851. throwUnpolyfillable(type);
  5852. break;
  5853. case 'FileList':
  5854. dataTransfer = createDataTransfer();
  5855. if (dataTransfer) {
  5856. for (i = 0, length = lengthOfArrayLike(value); i < length; i++) {
  5857. dataTransfer.items.add(structuredCloneInternal(value[i], map, transferredBuffers));
  5858. }
  5859. cloned = dataTransfer.files;
  5860. } else
  5861. cloned = tryNativeRestrictedStructuredClone(value, type);
  5862. break;
  5863. case 'ImageData':
  5864. try {
  5865. cloned = new ImageData(structuredCloneInternal(value.data, map, transferredBuffers), value.width, value.height, { colorSpace: value.colorSpace });
  5866. } catch (error) {
  5867. cloned = tryNativeRestrictedStructuredClone(value, type);
  5868. }
  5869. break;
  5870. default:
  5871. if (nativeRestrictedStructuredClone) {
  5872. cloned = nativeRestrictedStructuredClone(value);
  5873. } else
  5874. switch (type) {
  5875. case 'BigInt':
  5876. cloned = Object(value.valueOf());
  5877. break;
  5878. case 'Boolean':
  5879. cloned = Object(thisBooleanValue(value));
  5880. break;
  5881. case 'Number':
  5882. cloned = Object(thisNumberValue(value));
  5883. break;
  5884. case 'String':
  5885. cloned = Object(thisStringValue(value));
  5886. break;
  5887. case 'Date':
  5888. cloned = new Date(thisTimeValue(value));
  5889. break;
  5890. case 'Blob':
  5891. try {
  5892. cloned = value.slice(0, value.size, value.type);
  5893. } catch (error) {
  5894. throwUnpolyfillable(type);
  5895. }
  5896. break;
  5897. case 'DOMPoint':
  5898. case 'DOMPointReadOnly':
  5899. C = global[type];
  5900. try {
  5901. cloned = C.fromPoint ? C.fromPoint(value) : new C(value.x, value.y, value.z, value.w);
  5902. } catch (error) {
  5903. throwUnpolyfillable(type);
  5904. }
  5905. break;
  5906. case 'DOMRect':
  5907. case 'DOMRectReadOnly':
  5908. C = global[type];
  5909. try {
  5910. cloned = C.fromRect ? C.fromRect(value) : new C(value.x, value.y, value.width, value.height);
  5911. } catch (error) {
  5912. throwUnpolyfillable(type);
  5913. }
  5914. break;
  5915. case 'DOMMatrix':
  5916. case 'DOMMatrixReadOnly':
  5917. C = global[type];
  5918. try {
  5919. cloned = C.fromMatrix ? C.fromMatrix(value) : new C(value);
  5920. } catch (error) {
  5921. throwUnpolyfillable(type);
  5922. }
  5923. break;
  5924. case 'AudioData':
  5925. case 'VideoFrame':
  5926. if (!isCallable(value.clone))
  5927. throwUnpolyfillable(type);
  5928. try {
  5929. cloned = value.clone();
  5930. } catch (error) {
  5931. throwUncloneable(type);
  5932. }
  5933. break;
  5934. case 'CropTarget':
  5935. case 'CryptoKey':
  5936. case 'FileSystemDirectoryHandle':
  5937. case 'FileSystemFileHandle':
  5938. case 'FileSystemHandle':
  5939. case 'GPUCompilationInfo':
  5940. case 'GPUCompilationMessage':
  5941. case 'ImageBitmap':
  5942. case 'RTCCertificate':
  5943. case 'WebAssembly.Module':
  5944. throwUnpolyfillable(type);
  5945. default:
  5946. throwUncloneable(type);
  5947. }
  5948. }
  5949. mapSet(map, value, cloned);
  5950. switch (type) {
  5951. case 'Array':
  5952. case 'Object':
  5953. keys = objectKeys(value);
  5954. for (i = 0, length = lengthOfArrayLike(keys); i < length; i++) {
  5955. key = keys[i];
  5956. createProperty(cloned, key, structuredCloneInternal(value[key], map, transferredBuffers));
  5957. }
  5958. break;
  5959. case 'Map':
  5960. value.forEach(function (v, k) {
  5961. mapSet(cloned, structuredCloneInternal(k, map, transferredBuffers), structuredCloneInternal(v, map, transferredBuffers));
  5962. });
  5963. break;
  5964. case 'Set':
  5965. value.forEach(function (v) {
  5966. setAdd(cloned, structuredCloneInternal(v, map, transferredBuffers));
  5967. });
  5968. break;
  5969. case 'Error':
  5970. createNonEnumerableProperty(cloned, 'message', structuredCloneInternal(value.message, map, transferredBuffers));
  5971. if (hasOwn(value, 'cause')) {
  5972. createNonEnumerableProperty(cloned, 'cause', structuredCloneInternal(value.cause, map, transferredBuffers));
  5973. }
  5974. if (name === 'AggregateError') {
  5975. cloned.errors = structuredCloneInternal(value.errors, map, transferredBuffers);
  5976. }
  5977. case 'DOMException':
  5978. if (ERROR_STACK_INSTALLABLE) {
  5979. createNonEnumerableProperty(cloned, 'stack', structuredCloneInternal(value.stack, map, transferredBuffers));
  5980. }
  5981. }
  5982. return cloned;
  5983. };
  5984. var replacePlaceholders = function (value, map) {
  5985. if (!isObject(value))
  5986. return value;
  5987. if (mapHas(map, value))
  5988. return mapGet(map, value);
  5989. var type, object, metadata, i, length, keys, key, replacement;
  5990. if (value instanceof Placeholder) {
  5991. type = value.type;
  5992. object = value.object;
  5993. switch (type) {
  5994. case 'ArrayBuffer':
  5995. case 'SharedArrayBuffer':
  5996. replacement = cloneBuffer(object, map, type);
  5997. break;
  5998. case 'DataView':
  5999. case 'Int8Array':
  6000. case 'Uint8Array':
  6001. case 'Uint8ClampedArray':
  6002. case 'Int16Array':
  6003. case 'Uint16Array':
  6004. case 'Int32Array':
  6005. case 'Uint32Array':
  6006. case 'Float16Array':
  6007. case 'Float32Array':
  6008. case 'Float64Array':
  6009. case 'BigInt64Array':
  6010. case 'BigUint64Array':
  6011. metadata = value.metadata;
  6012. replacement = cloneView(object, type, metadata.offset, metadata.length, map);
  6013. }
  6014. } else
  6015. switch (classof(value)) {
  6016. case 'Array':
  6017. case 'Object':
  6018. keys = objectKeys(value);
  6019. for (i = 0, length = lengthOfArrayLike(keys); i < length; i++) {
  6020. key = keys[i];
  6021. value[key] = replacePlaceholders(value[key], map);
  6022. }
  6023. break;
  6024. case 'Map':
  6025. replacement = new Map();
  6026. value.forEach(function (v, k) {
  6027. mapSet(replacement, replacePlaceholders(k, map), replacePlaceholders(v, map));
  6028. });
  6029. break;
  6030. case 'Set':
  6031. replacement = new Set();
  6032. value.forEach(function (v) {
  6033. setAdd(replacement, replacePlaceholders(v, map));
  6034. });
  6035. break;
  6036. case 'Error':
  6037. value.message = replacePlaceholders(value.message, map);
  6038. if (hasOwn(value, 'cause')) {
  6039. value.cause = replacePlaceholders(value.cause, map);
  6040. }
  6041. if (value.name === 'AggregateError') {
  6042. value.errors = replacePlaceholders(value.errors, map);
  6043. }
  6044. case 'DOMException':
  6045. if (ERROR_STACK_INSTALLABLE) {
  6046. value.stack = replacePlaceholders(value.stack, map);
  6047. }
  6048. }
  6049. mapSet(map, value, replacement || value);
  6050. return replacement || value;
  6051. };
  6052. var tryToTransfer = function (rawTransfer, map) {
  6053. if (!isObject(rawTransfer))
  6054. throw TypeError('Transfer option cannot be converted to a sequence');
  6055. var transfer = [];
  6056. iterate(rawTransfer, function (value) {
  6057. push(transfer, anObject(value));
  6058. });
  6059. var i = 0;
  6060. var length = lengthOfArrayLike(transfer);
  6061. var buffers = [];
  6062. var value, type, C, transferred, canvas, context;
  6063. while (i < length) {
  6064. value = transfer[i++];
  6065. type = classof(value);
  6066. if (type === 'ArrayBuffer') {
  6067. push(buffers, value);
  6068. continue;
  6069. }
  6070. if (mapHas(map, value))
  6071. throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR);
  6072. if (PROPER_TRANSFER) {
  6073. transferred = nativeStructuredClone(value, { transfer: [value] });
  6074. } else
  6075. switch (type) {
  6076. case 'ImageBitmap':
  6077. C = global.OffscreenCanvas;
  6078. if (!isConstructor(C))
  6079. throwUnpolyfillable(type, TRANSFERRING);
  6080. try {
  6081. canvas = new C(value.width, value.height);
  6082. context = canvas.getContext('bitmaprenderer');
  6083. context.transferFromImageBitmap(value);
  6084. transferred = canvas.transferToImageBitmap();
  6085. } catch (error) {
  6086. }
  6087. break;
  6088. case 'AudioData':
  6089. case 'VideoFrame':
  6090. if (!isCallable(value.clone) || !isCallable(value.close))
  6091. throwUnpolyfillable(type, TRANSFERRING);
  6092. try {
  6093. transferred = value.clone();
  6094. value.close();
  6095. } catch (error) {
  6096. }
  6097. break;
  6098. case 'MediaSourceHandle':
  6099. case 'MessagePort':
  6100. case 'OffscreenCanvas':
  6101. case 'ReadableStream':
  6102. case 'TransformStream':
  6103. case 'WritableStream':
  6104. throwUnpolyfillable(type, TRANSFERRING);
  6105. }
  6106. if (transferred === undefined)
  6107. throw new DOMException('This object cannot be transferred: ' + type, DATA_CLONE_ERROR);
  6108. mapSet(map, value, transferred);
  6109. }
  6110. return buffers;
  6111. };
  6112. var tryToTransferBuffers = function (transfer, map) {
  6113. var i = 0;
  6114. var length = lengthOfArrayLike(transfer);
  6115. var value, transferred;
  6116. while (i < length) {
  6117. value = transfer[i++];
  6118. if (mapHas(map, value))
  6119. throw new DOMException('Duplicate transferable', DATA_CLONE_ERROR);
  6120. if (PROPER_TRANSFER) {
  6121. transferred = nativeStructuredClone(value, { transfer: [value] });
  6122. } else {
  6123. if (!isCallable(value.transfer))
  6124. throwUnpolyfillable('ArrayBuffer', TRANSFERRING);
  6125. transferred = value.transfer();
  6126. }
  6127. mapSet(map, value, transferred);
  6128. }
  6129. };
  6130. $({
  6131. global: true,
  6132. enumerable: true,
  6133. sham: !PROPER_TRANSFER,
  6134. forced: FORCED_REPLACEMENT
  6135. }, {
  6136. structuredClone: function structuredClone(value) {
  6137. var options = validateArgumentsLength(arguments.length, 1) > 1 && !isNullOrUndefined(arguments[1]) ? anObject(arguments[1]) : undefined;
  6138. var transfer = options ? options.transfer : undefined;
  6139. var transferredBuffers = false;
  6140. var map, buffers;
  6141. if (transfer !== undefined) {
  6142. map = new Map();
  6143. buffers = tryToTransfer(transfer, map);
  6144. transferredBuffers = !!lengthOfArrayLike(buffers);
  6145. }
  6146. var clone = structuredCloneInternal(value, map, transferredBuffers);
  6147. if (transferredBuffers) {
  6148. map = new Map();
  6149. tryToTransferBuffers(transfer, map);
  6150. clone = replacePlaceholders(clone, map);
  6151. }
  6152. return clone;
  6153. }
  6154. });
  6155. /***/ }),
  6156. /* 153 */
  6157. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6158. var uncurryThis = __w_pdfjs_require__(14);
  6159. var fails = __w_pdfjs_require__(7);
  6160. var isCallable = __w_pdfjs_require__(21);
  6161. var classof = __w_pdfjs_require__(78);
  6162. var getBuiltIn = __w_pdfjs_require__(24);
  6163. var inspectSource = __w_pdfjs_require__(51);
  6164. var noop = function () {
  6165. };
  6166. var empty = [];
  6167. var construct = getBuiltIn('Reflect', 'construct');
  6168. var constructorRegExp = /^\s*(?:class|function)\b/;
  6169. var exec = uncurryThis(constructorRegExp.exec);
  6170. var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
  6171. var isConstructorModern = function isConstructor(argument) {
  6172. if (!isCallable(argument))
  6173. return false;
  6174. try {
  6175. construct(noop, empty, argument);
  6176. return true;
  6177. } catch (error) {
  6178. return false;
  6179. }
  6180. };
  6181. var isConstructorLegacy = function isConstructor(argument) {
  6182. if (!isCallable(argument))
  6183. return false;
  6184. switch (classof(argument)) {
  6185. case 'AsyncFunction':
  6186. case 'GeneratorFunction':
  6187. case 'AsyncGeneratorFunction':
  6188. return false;
  6189. }
  6190. try {
  6191. return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
  6192. } catch (error) {
  6193. return true;
  6194. }
  6195. };
  6196. isConstructorLegacy.sham = true;
  6197. module.exports = !construct || fails(function () {
  6198. var called;
  6199. return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () {
  6200. called = true;
  6201. }) || called;
  6202. }) ? isConstructorLegacy : isConstructorModern;
  6203. /***/ }),
  6204. /* 154 */
  6205. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6206. var bind = __w_pdfjs_require__(99);
  6207. var call = __w_pdfjs_require__(8);
  6208. var anObject = __w_pdfjs_require__(47);
  6209. var tryToString = __w_pdfjs_require__(32);
  6210. var isArrayIteratorMethod = __w_pdfjs_require__(155);
  6211. var lengthOfArrayLike = __w_pdfjs_require__(64);
  6212. var isPrototypeOf = __w_pdfjs_require__(25);
  6213. var getIterator = __w_pdfjs_require__(157);
  6214. var getIteratorMethod = __w_pdfjs_require__(158);
  6215. var iteratorClose = __w_pdfjs_require__(140);
  6216. var $TypeError = TypeError;
  6217. var Result = function (stopped, result) {
  6218. this.stopped = stopped;
  6219. this.result = result;
  6220. };
  6221. var ResultPrototype = Result.prototype;
  6222. module.exports = function (iterable, unboundFunction, options) {
  6223. var that = options && options.that;
  6224. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  6225. var IS_RECORD = !!(options && options.IS_RECORD);
  6226. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  6227. var INTERRUPTED = !!(options && options.INTERRUPTED);
  6228. var fn = bind(unboundFunction, that);
  6229. var iterator, iterFn, index, length, result, next, step;
  6230. var stop = function (condition) {
  6231. if (iterator)
  6232. iteratorClose(iterator, 'normal', condition);
  6233. return new Result(true, condition);
  6234. };
  6235. var callFn = function (value) {
  6236. if (AS_ENTRIES) {
  6237. anObject(value);
  6238. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  6239. }
  6240. return INTERRUPTED ? fn(value, stop) : fn(value);
  6241. };
  6242. if (IS_RECORD) {
  6243. iterator = iterable.iterator;
  6244. } else if (IS_ITERATOR) {
  6245. iterator = iterable;
  6246. } else {
  6247. iterFn = getIteratorMethod(iterable);
  6248. if (!iterFn)
  6249. throw $TypeError(tryToString(iterable) + ' is not iterable');
  6250. if (isArrayIteratorMethod(iterFn)) {
  6251. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  6252. result = callFn(iterable[index]);
  6253. if (result && isPrototypeOf(ResultPrototype, result))
  6254. return result;
  6255. }
  6256. return new Result(false);
  6257. }
  6258. iterator = getIterator(iterable, iterFn);
  6259. }
  6260. next = IS_RECORD ? iterable.next : iterator.next;
  6261. while (!(step = call(next, iterator)).done) {
  6262. try {
  6263. result = callFn(step.value);
  6264. } catch (error) {
  6265. iteratorClose(iterator, 'throw', error);
  6266. }
  6267. if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result))
  6268. return result;
  6269. }
  6270. return new Result(false);
  6271. };
  6272. /***/ }),
  6273. /* 155 */
  6274. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6275. var wellKnownSymbol = __w_pdfjs_require__(34);
  6276. var Iterators = __w_pdfjs_require__(156);
  6277. var ITERATOR = wellKnownSymbol('iterator');
  6278. var ArrayPrototype = Array.prototype;
  6279. module.exports = function (it) {
  6280. return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
  6281. };
  6282. /***/ }),
  6283. /* 156 */
  6284. /***/ ((module) => {
  6285. module.exports = {};
  6286. /***/ }),
  6287. /* 157 */
  6288. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6289. var call = __w_pdfjs_require__(8);
  6290. var aCallable = __w_pdfjs_require__(31);
  6291. var anObject = __w_pdfjs_require__(47);
  6292. var tryToString = __w_pdfjs_require__(32);
  6293. var getIteratorMethod = __w_pdfjs_require__(158);
  6294. var $TypeError = TypeError;
  6295. module.exports = function (argument, usingIterator) {
  6296. var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
  6297. if (aCallable(iteratorMethod))
  6298. return anObject(call(iteratorMethod, argument));
  6299. throw $TypeError(tryToString(argument) + ' is not iterable');
  6300. };
  6301. /***/ }),
  6302. /* 158 */
  6303. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6304. var classof = __w_pdfjs_require__(78);
  6305. var getMethod = __w_pdfjs_require__(30);
  6306. var isNullOrUndefined = __w_pdfjs_require__(17);
  6307. var Iterators = __w_pdfjs_require__(156);
  6308. var wellKnownSymbol = __w_pdfjs_require__(34);
  6309. var ITERATOR = wellKnownSymbol('iterator');
  6310. module.exports = function (it) {
  6311. if (!isNullOrUndefined(it))
  6312. return getMethod(it, ITERATOR) || getMethod(it, '@@iterator') || Iterators[classof(it)];
  6313. };
  6314. /***/ }),
  6315. /* 159 */
  6316. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6317. var toPropertyKey = __w_pdfjs_require__(18);
  6318. var definePropertyModule = __w_pdfjs_require__(45);
  6319. var createPropertyDescriptor = __w_pdfjs_require__(11);
  6320. module.exports = function (object, key, value) {
  6321. var propertyKey = toPropertyKey(key);
  6322. if (propertyKey in object)
  6323. definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
  6324. else
  6325. object[propertyKey] = value;
  6326. };
  6327. /***/ }),
  6328. /* 160 */
  6329. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6330. var call = __w_pdfjs_require__(8);
  6331. var hasOwn = __w_pdfjs_require__(39);
  6332. var isPrototypeOf = __w_pdfjs_require__(25);
  6333. var regExpFlags = __w_pdfjs_require__(161);
  6334. var RegExpPrototype = RegExp.prototype;
  6335. module.exports = function (R) {
  6336. var flags = R.flags;
  6337. return flags === undefined && !('flags' in RegExpPrototype) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype, R) ? call(regExpFlags, R) : flags;
  6338. };
  6339. /***/ }),
  6340. /* 161 */
  6341. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6342. var anObject = __w_pdfjs_require__(47);
  6343. module.exports = function () {
  6344. var that = anObject(this);
  6345. var result = '';
  6346. if (that.hasIndices)
  6347. result += 'd';
  6348. if (that.global)
  6349. result += 'g';
  6350. if (that.ignoreCase)
  6351. result += 'i';
  6352. if (that.multiline)
  6353. result += 'm';
  6354. if (that.dotAll)
  6355. result += 's';
  6356. if (that.unicode)
  6357. result += 'u';
  6358. if (that.unicodeSets)
  6359. result += 'v';
  6360. if (that.sticky)
  6361. result += 'y';
  6362. return result;
  6363. };
  6364. /***/ }),
  6365. /* 162 */
  6366. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  6367. var uncurryThis = __w_pdfjs_require__(14);
  6368. var MapPrototype = Map.prototype;
  6369. module.exports = {
  6370. Map: Map,
  6371. set: uncurryThis(MapPrototype.set),
  6372. get: uncurryThis(MapPrototype.get),
  6373. has: uncurryThis(MapPrototype.has),
  6374. remove: uncurryThis(MapPrototype['delete']),
  6375. proto: MapPrototype
  6376. };
  6377. /***/ }),
  6378. /* 163 */
  6379. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6380. Object.defineProperty(exports, "__esModule", ({
  6381. value: true
  6382. }));
  6383. exports.SerializableEmpty = exports.PrintAnnotationStorage = exports.AnnotationStorage = void 0;
  6384. __w_pdfjs_require__(89);
  6385. __w_pdfjs_require__(149);
  6386. __w_pdfjs_require__(152);
  6387. var _util = __w_pdfjs_require__(1);
  6388. var _editor = __w_pdfjs_require__(164);
  6389. var _murmurhash = __w_pdfjs_require__(170);
  6390. const SerializableEmpty = Object.freeze({
  6391. map: null,
  6392. hash: "",
  6393. transfers: undefined
  6394. });
  6395. exports.SerializableEmpty = SerializableEmpty;
  6396. class AnnotationStorage {
  6397. #modified = false;
  6398. #storage = new Map();
  6399. constructor() {
  6400. this.onSetModified = null;
  6401. this.onResetModified = null;
  6402. this.onAnnotationEditor = null;
  6403. }
  6404. getValue(key, defaultValue) {
  6405. const value = this.#storage.get(key);
  6406. if (value === undefined) {
  6407. return defaultValue;
  6408. }
  6409. return Object.assign(defaultValue, value);
  6410. }
  6411. getRawValue(key) {
  6412. return this.#storage.get(key);
  6413. }
  6414. remove(key) {
  6415. this.#storage.delete(key);
  6416. if (this.#storage.size === 0) {
  6417. this.resetModified();
  6418. }
  6419. if (typeof this.onAnnotationEditor === "function") {
  6420. for (const value of this.#storage.values()) {
  6421. if (value instanceof _editor.AnnotationEditor) {
  6422. return;
  6423. }
  6424. }
  6425. this.onAnnotationEditor(null);
  6426. }
  6427. }
  6428. setValue(key, value) {
  6429. const obj = this.#storage.get(key);
  6430. let modified = false;
  6431. if (obj !== undefined) {
  6432. for (const [entry, val] of Object.entries(value)) {
  6433. if (obj[entry] !== val) {
  6434. modified = true;
  6435. obj[entry] = val;
  6436. }
  6437. }
  6438. } else {
  6439. modified = true;
  6440. this.#storage.set(key, value);
  6441. }
  6442. if (modified) {
  6443. this.#setModified();
  6444. }
  6445. if (value instanceof _editor.AnnotationEditor && typeof this.onAnnotationEditor === "function") {
  6446. this.onAnnotationEditor(value.constructor._type);
  6447. }
  6448. }
  6449. has(key) {
  6450. return this.#storage.has(key);
  6451. }
  6452. getAll() {
  6453. return this.#storage.size > 0 ? (0, _util.objectFromMap)(this.#storage) : null;
  6454. }
  6455. setAll(obj) {
  6456. for (const [key, val] of Object.entries(obj)) {
  6457. this.setValue(key, val);
  6458. }
  6459. }
  6460. get size() {
  6461. return this.#storage.size;
  6462. }
  6463. #setModified() {
  6464. if (!this.#modified) {
  6465. this.#modified = true;
  6466. if (typeof this.onSetModified === "function") {
  6467. this.onSetModified();
  6468. }
  6469. }
  6470. }
  6471. resetModified() {
  6472. if (this.#modified) {
  6473. this.#modified = false;
  6474. if (typeof this.onResetModified === "function") {
  6475. this.onResetModified();
  6476. }
  6477. }
  6478. }
  6479. get print() {
  6480. return new PrintAnnotationStorage(this);
  6481. }
  6482. get serializable() {
  6483. if (this.#storage.size === 0) {
  6484. return SerializableEmpty;
  6485. }
  6486. const map = new Map(),
  6487. hash = new _murmurhash.MurmurHash3_64(),
  6488. transfers = [];
  6489. const context = Object.create(null);
  6490. let hasBitmap = false;
  6491. for (const [key, val] of this.#storage) {
  6492. const serialized = val instanceof _editor.AnnotationEditor ? val.serialize(false, context) : val;
  6493. if (serialized) {
  6494. map.set(key, serialized);
  6495. hash.update(`${key}:${JSON.stringify(serialized)}`);
  6496. hasBitmap ||= !!serialized.bitmap;
  6497. }
  6498. }
  6499. if (hasBitmap) {
  6500. for (const value of map.values()) {
  6501. if (value.bitmap) {
  6502. transfers.push(value.bitmap);
  6503. }
  6504. }
  6505. }
  6506. return map.size > 0 ? {
  6507. map,
  6508. hash: hash.hexdigest(),
  6509. transfers
  6510. } : SerializableEmpty;
  6511. }
  6512. }
  6513. exports.AnnotationStorage = AnnotationStorage;
  6514. class PrintAnnotationStorage extends AnnotationStorage {
  6515. #serializable;
  6516. constructor(parent) {
  6517. super();
  6518. const {
  6519. map,
  6520. hash,
  6521. transfers
  6522. } = parent.serializable;
  6523. const clone = structuredClone(map, null);
  6524. this.#serializable = {
  6525. map: clone,
  6526. hash,
  6527. transfers
  6528. };
  6529. }
  6530. get print() {
  6531. (0, _util.unreachable)("Should not call PrintAnnotationStorage.print");
  6532. }
  6533. get serializable() {
  6534. return this.#serializable;
  6535. }
  6536. }
  6537. exports.PrintAnnotationStorage = PrintAnnotationStorage;
  6538. /***/ }),
  6539. /* 164 */
  6540. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6541. Object.defineProperty(exports, "__esModule", ({
  6542. value: true
  6543. }));
  6544. exports.AnnotationEditor = void 0;
  6545. __w_pdfjs_require__(89);
  6546. __w_pdfjs_require__(2);
  6547. var _tools = __w_pdfjs_require__(165);
  6548. var _util = __w_pdfjs_require__(1);
  6549. class AnnotationEditor {
  6550. #keepAspectRatio = false;
  6551. #resizersDiv = null;
  6552. #boundFocusin = this.focusin.bind(this);
  6553. #boundFocusout = this.focusout.bind(this);
  6554. #hasBeenClicked = false;
  6555. #isEditing = false;
  6556. #isInEditMode = false;
  6557. _initialOptions = Object.create(null);
  6558. _uiManager = null;
  6559. _focusEventsAllowed = true;
  6560. #isDraggable = false;
  6561. #zIndex = AnnotationEditor._zIndex++;
  6562. static _colorManager = new _tools.ColorManager();
  6563. static _zIndex = 1;
  6564. constructor(parameters) {
  6565. if (this.constructor === AnnotationEditor) {
  6566. (0, _util.unreachable)("Cannot initialize AnnotationEditor.");
  6567. }
  6568. this.parent = parameters.parent;
  6569. this.id = parameters.id;
  6570. this.width = this.height = null;
  6571. this.pageIndex = parameters.parent.pageIndex;
  6572. this.name = parameters.name;
  6573. this.div = null;
  6574. this._uiManager = parameters.uiManager;
  6575. this.annotationElementId = null;
  6576. this._willKeepAspectRatio = false;
  6577. this._initialOptions.isCentered = parameters.isCentered;
  6578. const {
  6579. rotation,
  6580. rawDims: {
  6581. pageWidth,
  6582. pageHeight,
  6583. pageX,
  6584. pageY
  6585. }
  6586. } = this.parent.viewport;
  6587. this.rotation = rotation;
  6588. this.pageRotation = (360 + rotation - this._uiManager.viewParameters.rotation) % 360;
  6589. this.pageDimensions = [pageWidth, pageHeight];
  6590. this.pageTranslation = [pageX, pageY];
  6591. const [width, height] = this.parentDimensions;
  6592. this.x = parameters.x / width;
  6593. this.y = parameters.y / height;
  6594. this.isAttachedToDOM = false;
  6595. this.deleted = false;
  6596. }
  6597. static get _defaultLineColor() {
  6598. return (0, _util.shadow)(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
  6599. }
  6600. static deleteAnnotationElement(editor) {
  6601. const fakeEditor = new FakeEditor({
  6602. id: editor.parent.getNextId(),
  6603. parent: editor.parent,
  6604. uiManager: editor._uiManager
  6605. });
  6606. fakeEditor.annotationElementId = editor.annotationElementId;
  6607. fakeEditor.deleted = true;
  6608. fakeEditor._uiManager.addToAnnotationStorage(fakeEditor);
  6609. }
  6610. static initialize(_l10n) {}
  6611. static updateDefaultParams(_type, _value) {}
  6612. static get defaultPropertiesToUpdate() {
  6613. return [];
  6614. }
  6615. static isHandlingMimeForPasting(_mime) {
  6616. return false;
  6617. }
  6618. static paste(item, parent) {
  6619. (0, _util.unreachable)("Not implemented");
  6620. }
  6621. get propertiesToUpdate() {
  6622. return [];
  6623. }
  6624. get _isDraggable() {
  6625. return this.#isDraggable;
  6626. }
  6627. set _isDraggable(value) {
  6628. this.#isDraggable = value;
  6629. this.div?.classList.toggle("draggable", value);
  6630. }
  6631. center() {
  6632. const [pageWidth, pageHeight] = this.pageDimensions;
  6633. switch (this.parentRotation) {
  6634. case 90:
  6635. this.x -= this.height * pageHeight / (pageWidth * 2);
  6636. this.y += this.width * pageWidth / (pageHeight * 2);
  6637. break;
  6638. case 180:
  6639. this.x += this.width / 2;
  6640. this.y += this.height / 2;
  6641. break;
  6642. case 270:
  6643. this.x += this.height * pageHeight / (pageWidth * 2);
  6644. this.y -= this.width * pageWidth / (pageHeight * 2);
  6645. break;
  6646. default:
  6647. this.x -= this.width / 2;
  6648. this.y -= this.height / 2;
  6649. break;
  6650. }
  6651. this.fixAndSetPosition();
  6652. }
  6653. addCommands(params) {
  6654. this._uiManager.addCommands(params);
  6655. }
  6656. get currentLayer() {
  6657. return this._uiManager.currentLayer;
  6658. }
  6659. setInBackground() {
  6660. this.div.style.zIndex = 0;
  6661. }
  6662. setInForeground() {
  6663. this.div.style.zIndex = this.#zIndex;
  6664. }
  6665. setParent(parent) {
  6666. if (parent !== null) {
  6667. this.pageIndex = parent.pageIndex;
  6668. this.pageDimensions = parent.pageDimensions;
  6669. }
  6670. this.parent = parent;
  6671. }
  6672. focusin(event) {
  6673. if (!this._focusEventsAllowed) {
  6674. return;
  6675. }
  6676. if (!this.#hasBeenClicked) {
  6677. this.parent.setSelected(this);
  6678. } else {
  6679. this.#hasBeenClicked = false;
  6680. }
  6681. }
  6682. focusout(event) {
  6683. if (!this._focusEventsAllowed) {
  6684. return;
  6685. }
  6686. if (!this.isAttachedToDOM) {
  6687. return;
  6688. }
  6689. const target = event.relatedTarget;
  6690. if (target?.closest(`#${this.id}`)) {
  6691. return;
  6692. }
  6693. event.preventDefault();
  6694. if (!this.parent?.isMultipleSelection) {
  6695. this.commitOrRemove();
  6696. }
  6697. }
  6698. commitOrRemove() {
  6699. if (this.isEmpty()) {
  6700. this.remove();
  6701. } else {
  6702. this.commit();
  6703. }
  6704. }
  6705. commit() {
  6706. this.addToAnnotationStorage();
  6707. }
  6708. addToAnnotationStorage() {
  6709. this._uiManager.addToAnnotationStorage(this);
  6710. }
  6711. setAt(x, y, tx, ty) {
  6712. const [width, height] = this.parentDimensions;
  6713. [tx, ty] = this.screenToPageTranslation(tx, ty);
  6714. this.x = (x + tx) / width;
  6715. this.y = (y + ty) / height;
  6716. this.fixAndSetPosition();
  6717. }
  6718. #translate(_ref, x, y) {
  6719. let [width, height] = _ref;
  6720. [x, y] = this.screenToPageTranslation(x, y);
  6721. this.x += x / width;
  6722. this.y += y / height;
  6723. this.fixAndSetPosition();
  6724. }
  6725. translate(x, y) {
  6726. this.#translate(this.parentDimensions, x, y);
  6727. }
  6728. translateInPage(x, y) {
  6729. this.#translate(this.pageDimensions, x, y);
  6730. this.moveInDOM();
  6731. this.div.scrollIntoView({
  6732. block: "nearest"
  6733. });
  6734. }
  6735. drag(tx, ty) {
  6736. const [parentWidth, parentHeight] = this.parentDimensions;
  6737. this.x += tx / parentWidth;
  6738. this.y += ty / parentHeight;
  6739. if (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1) {
  6740. const {
  6741. x,
  6742. y
  6743. } = this.div.getBoundingClientRect();
  6744. if (this.parent.findNewParent(this, x, y)) {
  6745. this.x -= Math.floor(this.x);
  6746. this.y -= Math.floor(this.y);
  6747. }
  6748. }
  6749. this.div.style.left = `${(100 * this.x).toFixed(2)}%`;
  6750. this.div.style.top = `${(100 * this.y).toFixed(2)}%`;
  6751. this.div.scrollIntoView({
  6752. block: "nearest"
  6753. });
  6754. }
  6755. fixAndSetPosition() {
  6756. const [pageWidth, pageHeight] = this.pageDimensions;
  6757. let {
  6758. x,
  6759. y,
  6760. width,
  6761. height
  6762. } = this;
  6763. width *= pageWidth;
  6764. height *= pageHeight;
  6765. x *= pageWidth;
  6766. y *= pageHeight;
  6767. switch (this.rotation) {
  6768. case 0:
  6769. x = Math.max(0, Math.min(pageWidth - width, x));
  6770. y = Math.max(0, Math.min(pageHeight - height, y));
  6771. break;
  6772. case 90:
  6773. x = Math.max(0, Math.min(pageWidth - height, x));
  6774. y = Math.min(pageHeight, Math.max(width, y));
  6775. break;
  6776. case 180:
  6777. x = Math.min(pageWidth, Math.max(width, x));
  6778. y = Math.min(pageHeight, Math.max(height, y));
  6779. break;
  6780. case 270:
  6781. x = Math.min(pageWidth, Math.max(height, x));
  6782. y = Math.max(0, Math.min(pageHeight - width, y));
  6783. break;
  6784. }
  6785. this.x = x / pageWidth;
  6786. this.y = y / pageHeight;
  6787. this.div.style.left = `${(100 * this.x).toFixed(2)}%`;
  6788. this.div.style.top = `${(100 * this.y).toFixed(2)}%`;
  6789. }
  6790. static #rotatePoint(x, y, angle) {
  6791. switch (angle) {
  6792. case 90:
  6793. return [y, -x];
  6794. case 180:
  6795. return [-x, -y];
  6796. case 270:
  6797. return [-y, x];
  6798. default:
  6799. return [x, y];
  6800. }
  6801. }
  6802. screenToPageTranslation(x, y) {
  6803. return AnnotationEditor.#rotatePoint(x, y, this.parentRotation);
  6804. }
  6805. pageTranslationToScreen(x, y) {
  6806. return AnnotationEditor.#rotatePoint(x, y, 360 - this.parentRotation);
  6807. }
  6808. #getRotationMatrix(rotation) {
  6809. switch (rotation) {
  6810. case 90:
  6811. {
  6812. const [pageWidth, pageHeight] = this.pageDimensions;
  6813. return [0, -pageWidth / pageHeight, pageHeight / pageWidth, 0];
  6814. }
  6815. case 180:
  6816. return [-1, 0, 0, -1];
  6817. case 270:
  6818. {
  6819. const [pageWidth, pageHeight] = this.pageDimensions;
  6820. return [0, pageWidth / pageHeight, -pageHeight / pageWidth, 0];
  6821. }
  6822. default:
  6823. return [1, 0, 0, 1];
  6824. }
  6825. }
  6826. get parentScale() {
  6827. return this._uiManager.viewParameters.realScale;
  6828. }
  6829. get parentRotation() {
  6830. return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
  6831. }
  6832. get parentDimensions() {
  6833. const {
  6834. parentScale,
  6835. pageDimensions: [pageWidth, pageHeight]
  6836. } = this;
  6837. const scaledWidth = pageWidth * parentScale;
  6838. const scaledHeight = pageHeight * parentScale;
  6839. return _util.FeatureTest.isCSSRoundSupported ? [Math.round(scaledWidth), Math.round(scaledHeight)] : [scaledWidth, scaledHeight];
  6840. }
  6841. setDims(width, height) {
  6842. const [parentWidth, parentHeight] = this.parentDimensions;
  6843. this.div.style.width = `${(100 * width / parentWidth).toFixed(2)}%`;
  6844. if (!this.#keepAspectRatio) {
  6845. this.div.style.height = `${(100 * height / parentHeight).toFixed(2)}%`;
  6846. }
  6847. }
  6848. fixDims() {
  6849. const {
  6850. style
  6851. } = this.div;
  6852. const {
  6853. height,
  6854. width
  6855. } = style;
  6856. const widthPercent = width.endsWith("%");
  6857. const heightPercent = !this.#keepAspectRatio && height.endsWith("%");
  6858. if (widthPercent && heightPercent) {
  6859. return;
  6860. }
  6861. const [parentWidth, parentHeight] = this.parentDimensions;
  6862. if (!widthPercent) {
  6863. style.width = `${(100 * parseFloat(width) / parentWidth).toFixed(2)}%`;
  6864. }
  6865. if (!this.#keepAspectRatio && !heightPercent) {
  6866. style.height = `${(100 * parseFloat(height) / parentHeight).toFixed(2)}%`;
  6867. }
  6868. }
  6869. getInitialTranslation() {
  6870. return [0, 0];
  6871. }
  6872. static #noContextMenu(e) {
  6873. e.preventDefault();
  6874. }
  6875. #createResizers() {
  6876. if (this.#resizersDiv) {
  6877. return;
  6878. }
  6879. this.#resizersDiv = document.createElement("div");
  6880. this.#resizersDiv.classList.add("resizers");
  6881. const classes = ["topLeft", "topRight", "bottomRight", "bottomLeft"];
  6882. if (!this._willKeepAspectRatio) {
  6883. classes.push("topMiddle", "middleRight", "bottomMiddle", "middleLeft");
  6884. }
  6885. for (const name of classes) {
  6886. const div = document.createElement("div");
  6887. this.#resizersDiv.append(div);
  6888. div.classList.add("resizer", name);
  6889. div.addEventListener("pointerdown", this.#resizerPointerdown.bind(this, name));
  6890. div.addEventListener("contextmenu", AnnotationEditor.#noContextMenu);
  6891. }
  6892. this.div.prepend(this.#resizersDiv);
  6893. }
  6894. #resizerPointerdown(name, event) {
  6895. event.preventDefault();
  6896. const {
  6897. isMac
  6898. } = _util.FeatureTest.platform;
  6899. if (event.button !== 0 || event.ctrlKey && isMac) {
  6900. return;
  6901. }
  6902. const boundResizerPointermove = this.#resizerPointermove.bind(this, name);
  6903. const savedDraggable = this._isDraggable;
  6904. this._isDraggable = false;
  6905. const pointerMoveOptions = {
  6906. passive: true,
  6907. capture: true
  6908. };
  6909. window.addEventListener("pointermove", boundResizerPointermove, pointerMoveOptions);
  6910. const savedX = this.x;
  6911. const savedY = this.y;
  6912. const savedWidth = this.width;
  6913. const savedHeight = this.height;
  6914. const savedParentCursor = this.parent.div.style.cursor;
  6915. const savedCursor = this.div.style.cursor;
  6916. this.div.style.cursor = this.parent.div.style.cursor = window.getComputedStyle(event.target).cursor;
  6917. const pointerUpCallback = () => {
  6918. this._isDraggable = savedDraggable;
  6919. window.removeEventListener("pointerup", pointerUpCallback);
  6920. window.removeEventListener("blur", pointerUpCallback);
  6921. window.removeEventListener("pointermove", boundResizerPointermove, pointerMoveOptions);
  6922. this.parent.div.style.cursor = savedParentCursor;
  6923. this.div.style.cursor = savedCursor;
  6924. const newX = this.x;
  6925. const newY = this.y;
  6926. const newWidth = this.width;
  6927. const newHeight = this.height;
  6928. if (newX === savedX && newY === savedY && newWidth === savedWidth && newHeight === savedHeight) {
  6929. return;
  6930. }
  6931. this.addCommands({
  6932. cmd: () => {
  6933. this.width = newWidth;
  6934. this.height = newHeight;
  6935. this.x = newX;
  6936. this.y = newY;
  6937. const [parentWidth, parentHeight] = this.parentDimensions;
  6938. this.setDims(parentWidth * newWidth, parentHeight * newHeight);
  6939. this.fixAndSetPosition();
  6940. this.moveInDOM();
  6941. },
  6942. undo: () => {
  6943. this.width = savedWidth;
  6944. this.height = savedHeight;
  6945. this.x = savedX;
  6946. this.y = savedY;
  6947. const [parentWidth, parentHeight] = this.parentDimensions;
  6948. this.setDims(parentWidth * savedWidth, parentHeight * savedHeight);
  6949. this.fixAndSetPosition();
  6950. this.moveInDOM();
  6951. },
  6952. mustExec: true
  6953. });
  6954. };
  6955. window.addEventListener("pointerup", pointerUpCallback);
  6956. window.addEventListener("blur", pointerUpCallback);
  6957. }
  6958. #resizerPointermove(name, event) {
  6959. const [parentWidth, parentHeight] = this.parentDimensions;
  6960. const savedX = this.x;
  6961. const savedY = this.y;
  6962. const savedWidth = this.width;
  6963. const savedHeight = this.height;
  6964. const minWidth = AnnotationEditor.MIN_SIZE / parentWidth;
  6965. const minHeight = AnnotationEditor.MIN_SIZE / parentHeight;
  6966. const round = x => Math.round(x * 10000) / 10000;
  6967. const rotationMatrix = this.#getRotationMatrix(this.rotation);
  6968. const transf = (x, y) => [rotationMatrix[0] * x + rotationMatrix[2] * y, rotationMatrix[1] * x + rotationMatrix[3] * y];
  6969. const invRotationMatrix = this.#getRotationMatrix(360 - this.rotation);
  6970. const invTransf = (x, y) => [invRotationMatrix[0] * x + invRotationMatrix[2] * y, invRotationMatrix[1] * x + invRotationMatrix[3] * y];
  6971. let getPoint;
  6972. let getOpposite;
  6973. let isDiagonal = false;
  6974. let isHorizontal = false;
  6975. switch (name) {
  6976. case "topLeft":
  6977. isDiagonal = true;
  6978. getPoint = (w, h) => [0, 0];
  6979. getOpposite = (w, h) => [w, h];
  6980. break;
  6981. case "topMiddle":
  6982. getPoint = (w, h) => [w / 2, 0];
  6983. getOpposite = (w, h) => [w / 2, h];
  6984. break;
  6985. case "topRight":
  6986. isDiagonal = true;
  6987. getPoint = (w, h) => [w, 0];
  6988. getOpposite = (w, h) => [0, h];
  6989. break;
  6990. case "middleRight":
  6991. isHorizontal = true;
  6992. getPoint = (w, h) => [w, h / 2];
  6993. getOpposite = (w, h) => [0, h / 2];
  6994. break;
  6995. case "bottomRight":
  6996. isDiagonal = true;
  6997. getPoint = (w, h) => [w, h];
  6998. getOpposite = (w, h) => [0, 0];
  6999. break;
  7000. case "bottomMiddle":
  7001. getPoint = (w, h) => [w / 2, h];
  7002. getOpposite = (w, h) => [w / 2, 0];
  7003. break;
  7004. case "bottomLeft":
  7005. isDiagonal = true;
  7006. getPoint = (w, h) => [0, h];
  7007. getOpposite = (w, h) => [w, 0];
  7008. break;
  7009. case "middleLeft":
  7010. isHorizontal = true;
  7011. getPoint = (w, h) => [0, h / 2];
  7012. getOpposite = (w, h) => [w, h / 2];
  7013. break;
  7014. }
  7015. const point = getPoint(savedWidth, savedHeight);
  7016. const oppositePoint = getOpposite(savedWidth, savedHeight);
  7017. let transfOppositePoint = transf(...oppositePoint);
  7018. const oppositeX = round(savedX + transfOppositePoint[0]);
  7019. const oppositeY = round(savedY + transfOppositePoint[1]);
  7020. let ratioX = 1;
  7021. let ratioY = 1;
  7022. let [deltaX, deltaY] = this.screenToPageTranslation(event.movementX, event.movementY);
  7023. [deltaX, deltaY] = invTransf(deltaX / parentWidth, deltaY / parentHeight);
  7024. if (isDiagonal) {
  7025. const oldDiag = Math.hypot(savedWidth, savedHeight);
  7026. ratioX = ratioY = Math.max(Math.min(Math.hypot(oppositePoint[0] - point[0] - deltaX, oppositePoint[1] - point[1] - deltaY) / oldDiag, 1 / savedWidth, 1 / savedHeight), minWidth / savedWidth, minHeight / savedHeight);
  7027. } else if (isHorizontal) {
  7028. ratioX = Math.max(minWidth, Math.min(1, Math.abs(oppositePoint[0] - point[0] - deltaX))) / savedWidth;
  7029. } else {
  7030. ratioY = Math.max(minHeight, Math.min(1, Math.abs(oppositePoint[1] - point[1] - deltaY))) / savedHeight;
  7031. }
  7032. const newWidth = round(savedWidth * ratioX);
  7033. const newHeight = round(savedHeight * ratioY);
  7034. transfOppositePoint = transf(...getOpposite(newWidth, newHeight));
  7035. const newX = oppositeX - transfOppositePoint[0];
  7036. const newY = oppositeY - transfOppositePoint[1];
  7037. this.width = newWidth;
  7038. this.height = newHeight;
  7039. this.x = newX;
  7040. this.y = newY;
  7041. this.setDims(parentWidth * newWidth, parentHeight * newHeight);
  7042. this.fixAndSetPosition();
  7043. }
  7044. render() {
  7045. this.div = document.createElement("div");
  7046. this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
  7047. this.div.className = this.name;
  7048. this.div.setAttribute("id", this.id);
  7049. this.div.setAttribute("tabIndex", 0);
  7050. this.setInForeground();
  7051. this.div.addEventListener("focusin", this.#boundFocusin);
  7052. this.div.addEventListener("focusout", this.#boundFocusout);
  7053. const [parentWidth, parentHeight] = this.parentDimensions;
  7054. if (this.parentRotation % 180 !== 0) {
  7055. this.div.style.maxWidth = `${(100 * parentHeight / parentWidth).toFixed(2)}%`;
  7056. this.div.style.maxHeight = `${(100 * parentWidth / parentHeight).toFixed(2)}%`;
  7057. }
  7058. const [tx, ty] = this.getInitialTranslation();
  7059. this.translate(tx, ty);
  7060. (0, _tools.bindEvents)(this, this.div, ["pointerdown"]);
  7061. return this.div;
  7062. }
  7063. pointerdown(event) {
  7064. const {
  7065. isMac
  7066. } = _util.FeatureTest.platform;
  7067. if (event.button !== 0 || event.ctrlKey && isMac) {
  7068. event.preventDefault();
  7069. return;
  7070. }
  7071. this.#hasBeenClicked = true;
  7072. this.#setUpDragSession(event);
  7073. }
  7074. #setUpDragSession(event) {
  7075. if (!this._isDraggable) {
  7076. return;
  7077. }
  7078. const isSelected = this._uiManager.isSelected(this);
  7079. this._uiManager.setUpDragSession();
  7080. let pointerMoveOptions, pointerMoveCallback;
  7081. if (isSelected) {
  7082. pointerMoveOptions = {
  7083. passive: true,
  7084. capture: true
  7085. };
  7086. pointerMoveCallback = e => {
  7087. const [tx, ty] = this.screenToPageTranslation(e.movementX, e.movementY);
  7088. this._uiManager.dragSelectedEditors(tx, ty);
  7089. };
  7090. window.addEventListener("pointermove", pointerMoveCallback, pointerMoveOptions);
  7091. }
  7092. const pointerUpCallback = () => {
  7093. window.removeEventListener("pointerup", pointerUpCallback);
  7094. window.removeEventListener("blur", pointerUpCallback);
  7095. if (isSelected) {
  7096. window.removeEventListener("pointermove", pointerMoveCallback, pointerMoveOptions);
  7097. }
  7098. this.#hasBeenClicked = false;
  7099. if (!this._uiManager.endDragSession()) {
  7100. const {
  7101. isMac
  7102. } = _util.FeatureTest.platform;
  7103. if (event.ctrlKey && !isMac || event.shiftKey || event.metaKey && isMac) {
  7104. this.parent.toggleSelected(this);
  7105. } else {
  7106. this.parent.setSelected(this);
  7107. }
  7108. }
  7109. };
  7110. window.addEventListener("pointerup", pointerUpCallback);
  7111. window.addEventListener("blur", pointerUpCallback);
  7112. }
  7113. moveInDOM() {
  7114. this.parent.moveEditorInDOM(this);
  7115. }
  7116. _setParentAndPosition(parent, x, y) {
  7117. parent.changeParent(this);
  7118. this.x = x;
  7119. this.y = y;
  7120. this.fixAndSetPosition();
  7121. this.moveInDOM();
  7122. }
  7123. getRect(tx, ty) {
  7124. const scale = this.parentScale;
  7125. const [pageWidth, pageHeight] = this.pageDimensions;
  7126. const [pageX, pageY] = this.pageTranslation;
  7127. const shiftX = tx / scale;
  7128. const shiftY = ty / scale;
  7129. const x = this.x * pageWidth;
  7130. const y = this.y * pageHeight;
  7131. const width = this.width * pageWidth;
  7132. const height = this.height * pageHeight;
  7133. switch (this.rotation) {
  7134. case 0:
  7135. return [x + shiftX + pageX, pageHeight - y - shiftY - height + pageY, x + shiftX + width + pageX, pageHeight - y - shiftY + pageY];
  7136. case 90:
  7137. return [x + shiftY + pageX, pageHeight - y + shiftX + pageY, x + shiftY + height + pageX, pageHeight - y + shiftX + width + pageY];
  7138. case 180:
  7139. return [x - shiftX - width + pageX, pageHeight - y + shiftY + pageY, x - shiftX + pageX, pageHeight - y + shiftY + height + pageY];
  7140. case 270:
  7141. return [x - shiftY - height + pageX, pageHeight - y - shiftX - width + pageY, x - shiftY + pageX, pageHeight - y - shiftX + pageY];
  7142. default:
  7143. throw new Error("Invalid rotation");
  7144. }
  7145. }
  7146. getRectInCurrentCoords(rect, pageHeight) {
  7147. const [x1, y1, x2, y2] = rect;
  7148. const width = x2 - x1;
  7149. const height = y2 - y1;
  7150. switch (this.rotation) {
  7151. case 0:
  7152. return [x1, pageHeight - y2, width, height];
  7153. case 90:
  7154. return [x1, pageHeight - y1, height, width];
  7155. case 180:
  7156. return [x2, pageHeight - y1, width, height];
  7157. case 270:
  7158. return [x2, pageHeight - y2, height, width];
  7159. default:
  7160. throw new Error("Invalid rotation");
  7161. }
  7162. }
  7163. onceAdded() {}
  7164. isEmpty() {
  7165. return false;
  7166. }
  7167. enableEditMode() {
  7168. this.#isInEditMode = true;
  7169. }
  7170. disableEditMode() {
  7171. this.#isInEditMode = false;
  7172. }
  7173. isInEditMode() {
  7174. return this.#isInEditMode;
  7175. }
  7176. shouldGetKeyboardEvents() {
  7177. return false;
  7178. }
  7179. needsToBeRebuilt() {
  7180. return this.div && !this.isAttachedToDOM;
  7181. }
  7182. rebuild() {
  7183. this.div?.addEventListener("focusin", this.#boundFocusin);
  7184. this.div?.addEventListener("focusout", this.#boundFocusout);
  7185. }
  7186. serialize() {
  7187. let _isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7188. let _context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7189. (0, _util.unreachable)("An editor must be serializable");
  7190. }
  7191. static deserialize(data, parent, uiManager) {
  7192. const editor = new this.prototype.constructor({
  7193. parent,
  7194. id: parent.getNextId(),
  7195. uiManager
  7196. });
  7197. editor.rotation = data.rotation;
  7198. const [pageWidth, pageHeight] = editor.pageDimensions;
  7199. const [x, y, width, height] = editor.getRectInCurrentCoords(data.rect, pageHeight);
  7200. editor.x = x / pageWidth;
  7201. editor.y = y / pageHeight;
  7202. editor.width = width / pageWidth;
  7203. editor.height = height / pageHeight;
  7204. return editor;
  7205. }
  7206. remove() {
  7207. this.div.removeEventListener("focusin", this.#boundFocusin);
  7208. this.div.removeEventListener("focusout", this.#boundFocusout);
  7209. if (!this.isEmpty()) {
  7210. this.commit();
  7211. }
  7212. if (this.parent) {
  7213. this.parent.remove(this);
  7214. } else {
  7215. this._uiManager.removeEditor(this);
  7216. }
  7217. }
  7218. get isResizable() {
  7219. return false;
  7220. }
  7221. makeResizable() {
  7222. if (this.isResizable) {
  7223. this.#createResizers();
  7224. this.#resizersDiv.classList.remove("hidden");
  7225. }
  7226. }
  7227. select() {
  7228. this.makeResizable();
  7229. this.div?.classList.add("selectedEditor");
  7230. }
  7231. unselect() {
  7232. this.#resizersDiv?.classList.add("hidden");
  7233. this.div?.classList.remove("selectedEditor");
  7234. if (this.div?.contains(document.activeElement)) {
  7235. this._uiManager.currentLayer.div.focus();
  7236. }
  7237. }
  7238. updateParams(type, value) {}
  7239. disableEditing() {}
  7240. enableEditing() {}
  7241. enterInEditMode() {}
  7242. get contentDiv() {
  7243. return this.div;
  7244. }
  7245. get isEditing() {
  7246. return this.#isEditing;
  7247. }
  7248. set isEditing(value) {
  7249. this.#isEditing = value;
  7250. if (!this.parent) {
  7251. return;
  7252. }
  7253. if (value) {
  7254. this.parent.setSelected(this);
  7255. this.parent.setActiveEditor(this);
  7256. } else {
  7257. this.parent.setActiveEditor(null);
  7258. }
  7259. }
  7260. setAspectRatio(width, height) {
  7261. this.#keepAspectRatio = true;
  7262. const aspectRatio = width / height;
  7263. const {
  7264. style
  7265. } = this.div;
  7266. style.aspectRatio = aspectRatio;
  7267. style.height = "auto";
  7268. }
  7269. static get MIN_SIZE() {
  7270. return 16;
  7271. }
  7272. }
  7273. exports.AnnotationEditor = AnnotationEditor;
  7274. class FakeEditor extends AnnotationEditor {
  7275. constructor(params) {
  7276. super(params);
  7277. this.annotationElementId = params.annotationElementId;
  7278. this.deleted = true;
  7279. }
  7280. serialize() {
  7281. return {
  7282. id: this.annotationElementId,
  7283. deleted: true,
  7284. pageIndex: this.pageIndex
  7285. };
  7286. }
  7287. }
  7288. /***/ }),
  7289. /* 165 */
  7290. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7291. Object.defineProperty(exports, "__esModule", ({
  7292. value: true
  7293. }));
  7294. exports.KeyboardManager = exports.CommandManager = exports.ColorManager = exports.AnnotationEditorUIManager = void 0;
  7295. exports.bindEvents = bindEvents;
  7296. exports.opacityToHex = opacityToHex;
  7297. __w_pdfjs_require__(93);
  7298. __w_pdfjs_require__(101);
  7299. __w_pdfjs_require__(102);
  7300. __w_pdfjs_require__(105);
  7301. __w_pdfjs_require__(107);
  7302. __w_pdfjs_require__(109);
  7303. __w_pdfjs_require__(113);
  7304. __w_pdfjs_require__(116);
  7305. __w_pdfjs_require__(123);
  7306. __w_pdfjs_require__(2);
  7307. __w_pdfjs_require__(89);
  7308. __w_pdfjs_require__(125);
  7309. __w_pdfjs_require__(136);
  7310. __w_pdfjs_require__(138);
  7311. __w_pdfjs_require__(141);
  7312. __w_pdfjs_require__(143);
  7313. __w_pdfjs_require__(145);
  7314. __w_pdfjs_require__(147);
  7315. __w_pdfjs_require__(166);
  7316. var _util = __w_pdfjs_require__(1);
  7317. var _display_utils = __w_pdfjs_require__(168);
  7318. function bindEvents(obj, element, names) {
  7319. for (const name of names) {
  7320. element.addEventListener(name, obj[name].bind(obj));
  7321. }
  7322. }
  7323. function opacityToHex(opacity) {
  7324. return Math.round(Math.min(255, Math.max(1, 255 * opacity))).toString(16).padStart(2, "0");
  7325. }
  7326. class IdManager {
  7327. #id = 0;
  7328. getId() {
  7329. return `${_util.AnnotationEditorPrefix}${this.#id++}`;
  7330. }
  7331. }
  7332. class ImageManager {
  7333. #baseId = (0, _util.getUuid)();
  7334. #id = 0;
  7335. #cache = null;
  7336. static get _isSVGFittingCanvas() {
  7337. const svg = `data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;
  7338. const canvas = new OffscreenCanvas(1, 3);
  7339. const ctx = canvas.getContext("2d");
  7340. const image = new Image();
  7341. image.src = svg;
  7342. const promise = image.decode().then(() => {
  7343. ctx.drawImage(image, 0, 0, 1, 1, 0, 0, 1, 3);
  7344. return new Uint32Array(ctx.getImageData(0, 0, 1, 1).data.buffer)[0] === 0;
  7345. });
  7346. return (0, _util.shadow)(this, "_isSVGFittingCanvas", promise);
  7347. }
  7348. async #get(key, rawData) {
  7349. this.#cache ||= new Map();
  7350. let data = this.#cache.get(key);
  7351. if (data === null) {
  7352. return null;
  7353. }
  7354. if (data?.bitmap) {
  7355. data.refCounter += 1;
  7356. return data;
  7357. }
  7358. try {
  7359. data ||= {
  7360. bitmap: null,
  7361. id: `image_${this.#baseId}_${this.#id++}`,
  7362. refCounter: 0,
  7363. isSvg: false
  7364. };
  7365. let image;
  7366. if (typeof rawData === "string") {
  7367. data.url = rawData;
  7368. const response = await fetch(rawData);
  7369. if (!response.ok) {
  7370. throw new Error(response.statusText);
  7371. }
  7372. image = await response.blob();
  7373. } else {
  7374. image = data.file = rawData;
  7375. }
  7376. if (image.type === "image/svg+xml") {
  7377. const mustRemoveAspectRatioPromise = ImageManager._isSVGFittingCanvas;
  7378. const fileReader = new FileReader();
  7379. const imageElement = new Image();
  7380. const imagePromise = new Promise((resolve, reject) => {
  7381. imageElement.onload = () => {
  7382. data.bitmap = imageElement;
  7383. data.isSvg = true;
  7384. resolve();
  7385. };
  7386. fileReader.onload = async () => {
  7387. const url = data.svgUrl = fileReader.result;
  7388. imageElement.src = (await mustRemoveAspectRatioPromise) ? `${url}#svgView(preserveAspectRatio(none))` : url;
  7389. };
  7390. imageElement.onerror = fileReader.onerror = reject;
  7391. });
  7392. fileReader.readAsDataURL(image);
  7393. await imagePromise;
  7394. } else {
  7395. data.bitmap = await createImageBitmap(image);
  7396. }
  7397. data.refCounter = 1;
  7398. } catch (e) {
  7399. console.error(e);
  7400. data = null;
  7401. }
  7402. this.#cache.set(key, data);
  7403. if (data) {
  7404. this.#cache.set(data.id, data);
  7405. }
  7406. return data;
  7407. }
  7408. async getFromFile(file) {
  7409. const {
  7410. lastModified,
  7411. name,
  7412. size,
  7413. type
  7414. } = file;
  7415. return this.#get(`${lastModified}_${name}_${size}_${type}`, file);
  7416. }
  7417. async getFromUrl(url) {
  7418. return this.#get(url, url);
  7419. }
  7420. async getFromId(id) {
  7421. this.#cache ||= new Map();
  7422. const data = this.#cache.get(id);
  7423. if (!data) {
  7424. return null;
  7425. }
  7426. if (data.bitmap) {
  7427. data.refCounter += 1;
  7428. return data;
  7429. }
  7430. if (data.file) {
  7431. return this.getFromFile(data.file);
  7432. }
  7433. return this.getFromUrl(data.url);
  7434. }
  7435. getSvgUrl(id) {
  7436. const data = this.#cache.get(id);
  7437. if (!data?.isSvg) {
  7438. return null;
  7439. }
  7440. return data.svgUrl;
  7441. }
  7442. deleteId(id) {
  7443. this.#cache ||= new Map();
  7444. const data = this.#cache.get(id);
  7445. if (!data) {
  7446. return;
  7447. }
  7448. data.refCounter -= 1;
  7449. if (data.refCounter !== 0) {
  7450. return;
  7451. }
  7452. data.bitmap = null;
  7453. }
  7454. isValidId(id) {
  7455. return id.startsWith(`image_${this.#baseId}_`);
  7456. }
  7457. }
  7458. class CommandManager {
  7459. #commands = [];
  7460. #locked = false;
  7461. #maxSize;
  7462. #position = -1;
  7463. constructor() {
  7464. let maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 128;
  7465. this.#maxSize = maxSize;
  7466. }
  7467. add(_ref) {
  7468. let {
  7469. cmd,
  7470. undo,
  7471. mustExec,
  7472. type = NaN,
  7473. overwriteIfSameType = false,
  7474. keepUndo = false
  7475. } = _ref;
  7476. if (mustExec) {
  7477. cmd();
  7478. }
  7479. if (this.#locked) {
  7480. return;
  7481. }
  7482. const save = {
  7483. cmd,
  7484. undo,
  7485. type
  7486. };
  7487. if (this.#position === -1) {
  7488. if (this.#commands.length > 0) {
  7489. this.#commands.length = 0;
  7490. }
  7491. this.#position = 0;
  7492. this.#commands.push(save);
  7493. return;
  7494. }
  7495. if (overwriteIfSameType && this.#commands[this.#position].type === type) {
  7496. if (keepUndo) {
  7497. save.undo = this.#commands[this.#position].undo;
  7498. }
  7499. this.#commands[this.#position] = save;
  7500. return;
  7501. }
  7502. const next = this.#position + 1;
  7503. if (next === this.#maxSize) {
  7504. this.#commands.splice(0, 1);
  7505. } else {
  7506. this.#position = next;
  7507. if (next < this.#commands.length) {
  7508. this.#commands.splice(next);
  7509. }
  7510. }
  7511. this.#commands.push(save);
  7512. }
  7513. undo() {
  7514. if (this.#position === -1) {
  7515. return;
  7516. }
  7517. this.#locked = true;
  7518. this.#commands[this.#position].undo();
  7519. this.#locked = false;
  7520. this.#position -= 1;
  7521. }
  7522. redo() {
  7523. if (this.#position < this.#commands.length - 1) {
  7524. this.#position += 1;
  7525. this.#locked = true;
  7526. this.#commands[this.#position].cmd();
  7527. this.#locked = false;
  7528. }
  7529. }
  7530. hasSomethingToUndo() {
  7531. return this.#position !== -1;
  7532. }
  7533. hasSomethingToRedo() {
  7534. return this.#position < this.#commands.length - 1;
  7535. }
  7536. destroy() {
  7537. this.#commands = null;
  7538. }
  7539. }
  7540. exports.CommandManager = CommandManager;
  7541. class KeyboardManager {
  7542. constructor(callbacks) {
  7543. this.buffer = [];
  7544. this.callbacks = new Map();
  7545. this.allKeys = new Set();
  7546. const {
  7547. isMac
  7548. } = _util.FeatureTest.platform;
  7549. for (const [keys, callback, options = {}] of callbacks) {
  7550. for (const key of keys) {
  7551. const isMacKey = key.startsWith("mac+");
  7552. if (isMac && isMacKey) {
  7553. this.callbacks.set(key.slice(4), {
  7554. callback,
  7555. options
  7556. });
  7557. this.allKeys.add(key.split("+").at(-1));
  7558. } else if (!isMac && !isMacKey) {
  7559. this.callbacks.set(key, {
  7560. callback,
  7561. options
  7562. });
  7563. this.allKeys.add(key.split("+").at(-1));
  7564. }
  7565. }
  7566. }
  7567. }
  7568. #serialize(event) {
  7569. if (event.altKey) {
  7570. this.buffer.push("alt");
  7571. }
  7572. if (event.ctrlKey) {
  7573. this.buffer.push("ctrl");
  7574. }
  7575. if (event.metaKey) {
  7576. this.buffer.push("meta");
  7577. }
  7578. if (event.shiftKey) {
  7579. this.buffer.push("shift");
  7580. }
  7581. this.buffer.push(event.key);
  7582. const str = this.buffer.join("+");
  7583. this.buffer.length = 0;
  7584. return str;
  7585. }
  7586. exec(self, event) {
  7587. if (!this.allKeys.has(event.key)) {
  7588. return;
  7589. }
  7590. const info = this.callbacks.get(this.#serialize(event));
  7591. if (!info) {
  7592. return;
  7593. }
  7594. const {
  7595. callback,
  7596. options: {
  7597. bubbles = false,
  7598. args = [],
  7599. checker = null
  7600. }
  7601. } = info;
  7602. if (checker && !checker(self, event)) {
  7603. return;
  7604. }
  7605. callback.bind(self, ...args)();
  7606. if (!bubbles) {
  7607. event.stopPropagation();
  7608. event.preventDefault();
  7609. }
  7610. }
  7611. }
  7612. exports.KeyboardManager = KeyboardManager;
  7613. class ColorManager {
  7614. static _colorsMapping = new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]]);
  7615. get _colors() {
  7616. const colors = new Map([["CanvasText", null], ["Canvas", null]]);
  7617. (0, _display_utils.getColorValues)(colors);
  7618. return (0, _util.shadow)(this, "_colors", colors);
  7619. }
  7620. convert(color) {
  7621. const rgb = (0, _display_utils.getRGB)(color);
  7622. if (!window.matchMedia("(forced-colors: active)").matches) {
  7623. return rgb;
  7624. }
  7625. for (const [name, RGB] of this._colors) {
  7626. if (RGB.every((x, i) => x === rgb[i])) {
  7627. return ColorManager._colorsMapping.get(name);
  7628. }
  7629. }
  7630. return rgb;
  7631. }
  7632. getHexCode(name) {
  7633. const rgb = this._colors.get(name);
  7634. if (!rgb) {
  7635. return name;
  7636. }
  7637. return _util.Util.makeHexColor(...rgb);
  7638. }
  7639. }
  7640. exports.ColorManager = ColorManager;
  7641. class AnnotationEditorUIManager {
  7642. #activeEditor = null;
  7643. #allEditors = new Map();
  7644. #allLayers = new Map();
  7645. #annotationStorage = null;
  7646. #commandManager = new CommandManager();
  7647. #currentPageIndex = 0;
  7648. #deletedAnnotationsElementIds = new Set();
  7649. #draggingEditors = null;
  7650. #editorTypes = null;
  7651. #editorsToRescale = new Set();
  7652. #eventBus = null;
  7653. #filterFactory = null;
  7654. #idManager = new IdManager();
  7655. #isEnabled = false;
  7656. #isWaiting = false;
  7657. #lastActiveElement = null;
  7658. #mode = _util.AnnotationEditorType.NONE;
  7659. #selectedEditors = new Set();
  7660. #pageColors = null;
  7661. #boundBlur = this.blur.bind(this);
  7662. #boundFocus = this.focus.bind(this);
  7663. #boundCopy = this.copy.bind(this);
  7664. #boundCut = this.cut.bind(this);
  7665. #boundPaste = this.paste.bind(this);
  7666. #boundKeydown = this.keydown.bind(this);
  7667. #boundOnEditingAction = this.onEditingAction.bind(this);
  7668. #boundOnPageChanging = this.onPageChanging.bind(this);
  7669. #boundOnScaleChanging = this.onScaleChanging.bind(this);
  7670. #boundOnRotationChanging = this.onRotationChanging.bind(this);
  7671. #previousStates = {
  7672. isEditing: false,
  7673. isEmpty: true,
  7674. hasSomethingToUndo: false,
  7675. hasSomethingToRedo: false,
  7676. hasSelectedEditor: false
  7677. };
  7678. #translation = [0, 0];
  7679. #translationTimeoutId = null;
  7680. #container = null;
  7681. #viewer = null;
  7682. static TRANSLATE_SMALL = 1;
  7683. static TRANSLATE_BIG = 10;
  7684. static get _keyboardManager() {
  7685. const proto = AnnotationEditorUIManager.prototype;
  7686. const arrowChecker = self => {
  7687. const {
  7688. activeElement
  7689. } = document;
  7690. return activeElement && self.#container.contains(activeElement) && self.hasSomethingToControl();
  7691. };
  7692. const small = this.TRANSLATE_SMALL;
  7693. const big = this.TRANSLATE_BIG;
  7694. return (0, _util.shadow)(this, "_keyboardManager", new KeyboardManager([[["ctrl+a", "mac+meta+a"], proto.selectAll], [["ctrl+z", "mac+meta+z"], proto.undo], [["ctrl+y", "ctrl+shift+z", "mac+meta+shift+z", "ctrl+shift+Z", "mac+meta+shift+Z"], proto.redo], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete", "mac+Delete"], proto.delete], [["Escape", "mac+Escape"], proto.unselectAll], [["ArrowLeft", "mac+ArrowLeft"], proto.translateSelectedEditors, {
  7695. args: [-small, 0],
  7696. checker: arrowChecker
  7697. }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto.translateSelectedEditors, {
  7698. args: [-big, 0],
  7699. checker: arrowChecker
  7700. }], [["ArrowRight", "mac+ArrowRight"], proto.translateSelectedEditors, {
  7701. args: [small, 0],
  7702. checker: arrowChecker
  7703. }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto.translateSelectedEditors, {
  7704. args: [big, 0],
  7705. checker: arrowChecker
  7706. }], [["ArrowUp", "mac+ArrowUp"], proto.translateSelectedEditors, {
  7707. args: [0, -small],
  7708. checker: arrowChecker
  7709. }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto.translateSelectedEditors, {
  7710. args: [0, -big],
  7711. checker: arrowChecker
  7712. }], [["ArrowDown", "mac+ArrowDown"], proto.translateSelectedEditors, {
  7713. args: [0, small],
  7714. checker: arrowChecker
  7715. }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto.translateSelectedEditors, {
  7716. args: [0, big],
  7717. checker: arrowChecker
  7718. }]]));
  7719. }
  7720. constructor(container, viewer, eventBus, pdfDocument, pageColors) {
  7721. this.#container = container;
  7722. this.#viewer = viewer;
  7723. this.#eventBus = eventBus;
  7724. this.#eventBus._on("editingaction", this.#boundOnEditingAction);
  7725. this.#eventBus._on("pagechanging", this.#boundOnPageChanging);
  7726. this.#eventBus._on("scalechanging", this.#boundOnScaleChanging);
  7727. this.#eventBus._on("rotationchanging", this.#boundOnRotationChanging);
  7728. this.#annotationStorage = pdfDocument.annotationStorage;
  7729. this.#filterFactory = pdfDocument.filterFactory;
  7730. this.#pageColors = pageColors;
  7731. this.viewParameters = {
  7732. realScale: _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS,
  7733. rotation: 0
  7734. };
  7735. }
  7736. destroy() {
  7737. this.#removeKeyboardManager();
  7738. this.#removeFocusManager();
  7739. this.#eventBus._off("editingaction", this.#boundOnEditingAction);
  7740. this.#eventBus._off("pagechanging", this.#boundOnPageChanging);
  7741. this.#eventBus._off("scalechanging", this.#boundOnScaleChanging);
  7742. this.#eventBus._off("rotationchanging", this.#boundOnRotationChanging);
  7743. for (const layer of this.#allLayers.values()) {
  7744. layer.destroy();
  7745. }
  7746. this.#allLayers.clear();
  7747. this.#allEditors.clear();
  7748. this.#editorsToRescale.clear();
  7749. this.#activeEditor = null;
  7750. this.#selectedEditors.clear();
  7751. this.#commandManager.destroy();
  7752. }
  7753. get hcmFilter() {
  7754. return (0, _util.shadow)(this, "hcmFilter", this.#pageColors ? this.#filterFactory.addHCMFilter(this.#pageColors.foreground, this.#pageColors.background) : "none");
  7755. }
  7756. onPageChanging(_ref2) {
  7757. let {
  7758. pageNumber
  7759. } = _ref2;
  7760. this.#currentPageIndex = pageNumber - 1;
  7761. }
  7762. focusMainContainer() {
  7763. this.#container.focus();
  7764. }
  7765. findParent(x, y) {
  7766. for (const layer of this.#allLayers.values()) {
  7767. const {
  7768. x: layerX,
  7769. y: layerY,
  7770. width,
  7771. height
  7772. } = layer.div.getBoundingClientRect();
  7773. if (x >= layerX && x <= layerX + width && y >= layerY && y <= layerY + height) {
  7774. return layer;
  7775. }
  7776. }
  7777. return null;
  7778. }
  7779. disableUserSelect() {
  7780. let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7781. this.#viewer.classList.toggle("noUserSelect", value);
  7782. }
  7783. addShouldRescale(editor) {
  7784. this.#editorsToRescale.add(editor);
  7785. }
  7786. removeShouldRescale(editor) {
  7787. this.#editorsToRescale.delete(editor);
  7788. }
  7789. onScaleChanging(_ref3) {
  7790. let {
  7791. scale
  7792. } = _ref3;
  7793. this.commitOrRemove();
  7794. this.viewParameters.realScale = scale * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS;
  7795. for (const editor of this.#editorsToRescale) {
  7796. editor.onScaleChanging();
  7797. }
  7798. }
  7799. onRotationChanging(_ref4) {
  7800. let {
  7801. pagesRotation
  7802. } = _ref4;
  7803. this.commitOrRemove();
  7804. this.viewParameters.rotation = pagesRotation;
  7805. }
  7806. addToAnnotationStorage(editor) {
  7807. if (!editor.isEmpty() && this.#annotationStorage && !this.#annotationStorage.has(editor.id)) {
  7808. this.#annotationStorage.setValue(editor.id, editor);
  7809. }
  7810. }
  7811. #addFocusManager() {
  7812. window.addEventListener("focus", this.#boundFocus);
  7813. window.addEventListener("blur", this.#boundBlur);
  7814. }
  7815. #removeFocusManager() {
  7816. window.removeEventListener("focus", this.#boundFocus);
  7817. window.removeEventListener("blur", this.#boundBlur);
  7818. }
  7819. blur() {
  7820. if (!this.hasSelection) {
  7821. return;
  7822. }
  7823. const {
  7824. activeElement
  7825. } = document;
  7826. for (const editor of this.#selectedEditors) {
  7827. if (editor.div.contains(activeElement)) {
  7828. this.#lastActiveElement = [editor, activeElement];
  7829. editor._focusEventsAllowed = false;
  7830. break;
  7831. }
  7832. }
  7833. }
  7834. focus() {
  7835. if (!this.#lastActiveElement) {
  7836. return;
  7837. }
  7838. const [lastEditor, lastActiveElement] = this.#lastActiveElement;
  7839. this.#lastActiveElement = null;
  7840. lastActiveElement.addEventListener("focusin", () => {
  7841. lastEditor._focusEventsAllowed = true;
  7842. }, {
  7843. once: true
  7844. });
  7845. lastActiveElement.focus();
  7846. }
  7847. #addKeyboardManager() {
  7848. window.addEventListener("keydown", this.#boundKeydown, {
  7849. capture: true
  7850. });
  7851. }
  7852. #removeKeyboardManager() {
  7853. window.removeEventListener("keydown", this.#boundKeydown, {
  7854. capture: true
  7855. });
  7856. }
  7857. #addCopyPasteListeners() {
  7858. document.addEventListener("copy", this.#boundCopy);
  7859. document.addEventListener("cut", this.#boundCut);
  7860. document.addEventListener("paste", this.#boundPaste);
  7861. }
  7862. #removeCopyPasteListeners() {
  7863. document.removeEventListener("copy", this.#boundCopy);
  7864. document.removeEventListener("cut", this.#boundCut);
  7865. document.removeEventListener("paste", this.#boundPaste);
  7866. }
  7867. copy(event) {
  7868. event.preventDefault();
  7869. this.#activeEditor?.commitOrRemove();
  7870. if (!this.hasSelection) {
  7871. return;
  7872. }
  7873. const editors = [];
  7874. for (const editor of this.#selectedEditors) {
  7875. const serialized = editor.serialize(true);
  7876. if (serialized) {
  7877. editors.push(serialized);
  7878. }
  7879. }
  7880. if (editors.length === 0) {
  7881. return;
  7882. }
  7883. event.clipboardData.setData("application/pdfjs", JSON.stringify(editors));
  7884. }
  7885. cut(event) {
  7886. this.copy(event);
  7887. this.delete();
  7888. }
  7889. paste(event) {
  7890. event.preventDefault();
  7891. const {
  7892. clipboardData
  7893. } = event;
  7894. for (const item of clipboardData.items) {
  7895. for (const editorType of this.#editorTypes) {
  7896. if (editorType.isHandlingMimeForPasting(item.type)) {
  7897. editorType.paste(item, this.currentLayer);
  7898. return;
  7899. }
  7900. }
  7901. }
  7902. let data = clipboardData.getData("application/pdfjs");
  7903. if (!data) {
  7904. return;
  7905. }
  7906. try {
  7907. data = JSON.parse(data);
  7908. } catch (ex) {
  7909. (0, _util.warn)(`paste: "${ex.message}".`);
  7910. return;
  7911. }
  7912. if (!Array.isArray(data)) {
  7913. return;
  7914. }
  7915. this.unselectAll();
  7916. const layer = this.currentLayer;
  7917. try {
  7918. const newEditors = [];
  7919. for (const editor of data) {
  7920. const deserializedEditor = layer.deserialize(editor);
  7921. if (!deserializedEditor) {
  7922. return;
  7923. }
  7924. newEditors.push(deserializedEditor);
  7925. }
  7926. const cmd = () => {
  7927. for (const editor of newEditors) {
  7928. this.#addEditorToLayer(editor);
  7929. }
  7930. this.#selectEditors(newEditors);
  7931. };
  7932. const undo = () => {
  7933. for (const editor of newEditors) {
  7934. editor.remove();
  7935. }
  7936. };
  7937. this.addCommands({
  7938. cmd,
  7939. undo,
  7940. mustExec: true
  7941. });
  7942. } catch (ex) {
  7943. (0, _util.warn)(`paste: "${ex.message}".`);
  7944. }
  7945. }
  7946. keydown(event) {
  7947. if (!this.getActive()?.shouldGetKeyboardEvents()) {
  7948. AnnotationEditorUIManager._keyboardManager.exec(this, event);
  7949. }
  7950. }
  7951. onEditingAction(details) {
  7952. if (["undo", "redo", "delete", "selectAll"].includes(details.name)) {
  7953. this[details.name]();
  7954. }
  7955. }
  7956. #dispatchUpdateStates(details) {
  7957. const hasChanged = Object.entries(details).some(_ref5 => {
  7958. let [key, value] = _ref5;
  7959. return this.#previousStates[key] !== value;
  7960. });
  7961. if (hasChanged) {
  7962. this.#eventBus.dispatch("annotationeditorstateschanged", {
  7963. source: this,
  7964. details: Object.assign(this.#previousStates, details)
  7965. });
  7966. }
  7967. }
  7968. #dispatchUpdateUI(details) {
  7969. this.#eventBus.dispatch("annotationeditorparamschanged", {
  7970. source: this,
  7971. details
  7972. });
  7973. }
  7974. setEditingState(isEditing) {
  7975. if (isEditing) {
  7976. this.#addFocusManager();
  7977. this.#addKeyboardManager();
  7978. this.#addCopyPasteListeners();
  7979. this.#dispatchUpdateStates({
  7980. isEditing: this.#mode !== _util.AnnotationEditorType.NONE,
  7981. isEmpty: this.#isEmpty(),
  7982. hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
  7983. hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
  7984. hasSelectedEditor: false
  7985. });
  7986. } else {
  7987. this.#removeFocusManager();
  7988. this.#removeKeyboardManager();
  7989. this.#removeCopyPasteListeners();
  7990. this.#dispatchUpdateStates({
  7991. isEditing: false
  7992. });
  7993. this.disableUserSelect(false);
  7994. }
  7995. }
  7996. registerEditorTypes(types) {
  7997. if (this.#editorTypes) {
  7998. return;
  7999. }
  8000. this.#editorTypes = types;
  8001. for (const editorType of this.#editorTypes) {
  8002. this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);
  8003. }
  8004. }
  8005. getId() {
  8006. return this.#idManager.getId();
  8007. }
  8008. get currentLayer() {
  8009. return this.#allLayers.get(this.#currentPageIndex);
  8010. }
  8011. getLayer(pageIndex) {
  8012. return this.#allLayers.get(pageIndex);
  8013. }
  8014. get currentPageIndex() {
  8015. return this.#currentPageIndex;
  8016. }
  8017. addLayer(layer) {
  8018. this.#allLayers.set(layer.pageIndex, layer);
  8019. if (this.#isEnabled) {
  8020. layer.enable();
  8021. } else {
  8022. layer.disable();
  8023. }
  8024. }
  8025. removeLayer(layer) {
  8026. this.#allLayers.delete(layer.pageIndex);
  8027. }
  8028. updateMode(mode) {
  8029. let editId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  8030. if (this.#mode === mode) {
  8031. return;
  8032. }
  8033. this.#mode = mode;
  8034. if (mode === _util.AnnotationEditorType.NONE) {
  8035. this.setEditingState(false);
  8036. this.#disableAll();
  8037. return;
  8038. }
  8039. this.setEditingState(true);
  8040. this.#enableAll();
  8041. this.unselectAll();
  8042. for (const layer of this.#allLayers.values()) {
  8043. layer.updateMode(mode);
  8044. }
  8045. if (!editId) {
  8046. return;
  8047. }
  8048. for (const editor of this.#allEditors.values()) {
  8049. if (editor.annotationElementId === editId) {
  8050. this.setSelected(editor);
  8051. editor.enterInEditMode();
  8052. break;
  8053. }
  8054. }
  8055. }
  8056. updateToolbar(mode) {
  8057. if (mode === this.#mode) {
  8058. return;
  8059. }
  8060. this.#eventBus.dispatch("switchannotationeditormode", {
  8061. source: this,
  8062. mode
  8063. });
  8064. }
  8065. updateParams(type, value) {
  8066. if (!this.#editorTypes) {
  8067. return;
  8068. }
  8069. if (type === _util.AnnotationEditorParamsType.CREATE) {
  8070. this.currentLayer.addNewEditor(type);
  8071. return;
  8072. }
  8073. for (const editor of this.#selectedEditors) {
  8074. editor.updateParams(type, value);
  8075. }
  8076. for (const editorType of this.#editorTypes) {
  8077. editorType.updateDefaultParams(type, value);
  8078. }
  8079. }
  8080. enableWaiting() {
  8081. let mustWait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8082. if (this.#isWaiting === mustWait) {
  8083. return;
  8084. }
  8085. this.#isWaiting = mustWait;
  8086. for (const layer of this.#allLayers.values()) {
  8087. if (mustWait) {
  8088. layer.disableClick();
  8089. } else {
  8090. layer.enableClick();
  8091. }
  8092. layer.div.classList.toggle("waiting", mustWait);
  8093. }
  8094. }
  8095. #enableAll() {
  8096. if (!this.#isEnabled) {
  8097. this.#isEnabled = true;
  8098. for (const layer of this.#allLayers.values()) {
  8099. layer.enable();
  8100. }
  8101. }
  8102. }
  8103. #disableAll() {
  8104. this.unselectAll();
  8105. if (this.#isEnabled) {
  8106. this.#isEnabled = false;
  8107. for (const layer of this.#allLayers.values()) {
  8108. layer.disable();
  8109. }
  8110. }
  8111. }
  8112. getEditors(pageIndex) {
  8113. const editors = [];
  8114. for (const editor of this.#allEditors.values()) {
  8115. if (editor.pageIndex === pageIndex) {
  8116. editors.push(editor);
  8117. }
  8118. }
  8119. return editors;
  8120. }
  8121. getEditor(id) {
  8122. return this.#allEditors.get(id);
  8123. }
  8124. addEditor(editor) {
  8125. this.#allEditors.set(editor.id, editor);
  8126. }
  8127. removeEditor(editor) {
  8128. this.#allEditors.delete(editor.id);
  8129. this.unselect(editor);
  8130. if (!editor.annotationElementId || !this.#deletedAnnotationsElementIds.has(editor.annotationElementId)) {
  8131. this.#annotationStorage?.remove(editor.id);
  8132. }
  8133. }
  8134. addDeletedAnnotationElement(editor) {
  8135. this.#deletedAnnotationsElementIds.add(editor.annotationElementId);
  8136. editor.deleted = true;
  8137. }
  8138. isDeletedAnnotationElement(annotationElementId) {
  8139. return this.#deletedAnnotationsElementIds.has(annotationElementId);
  8140. }
  8141. removeDeletedAnnotationElement(editor) {
  8142. this.#deletedAnnotationsElementIds.delete(editor.annotationElementId);
  8143. editor.deleted = false;
  8144. }
  8145. #addEditorToLayer(editor) {
  8146. const layer = this.#allLayers.get(editor.pageIndex);
  8147. if (layer) {
  8148. layer.addOrRebuild(editor);
  8149. } else {
  8150. this.addEditor(editor);
  8151. }
  8152. }
  8153. setActiveEditor(editor) {
  8154. if (this.#activeEditor === editor) {
  8155. return;
  8156. }
  8157. this.#activeEditor = editor;
  8158. if (editor) {
  8159. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  8160. }
  8161. }
  8162. toggleSelected(editor) {
  8163. if (this.#selectedEditors.has(editor)) {
  8164. this.#selectedEditors.delete(editor);
  8165. editor.unselect();
  8166. this.#dispatchUpdateStates({
  8167. hasSelectedEditor: this.hasSelection
  8168. });
  8169. return;
  8170. }
  8171. this.#selectedEditors.add(editor);
  8172. editor.select();
  8173. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  8174. this.#dispatchUpdateStates({
  8175. hasSelectedEditor: true
  8176. });
  8177. }
  8178. setSelected(editor) {
  8179. for (const ed of this.#selectedEditors) {
  8180. if (ed !== editor) {
  8181. ed.unselect();
  8182. }
  8183. }
  8184. this.#selectedEditors.clear();
  8185. this.#selectedEditors.add(editor);
  8186. editor.select();
  8187. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  8188. this.#dispatchUpdateStates({
  8189. hasSelectedEditor: true
  8190. });
  8191. }
  8192. isSelected(editor) {
  8193. return this.#selectedEditors.has(editor);
  8194. }
  8195. unselect(editor) {
  8196. editor.unselect();
  8197. this.#selectedEditors.delete(editor);
  8198. this.#dispatchUpdateStates({
  8199. hasSelectedEditor: this.hasSelection
  8200. });
  8201. }
  8202. get hasSelection() {
  8203. return this.#selectedEditors.size !== 0;
  8204. }
  8205. undo() {
  8206. this.#commandManager.undo();
  8207. this.#dispatchUpdateStates({
  8208. hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
  8209. hasSomethingToRedo: true,
  8210. isEmpty: this.#isEmpty()
  8211. });
  8212. }
  8213. redo() {
  8214. this.#commandManager.redo();
  8215. this.#dispatchUpdateStates({
  8216. hasSomethingToUndo: true,
  8217. hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
  8218. isEmpty: this.#isEmpty()
  8219. });
  8220. }
  8221. addCommands(params) {
  8222. this.#commandManager.add(params);
  8223. this.#dispatchUpdateStates({
  8224. hasSomethingToUndo: true,
  8225. hasSomethingToRedo: false,
  8226. isEmpty: this.#isEmpty()
  8227. });
  8228. }
  8229. #isEmpty() {
  8230. if (this.#allEditors.size === 0) {
  8231. return true;
  8232. }
  8233. if (this.#allEditors.size === 1) {
  8234. for (const editor of this.#allEditors.values()) {
  8235. return editor.isEmpty();
  8236. }
  8237. }
  8238. return false;
  8239. }
  8240. delete() {
  8241. this.commitOrRemove();
  8242. if (!this.hasSelection) {
  8243. return;
  8244. }
  8245. const editors = [...this.#selectedEditors];
  8246. const cmd = () => {
  8247. for (const editor of editors) {
  8248. editor.remove();
  8249. }
  8250. };
  8251. const undo = () => {
  8252. for (const editor of editors) {
  8253. this.#addEditorToLayer(editor);
  8254. }
  8255. };
  8256. this.addCommands({
  8257. cmd,
  8258. undo,
  8259. mustExec: true
  8260. });
  8261. }
  8262. commitOrRemove() {
  8263. this.#activeEditor?.commitOrRemove();
  8264. }
  8265. hasSomethingToControl() {
  8266. return this.#activeEditor || this.hasSelection;
  8267. }
  8268. #selectEditors(editors) {
  8269. this.#selectedEditors.clear();
  8270. for (const editor of editors) {
  8271. if (editor.isEmpty()) {
  8272. continue;
  8273. }
  8274. this.#selectedEditors.add(editor);
  8275. editor.select();
  8276. }
  8277. this.#dispatchUpdateStates({
  8278. hasSelectedEditor: true
  8279. });
  8280. }
  8281. selectAll() {
  8282. for (const editor of this.#selectedEditors) {
  8283. editor.commit();
  8284. }
  8285. this.#selectEditors(this.#allEditors.values());
  8286. }
  8287. unselectAll() {
  8288. if (this.#activeEditor) {
  8289. this.#activeEditor.commitOrRemove();
  8290. return;
  8291. }
  8292. if (!this.hasSelection) {
  8293. return;
  8294. }
  8295. for (const editor of this.#selectedEditors) {
  8296. editor.unselect();
  8297. }
  8298. this.#selectedEditors.clear();
  8299. this.#dispatchUpdateStates({
  8300. hasSelectedEditor: false
  8301. });
  8302. }
  8303. translateSelectedEditors(x, y) {
  8304. let noCommit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8305. if (!noCommit) {
  8306. this.commitOrRemove();
  8307. }
  8308. if (!this.hasSelection) {
  8309. return;
  8310. }
  8311. this.#translation[0] += x;
  8312. this.#translation[1] += y;
  8313. const [totalX, totalY] = this.#translation;
  8314. const editors = [...this.#selectedEditors];
  8315. const TIME_TO_WAIT = 1000;
  8316. if (this.#translationTimeoutId) {
  8317. clearTimeout(this.#translationTimeoutId);
  8318. }
  8319. this.#translationTimeoutId = setTimeout(() => {
  8320. this.#translationTimeoutId = null;
  8321. this.#translation[0] = this.#translation[1] = 0;
  8322. this.addCommands({
  8323. cmd: () => {
  8324. for (const editor of editors) {
  8325. if (this.#allEditors.has(editor.id)) {
  8326. editor.translateInPage(totalX, totalY);
  8327. }
  8328. }
  8329. },
  8330. undo: () => {
  8331. for (const editor of editors) {
  8332. if (this.#allEditors.has(editor.id)) {
  8333. editor.translateInPage(-totalX, -totalY);
  8334. }
  8335. }
  8336. },
  8337. mustExec: false
  8338. });
  8339. }, TIME_TO_WAIT);
  8340. for (const editor of editors) {
  8341. editor.translateInPage(x, y);
  8342. }
  8343. }
  8344. setUpDragSession() {
  8345. if (!this.hasSelection) {
  8346. return;
  8347. }
  8348. this.disableUserSelect(true);
  8349. this.#draggingEditors = new Map();
  8350. for (const editor of this.#selectedEditors) {
  8351. this.#draggingEditors.set(editor, {
  8352. savedX: editor.x,
  8353. savedY: editor.y,
  8354. savedPageIndex: editor.parent.pageIndex,
  8355. newX: 0,
  8356. newY: 0,
  8357. newPageIndex: -1
  8358. });
  8359. }
  8360. }
  8361. endDragSession() {
  8362. if (!this.#draggingEditors) {
  8363. return false;
  8364. }
  8365. this.disableUserSelect(false);
  8366. const map = this.#draggingEditors;
  8367. this.#draggingEditors = null;
  8368. let mustBeAddedInUndoStack = false;
  8369. for (const [{
  8370. x,
  8371. y,
  8372. parent
  8373. }, value] of map) {
  8374. value.newX = x;
  8375. value.newY = y;
  8376. value.newPageIndex = parent.pageIndex;
  8377. mustBeAddedInUndoStack ||= x !== value.savedX || y !== value.savedY || parent.pageIndex !== value.savedPageIndex;
  8378. }
  8379. if (!mustBeAddedInUndoStack) {
  8380. return false;
  8381. }
  8382. const move = (editor, x, y, pageIndex) => {
  8383. if (this.#allEditors.has(editor.id)) {
  8384. const parent = this.#allLayers.get(pageIndex);
  8385. if (parent) {
  8386. editor._setParentAndPosition(parent, x, y);
  8387. } else {
  8388. editor.pageIndex = pageIndex;
  8389. editor.x = x;
  8390. editor.y = y;
  8391. }
  8392. }
  8393. };
  8394. this.addCommands({
  8395. cmd: () => {
  8396. for (const [editor, {
  8397. newX,
  8398. newY,
  8399. newPageIndex
  8400. }] of map) {
  8401. move(editor, newX, newY, newPageIndex);
  8402. }
  8403. },
  8404. undo: () => {
  8405. for (const [editor, {
  8406. savedX,
  8407. savedY,
  8408. savedPageIndex
  8409. }] of map) {
  8410. move(editor, savedX, savedY, savedPageIndex);
  8411. }
  8412. },
  8413. mustExec: true
  8414. });
  8415. return true;
  8416. }
  8417. dragSelectedEditors(tx, ty) {
  8418. if (!this.#draggingEditors) {
  8419. return;
  8420. }
  8421. for (const editor of this.#draggingEditors.keys()) {
  8422. editor.drag(tx, ty);
  8423. }
  8424. }
  8425. rebuild(editor) {
  8426. if (editor.parent === null) {
  8427. const parent = this.getLayer(editor.pageIndex);
  8428. if (parent) {
  8429. parent.changeParent(editor);
  8430. parent.addOrRebuild(editor);
  8431. } else {
  8432. this.addEditor(editor);
  8433. this.addToAnnotationStorage(editor);
  8434. editor.rebuild();
  8435. }
  8436. } else {
  8437. editor.parent.addOrRebuild(editor);
  8438. }
  8439. }
  8440. isActive(editor) {
  8441. return this.#activeEditor === editor;
  8442. }
  8443. getActive() {
  8444. return this.#activeEditor;
  8445. }
  8446. getMode() {
  8447. return this.#mode;
  8448. }
  8449. get imageManager() {
  8450. return (0, _util.shadow)(this, "imageManager", new ImageManager());
  8451. }
  8452. }
  8453. exports.AnnotationEditorUIManager = AnnotationEditorUIManager;
  8454. /***/ }),
  8455. /* 166 */
  8456. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  8457. var $ = __w_pdfjs_require__(3);
  8458. var DESCRIPTORS = __w_pdfjs_require__(6);
  8459. var global = __w_pdfjs_require__(4);
  8460. var getBuiltIn = __w_pdfjs_require__(24);
  8461. var uncurryThis = __w_pdfjs_require__(14);
  8462. var call = __w_pdfjs_require__(8);
  8463. var isCallable = __w_pdfjs_require__(21);
  8464. var isObject = __w_pdfjs_require__(20);
  8465. var isArray = __w_pdfjs_require__(91);
  8466. var hasOwn = __w_pdfjs_require__(39);
  8467. var toString = __w_pdfjs_require__(77);
  8468. var lengthOfArrayLike = __w_pdfjs_require__(64);
  8469. var createProperty = __w_pdfjs_require__(159);
  8470. var fails = __w_pdfjs_require__(7);
  8471. var parseJSONString = __w_pdfjs_require__(167);
  8472. var NATIVE_SYMBOL = __w_pdfjs_require__(27);
  8473. var JSON = global.JSON;
  8474. var Number = global.Number;
  8475. var SyntaxError = global.SyntaxError;
  8476. var nativeParse = JSON && JSON.parse;
  8477. var enumerableOwnProperties = getBuiltIn('Object', 'keys');
  8478. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  8479. var at = uncurryThis(''.charAt);
  8480. var slice = uncurryThis(''.slice);
  8481. var exec = uncurryThis(/./.exec);
  8482. var push = uncurryThis([].push);
  8483. var IS_DIGIT = /^\d$/;
  8484. var IS_NON_ZERO_DIGIT = /^[1-9]$/;
  8485. var IS_NUMBER_START = /^(-|\d)$/;
  8486. var IS_WHITESPACE = /^[\t\n\r ]$/;
  8487. var PRIMITIVE = 0;
  8488. var OBJECT = 1;
  8489. var $parse = function (source, reviver) {
  8490. source = toString(source);
  8491. var context = new Context(source, 0, '');
  8492. var root = context.parse();
  8493. var value = root.value;
  8494. var endIndex = context.skip(IS_WHITESPACE, root.end);
  8495. if (endIndex < source.length) {
  8496. throw SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex);
  8497. }
  8498. return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value;
  8499. };
  8500. var internalize = function (holder, name, reviver, node) {
  8501. var val = holder[name];
  8502. var unmodified = node && val === node.value;
  8503. var context = unmodified && typeof node.source == 'string' ? { source: node.source } : {};
  8504. var elementRecordsLen, keys, len, i, P;
  8505. if (isObject(val)) {
  8506. var nodeIsArray = isArray(val);
  8507. var nodes = unmodified ? node.nodes : nodeIsArray ? [] : {};
  8508. if (nodeIsArray) {
  8509. elementRecordsLen = nodes.length;
  8510. len = lengthOfArrayLike(val);
  8511. for (i = 0; i < len; i++) {
  8512. internalizeProperty(val, i, internalize(val, '' + i, reviver, i < elementRecordsLen ? nodes[i] : undefined));
  8513. }
  8514. } else {
  8515. keys = enumerableOwnProperties(val);
  8516. len = lengthOfArrayLike(keys);
  8517. for (i = 0; i < len; i++) {
  8518. P = keys[i];
  8519. internalizeProperty(val, P, internalize(val, P, reviver, hasOwn(nodes, P) ? nodes[P] : undefined));
  8520. }
  8521. }
  8522. }
  8523. return call(reviver, holder, name, val, context);
  8524. };
  8525. var internalizeProperty = function (object, key, value) {
  8526. if (DESCRIPTORS) {
  8527. var descriptor = getOwnPropertyDescriptor(object, key);
  8528. if (descriptor && !descriptor.configurable)
  8529. return;
  8530. }
  8531. if (value === undefined)
  8532. delete object[key];
  8533. else
  8534. createProperty(object, key, value);
  8535. };
  8536. var Node = function (value, end, source, nodes) {
  8537. this.value = value;
  8538. this.end = end;
  8539. this.source = source;
  8540. this.nodes = nodes;
  8541. };
  8542. var Context = function (source, index) {
  8543. this.source = source;
  8544. this.index = index;
  8545. };
  8546. Context.prototype = {
  8547. fork: function (nextIndex) {
  8548. return new Context(this.source, nextIndex);
  8549. },
  8550. parse: function () {
  8551. var source = this.source;
  8552. var i = this.skip(IS_WHITESPACE, this.index);
  8553. var fork = this.fork(i);
  8554. var chr = at(source, i);
  8555. if (exec(IS_NUMBER_START, chr))
  8556. return fork.number();
  8557. switch (chr) {
  8558. case '{':
  8559. return fork.object();
  8560. case '[':
  8561. return fork.array();
  8562. case '"':
  8563. return fork.string();
  8564. case 't':
  8565. return fork.keyword(true);
  8566. case 'f':
  8567. return fork.keyword(false);
  8568. case 'n':
  8569. return fork.keyword(null);
  8570. }
  8571. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  8572. },
  8573. node: function (type, value, start, end, nodes) {
  8574. return new Node(value, end, type ? null : slice(this.source, start, end), nodes);
  8575. },
  8576. object: function () {
  8577. var source = this.source;
  8578. var i = this.index + 1;
  8579. var expectKeypair = false;
  8580. var object = {};
  8581. var nodes = {};
  8582. while (i < source.length) {
  8583. i = this.until([
  8584. '"',
  8585. '}'
  8586. ], i);
  8587. if (at(source, i) === '}' && !expectKeypair) {
  8588. i++;
  8589. break;
  8590. }
  8591. var result = this.fork(i).string();
  8592. var key = result.value;
  8593. i = result.end;
  8594. i = this.until([':'], i) + 1;
  8595. i = this.skip(IS_WHITESPACE, i);
  8596. result = this.fork(i).parse();
  8597. createProperty(nodes, key, result);
  8598. createProperty(object, key, result.value);
  8599. i = this.until([
  8600. ',',
  8601. '}'
  8602. ], result.end);
  8603. var chr = at(source, i);
  8604. if (chr === ',') {
  8605. expectKeypair = true;
  8606. i++;
  8607. } else if (chr === '}') {
  8608. i++;
  8609. break;
  8610. }
  8611. }
  8612. return this.node(OBJECT, object, this.index, i, nodes);
  8613. },
  8614. array: function () {
  8615. var source = this.source;
  8616. var i = this.index + 1;
  8617. var expectElement = false;
  8618. var array = [];
  8619. var nodes = [];
  8620. while (i < source.length) {
  8621. i = this.skip(IS_WHITESPACE, i);
  8622. if (at(source, i) === ']' && !expectElement) {
  8623. i++;
  8624. break;
  8625. }
  8626. var result = this.fork(i).parse();
  8627. push(nodes, result);
  8628. push(array, result.value);
  8629. i = this.until([
  8630. ',',
  8631. ']'
  8632. ], result.end);
  8633. if (at(source, i) === ',') {
  8634. expectElement = true;
  8635. i++;
  8636. } else if (at(source, i) === ']') {
  8637. i++;
  8638. break;
  8639. }
  8640. }
  8641. return this.node(OBJECT, array, this.index, i, nodes);
  8642. },
  8643. string: function () {
  8644. var index = this.index;
  8645. var parsed = parseJSONString(this.source, this.index + 1);
  8646. return this.node(PRIMITIVE, parsed.value, index, parsed.end);
  8647. },
  8648. number: function () {
  8649. var source = this.source;
  8650. var startIndex = this.index;
  8651. var i = startIndex;
  8652. if (at(source, i) === '-')
  8653. i++;
  8654. if (at(source, i) === '0')
  8655. i++;
  8656. else if (exec(IS_NON_ZERO_DIGIT, at(source, i)))
  8657. i = this.skip(IS_DIGIT, ++i);
  8658. else
  8659. throw SyntaxError('Failed to parse number at: ' + i);
  8660. if (at(source, i) === '.')
  8661. i = this.skip(IS_DIGIT, ++i);
  8662. if (at(source, i) === 'e' || at(source, i) === 'E') {
  8663. i++;
  8664. if (at(source, i) === '+' || at(source, i) === '-')
  8665. i++;
  8666. var exponentStartIndex = i;
  8667. i = this.skip(IS_DIGIT, i);
  8668. if (exponentStartIndex === i)
  8669. throw SyntaxError("Failed to parse number's exponent value at: " + i);
  8670. }
  8671. return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);
  8672. },
  8673. keyword: function (value) {
  8674. var keyword = '' + value;
  8675. var index = this.index;
  8676. var endIndex = index + keyword.length;
  8677. if (slice(this.source, index, endIndex) !== keyword)
  8678. throw SyntaxError('Failed to parse value at: ' + index);
  8679. return this.node(PRIMITIVE, value, index, endIndex);
  8680. },
  8681. skip: function (regex, i) {
  8682. var source = this.source;
  8683. for (; i < source.length; i++)
  8684. if (!exec(regex, at(source, i)))
  8685. break;
  8686. return i;
  8687. },
  8688. until: function (array, i) {
  8689. i = this.skip(IS_WHITESPACE, i);
  8690. var chr = at(this.source, i);
  8691. for (var j = 0; j < array.length; j++)
  8692. if (array[j] === chr)
  8693. return i;
  8694. throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i);
  8695. }
  8696. };
  8697. var NO_SOURCE_SUPPORT = fails(function () {
  8698. var unsafeInt = '9007199254740993';
  8699. var source;
  8700. nativeParse(unsafeInt, function (key, value, context) {
  8701. source = context.source;
  8702. });
  8703. return source !== unsafeInt;
  8704. });
  8705. var PROPER_BASE_PARSE = NATIVE_SYMBOL && !fails(function () {
  8706. return 1 / nativeParse('-0 \t') !== -Infinity;
  8707. });
  8708. $({
  8709. target: 'JSON',
  8710. stat: true,
  8711. forced: NO_SOURCE_SUPPORT
  8712. }, {
  8713. parse: function parse(text, reviver) {
  8714. return PROPER_BASE_PARSE && !isCallable(reviver) ? nativeParse(text) : $parse(text, reviver);
  8715. }
  8716. });
  8717. /***/ }),
  8718. /* 167 */
  8719. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  8720. var uncurryThis = __w_pdfjs_require__(14);
  8721. var hasOwn = __w_pdfjs_require__(39);
  8722. var $SyntaxError = SyntaxError;
  8723. var $parseInt = parseInt;
  8724. var fromCharCode = String.fromCharCode;
  8725. var at = uncurryThis(''.charAt);
  8726. var slice = uncurryThis(''.slice);
  8727. var exec = uncurryThis(/./.exec);
  8728. var codePoints = {
  8729. '\\"': '"',
  8730. '\\\\': '\\',
  8731. '\\/': '/',
  8732. '\\b': '\b',
  8733. '\\f': '\f',
  8734. '\\n': '\n',
  8735. '\\r': '\r',
  8736. '\\t': '\t'
  8737. };
  8738. var IS_4_HEX_DIGITS = /^[\da-f]{4}$/i;
  8739. var IS_C0_CONTROL_CODE = /^[\u0000-\u001F]$/;
  8740. module.exports = function (source, i) {
  8741. var unterminated = true;
  8742. var value = '';
  8743. while (i < source.length) {
  8744. var chr = at(source, i);
  8745. if (chr === '\\') {
  8746. var twoChars = slice(source, i, i + 2);
  8747. if (hasOwn(codePoints, twoChars)) {
  8748. value += codePoints[twoChars];
  8749. i += 2;
  8750. } else if (twoChars === '\\u') {
  8751. i += 2;
  8752. var fourHexDigits = slice(source, i, i + 4);
  8753. if (!exec(IS_4_HEX_DIGITS, fourHexDigits))
  8754. throw $SyntaxError('Bad Unicode escape at: ' + i);
  8755. value += fromCharCode($parseInt(fourHexDigits, 16));
  8756. i += 4;
  8757. } else
  8758. throw $SyntaxError('Unknown escape sequence: "' + twoChars + '"');
  8759. } else if (chr === '"') {
  8760. unterminated = false;
  8761. i++;
  8762. break;
  8763. } else {
  8764. if (exec(IS_C0_CONTROL_CODE, chr))
  8765. throw $SyntaxError('Bad control character in string literal at: ' + i);
  8766. value += chr;
  8767. i++;
  8768. }
  8769. }
  8770. if (unterminated)
  8771. throw $SyntaxError('Unterminated string at: ' + i);
  8772. return {
  8773. value: value,
  8774. end: i
  8775. };
  8776. };
  8777. /***/ }),
  8778. /* 168 */
  8779. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8780. Object.defineProperty(exports, "__esModule", ({
  8781. value: true
  8782. }));
  8783. exports.StatTimer = exports.RenderingCancelledException = exports.PixelsPerInch = exports.PageViewport = exports.PDFDateString = exports.DOMStandardFontDataFactory = exports.DOMSVGFactory = exports.DOMFilterFactory = exports.DOMCanvasFactory = exports.DOMCMapReaderFactory = exports.AnnotationPrefix = void 0;
  8784. exports.deprecated = deprecated;
  8785. exports.getColorValues = getColorValues;
  8786. exports.getCurrentTransform = getCurrentTransform;
  8787. exports.getCurrentTransformInverse = getCurrentTransformInverse;
  8788. exports.getFilenameFromUrl = getFilenameFromUrl;
  8789. exports.getPdfFilenameFromUrl = getPdfFilenameFromUrl;
  8790. exports.getRGB = getRGB;
  8791. exports.getXfaPageViewport = getXfaPageViewport;
  8792. exports.isDataScheme = isDataScheme;
  8793. exports.isPdfFile = isPdfFile;
  8794. exports.isValidFetchUrl = isValidFetchUrl;
  8795. exports.loadScript = loadScript;
  8796. exports.setLayerDimensions = setLayerDimensions;
  8797. __w_pdfjs_require__(2);
  8798. __w_pdfjs_require__(93);
  8799. __w_pdfjs_require__(101);
  8800. __w_pdfjs_require__(102);
  8801. __w_pdfjs_require__(105);
  8802. __w_pdfjs_require__(107);
  8803. __w_pdfjs_require__(109);
  8804. __w_pdfjs_require__(113);
  8805. __w_pdfjs_require__(116);
  8806. __w_pdfjs_require__(123);
  8807. __w_pdfjs_require__(89);
  8808. __w_pdfjs_require__(84);
  8809. __w_pdfjs_require__(86);
  8810. __w_pdfjs_require__(87);
  8811. var _base_factory = __w_pdfjs_require__(169);
  8812. var _util = __w_pdfjs_require__(1);
  8813. const SVG_NS = "http://www.w3.org/2000/svg";
  8814. const AnnotationPrefix = "pdfjs_internal_id_";
  8815. exports.AnnotationPrefix = AnnotationPrefix;
  8816. class PixelsPerInch {
  8817. static CSS = 96.0;
  8818. static PDF = 72.0;
  8819. static PDF_TO_CSS_UNITS = this.CSS / this.PDF;
  8820. }
  8821. exports.PixelsPerInch = PixelsPerInch;
  8822. class DOMFilterFactory extends _base_factory.BaseFilterFactory {
  8823. #_cache;
  8824. #_defs;
  8825. #docId;
  8826. #document;
  8827. #hcmFilter;
  8828. #hcmKey;
  8829. #hcmUrl;
  8830. #hcmHighlightFilter;
  8831. #hcmHighlightKey;
  8832. #hcmHighlightUrl;
  8833. #id = 0;
  8834. constructor() {
  8835. let {
  8836. docId,
  8837. ownerDocument = globalThis.document
  8838. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8839. super();
  8840. this.#docId = docId;
  8841. this.#document = ownerDocument;
  8842. }
  8843. get #cache() {
  8844. return this.#_cache ||= new Map();
  8845. }
  8846. get #defs() {
  8847. if (!this.#_defs) {
  8848. const div = this.#document.createElement("div");
  8849. const {
  8850. style
  8851. } = div;
  8852. style.visibility = "hidden";
  8853. style.contain = "strict";
  8854. style.width = style.height = 0;
  8855. style.position = "absolute";
  8856. style.top = style.left = 0;
  8857. style.zIndex = -1;
  8858. const svg = this.#document.createElementNS(SVG_NS, "svg");
  8859. svg.setAttribute("width", 0);
  8860. svg.setAttribute("height", 0);
  8861. this.#_defs = this.#document.createElementNS(SVG_NS, "defs");
  8862. div.append(svg);
  8863. svg.append(this.#_defs);
  8864. this.#document.body.append(div);
  8865. }
  8866. return this.#_defs;
  8867. }
  8868. addFilter(maps) {
  8869. if (!maps) {
  8870. return "none";
  8871. }
  8872. let value = this.#cache.get(maps);
  8873. if (value) {
  8874. return value;
  8875. }
  8876. let tableR, tableG, tableB, key;
  8877. if (maps.length === 1) {
  8878. const mapR = maps[0];
  8879. const buffer = new Array(256);
  8880. for (let i = 0; i < 256; i++) {
  8881. buffer[i] = mapR[i] / 255;
  8882. }
  8883. key = tableR = tableG = tableB = buffer.join(",");
  8884. } else {
  8885. const [mapR, mapG, mapB] = maps;
  8886. const bufferR = new Array(256);
  8887. const bufferG = new Array(256);
  8888. const bufferB = new Array(256);
  8889. for (let i = 0; i < 256; i++) {
  8890. bufferR[i] = mapR[i] / 255;
  8891. bufferG[i] = mapG[i] / 255;
  8892. bufferB[i] = mapB[i] / 255;
  8893. }
  8894. tableR = bufferR.join(",");
  8895. tableG = bufferG.join(",");
  8896. tableB = bufferB.join(",");
  8897. key = `${tableR}${tableG}${tableB}`;
  8898. }
  8899. value = this.#cache.get(key);
  8900. if (value) {
  8901. this.#cache.set(maps, value);
  8902. return value;
  8903. }
  8904. const id = `g_${this.#docId}_transfer_map_${this.#id++}`;
  8905. const url = `url(#${id})`;
  8906. this.#cache.set(maps, url);
  8907. this.#cache.set(key, url);
  8908. const filter = this.#createFilter(id);
  8909. this.#addTransferMapConversion(tableR, tableG, tableB, filter);
  8910. return url;
  8911. }
  8912. addHCMFilter(fgColor, bgColor) {
  8913. const key = `${fgColor}-${bgColor}`;
  8914. if (this.#hcmKey === key) {
  8915. return this.#hcmUrl;
  8916. }
  8917. this.#hcmKey = key;
  8918. this.#hcmUrl = "none";
  8919. this.#hcmFilter?.remove();
  8920. if (!fgColor || !bgColor) {
  8921. return this.#hcmUrl;
  8922. }
  8923. const fgRGB = this.#getRGB(fgColor);
  8924. fgColor = _util.Util.makeHexColor(...fgRGB);
  8925. const bgRGB = this.#getRGB(bgColor);
  8926. bgColor = _util.Util.makeHexColor(...bgRGB);
  8927. this.#defs.style.color = "";
  8928. if (fgColor === "#000000" && bgColor === "#ffffff" || fgColor === bgColor) {
  8929. return this.#hcmUrl;
  8930. }
  8931. const map = new Array(256);
  8932. for (let i = 0; i <= 255; i++) {
  8933. const x = i / 255;
  8934. map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
  8935. }
  8936. const table = map.join(",");
  8937. const id = `g_${this.#docId}_hcm_filter`;
  8938. const filter = this.#hcmHighlightFilter = this.#createFilter(id);
  8939. this.#addTransferMapConversion(table, table, table, filter);
  8940. this.#addGrayConversion(filter);
  8941. const getSteps = (c, n) => {
  8942. const start = fgRGB[c] / 255;
  8943. const end = bgRGB[c] / 255;
  8944. const arr = new Array(n + 1);
  8945. for (let i = 0; i <= n; i++) {
  8946. arr[i] = start + i / n * (end - start);
  8947. }
  8948. return arr.join(",");
  8949. };
  8950. this.#addTransferMapConversion(getSteps(0, 5), getSteps(1, 5), getSteps(2, 5), filter);
  8951. this.#hcmUrl = `url(#${id})`;
  8952. return this.#hcmUrl;
  8953. }
  8954. addHighlightHCMFilter(fgColor, bgColor, newFgColor, newBgColor) {
  8955. const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
  8956. if (this.#hcmHighlightKey === key) {
  8957. return this.#hcmHighlightUrl;
  8958. }
  8959. this.#hcmHighlightKey = key;
  8960. this.#hcmHighlightUrl = "none";
  8961. this.#hcmHighlightFilter?.remove();
  8962. if (!fgColor || !bgColor) {
  8963. return this.#hcmHighlightUrl;
  8964. }
  8965. const [fgRGB, bgRGB] = [fgColor, bgColor].map(this.#getRGB.bind(this));
  8966. let fgGray = Math.round(0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]);
  8967. let bgGray = Math.round(0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]);
  8968. let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(this.#getRGB.bind(this));
  8969. if (bgGray < fgGray) {
  8970. [fgGray, bgGray, newFgRGB, newBgRGB] = [bgGray, fgGray, newBgRGB, newFgRGB];
  8971. }
  8972. this.#defs.style.color = "";
  8973. const getSteps = (fg, bg, n) => {
  8974. const arr = new Array(256);
  8975. const step = (bgGray - fgGray) / n;
  8976. const newStart = fg / 255;
  8977. const newStep = (bg - fg) / (255 * n);
  8978. let prev = 0;
  8979. for (let i = 0; i <= n; i++) {
  8980. const k = Math.round(fgGray + i * step);
  8981. const value = newStart + i * newStep;
  8982. for (let j = prev; j <= k; j++) {
  8983. arr[j] = value;
  8984. }
  8985. prev = k + 1;
  8986. }
  8987. for (let i = prev; i < 256; i++) {
  8988. arr[i] = arr[prev - 1];
  8989. }
  8990. return arr.join(",");
  8991. };
  8992. const id = `g_${this.#docId}_hcm_highlight_filter`;
  8993. const filter = this.#hcmHighlightFilter = this.#createFilter(id);
  8994. this.#addGrayConversion(filter);
  8995. this.#addTransferMapConversion(getSteps(newFgRGB[0], newBgRGB[0], 5), getSteps(newFgRGB[1], newBgRGB[1], 5), getSteps(newFgRGB[2], newBgRGB[2], 5), filter);
  8996. this.#hcmHighlightUrl = `url(#${id})`;
  8997. return this.#hcmHighlightUrl;
  8998. }
  8999. destroy() {
  9000. let keepHCM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9001. if (keepHCM && (this.#hcmUrl || this.#hcmHighlightUrl)) {
  9002. return;
  9003. }
  9004. if (this.#_defs) {
  9005. this.#_defs.parentNode.parentNode.remove();
  9006. this.#_defs = null;
  9007. }
  9008. if (this.#_cache) {
  9009. this.#_cache.clear();
  9010. this.#_cache = null;
  9011. }
  9012. this.#id = 0;
  9013. }
  9014. #addGrayConversion(filter) {
  9015. const feColorMatrix = this.#document.createElementNS(SVG_NS, "feColorMatrix");
  9016. feColorMatrix.setAttribute("type", "matrix");
  9017. feColorMatrix.setAttribute("values", "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");
  9018. filter.append(feColorMatrix);
  9019. }
  9020. #createFilter(id) {
  9021. const filter = this.#document.createElementNS(SVG_NS, "filter");
  9022. filter.setAttribute("color-interpolation-filters", "sRGB");
  9023. filter.setAttribute("id", id);
  9024. this.#defs.append(filter);
  9025. return filter;
  9026. }
  9027. #appendFeFunc(feComponentTransfer, func, table) {
  9028. const feFunc = this.#document.createElementNS(SVG_NS, func);
  9029. feFunc.setAttribute("type", "discrete");
  9030. feFunc.setAttribute("tableValues", table);
  9031. feComponentTransfer.append(feFunc);
  9032. }
  9033. #addTransferMapConversion(rTable, gTable, bTable, filter) {
  9034. const feComponentTransfer = this.#document.createElementNS(SVG_NS, "feComponentTransfer");
  9035. filter.append(feComponentTransfer);
  9036. this.#appendFeFunc(feComponentTransfer, "feFuncR", rTable);
  9037. this.#appendFeFunc(feComponentTransfer, "feFuncG", gTable);
  9038. this.#appendFeFunc(feComponentTransfer, "feFuncB", bTable);
  9039. }
  9040. #getRGB(color) {
  9041. this.#defs.style.color = color;
  9042. return getRGB(getComputedStyle(this.#defs).getPropertyValue("color"));
  9043. }
  9044. }
  9045. exports.DOMFilterFactory = DOMFilterFactory;
  9046. class DOMCanvasFactory extends _base_factory.BaseCanvasFactory {
  9047. constructor() {
  9048. let {
  9049. ownerDocument = globalThis.document
  9050. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9051. super();
  9052. this._document = ownerDocument;
  9053. }
  9054. _createCanvas(width, height) {
  9055. const canvas = this._document.createElement("canvas");
  9056. canvas.width = width;
  9057. canvas.height = height;
  9058. return canvas;
  9059. }
  9060. }
  9061. exports.DOMCanvasFactory = DOMCanvasFactory;
  9062. async function fetchData(url) {
  9063. let asTypedArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9064. if (isValidFetchUrl(url, document.baseURI)) {
  9065. const response = await fetch(url);
  9066. if (!response.ok) {
  9067. throw new Error(response.statusText);
  9068. }
  9069. return asTypedArray ? new Uint8Array(await response.arrayBuffer()) : (0, _util.stringToBytes)(await response.text());
  9070. }
  9071. return new Promise((resolve, reject) => {
  9072. const request = new XMLHttpRequest();
  9073. request.open("GET", url, true);
  9074. if (asTypedArray) {
  9075. request.responseType = "arraybuffer";
  9076. }
  9077. request.onreadystatechange = () => {
  9078. if (request.readyState !== XMLHttpRequest.DONE) {
  9079. return;
  9080. }
  9081. if (request.status === 200 || request.status === 0) {
  9082. let data;
  9083. if (asTypedArray && request.response) {
  9084. data = new Uint8Array(request.response);
  9085. } else if (!asTypedArray && request.responseText) {
  9086. data = (0, _util.stringToBytes)(request.responseText);
  9087. }
  9088. if (data) {
  9089. resolve(data);
  9090. return;
  9091. }
  9092. }
  9093. reject(new Error(request.statusText));
  9094. };
  9095. request.send(null);
  9096. });
  9097. }
  9098. class DOMCMapReaderFactory extends _base_factory.BaseCMapReaderFactory {
  9099. _fetchData(url, compressionType) {
  9100. return fetchData(url, this.isCompressed).then(data => {
  9101. return {
  9102. cMapData: data,
  9103. compressionType
  9104. };
  9105. });
  9106. }
  9107. }
  9108. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  9109. class DOMStandardFontDataFactory extends _base_factory.BaseStandardFontDataFactory {
  9110. _fetchData(url) {
  9111. return fetchData(url, true);
  9112. }
  9113. }
  9114. exports.DOMStandardFontDataFactory = DOMStandardFontDataFactory;
  9115. class DOMSVGFactory extends _base_factory.BaseSVGFactory {
  9116. _createSVG(type) {
  9117. return document.createElementNS(SVG_NS, type);
  9118. }
  9119. }
  9120. exports.DOMSVGFactory = DOMSVGFactory;
  9121. class PageViewport {
  9122. constructor(_ref) {
  9123. let {
  9124. viewBox,
  9125. scale,
  9126. rotation,
  9127. offsetX = 0,
  9128. offsetY = 0,
  9129. dontFlip = false
  9130. } = _ref;
  9131. this.viewBox = viewBox;
  9132. this.scale = scale;
  9133. this.rotation = rotation;
  9134. this.offsetX = offsetX;
  9135. this.offsetY = offsetY;
  9136. const centerX = (viewBox[2] + viewBox[0]) / 2;
  9137. const centerY = (viewBox[3] + viewBox[1]) / 2;
  9138. let rotateA, rotateB, rotateC, rotateD;
  9139. rotation %= 360;
  9140. if (rotation < 0) {
  9141. rotation += 360;
  9142. }
  9143. switch (rotation) {
  9144. case 180:
  9145. rotateA = -1;
  9146. rotateB = 0;
  9147. rotateC = 0;
  9148. rotateD = 1;
  9149. break;
  9150. case 90:
  9151. rotateA = 0;
  9152. rotateB = 1;
  9153. rotateC = 1;
  9154. rotateD = 0;
  9155. break;
  9156. case 270:
  9157. rotateA = 0;
  9158. rotateB = -1;
  9159. rotateC = -1;
  9160. rotateD = 0;
  9161. break;
  9162. case 0:
  9163. rotateA = 1;
  9164. rotateB = 0;
  9165. rotateC = 0;
  9166. rotateD = -1;
  9167. break;
  9168. default:
  9169. throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.");
  9170. }
  9171. if (dontFlip) {
  9172. rotateC = -rotateC;
  9173. rotateD = -rotateD;
  9174. }
  9175. let offsetCanvasX, offsetCanvasY;
  9176. let width, height;
  9177. if (rotateA === 0) {
  9178. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  9179. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  9180. width = (viewBox[3] - viewBox[1]) * scale;
  9181. height = (viewBox[2] - viewBox[0]) * scale;
  9182. } else {
  9183. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  9184. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  9185. width = (viewBox[2] - viewBox[0]) * scale;
  9186. height = (viewBox[3] - viewBox[1]) * scale;
  9187. }
  9188. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  9189. this.width = width;
  9190. this.height = height;
  9191. }
  9192. get rawDims() {
  9193. const {
  9194. viewBox
  9195. } = this;
  9196. return (0, _util.shadow)(this, "rawDims", {
  9197. pageWidth: viewBox[2] - viewBox[0],
  9198. pageHeight: viewBox[3] - viewBox[1],
  9199. pageX: viewBox[0],
  9200. pageY: viewBox[1]
  9201. });
  9202. }
  9203. clone() {
  9204. let {
  9205. scale = this.scale,
  9206. rotation = this.rotation,
  9207. offsetX = this.offsetX,
  9208. offsetY = this.offsetY,
  9209. dontFlip = false
  9210. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  9211. return new PageViewport({
  9212. viewBox: this.viewBox.slice(),
  9213. scale,
  9214. rotation,
  9215. offsetX,
  9216. offsetY,
  9217. dontFlip
  9218. });
  9219. }
  9220. convertToViewportPoint(x, y) {
  9221. return _util.Util.applyTransform([x, y], this.transform);
  9222. }
  9223. convertToViewportRectangle(rect) {
  9224. const topLeft = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  9225. const bottomRight = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  9226. return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
  9227. }
  9228. convertToPdfPoint(x, y) {
  9229. return _util.Util.applyInverseTransform([x, y], this.transform);
  9230. }
  9231. }
  9232. exports.PageViewport = PageViewport;
  9233. class RenderingCancelledException extends _util.BaseException {
  9234. constructor(msg) {
  9235. let extraDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  9236. super(msg, "RenderingCancelledException");
  9237. this.extraDelay = extraDelay;
  9238. }
  9239. }
  9240. exports.RenderingCancelledException = RenderingCancelledException;
  9241. function isDataScheme(url) {
  9242. const ii = url.length;
  9243. let i = 0;
  9244. while (i < ii && url[i].trim() === "") {
  9245. i++;
  9246. }
  9247. return url.substring(i, i + 5).toLowerCase() === "data:";
  9248. }
  9249. function isPdfFile(filename) {
  9250. return typeof filename === "string" && /\.pdf$/i.test(filename);
  9251. }
  9252. function getFilenameFromUrl(url) {
  9253. let onlyStripPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9254. if (!onlyStripPath) {
  9255. [url] = url.split(/[#?]/, 1);
  9256. }
  9257. return url.substring(url.lastIndexOf("/") + 1);
  9258. }
  9259. function getPdfFilenameFromUrl(url) {
  9260. let defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  9261. if (typeof url !== "string") {
  9262. return defaultFilename;
  9263. }
  9264. if (isDataScheme(url)) {
  9265. (0, _util.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
  9266. return defaultFilename;
  9267. }
  9268. const reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  9269. const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  9270. const splitURI = reURI.exec(url);
  9271. let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  9272. if (suggestedFilename) {
  9273. suggestedFilename = suggestedFilename[0];
  9274. if (suggestedFilename.includes("%")) {
  9275. try {
  9276. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  9277. } catch {}
  9278. }
  9279. }
  9280. return suggestedFilename || defaultFilename;
  9281. }
  9282. class StatTimer {
  9283. started = Object.create(null);
  9284. times = [];
  9285. time(name) {
  9286. if (name in this.started) {
  9287. (0, _util.warn)(`Timer is already running for ${name}`);
  9288. }
  9289. this.started[name] = Date.now();
  9290. }
  9291. timeEnd(name) {
  9292. if (!(name in this.started)) {
  9293. (0, _util.warn)(`Timer has not been started for ${name}`);
  9294. }
  9295. this.times.push({
  9296. name,
  9297. start: this.started[name],
  9298. end: Date.now()
  9299. });
  9300. delete this.started[name];
  9301. }
  9302. toString() {
  9303. const outBuf = [];
  9304. let longest = 0;
  9305. for (const {
  9306. name
  9307. } of this.times) {
  9308. longest = Math.max(name.length, longest);
  9309. }
  9310. for (const {
  9311. name,
  9312. start,
  9313. end
  9314. } of this.times) {
  9315. outBuf.push(`${name.padEnd(longest)} ${end - start}ms\n`);
  9316. }
  9317. return outBuf.join("");
  9318. }
  9319. }
  9320. exports.StatTimer = StatTimer;
  9321. function isValidFetchUrl(url, baseUrl) {
  9322. try {
  9323. const {
  9324. protocol
  9325. } = baseUrl ? new URL(url, baseUrl) : new URL(url);
  9326. return protocol === "http:" || protocol === "https:";
  9327. } catch {
  9328. return false;
  9329. }
  9330. }
  9331. function loadScript(src) {
  9332. let removeScriptElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9333. return new Promise((resolve, reject) => {
  9334. const script = document.createElement("script");
  9335. script.src = src;
  9336. script.onload = function (evt) {
  9337. if (removeScriptElement) {
  9338. script.remove();
  9339. }
  9340. resolve(evt);
  9341. };
  9342. script.onerror = function () {
  9343. reject(new Error(`Cannot load script at: ${script.src}`));
  9344. };
  9345. (document.head || document.documentElement).append(script);
  9346. });
  9347. }
  9348. function deprecated(details) {
  9349. console.log("Deprecated API usage: " + details);
  9350. }
  9351. let pdfDateStringRegex;
  9352. class PDFDateString {
  9353. static toDateObject(input) {
  9354. if (!input || typeof input !== "string") {
  9355. return null;
  9356. }
  9357. pdfDateStringRegex ||= new RegExp("^D:" + "(\\d{4})" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "(\\d{2})?" + "([Z|+|-])?" + "(\\d{2})?" + "'?" + "(\\d{2})?" + "'?");
  9358. const matches = pdfDateStringRegex.exec(input);
  9359. if (!matches) {
  9360. return null;
  9361. }
  9362. const year = parseInt(matches[1], 10);
  9363. let month = parseInt(matches[2], 10);
  9364. month = month >= 1 && month <= 12 ? month - 1 : 0;
  9365. let day = parseInt(matches[3], 10);
  9366. day = day >= 1 && day <= 31 ? day : 1;
  9367. let hour = parseInt(matches[4], 10);
  9368. hour = hour >= 0 && hour <= 23 ? hour : 0;
  9369. let minute = parseInt(matches[5], 10);
  9370. minute = minute >= 0 && minute <= 59 ? minute : 0;
  9371. let second = parseInt(matches[6], 10);
  9372. second = second >= 0 && second <= 59 ? second : 0;
  9373. const universalTimeRelation = matches[7] || "Z";
  9374. let offsetHour = parseInt(matches[8], 10);
  9375. offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
  9376. let offsetMinute = parseInt(matches[9], 10) || 0;
  9377. offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
  9378. if (universalTimeRelation === "-") {
  9379. hour += offsetHour;
  9380. minute += offsetMinute;
  9381. } else if (universalTimeRelation === "+") {
  9382. hour -= offsetHour;
  9383. minute -= offsetMinute;
  9384. }
  9385. return new Date(Date.UTC(year, month, day, hour, minute, second));
  9386. }
  9387. }
  9388. exports.PDFDateString = PDFDateString;
  9389. function getXfaPageViewport(xfaPage, _ref2) {
  9390. let {
  9391. scale = 1,
  9392. rotation = 0
  9393. } = _ref2;
  9394. const {
  9395. width,
  9396. height
  9397. } = xfaPage.attributes.style;
  9398. const viewBox = [0, 0, parseInt(width), parseInt(height)];
  9399. return new PageViewport({
  9400. viewBox,
  9401. scale,
  9402. rotation
  9403. });
  9404. }
  9405. function getRGB(color) {
  9406. if (color.startsWith("#")) {
  9407. const colorRGB = parseInt(color.slice(1), 16);
  9408. return [(colorRGB & 0xff0000) >> 16, (colorRGB & 0x00ff00) >> 8, colorRGB & 0x0000ff];
  9409. }
  9410. if (color.startsWith("rgb(")) {
  9411. return color.slice(4, -1).split(",").map(x => parseInt(x));
  9412. }
  9413. if (color.startsWith("rgba(")) {
  9414. return color.slice(5, -1).split(",").map(x => parseInt(x)).slice(0, 3);
  9415. }
  9416. (0, _util.warn)(`Not a valid color format: "${color}"`);
  9417. return [0, 0, 0];
  9418. }
  9419. function getColorValues(colors) {
  9420. const span = document.createElement("span");
  9421. span.style.visibility = "hidden";
  9422. document.body.append(span);
  9423. for (const name of colors.keys()) {
  9424. span.style.color = name;
  9425. const computedColor = window.getComputedStyle(span).color;
  9426. colors.set(name, getRGB(computedColor));
  9427. }
  9428. span.remove();
  9429. }
  9430. function getCurrentTransform(ctx) {
  9431. const {
  9432. a,
  9433. b,
  9434. c,
  9435. d,
  9436. e,
  9437. f
  9438. } = ctx.getTransform();
  9439. return [a, b, c, d, e, f];
  9440. }
  9441. function getCurrentTransformInverse(ctx) {
  9442. const {
  9443. a,
  9444. b,
  9445. c,
  9446. d,
  9447. e,
  9448. f
  9449. } = ctx.getTransform().invertSelf();
  9450. return [a, b, c, d, e, f];
  9451. }
  9452. function setLayerDimensions(div, viewport) {
  9453. let mustFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9454. let mustRotate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  9455. if (viewport instanceof PageViewport) {
  9456. const {
  9457. pageWidth,
  9458. pageHeight
  9459. } = viewport.rawDims;
  9460. const {
  9461. style
  9462. } = div;
  9463. const useRound = _util.FeatureTest.isCSSRoundSupported;
  9464. const w = `var(--scale-factor) * ${pageWidth}px`,
  9465. h = `var(--scale-factor) * ${pageHeight}px`;
  9466. const widthStr = useRound ? `round(${w}, 1px)` : `calc(${w})`,
  9467. heightStr = useRound ? `round(${h}, 1px)` : `calc(${h})`;
  9468. if (!mustFlip || viewport.rotation % 180 === 0) {
  9469. style.width = widthStr;
  9470. style.height = heightStr;
  9471. } else {
  9472. style.width = heightStr;
  9473. style.height = widthStr;
  9474. }
  9475. }
  9476. if (mustRotate) {
  9477. div.setAttribute("data-main-rotation", viewport.rotation);
  9478. }
  9479. }
  9480. /***/ }),
  9481. /* 169 */
  9482. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  9483. Object.defineProperty(exports, "__esModule", ({
  9484. value: true
  9485. }));
  9486. exports.BaseStandardFontDataFactory = exports.BaseSVGFactory = exports.BaseFilterFactory = exports.BaseCanvasFactory = exports.BaseCMapReaderFactory = void 0;
  9487. __w_pdfjs_require__(2);
  9488. var _util = __w_pdfjs_require__(1);
  9489. class BaseFilterFactory {
  9490. constructor() {
  9491. if (this.constructor === BaseFilterFactory) {
  9492. (0, _util.unreachable)("Cannot initialize BaseFilterFactory.");
  9493. }
  9494. }
  9495. addFilter(maps) {
  9496. return "none";
  9497. }
  9498. addHCMFilter(fgColor, bgColor) {
  9499. return "none";
  9500. }
  9501. addHighlightHCMFilter(fgColor, bgColor, newFgColor, newBgColor) {
  9502. return "none";
  9503. }
  9504. destroy() {
  9505. let keepHCM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9506. }
  9507. }
  9508. exports.BaseFilterFactory = BaseFilterFactory;
  9509. class BaseCanvasFactory {
  9510. constructor() {
  9511. if (this.constructor === BaseCanvasFactory) {
  9512. (0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
  9513. }
  9514. }
  9515. create(width, height) {
  9516. if (width <= 0 || height <= 0) {
  9517. throw new Error("Invalid canvas size");
  9518. }
  9519. const canvas = this._createCanvas(width, height);
  9520. return {
  9521. canvas,
  9522. context: canvas.getContext("2d")
  9523. };
  9524. }
  9525. reset(canvasAndContext, width, height) {
  9526. if (!canvasAndContext.canvas) {
  9527. throw new Error("Canvas is not specified");
  9528. }
  9529. if (width <= 0 || height <= 0) {
  9530. throw new Error("Invalid canvas size");
  9531. }
  9532. canvasAndContext.canvas.width = width;
  9533. canvasAndContext.canvas.height = height;
  9534. }
  9535. destroy(canvasAndContext) {
  9536. if (!canvasAndContext.canvas) {
  9537. throw new Error("Canvas is not specified");
  9538. }
  9539. canvasAndContext.canvas.width = 0;
  9540. canvasAndContext.canvas.height = 0;
  9541. canvasAndContext.canvas = null;
  9542. canvasAndContext.context = null;
  9543. }
  9544. _createCanvas(width, height) {
  9545. (0, _util.unreachable)("Abstract method `_createCanvas` called.");
  9546. }
  9547. }
  9548. exports.BaseCanvasFactory = BaseCanvasFactory;
  9549. class BaseCMapReaderFactory {
  9550. constructor(_ref) {
  9551. let {
  9552. baseUrl = null,
  9553. isCompressed = true
  9554. } = _ref;
  9555. if (this.constructor === BaseCMapReaderFactory) {
  9556. (0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
  9557. }
  9558. this.baseUrl = baseUrl;
  9559. this.isCompressed = isCompressed;
  9560. }
  9561. async fetch(_ref2) {
  9562. let {
  9563. name
  9564. } = _ref2;
  9565. if (!this.baseUrl) {
  9566. throw new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
  9567. }
  9568. if (!name) {
  9569. throw new Error("CMap name must be specified.");
  9570. }
  9571. const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
  9572. const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
  9573. return this._fetchData(url, compressionType).catch(reason => {
  9574. throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
  9575. });
  9576. }
  9577. _fetchData(url, compressionType) {
  9578. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  9579. }
  9580. }
  9581. exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
  9582. class BaseStandardFontDataFactory {
  9583. constructor(_ref3) {
  9584. let {
  9585. baseUrl = null
  9586. } = _ref3;
  9587. if (this.constructor === BaseStandardFontDataFactory) {
  9588. (0, _util.unreachable)("Cannot initialize BaseStandardFontDataFactory.");
  9589. }
  9590. this.baseUrl = baseUrl;
  9591. }
  9592. async fetch(_ref4) {
  9593. let {
  9594. filename
  9595. } = _ref4;
  9596. if (!this.baseUrl) {
  9597. throw new Error('The standard font "baseUrl" parameter must be specified, ensure that ' + 'the "standardFontDataUrl" API parameter is provided.');
  9598. }
  9599. if (!filename) {
  9600. throw new Error("Font filename must be specified.");
  9601. }
  9602. const url = `${this.baseUrl}${filename}`;
  9603. return this._fetchData(url).catch(reason => {
  9604. throw new Error(`Unable to load font data at: ${url}`);
  9605. });
  9606. }
  9607. _fetchData(url) {
  9608. (0, _util.unreachable)("Abstract method `_fetchData` called.");
  9609. }
  9610. }
  9611. exports.BaseStandardFontDataFactory = BaseStandardFontDataFactory;
  9612. class BaseSVGFactory {
  9613. constructor() {
  9614. if (this.constructor === BaseSVGFactory) {
  9615. (0, _util.unreachable)("Cannot initialize BaseSVGFactory.");
  9616. }
  9617. }
  9618. create(width, height) {
  9619. let skipDimensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9620. if (width <= 0 || height <= 0) {
  9621. throw new Error("Invalid SVG dimensions");
  9622. }
  9623. const svg = this._createSVG("svg:svg");
  9624. svg.setAttribute("version", "1.1");
  9625. if (!skipDimensions) {
  9626. svg.setAttribute("width", `${width}px`);
  9627. svg.setAttribute("height", `${height}px`);
  9628. }
  9629. svg.setAttribute("preserveAspectRatio", "none");
  9630. svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
  9631. return svg;
  9632. }
  9633. createElement(type) {
  9634. if (typeof type !== "string") {
  9635. throw new Error("Invalid SVG element type");
  9636. }
  9637. return this._createSVG(type);
  9638. }
  9639. _createSVG(type) {
  9640. (0, _util.unreachable)("Abstract method `_createSVG` called.");
  9641. }
  9642. }
  9643. exports.BaseSVGFactory = BaseSVGFactory;
  9644. /***/ }),
  9645. /* 170 */
  9646. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  9647. Object.defineProperty(exports, "__esModule", ({
  9648. value: true
  9649. }));
  9650. exports.MurmurHash3_64 = void 0;
  9651. __w_pdfjs_require__(93);
  9652. __w_pdfjs_require__(101);
  9653. __w_pdfjs_require__(102);
  9654. __w_pdfjs_require__(105);
  9655. __w_pdfjs_require__(107);
  9656. __w_pdfjs_require__(109);
  9657. __w_pdfjs_require__(113);
  9658. __w_pdfjs_require__(116);
  9659. __w_pdfjs_require__(123);
  9660. __w_pdfjs_require__(2);
  9661. var _util = __w_pdfjs_require__(1);
  9662. const SEED = 0xc3d2e1f0;
  9663. const MASK_HIGH = 0xffff0000;
  9664. const MASK_LOW = 0xffff;
  9665. class MurmurHash3_64 {
  9666. constructor(seed) {
  9667. this.h1 = seed ? seed & 0xffffffff : SEED;
  9668. this.h2 = seed ? seed & 0xffffffff : SEED;
  9669. }
  9670. update(input) {
  9671. let data, length;
  9672. if (typeof input === "string") {
  9673. data = new Uint8Array(input.length * 2);
  9674. length = 0;
  9675. for (let i = 0, ii = input.length; i < ii; i++) {
  9676. const code = input.charCodeAt(i);
  9677. if (code <= 0xff) {
  9678. data[length++] = code;
  9679. } else {
  9680. data[length++] = code >>> 8;
  9681. data[length++] = code & 0xff;
  9682. }
  9683. }
  9684. } else if ((0, _util.isArrayBuffer)(input)) {
  9685. data = input.slice();
  9686. length = data.byteLength;
  9687. } else {
  9688. throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
  9689. }
  9690. const blockCounts = length >> 2;
  9691. const tailLength = length - blockCounts * 4;
  9692. const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  9693. let k1 = 0,
  9694. k2 = 0;
  9695. let h1 = this.h1,
  9696. h2 = this.h2;
  9697. const C1 = 0xcc9e2d51,
  9698. C2 = 0x1b873593;
  9699. const C1_LOW = C1 & MASK_LOW,
  9700. C2_LOW = C2 & MASK_LOW;
  9701. for (let i = 0; i < blockCounts; i++) {
  9702. if (i & 1) {
  9703. k1 = dataUint32[i];
  9704. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  9705. k1 = k1 << 15 | k1 >>> 17;
  9706. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  9707. h1 ^= k1;
  9708. h1 = h1 << 13 | h1 >>> 19;
  9709. h1 = h1 * 5 + 0xe6546b64;
  9710. } else {
  9711. k2 = dataUint32[i];
  9712. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  9713. k2 = k2 << 15 | k2 >>> 17;
  9714. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  9715. h2 ^= k2;
  9716. h2 = h2 << 13 | h2 >>> 19;
  9717. h2 = h2 * 5 + 0xe6546b64;
  9718. }
  9719. }
  9720. k1 = 0;
  9721. switch (tailLength) {
  9722. case 3:
  9723. k1 ^= data[blockCounts * 4 + 2] << 16;
  9724. case 2:
  9725. k1 ^= data[blockCounts * 4 + 1] << 8;
  9726. case 1:
  9727. k1 ^= data[blockCounts * 4];
  9728. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  9729. k1 = k1 << 15 | k1 >>> 17;
  9730. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  9731. if (blockCounts & 1) {
  9732. h1 ^= k1;
  9733. } else {
  9734. h2 ^= k1;
  9735. }
  9736. }
  9737. this.h1 = h1;
  9738. this.h2 = h2;
  9739. }
  9740. hexdigest() {
  9741. let h1 = this.h1,
  9742. h2 = this.h2;
  9743. h1 ^= h2 >>> 1;
  9744. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  9745. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  9746. h1 ^= h2 >>> 1;
  9747. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  9748. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  9749. h1 ^= h2 >>> 1;
  9750. return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
  9751. }
  9752. }
  9753. exports.MurmurHash3_64 = MurmurHash3_64;
  9754. /***/ }),
  9755. /* 171 */
  9756. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  9757. Object.defineProperty(exports, "__esModule", ({
  9758. value: true
  9759. }));
  9760. exports.FontLoader = exports.FontFaceObject = void 0;
  9761. __w_pdfjs_require__(125);
  9762. __w_pdfjs_require__(136);
  9763. __w_pdfjs_require__(138);
  9764. __w_pdfjs_require__(141);
  9765. __w_pdfjs_require__(143);
  9766. __w_pdfjs_require__(145);
  9767. __w_pdfjs_require__(147);
  9768. __w_pdfjs_require__(89);
  9769. __w_pdfjs_require__(149);
  9770. var _util = __w_pdfjs_require__(1);
  9771. class FontLoader {
  9772. #systemFonts = new Set();
  9773. constructor(_ref) {
  9774. let {
  9775. ownerDocument = globalThis.document,
  9776. styleElement = null
  9777. } = _ref;
  9778. this._document = ownerDocument;
  9779. this.nativeFontFaces = new Set();
  9780. this.styleElement = null;
  9781. this.loadingRequests = [];
  9782. this.loadTestFontId = 0;
  9783. }
  9784. addNativeFontFace(nativeFontFace) {
  9785. this.nativeFontFaces.add(nativeFontFace);
  9786. this._document.fonts.add(nativeFontFace);
  9787. }
  9788. removeNativeFontFace(nativeFontFace) {
  9789. this.nativeFontFaces.delete(nativeFontFace);
  9790. this._document.fonts.delete(nativeFontFace);
  9791. }
  9792. insertRule(rule) {
  9793. if (!this.styleElement) {
  9794. this.styleElement = this._document.createElement("style");
  9795. this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);
  9796. }
  9797. const styleSheet = this.styleElement.sheet;
  9798. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  9799. }
  9800. clear() {
  9801. for (const nativeFontFace of this.nativeFontFaces) {
  9802. this._document.fonts.delete(nativeFontFace);
  9803. }
  9804. this.nativeFontFaces.clear();
  9805. this.#systemFonts.clear();
  9806. if (this.styleElement) {
  9807. this.styleElement.remove();
  9808. this.styleElement = null;
  9809. }
  9810. }
  9811. async loadSystemFont(info) {
  9812. if (!info || this.#systemFonts.has(info.loadedName)) {
  9813. return;
  9814. }
  9815. (0, _util.assert)(!this.disableFontFace, "loadSystemFont shouldn't be called when `disableFontFace` is set.");
  9816. if (this.isFontLoadingAPISupported) {
  9817. const {
  9818. loadedName,
  9819. src,
  9820. style
  9821. } = info;
  9822. const fontFace = new FontFace(loadedName, src, style);
  9823. this.addNativeFontFace(fontFace);
  9824. try {
  9825. await fontFace.load();
  9826. this.#systemFonts.add(loadedName);
  9827. } catch {
  9828. (0, _util.warn)(`Cannot load system font: ${info.baseFontName}, installing it could help to improve PDF rendering.`);
  9829. this.removeNativeFontFace(fontFace);
  9830. }
  9831. return;
  9832. }
  9833. (0, _util.unreachable)("Not implemented: loadSystemFont without the Font Loading API.");
  9834. }
  9835. async bind(font) {
  9836. if (font.attached || font.missingFile && !font.systemFontInfo) {
  9837. return;
  9838. }
  9839. font.attached = true;
  9840. if (font.systemFontInfo) {
  9841. await this.loadSystemFont(font.systemFontInfo);
  9842. return;
  9843. }
  9844. if (this.isFontLoadingAPISupported) {
  9845. const nativeFontFace = font.createNativeFontFace();
  9846. if (nativeFontFace) {
  9847. this.addNativeFontFace(nativeFontFace);
  9848. try {
  9849. await nativeFontFace.loaded;
  9850. } catch (ex) {
  9851. (0, _util.warn)(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);
  9852. font.disableFontFace = true;
  9853. throw ex;
  9854. }
  9855. }
  9856. return;
  9857. }
  9858. const rule = font.createFontFaceRule();
  9859. if (rule) {
  9860. this.insertRule(rule);
  9861. if (this.isSyncFontLoadingSupported) {
  9862. return;
  9863. }
  9864. await new Promise(resolve => {
  9865. const request = this._queueLoadingCallback(resolve);
  9866. this._prepareFontLoadEvent(font, request);
  9867. });
  9868. }
  9869. }
  9870. get isFontLoadingAPISupported() {
  9871. const hasFonts = !!this._document?.fonts;
  9872. return (0, _util.shadow)(this, "isFontLoadingAPISupported", hasFonts);
  9873. }
  9874. get isSyncFontLoadingSupported() {
  9875. let supported = false;
  9876. if (_util.isNodeJS) {
  9877. supported = true;
  9878. } else if (typeof navigator !== "undefined" && /Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)) {
  9879. supported = true;
  9880. }
  9881. return (0, _util.shadow)(this, "isSyncFontLoadingSupported", supported);
  9882. }
  9883. _queueLoadingCallback(callback) {
  9884. function completeRequest() {
  9885. (0, _util.assert)(!request.done, "completeRequest() cannot be called twice.");
  9886. request.done = true;
  9887. while (loadingRequests.length > 0 && loadingRequests[0].done) {
  9888. const otherRequest = loadingRequests.shift();
  9889. setTimeout(otherRequest.callback, 0);
  9890. }
  9891. }
  9892. const {
  9893. loadingRequests
  9894. } = this;
  9895. const request = {
  9896. done: false,
  9897. complete: completeRequest,
  9898. callback
  9899. };
  9900. loadingRequests.push(request);
  9901. return request;
  9902. }
  9903. get _loadTestFont() {
  9904. const testFont = 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==");
  9905. return (0, _util.shadow)(this, "_loadTestFont", testFont);
  9906. }
  9907. _prepareFontLoadEvent(font, request) {
  9908. function int32(data, offset) {
  9909. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  9910. }
  9911. function spliceString(s, offset, remove, insert) {
  9912. const chunk1 = s.substring(0, offset);
  9913. const chunk2 = s.substring(offset + remove);
  9914. return chunk1 + insert + chunk2;
  9915. }
  9916. let i, ii;
  9917. const canvas = this._document.createElement("canvas");
  9918. canvas.width = 1;
  9919. canvas.height = 1;
  9920. const ctx = canvas.getContext("2d");
  9921. let called = 0;
  9922. function isFontReady(name, callback) {
  9923. if (++called > 30) {
  9924. (0, _util.warn)("Load test font never loaded.");
  9925. callback();
  9926. return;
  9927. }
  9928. ctx.font = "30px " + name;
  9929. ctx.fillText(".", 0, 20);
  9930. const imageData = ctx.getImageData(0, 0, 1, 1);
  9931. if (imageData.data[3] > 0) {
  9932. callback();
  9933. return;
  9934. }
  9935. setTimeout(isFontReady.bind(null, name, callback));
  9936. }
  9937. const loadTestFontId = `lt${Date.now()}${this.loadTestFontId++}`;
  9938. let data = this._loadTestFont;
  9939. const COMMENT_OFFSET = 976;
  9940. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  9941. const CFF_CHECKSUM_OFFSET = 16;
  9942. const XXXX_VALUE = 0x58585858;
  9943. let checksum = int32(data, CFF_CHECKSUM_OFFSET);
  9944. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  9945. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  9946. }
  9947. if (i < loadTestFontId.length) {
  9948. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + "XXX", i) | 0;
  9949. }
  9950. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  9951. const url = `url(data:font/opentype;base64,${btoa(data)});`;
  9952. const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
  9953. this.insertRule(rule);
  9954. const div = this._document.createElement("div");
  9955. div.style.visibility = "hidden";
  9956. div.style.width = div.style.height = "10px";
  9957. div.style.position = "absolute";
  9958. div.style.top = div.style.left = "0px";
  9959. for (const name of [font.loadedName, loadTestFontId]) {
  9960. const span = this._document.createElement("span");
  9961. span.textContent = "Hi";
  9962. span.style.fontFamily = name;
  9963. div.append(span);
  9964. }
  9965. this._document.body.append(div);
  9966. isFontReady(loadTestFontId, () => {
  9967. div.remove();
  9968. request.complete();
  9969. });
  9970. }
  9971. }
  9972. exports.FontLoader = FontLoader;
  9973. class FontFaceObject {
  9974. constructor(translatedData, _ref2) {
  9975. let {
  9976. isEvalSupported = true,
  9977. disableFontFace = false,
  9978. ignoreErrors = false,
  9979. inspectFont = null
  9980. } = _ref2;
  9981. this.compiledGlyphs = Object.create(null);
  9982. for (const i in translatedData) {
  9983. this[i] = translatedData[i];
  9984. }
  9985. this.isEvalSupported = isEvalSupported !== false;
  9986. this.disableFontFace = disableFontFace === true;
  9987. this.ignoreErrors = ignoreErrors === true;
  9988. this._inspectFont = inspectFont;
  9989. }
  9990. createNativeFontFace() {
  9991. if (!this.data || this.disableFontFace) {
  9992. return null;
  9993. }
  9994. let nativeFontFace;
  9995. if (!this.cssFontInfo) {
  9996. nativeFontFace = new FontFace(this.loadedName, this.data, {});
  9997. } else {
  9998. const css = {
  9999. weight: this.cssFontInfo.fontWeight
  10000. };
  10001. if (this.cssFontInfo.italicAngle) {
  10002. css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;
  10003. }
  10004. nativeFontFace = new FontFace(this.cssFontInfo.fontFamily, this.data, css);
  10005. }
  10006. this._inspectFont?.(this);
  10007. return nativeFontFace;
  10008. }
  10009. createFontFaceRule() {
  10010. if (!this.data || this.disableFontFace) {
  10011. return null;
  10012. }
  10013. const data = (0, _util.bytesToString)(this.data);
  10014. const url = `url(data:${this.mimetype};base64,${btoa(data)});`;
  10015. let rule;
  10016. if (!this.cssFontInfo) {
  10017. rule = `@font-face {font-family:"${this.loadedName}";src:${url}}`;
  10018. } else {
  10019. let css = `font-weight: ${this.cssFontInfo.fontWeight};`;
  10020. if (this.cssFontInfo.italicAngle) {
  10021. css += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;
  10022. }
  10023. rule = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${css}src:${url}}`;
  10024. }
  10025. this._inspectFont?.(this, url);
  10026. return rule;
  10027. }
  10028. getPathGenerator(objs, character) {
  10029. if (this.compiledGlyphs[character] !== undefined) {
  10030. return this.compiledGlyphs[character];
  10031. }
  10032. let cmds;
  10033. try {
  10034. cmds = objs.get(this.loadedName + "_path_" + character);
  10035. } catch (ex) {
  10036. if (!this.ignoreErrors) {
  10037. throw ex;
  10038. }
  10039. (0, _util.warn)(`getPathGenerator - ignoring character: "${ex}".`);
  10040. return this.compiledGlyphs[character] = function (c, size) {};
  10041. }
  10042. if (this.isEvalSupported && _util.FeatureTest.isEvalSupported) {
  10043. const jsBuf = [];
  10044. for (const current of cmds) {
  10045. const args = current.args !== undefined ? current.args.join(",") : "";
  10046. jsBuf.push("c.", current.cmd, "(", args, ");\n");
  10047. }
  10048. return this.compiledGlyphs[character] = new Function("c", "size", jsBuf.join(""));
  10049. }
  10050. return this.compiledGlyphs[character] = function (c, size) {
  10051. for (const current of cmds) {
  10052. if (current.cmd === "scale") {
  10053. current.args = [size, -size];
  10054. }
  10055. c[current.cmd].apply(c, current.args);
  10056. }
  10057. };
  10058. }
  10059. }
  10060. exports.FontFaceObject = FontFaceObject;
  10061. /***/ }),
  10062. /* 172 */
  10063. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10064. Object.defineProperty(exports, "__esModule", ({
  10065. value: true
  10066. }));
  10067. exports.NodeStandardFontDataFactory = exports.NodeFilterFactory = exports.NodeCanvasFactory = exports.NodeCMapReaderFactory = void 0;
  10068. __w_pdfjs_require__(2);
  10069. __w_pdfjs_require__(93);
  10070. __w_pdfjs_require__(101);
  10071. __w_pdfjs_require__(102);
  10072. __w_pdfjs_require__(105);
  10073. __w_pdfjs_require__(107);
  10074. __w_pdfjs_require__(109);
  10075. __w_pdfjs_require__(113);
  10076. __w_pdfjs_require__(116);
  10077. __w_pdfjs_require__(123);
  10078. var _base_factory = __w_pdfjs_require__(169);
  10079. var _util = __w_pdfjs_require__(1);
  10080. ;
  10081. {
  10082. (function checkDOMMatrix() {
  10083. if (globalThis.DOMMatrix || !_util.isNodeJS) {
  10084. return;
  10085. }
  10086. try {
  10087. globalThis.DOMMatrix = require("canvas").DOMMatrix;
  10088. } catch (ex) {
  10089. (0, _util.warn)(`Cannot polyfill \`DOMMatrix\`, rendering may be broken: "${ex}".`);
  10090. }
  10091. })();
  10092. (function checkPath2D() {
  10093. if (globalThis.Path2D || !_util.isNodeJS) {
  10094. return;
  10095. }
  10096. try {
  10097. const {
  10098. CanvasRenderingContext2D
  10099. } = require("canvas");
  10100. const {
  10101. polyfillPath2D
  10102. } = require("path2d-polyfill");
  10103. globalThis.CanvasRenderingContext2D = CanvasRenderingContext2D;
  10104. polyfillPath2D(globalThis);
  10105. } catch (ex) {
  10106. (0, _util.warn)(`Cannot polyfill \`Path2D\`, rendering may be broken: "${ex}".`);
  10107. }
  10108. })();
  10109. }
  10110. const fetchData = function (url) {
  10111. return new Promise((resolve, reject) => {
  10112. const fs = require("fs");
  10113. fs.readFile(url, (error, data) => {
  10114. if (error || !data) {
  10115. reject(new Error(error));
  10116. return;
  10117. }
  10118. resolve(new Uint8Array(data));
  10119. });
  10120. });
  10121. };
  10122. class NodeFilterFactory extends _base_factory.BaseFilterFactory {}
  10123. exports.NodeFilterFactory = NodeFilterFactory;
  10124. class NodeCanvasFactory extends _base_factory.BaseCanvasFactory {
  10125. _createCanvas(width, height) {
  10126. const Canvas = require("canvas");
  10127. return Canvas.createCanvas(width, height);
  10128. }
  10129. }
  10130. exports.NodeCanvasFactory = NodeCanvasFactory;
  10131. class NodeCMapReaderFactory extends _base_factory.BaseCMapReaderFactory {
  10132. _fetchData(url, compressionType) {
  10133. return fetchData(url).then(data => {
  10134. return {
  10135. cMapData: data,
  10136. compressionType
  10137. };
  10138. });
  10139. }
  10140. }
  10141. exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
  10142. class NodeStandardFontDataFactory extends _base_factory.BaseStandardFontDataFactory {
  10143. _fetchData(url) {
  10144. return fetchData(url);
  10145. }
  10146. }
  10147. exports.NodeStandardFontDataFactory = NodeStandardFontDataFactory;
  10148. /***/ }),
  10149. /* 173 */
  10150. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  10151. Object.defineProperty(exports, "__esModule", ({
  10152. value: true
  10153. }));
  10154. exports.CanvasGraphics = void 0;
  10155. __w_pdfjs_require__(2);
  10156. __w_pdfjs_require__(93);
  10157. __w_pdfjs_require__(101);
  10158. __w_pdfjs_require__(102);
  10159. __w_pdfjs_require__(105);
  10160. __w_pdfjs_require__(107);
  10161. __w_pdfjs_require__(109);
  10162. __w_pdfjs_require__(113);
  10163. __w_pdfjs_require__(116);
  10164. __w_pdfjs_require__(123);
  10165. __w_pdfjs_require__(89);
  10166. var _util = __w_pdfjs_require__(1);
  10167. var _display_utils = __w_pdfjs_require__(168);
  10168. var _pattern_helper = __w_pdfjs_require__(174);
  10169. var _image_utils = __w_pdfjs_require__(175);
  10170. const MIN_FONT_SIZE = 16;
  10171. const MAX_FONT_SIZE = 100;
  10172. const MAX_GROUP_SIZE = 4096;
  10173. const EXECUTION_TIME = 15;
  10174. const EXECUTION_STEPS = 10;
  10175. const MAX_SIZE_TO_COMPILE = 1000;
  10176. const FULL_CHUNK_HEIGHT = 16;
  10177. function mirrorContextOperations(ctx, destCtx) {
  10178. if (ctx._removeMirroring) {
  10179. throw new Error("Context is already forwarding operations.");
  10180. }
  10181. ctx.__originalSave = ctx.save;
  10182. ctx.__originalRestore = ctx.restore;
  10183. ctx.__originalRotate = ctx.rotate;
  10184. ctx.__originalScale = ctx.scale;
  10185. ctx.__originalTranslate = ctx.translate;
  10186. ctx.__originalTransform = ctx.transform;
  10187. ctx.__originalSetTransform = ctx.setTransform;
  10188. ctx.__originalResetTransform = ctx.resetTransform;
  10189. ctx.__originalClip = ctx.clip;
  10190. ctx.__originalMoveTo = ctx.moveTo;
  10191. ctx.__originalLineTo = ctx.lineTo;
  10192. ctx.__originalBezierCurveTo = ctx.bezierCurveTo;
  10193. ctx.__originalRect = ctx.rect;
  10194. ctx.__originalClosePath = ctx.closePath;
  10195. ctx.__originalBeginPath = ctx.beginPath;
  10196. ctx._removeMirroring = () => {
  10197. ctx.save = ctx.__originalSave;
  10198. ctx.restore = ctx.__originalRestore;
  10199. ctx.rotate = ctx.__originalRotate;
  10200. ctx.scale = ctx.__originalScale;
  10201. ctx.translate = ctx.__originalTranslate;
  10202. ctx.transform = ctx.__originalTransform;
  10203. ctx.setTransform = ctx.__originalSetTransform;
  10204. ctx.resetTransform = ctx.__originalResetTransform;
  10205. ctx.clip = ctx.__originalClip;
  10206. ctx.moveTo = ctx.__originalMoveTo;
  10207. ctx.lineTo = ctx.__originalLineTo;
  10208. ctx.bezierCurveTo = ctx.__originalBezierCurveTo;
  10209. ctx.rect = ctx.__originalRect;
  10210. ctx.closePath = ctx.__originalClosePath;
  10211. ctx.beginPath = ctx.__originalBeginPath;
  10212. delete ctx._removeMirroring;
  10213. };
  10214. ctx.save = function ctxSave() {
  10215. destCtx.save();
  10216. this.__originalSave();
  10217. };
  10218. ctx.restore = function ctxRestore() {
  10219. destCtx.restore();
  10220. this.__originalRestore();
  10221. };
  10222. ctx.translate = function ctxTranslate(x, y) {
  10223. destCtx.translate(x, y);
  10224. this.__originalTranslate(x, y);
  10225. };
  10226. ctx.scale = function ctxScale(x, y) {
  10227. destCtx.scale(x, y);
  10228. this.__originalScale(x, y);
  10229. };
  10230. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  10231. destCtx.transform(a, b, c, d, e, f);
  10232. this.__originalTransform(a, b, c, d, e, f);
  10233. };
  10234. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  10235. destCtx.setTransform(a, b, c, d, e, f);
  10236. this.__originalSetTransform(a, b, c, d, e, f);
  10237. };
  10238. ctx.resetTransform = function ctxResetTransform() {
  10239. destCtx.resetTransform();
  10240. this.__originalResetTransform();
  10241. };
  10242. ctx.rotate = function ctxRotate(angle) {
  10243. destCtx.rotate(angle);
  10244. this.__originalRotate(angle);
  10245. };
  10246. ctx.clip = function ctxRotate(rule) {
  10247. destCtx.clip(rule);
  10248. this.__originalClip(rule);
  10249. };
  10250. ctx.moveTo = function (x, y) {
  10251. destCtx.moveTo(x, y);
  10252. this.__originalMoveTo(x, y);
  10253. };
  10254. ctx.lineTo = function (x, y) {
  10255. destCtx.lineTo(x, y);
  10256. this.__originalLineTo(x, y);
  10257. };
  10258. ctx.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
  10259. destCtx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
  10260. this.__originalBezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
  10261. };
  10262. ctx.rect = function (x, y, width, height) {
  10263. destCtx.rect(x, y, width, height);
  10264. this.__originalRect(x, y, width, height);
  10265. };
  10266. ctx.closePath = function () {
  10267. destCtx.closePath();
  10268. this.__originalClosePath();
  10269. };
  10270. ctx.beginPath = function () {
  10271. destCtx.beginPath();
  10272. this.__originalBeginPath();
  10273. };
  10274. }
  10275. class CachedCanvases {
  10276. constructor(canvasFactory) {
  10277. this.canvasFactory = canvasFactory;
  10278. this.cache = Object.create(null);
  10279. }
  10280. getCanvas(id, width, height) {
  10281. let canvasEntry;
  10282. if (this.cache[id] !== undefined) {
  10283. canvasEntry = this.cache[id];
  10284. this.canvasFactory.reset(canvasEntry, width, height);
  10285. } else {
  10286. canvasEntry = this.canvasFactory.create(width, height);
  10287. this.cache[id] = canvasEntry;
  10288. }
  10289. return canvasEntry;
  10290. }
  10291. delete(id) {
  10292. delete this.cache[id];
  10293. }
  10294. clear() {
  10295. for (const id in this.cache) {
  10296. const canvasEntry = this.cache[id];
  10297. this.canvasFactory.destroy(canvasEntry);
  10298. delete this.cache[id];
  10299. }
  10300. }
  10301. }
  10302. function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
  10303. const [a, b, c, d, tx, ty] = (0, _display_utils.getCurrentTransform)(ctx);
  10304. if (b === 0 && c === 0) {
  10305. const tlX = destX * a + tx;
  10306. const rTlX = Math.round(tlX);
  10307. const tlY = destY * d + ty;
  10308. const rTlY = Math.round(tlY);
  10309. const brX = (destX + destW) * a + tx;
  10310. const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
  10311. const brY = (destY + destH) * d + ty;
  10312. const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
  10313. ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);
  10314. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);
  10315. ctx.setTransform(a, b, c, d, tx, ty);
  10316. return [rWidth, rHeight];
  10317. }
  10318. if (a === 0 && d === 0) {
  10319. const tlX = destY * c + tx;
  10320. const rTlX = Math.round(tlX);
  10321. const tlY = destX * b + ty;
  10322. const rTlY = Math.round(tlY);
  10323. const brX = (destY + destH) * c + tx;
  10324. const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
  10325. const brY = (destX + destW) * b + ty;
  10326. const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
  10327. ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);
  10328. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);
  10329. ctx.setTransform(a, b, c, d, tx, ty);
  10330. return [rHeight, rWidth];
  10331. }
  10332. ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
  10333. const scaleX = Math.hypot(a, b);
  10334. const scaleY = Math.hypot(c, d);
  10335. return [scaleX * destW, scaleY * destH];
  10336. }
  10337. function compileType3Glyph(imgData) {
  10338. const {
  10339. width,
  10340. height
  10341. } = imgData;
  10342. if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
  10343. return null;
  10344. }
  10345. const POINT_TO_PROCESS_LIMIT = 1000;
  10346. const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  10347. const width1 = width + 1;
  10348. let points = new Uint8Array(width1 * (height + 1));
  10349. let i, j, j0;
  10350. const lineSize = width + 7 & ~7;
  10351. let data = new Uint8Array(lineSize * height),
  10352. pos = 0;
  10353. for (const elem of imgData.data) {
  10354. let mask = 128;
  10355. while (mask > 0) {
  10356. data[pos++] = elem & mask ? 0 : 255;
  10357. mask >>= 1;
  10358. }
  10359. }
  10360. let count = 0;
  10361. pos = 0;
  10362. if (data[pos] !== 0) {
  10363. points[0] = 1;
  10364. ++count;
  10365. }
  10366. for (j = 1; j < width; j++) {
  10367. if (data[pos] !== data[pos + 1]) {
  10368. points[j] = data[pos] ? 2 : 1;
  10369. ++count;
  10370. }
  10371. pos++;
  10372. }
  10373. if (data[pos] !== 0) {
  10374. points[j] = 2;
  10375. ++count;
  10376. }
  10377. for (i = 1; i < height; i++) {
  10378. pos = i * lineSize;
  10379. j0 = i * width1;
  10380. if (data[pos - lineSize] !== data[pos]) {
  10381. points[j0] = data[pos] ? 1 : 8;
  10382. ++count;
  10383. }
  10384. let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  10385. for (j = 1; j < width; j++) {
  10386. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  10387. if (POINT_TYPES[sum]) {
  10388. points[j0 + j] = POINT_TYPES[sum];
  10389. ++count;
  10390. }
  10391. pos++;
  10392. }
  10393. if (data[pos - lineSize] !== data[pos]) {
  10394. points[j0 + j] = data[pos] ? 2 : 4;
  10395. ++count;
  10396. }
  10397. if (count > POINT_TO_PROCESS_LIMIT) {
  10398. return null;
  10399. }
  10400. }
  10401. pos = lineSize * (height - 1);
  10402. j0 = i * width1;
  10403. if (data[pos] !== 0) {
  10404. points[j0] = 8;
  10405. ++count;
  10406. }
  10407. for (j = 1; j < width; j++) {
  10408. if (data[pos] !== data[pos + 1]) {
  10409. points[j0 + j] = data[pos] ? 4 : 8;
  10410. ++count;
  10411. }
  10412. pos++;
  10413. }
  10414. if (data[pos] !== 0) {
  10415. points[j0 + j] = 4;
  10416. ++count;
  10417. }
  10418. if (count > POINT_TO_PROCESS_LIMIT) {
  10419. return null;
  10420. }
  10421. const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  10422. const path = new Path2D();
  10423. for (i = 0; count && i <= height; i++) {
  10424. let p = i * width1;
  10425. const end = p + width;
  10426. while (p < end && !points[p]) {
  10427. p++;
  10428. }
  10429. if (p === end) {
  10430. continue;
  10431. }
  10432. path.moveTo(p % width1, i);
  10433. const p0 = p;
  10434. let type = points[p];
  10435. do {
  10436. const step = steps[type];
  10437. do {
  10438. p += step;
  10439. } while (!points[p]);
  10440. const pp = points[p];
  10441. if (pp !== 5 && pp !== 10) {
  10442. type = pp;
  10443. points[p] = 0;
  10444. } else {
  10445. type = pp & 0x33 * type >> 4;
  10446. points[p] &= type >> 2 | type << 2;
  10447. }
  10448. path.lineTo(p % width1, p / width1 | 0);
  10449. if (!points[p]) {
  10450. --count;
  10451. }
  10452. } while (p0 !== p);
  10453. --i;
  10454. }
  10455. data = null;
  10456. points = null;
  10457. const drawOutline = function (c) {
  10458. c.save();
  10459. c.scale(1 / width, -1 / height);
  10460. c.translate(0, -height);
  10461. c.fill(path);
  10462. c.beginPath();
  10463. c.restore();
  10464. };
  10465. return drawOutline;
  10466. }
  10467. class CanvasExtraState {
  10468. constructor(width, height) {
  10469. this.alphaIsShape = false;
  10470. this.fontSize = 0;
  10471. this.fontSizeScale = 1;
  10472. this.textMatrix = _util.IDENTITY_MATRIX;
  10473. this.textMatrixScale = 1;
  10474. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  10475. this.leading = 0;
  10476. this.x = 0;
  10477. this.y = 0;
  10478. this.lineX = 0;
  10479. this.lineY = 0;
  10480. this.charSpacing = 0;
  10481. this.wordSpacing = 0;
  10482. this.textHScale = 1;
  10483. this.textRenderingMode = _util.TextRenderingMode.FILL;
  10484. this.textRise = 0;
  10485. this.fillColor = "#000000";
  10486. this.strokeColor = "#000000";
  10487. this.patternFill = false;
  10488. this.fillAlpha = 1;
  10489. this.strokeAlpha = 1;
  10490. this.lineWidth = 1;
  10491. this.activeSMask = null;
  10492. this.transferMaps = "none";
  10493. this.startNewPathAndClipBox([0, 0, width, height]);
  10494. }
  10495. clone() {
  10496. const clone = Object.create(this);
  10497. clone.clipBox = this.clipBox.slice();
  10498. return clone;
  10499. }
  10500. setCurrentPoint(x, y) {
  10501. this.x = x;
  10502. this.y = y;
  10503. }
  10504. updatePathMinMax(transform, x, y) {
  10505. [x, y] = _util.Util.applyTransform([x, y], transform);
  10506. this.minX = Math.min(this.minX, x);
  10507. this.minY = Math.min(this.minY, y);
  10508. this.maxX = Math.max(this.maxX, x);
  10509. this.maxY = Math.max(this.maxY, y);
  10510. }
  10511. updateRectMinMax(transform, rect) {
  10512. const p1 = _util.Util.applyTransform(rect, transform);
  10513. const p2 = _util.Util.applyTransform(rect.slice(2), transform);
  10514. this.minX = Math.min(this.minX, p1[0], p2[0]);
  10515. this.minY = Math.min(this.minY, p1[1], p2[1]);
  10516. this.maxX = Math.max(this.maxX, p1[0], p2[0]);
  10517. this.maxY = Math.max(this.maxY, p1[1], p2[1]);
  10518. }
  10519. updateScalingPathMinMax(transform, minMax) {
  10520. _util.Util.scaleMinMax(transform, minMax);
  10521. this.minX = Math.min(this.minX, minMax[0]);
  10522. this.maxX = Math.max(this.maxX, minMax[1]);
  10523. this.minY = Math.min(this.minY, minMax[2]);
  10524. this.maxY = Math.max(this.maxY, minMax[3]);
  10525. }
  10526. updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
  10527. const box = _util.Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3);
  10528. if (minMax) {
  10529. minMax[0] = Math.min(minMax[0], box[0], box[2]);
  10530. minMax[1] = Math.max(minMax[1], box[0], box[2]);
  10531. minMax[2] = Math.min(minMax[2], box[1], box[3]);
  10532. minMax[3] = Math.max(minMax[3], box[1], box[3]);
  10533. return;
  10534. }
  10535. this.updateRectMinMax(transform, box);
  10536. }
  10537. getPathBoundingBox() {
  10538. let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _pattern_helper.PathType.FILL;
  10539. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10540. const box = [this.minX, this.minY, this.maxX, this.maxY];
  10541. if (pathType === _pattern_helper.PathType.STROKE) {
  10542. if (!transform) {
  10543. (0, _util.unreachable)("Stroke bounding box must include transform.");
  10544. }
  10545. const scale = _util.Util.singularValueDecompose2dScale(transform);
  10546. const xStrokePad = scale[0] * this.lineWidth / 2;
  10547. const yStrokePad = scale[1] * this.lineWidth / 2;
  10548. box[0] -= xStrokePad;
  10549. box[1] -= yStrokePad;
  10550. box[2] += xStrokePad;
  10551. box[3] += yStrokePad;
  10552. }
  10553. return box;
  10554. }
  10555. updateClipFromPath() {
  10556. const intersect = _util.Util.intersect(this.clipBox, this.getPathBoundingBox());
  10557. this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
  10558. }
  10559. isEmptyClip() {
  10560. return this.minX === Infinity;
  10561. }
  10562. startNewPathAndClipBox(box) {
  10563. this.clipBox = box;
  10564. this.minX = Infinity;
  10565. this.minY = Infinity;
  10566. this.maxX = 0;
  10567. this.maxY = 0;
  10568. }
  10569. getClippedPathBoundingBox() {
  10570. let pathType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _pattern_helper.PathType.FILL;
  10571. let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10572. return _util.Util.intersect(this.clipBox, this.getPathBoundingBox(pathType, transform));
  10573. }
  10574. }
  10575. function putBinaryImageData(ctx, imgData) {
  10576. if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
  10577. ctx.putImageData(imgData, 0, 0);
  10578. return;
  10579. }
  10580. const height = imgData.height,
  10581. width = imgData.width;
  10582. const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  10583. const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  10584. const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  10585. const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  10586. let srcPos = 0,
  10587. destPos;
  10588. const src = imgData.data;
  10589. const dest = chunkImgData.data;
  10590. let i, j, thisChunkHeight, elemsInThisChunk;
  10591. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  10592. const srcLength = src.byteLength;
  10593. const dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  10594. const dest32DataLength = dest32.length;
  10595. const fullSrcDiff = width + 7 >> 3;
  10596. const white = 0xffffffff;
  10597. const black = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  10598. for (i = 0; i < totalChunks; i++) {
  10599. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  10600. destPos = 0;
  10601. for (j = 0; j < thisChunkHeight; j++) {
  10602. const srcDiff = srcLength - srcPos;
  10603. let k = 0;
  10604. const kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  10605. const kEndUnrolled = kEnd & ~7;
  10606. let mask = 0;
  10607. let srcByte = 0;
  10608. for (; k < kEndUnrolled; k += 8) {
  10609. srcByte = src[srcPos++];
  10610. dest32[destPos++] = srcByte & 128 ? white : black;
  10611. dest32[destPos++] = srcByte & 64 ? white : black;
  10612. dest32[destPos++] = srcByte & 32 ? white : black;
  10613. dest32[destPos++] = srcByte & 16 ? white : black;
  10614. dest32[destPos++] = srcByte & 8 ? white : black;
  10615. dest32[destPos++] = srcByte & 4 ? white : black;
  10616. dest32[destPos++] = srcByte & 2 ? white : black;
  10617. dest32[destPos++] = srcByte & 1 ? white : black;
  10618. }
  10619. for (; k < kEnd; k++) {
  10620. if (mask === 0) {
  10621. srcByte = src[srcPos++];
  10622. mask = 128;
  10623. }
  10624. dest32[destPos++] = srcByte & mask ? white : black;
  10625. mask >>= 1;
  10626. }
  10627. }
  10628. while (destPos < dest32DataLength) {
  10629. dest32[destPos++] = 0;
  10630. }
  10631. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10632. }
  10633. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  10634. j = 0;
  10635. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  10636. for (i = 0; i < fullChunks; i++) {
  10637. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  10638. srcPos += elemsInThisChunk;
  10639. ctx.putImageData(chunkImgData, 0, j);
  10640. j += FULL_CHUNK_HEIGHT;
  10641. }
  10642. if (i < totalChunks) {
  10643. elemsInThisChunk = width * partialChunkHeight * 4;
  10644. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  10645. ctx.putImageData(chunkImgData, 0, j);
  10646. }
  10647. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  10648. thisChunkHeight = FULL_CHUNK_HEIGHT;
  10649. elemsInThisChunk = width * thisChunkHeight;
  10650. for (i = 0; i < totalChunks; i++) {
  10651. if (i >= fullChunks) {
  10652. thisChunkHeight = partialChunkHeight;
  10653. elemsInThisChunk = width * thisChunkHeight;
  10654. }
  10655. destPos = 0;
  10656. for (j = elemsInThisChunk; j--;) {
  10657. dest[destPos++] = src[srcPos++];
  10658. dest[destPos++] = src[srcPos++];
  10659. dest[destPos++] = src[srcPos++];
  10660. dest[destPos++] = 255;
  10661. }
  10662. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10663. }
  10664. } else {
  10665. throw new Error(`bad image kind: ${imgData.kind}`);
  10666. }
  10667. }
  10668. function putBinaryImageMask(ctx, imgData) {
  10669. if (imgData.bitmap) {
  10670. ctx.drawImage(imgData.bitmap, 0, 0);
  10671. return;
  10672. }
  10673. const height = imgData.height,
  10674. width = imgData.width;
  10675. const partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  10676. const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  10677. const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  10678. const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  10679. let srcPos = 0;
  10680. const src = imgData.data;
  10681. const dest = chunkImgData.data;
  10682. for (let i = 0; i < totalChunks; i++) {
  10683. const thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  10684. ({
  10685. srcPos
  10686. } = (0, _image_utils.convertBlackAndWhiteToRGBA)({
  10687. src,
  10688. srcPos,
  10689. dest,
  10690. width,
  10691. height: thisChunkHeight,
  10692. nonBlackColor: 0
  10693. }));
  10694. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10695. }
  10696. }
  10697. function copyCtxState(sourceCtx, destCtx) {
  10698. const properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font", "filter"];
  10699. for (const property of properties) {
  10700. if (sourceCtx[property] !== undefined) {
  10701. destCtx[property] = sourceCtx[property];
  10702. }
  10703. }
  10704. if (sourceCtx.setLineDash !== undefined) {
  10705. destCtx.setLineDash(sourceCtx.getLineDash());
  10706. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  10707. }
  10708. }
  10709. function resetCtxToDefault(ctx) {
  10710. ctx.strokeStyle = ctx.fillStyle = "#000000";
  10711. ctx.fillRule = "nonzero";
  10712. ctx.globalAlpha = 1;
  10713. ctx.lineWidth = 1;
  10714. ctx.lineCap = "butt";
  10715. ctx.lineJoin = "miter";
  10716. ctx.miterLimit = 10;
  10717. ctx.globalCompositeOperation = "source-over";
  10718. ctx.font = "10px sans-serif";
  10719. if (ctx.setLineDash !== undefined) {
  10720. ctx.setLineDash([]);
  10721. ctx.lineDashOffset = 0;
  10722. }
  10723. if (!_util.isNodeJS) {
  10724. const {
  10725. filter
  10726. } = ctx;
  10727. if (filter !== "none" && filter !== "") {
  10728. ctx.filter = "none";
  10729. }
  10730. }
  10731. }
  10732. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  10733. const length = bytes.length;
  10734. for (let i = 3; i < length; i += 4) {
  10735. const alpha = bytes[i];
  10736. if (alpha === 0) {
  10737. bytes[i - 3] = r0;
  10738. bytes[i - 2] = g0;
  10739. bytes[i - 1] = b0;
  10740. } else if (alpha < 255) {
  10741. const alpha_ = 255 - alpha;
  10742. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  10743. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  10744. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  10745. }
  10746. }
  10747. }
  10748. function composeSMaskAlpha(maskData, layerData, transferMap) {
  10749. const length = maskData.length;
  10750. const scale = 1 / 255;
  10751. for (let i = 3; i < length; i += 4) {
  10752. const alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  10753. layerData[i] = layerData[i] * alpha * scale | 0;
  10754. }
  10755. }
  10756. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  10757. const length = maskData.length;
  10758. for (let i = 3; i < length; i += 4) {
  10759. const y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  10760. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  10761. }
  10762. }
  10763. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap, layerOffsetX, layerOffsetY, maskOffsetX, maskOffsetY) {
  10764. const hasBackdrop = !!backdrop;
  10765. const r0 = hasBackdrop ? backdrop[0] : 0;
  10766. const g0 = hasBackdrop ? backdrop[1] : 0;
  10767. const b0 = hasBackdrop ? backdrop[2] : 0;
  10768. const composeFn = subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
  10769. const PIXELS_TO_PROCESS = 1048576;
  10770. const chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  10771. for (let row = 0; row < height; row += chunkSize) {
  10772. const chunkHeight = Math.min(chunkSize, height - row);
  10773. const maskData = maskCtx.getImageData(layerOffsetX - maskOffsetX, row + (layerOffsetY - maskOffsetY), width, chunkHeight);
  10774. const layerData = layerCtx.getImageData(layerOffsetX, row + layerOffsetY, width, chunkHeight);
  10775. if (hasBackdrop) {
  10776. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  10777. }
  10778. composeFn(maskData.data, layerData.data, transferMap);
  10779. layerCtx.putImageData(layerData, layerOffsetX, row + layerOffsetY);
  10780. }
  10781. }
  10782. function composeSMask(ctx, smask, layerCtx, layerBox) {
  10783. const layerOffsetX = layerBox[0];
  10784. const layerOffsetY = layerBox[1];
  10785. const layerWidth = layerBox[2] - layerOffsetX;
  10786. const layerHeight = layerBox[3] - layerOffsetY;
  10787. if (layerWidth === 0 || layerHeight === 0) {
  10788. return;
  10789. }
  10790. genericComposeSMask(smask.context, layerCtx, layerWidth, layerHeight, smask.subtype, smask.backdrop, smask.transferMap, layerOffsetX, layerOffsetY, smask.offsetX, smask.offsetY);
  10791. ctx.save();
  10792. ctx.globalAlpha = 1;
  10793. ctx.globalCompositeOperation = "source-over";
  10794. ctx.setTransform(1, 0, 0, 1, 0, 0);
  10795. ctx.drawImage(layerCtx.canvas, 0, 0);
  10796. ctx.restore();
  10797. }
  10798. function getImageSmoothingEnabled(transform, interpolate) {
  10799. const scale = _util.Util.singularValueDecompose2dScale(transform);
  10800. scale[0] = Math.fround(scale[0]);
  10801. scale[1] = Math.fround(scale[1]);
  10802. const actualScale = Math.fround((globalThis.devicePixelRatio || 1) * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
  10803. if (interpolate !== undefined) {
  10804. return interpolate;
  10805. } else if (scale[0] <= actualScale || scale[1] <= actualScale) {
  10806. return true;
  10807. }
  10808. return false;
  10809. }
  10810. const LINE_CAP_STYLES = ["butt", "round", "square"];
  10811. const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  10812. const NORMAL_CLIP = {};
  10813. const EO_CLIP = {};
  10814. class CanvasGraphics {
  10815. constructor(canvasCtx, commonObjs, objs, canvasFactory, filterFactory, _ref, annotationCanvasMap, pageColors) {
  10816. let {
  10817. optionalContentConfig,
  10818. markedContentStack = null
  10819. } = _ref;
  10820. this.ctx = canvasCtx;
  10821. this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
  10822. this.stateStack = [];
  10823. this.pendingClip = null;
  10824. this.pendingEOFill = false;
  10825. this.res = null;
  10826. this.xobjs = null;
  10827. this.commonObjs = commonObjs;
  10828. this.objs = objs;
  10829. this.canvasFactory = canvasFactory;
  10830. this.filterFactory = filterFactory;
  10831. this.groupStack = [];
  10832. this.processingType3 = null;
  10833. this.baseTransform = null;
  10834. this.baseTransformStack = [];
  10835. this.groupLevel = 0;
  10836. this.smaskStack = [];
  10837. this.smaskCounter = 0;
  10838. this.tempSMask = null;
  10839. this.suspendedCtx = null;
  10840. this.contentVisible = true;
  10841. this.markedContentStack = markedContentStack || [];
  10842. this.optionalContentConfig = optionalContentConfig;
  10843. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  10844. this.cachedPatterns = new Map();
  10845. this.annotationCanvasMap = annotationCanvasMap;
  10846. this.viewportScale = 1;
  10847. this.outputScaleX = 1;
  10848. this.outputScaleY = 1;
  10849. this.pageColors = pageColors;
  10850. this._cachedScaleForStroking = [-1, 0];
  10851. this._cachedGetSinglePixelWidth = null;
  10852. this._cachedBitmapsMap = new Map();
  10853. }
  10854. getObject(data) {
  10855. let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10856. if (typeof data === "string") {
  10857. return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
  10858. }
  10859. return fallback;
  10860. }
  10861. beginDrawing(_ref2) {
  10862. let {
  10863. transform,
  10864. viewport,
  10865. transparency = false,
  10866. background = null
  10867. } = _ref2;
  10868. const width = this.ctx.canvas.width;
  10869. const height = this.ctx.canvas.height;
  10870. const savedFillStyle = this.ctx.fillStyle;
  10871. this.ctx.fillStyle = background || "#ffffff";
  10872. this.ctx.fillRect(0, 0, width, height);
  10873. this.ctx.fillStyle = savedFillStyle;
  10874. if (transparency) {
  10875. const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height);
  10876. this.compositeCtx = this.ctx;
  10877. this.transparentCanvas = transparentCanvas.canvas;
  10878. this.ctx = transparentCanvas.context;
  10879. this.ctx.save();
  10880. this.ctx.transform(...(0, _display_utils.getCurrentTransform)(this.compositeCtx));
  10881. }
  10882. this.ctx.save();
  10883. resetCtxToDefault(this.ctx);
  10884. if (transform) {
  10885. this.ctx.transform(...transform);
  10886. this.outputScaleX = transform[0];
  10887. this.outputScaleY = transform[0];
  10888. }
  10889. this.ctx.transform(...viewport.transform);
  10890. this.viewportScale = viewport.scale;
  10891. this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
  10892. }
  10893. executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  10894. const argsArray = operatorList.argsArray;
  10895. const fnArray = operatorList.fnArray;
  10896. let i = executionStartIdx || 0;
  10897. const argsArrayLen = argsArray.length;
  10898. if (argsArrayLen === i) {
  10899. return i;
  10900. }
  10901. const chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
  10902. const endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  10903. let steps = 0;
  10904. const commonObjs = this.commonObjs;
  10905. const objs = this.objs;
  10906. let fnId;
  10907. while (true) {
  10908. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  10909. stepper.breakIt(i, continueCallback);
  10910. return i;
  10911. }
  10912. fnId = fnArray[i];
  10913. if (fnId !== _util.OPS.dependency) {
  10914. this[fnId].apply(this, argsArray[i]);
  10915. } else {
  10916. for (const depObjId of argsArray[i]) {
  10917. const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
  10918. if (!objsPool.has(depObjId)) {
  10919. objsPool.get(depObjId, continueCallback);
  10920. return i;
  10921. }
  10922. }
  10923. }
  10924. i++;
  10925. if (i === argsArrayLen) {
  10926. return i;
  10927. }
  10928. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  10929. if (Date.now() > endTime) {
  10930. continueCallback();
  10931. return i;
  10932. }
  10933. steps = 0;
  10934. }
  10935. }
  10936. }
  10937. #restoreInitialState() {
  10938. while (this.stateStack.length || this.inSMaskMode) {
  10939. this.restore();
  10940. }
  10941. this.ctx.restore();
  10942. if (this.transparentCanvas) {
  10943. this.ctx = this.compositeCtx;
  10944. this.ctx.save();
  10945. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  10946. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  10947. this.ctx.restore();
  10948. this.transparentCanvas = null;
  10949. }
  10950. }
  10951. endDrawing() {
  10952. this.#restoreInitialState();
  10953. this.cachedCanvases.clear();
  10954. this.cachedPatterns.clear();
  10955. for (const cache of this._cachedBitmapsMap.values()) {
  10956. for (const canvas of cache.values()) {
  10957. if (typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement) {
  10958. canvas.width = canvas.height = 0;
  10959. }
  10960. }
  10961. cache.clear();
  10962. }
  10963. this._cachedBitmapsMap.clear();
  10964. this.#drawFilter();
  10965. }
  10966. #drawFilter() {
  10967. if (this.pageColors) {
  10968. const hcmFilterId = this.filterFactory.addHCMFilter(this.pageColors.foreground, this.pageColors.background);
  10969. if (hcmFilterId !== "none") {
  10970. const savedFilter = this.ctx.filter;
  10971. this.ctx.filter = hcmFilterId;
  10972. this.ctx.drawImage(this.ctx.canvas, 0, 0);
  10973. this.ctx.filter = savedFilter;
  10974. }
  10975. }
  10976. }
  10977. _scaleImage(img, inverseTransform) {
  10978. const width = img.width;
  10979. const height = img.height;
  10980. let widthScale = Math.max(Math.hypot(inverseTransform[0], inverseTransform[1]), 1);
  10981. let heightScale = Math.max(Math.hypot(inverseTransform[2], inverseTransform[3]), 1);
  10982. let paintWidth = width,
  10983. paintHeight = height;
  10984. let tmpCanvasId = "prescale1";
  10985. let tmpCanvas, tmpCtx;
  10986. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  10987. let newWidth = paintWidth,
  10988. newHeight = paintHeight;
  10989. if (widthScale > 2 && paintWidth > 1) {
  10990. newWidth = paintWidth >= 16384 ? Math.floor(paintWidth / 2) - 1 || 1 : Math.ceil(paintWidth / 2);
  10991. widthScale /= paintWidth / newWidth;
  10992. }
  10993. if (heightScale > 2 && paintHeight > 1) {
  10994. newHeight = paintHeight >= 16384 ? Math.floor(paintHeight / 2) - 1 || 1 : Math.ceil(paintHeight) / 2;
  10995. heightScale /= paintHeight / newHeight;
  10996. }
  10997. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  10998. tmpCtx = tmpCanvas.context;
  10999. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  11000. tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  11001. img = tmpCanvas.canvas;
  11002. paintWidth = newWidth;
  11003. paintHeight = newHeight;
  11004. tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
  11005. }
  11006. return {
  11007. img,
  11008. paintWidth,
  11009. paintHeight
  11010. };
  11011. }
  11012. _createMaskCanvas(img) {
  11013. const ctx = this.ctx;
  11014. const {
  11015. width,
  11016. height
  11017. } = img;
  11018. const fillColor = this.current.fillColor;
  11019. const isPatternFill = this.current.patternFill;
  11020. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  11021. let cache, cacheKey, scaled, maskCanvas;
  11022. if ((img.bitmap || img.data) && img.count > 1) {
  11023. const mainKey = img.bitmap || img.data.buffer;
  11024. cacheKey = JSON.stringify(isPatternFill ? currentTransform : [currentTransform.slice(0, 4), fillColor]);
  11025. cache = this._cachedBitmapsMap.get(mainKey);
  11026. if (!cache) {
  11027. cache = new Map();
  11028. this._cachedBitmapsMap.set(mainKey, cache);
  11029. }
  11030. const cachedImage = cache.get(cacheKey);
  11031. if (cachedImage && !isPatternFill) {
  11032. const offsetX = Math.round(Math.min(currentTransform[0], currentTransform[2]) + currentTransform[4]);
  11033. const offsetY = Math.round(Math.min(currentTransform[1], currentTransform[3]) + currentTransform[5]);
  11034. return {
  11035. canvas: cachedImage,
  11036. offsetX,
  11037. offsetY
  11038. };
  11039. }
  11040. scaled = cachedImage;
  11041. }
  11042. if (!scaled) {
  11043. maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  11044. putBinaryImageMask(maskCanvas.context, img);
  11045. }
  11046. let maskToCanvas = _util.Util.transform(currentTransform, [1 / width, 0, 0, -1 / height, 0, 0]);
  11047. maskToCanvas = _util.Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
  11048. const cord1 = _util.Util.applyTransform([0, 0], maskToCanvas);
  11049. const cord2 = _util.Util.applyTransform([width, height], maskToCanvas);
  11050. const rect = _util.Util.normalizeRect([cord1[0], cord1[1], cord2[0], cord2[1]]);
  11051. const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
  11052. const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
  11053. const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight);
  11054. const fillCtx = fillCanvas.context;
  11055. const offsetX = Math.min(cord1[0], cord2[0]);
  11056. const offsetY = Math.min(cord1[1], cord2[1]);
  11057. fillCtx.translate(-offsetX, -offsetY);
  11058. fillCtx.transform(...maskToCanvas);
  11059. if (!scaled) {
  11060. scaled = this._scaleImage(maskCanvas.canvas, (0, _display_utils.getCurrentTransformInverse)(fillCtx));
  11061. scaled = scaled.img;
  11062. if (cache && isPatternFill) {
  11063. cache.set(cacheKey, scaled);
  11064. }
  11065. }
  11066. fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(fillCtx), img.interpolate);
  11067. drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
  11068. fillCtx.globalCompositeOperation = "source-in";
  11069. const inverse = _util.Util.transform((0, _display_utils.getCurrentTransformInverse)(fillCtx), [1, 0, 0, 1, -offsetX, -offsetY]);
  11070. fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, _pattern_helper.PathType.FILL) : fillColor;
  11071. fillCtx.fillRect(0, 0, width, height);
  11072. if (cache && !isPatternFill) {
  11073. this.cachedCanvases.delete("fillCanvas");
  11074. cache.set(cacheKey, fillCanvas.canvas);
  11075. }
  11076. return {
  11077. canvas: fillCanvas.canvas,
  11078. offsetX: Math.round(offsetX),
  11079. offsetY: Math.round(offsetY)
  11080. };
  11081. }
  11082. setLineWidth(width) {
  11083. if (width !== this.current.lineWidth) {
  11084. this._cachedScaleForStroking[0] = -1;
  11085. }
  11086. this.current.lineWidth = width;
  11087. this.ctx.lineWidth = width;
  11088. }
  11089. setLineCap(style) {
  11090. this.ctx.lineCap = LINE_CAP_STYLES[style];
  11091. }
  11092. setLineJoin(style) {
  11093. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  11094. }
  11095. setMiterLimit(limit) {
  11096. this.ctx.miterLimit = limit;
  11097. }
  11098. setDash(dashArray, dashPhase) {
  11099. const ctx = this.ctx;
  11100. if (ctx.setLineDash !== undefined) {
  11101. ctx.setLineDash(dashArray);
  11102. ctx.lineDashOffset = dashPhase;
  11103. }
  11104. }
  11105. setRenderingIntent(intent) {}
  11106. setFlatness(flatness) {}
  11107. setGState(states) {
  11108. for (const [key, value] of states) {
  11109. switch (key) {
  11110. case "LW":
  11111. this.setLineWidth(value);
  11112. break;
  11113. case "LC":
  11114. this.setLineCap(value);
  11115. break;
  11116. case "LJ":
  11117. this.setLineJoin(value);
  11118. break;
  11119. case "ML":
  11120. this.setMiterLimit(value);
  11121. break;
  11122. case "D":
  11123. this.setDash(value[0], value[1]);
  11124. break;
  11125. case "RI":
  11126. this.setRenderingIntent(value);
  11127. break;
  11128. case "FL":
  11129. this.setFlatness(value);
  11130. break;
  11131. case "Font":
  11132. this.setFont(value[0], value[1]);
  11133. break;
  11134. case "CA":
  11135. this.current.strokeAlpha = value;
  11136. break;
  11137. case "ca":
  11138. this.current.fillAlpha = value;
  11139. this.ctx.globalAlpha = value;
  11140. break;
  11141. case "BM":
  11142. this.ctx.globalCompositeOperation = value;
  11143. break;
  11144. case "SMask":
  11145. this.current.activeSMask = value ? this.tempSMask : null;
  11146. this.tempSMask = null;
  11147. this.checkSMaskState();
  11148. break;
  11149. case "TR":
  11150. this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(value);
  11151. break;
  11152. }
  11153. }
  11154. }
  11155. get inSMaskMode() {
  11156. return !!this.suspendedCtx;
  11157. }
  11158. checkSMaskState() {
  11159. const inSMaskMode = this.inSMaskMode;
  11160. if (this.current.activeSMask && !inSMaskMode) {
  11161. this.beginSMaskMode();
  11162. } else if (!this.current.activeSMask && inSMaskMode) {
  11163. this.endSMaskMode();
  11164. }
  11165. }
  11166. beginSMaskMode() {
  11167. if (this.inSMaskMode) {
  11168. throw new Error("beginSMaskMode called while already in smask mode");
  11169. }
  11170. const drawnWidth = this.ctx.canvas.width;
  11171. const drawnHeight = this.ctx.canvas.height;
  11172. const cacheId = "smaskGroupAt" + this.groupLevel;
  11173. const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
  11174. this.suspendedCtx = this.ctx;
  11175. this.ctx = scratchCanvas.context;
  11176. const ctx = this.ctx;
  11177. ctx.setTransform(...(0, _display_utils.getCurrentTransform)(this.suspendedCtx));
  11178. copyCtxState(this.suspendedCtx, ctx);
  11179. mirrorContextOperations(ctx, this.suspendedCtx);
  11180. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  11181. }
  11182. endSMaskMode() {
  11183. if (!this.inSMaskMode) {
  11184. throw new Error("endSMaskMode called while not in smask mode");
  11185. }
  11186. this.ctx._removeMirroring();
  11187. copyCtxState(this.ctx, this.suspendedCtx);
  11188. this.ctx = this.suspendedCtx;
  11189. this.suspendedCtx = null;
  11190. }
  11191. compose(dirtyBox) {
  11192. if (!this.current.activeSMask) {
  11193. return;
  11194. }
  11195. if (!dirtyBox) {
  11196. dirtyBox = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];
  11197. } else {
  11198. dirtyBox[0] = Math.floor(dirtyBox[0]);
  11199. dirtyBox[1] = Math.floor(dirtyBox[1]);
  11200. dirtyBox[2] = Math.ceil(dirtyBox[2]);
  11201. dirtyBox[3] = Math.ceil(dirtyBox[3]);
  11202. }
  11203. const smask = this.current.activeSMask;
  11204. const suspendedCtx = this.suspendedCtx;
  11205. composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);
  11206. this.ctx.save();
  11207. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  11208. this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
  11209. this.ctx.restore();
  11210. }
  11211. save() {
  11212. if (this.inSMaskMode) {
  11213. copyCtxState(this.ctx, this.suspendedCtx);
  11214. this.suspendedCtx.save();
  11215. } else {
  11216. this.ctx.save();
  11217. }
  11218. const old = this.current;
  11219. this.stateStack.push(old);
  11220. this.current = old.clone();
  11221. }
  11222. restore() {
  11223. if (this.stateStack.length === 0 && this.inSMaskMode) {
  11224. this.endSMaskMode();
  11225. }
  11226. if (this.stateStack.length !== 0) {
  11227. this.current = this.stateStack.pop();
  11228. if (this.inSMaskMode) {
  11229. this.suspendedCtx.restore();
  11230. copyCtxState(this.suspendedCtx, this.ctx);
  11231. } else {
  11232. this.ctx.restore();
  11233. }
  11234. this.checkSMaskState();
  11235. this.pendingClip = null;
  11236. this._cachedScaleForStroking[0] = -1;
  11237. this._cachedGetSinglePixelWidth = null;
  11238. }
  11239. }
  11240. transform(a, b, c, d, e, f) {
  11241. this.ctx.transform(a, b, c, d, e, f);
  11242. this._cachedScaleForStroking[0] = -1;
  11243. this._cachedGetSinglePixelWidth = null;
  11244. }
  11245. constructPath(ops, args, minMax) {
  11246. const ctx = this.ctx;
  11247. const current = this.current;
  11248. let x = current.x,
  11249. y = current.y;
  11250. let startX, startY;
  11251. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  11252. const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
  11253. const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
  11254. for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
  11255. switch (ops[i] | 0) {
  11256. case _util.OPS.rectangle:
  11257. x = args[j++];
  11258. y = args[j++];
  11259. const width = args[j++];
  11260. const height = args[j++];
  11261. const xw = x + width;
  11262. const yh = y + height;
  11263. ctx.moveTo(x, y);
  11264. if (width === 0 || height === 0) {
  11265. ctx.lineTo(xw, yh);
  11266. } else {
  11267. ctx.lineTo(xw, y);
  11268. ctx.lineTo(xw, yh);
  11269. ctx.lineTo(x, yh);
  11270. }
  11271. if (!isScalingMatrix) {
  11272. current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
  11273. }
  11274. ctx.closePath();
  11275. break;
  11276. case _util.OPS.moveTo:
  11277. x = args[j++];
  11278. y = args[j++];
  11279. ctx.moveTo(x, y);
  11280. if (!isScalingMatrix) {
  11281. current.updatePathMinMax(currentTransform, x, y);
  11282. }
  11283. break;
  11284. case _util.OPS.lineTo:
  11285. x = args[j++];
  11286. y = args[j++];
  11287. ctx.lineTo(x, y);
  11288. if (!isScalingMatrix) {
  11289. current.updatePathMinMax(currentTransform, x, y);
  11290. }
  11291. break;
  11292. case _util.OPS.curveTo:
  11293. startX = x;
  11294. startY = y;
  11295. x = args[j + 4];
  11296. y = args[j + 5];
  11297. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  11298. current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], args[j + 2], args[j + 3], x, y, minMaxForBezier);
  11299. j += 6;
  11300. break;
  11301. case _util.OPS.curveTo2:
  11302. startX = x;
  11303. startY = y;
  11304. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  11305. current.updateCurvePathMinMax(currentTransform, startX, startY, x, y, args[j], args[j + 1], args[j + 2], args[j + 3], minMaxForBezier);
  11306. x = args[j + 2];
  11307. y = args[j + 3];
  11308. j += 4;
  11309. break;
  11310. case _util.OPS.curveTo3:
  11311. startX = x;
  11312. startY = y;
  11313. x = args[j + 2];
  11314. y = args[j + 3];
  11315. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  11316. current.updateCurvePathMinMax(currentTransform, startX, startY, args[j], args[j + 1], x, y, x, y, minMaxForBezier);
  11317. j += 4;
  11318. break;
  11319. case _util.OPS.closePath:
  11320. ctx.closePath();
  11321. break;
  11322. }
  11323. }
  11324. if (isScalingMatrix) {
  11325. current.updateScalingPathMinMax(currentTransform, minMaxForBezier);
  11326. }
  11327. current.setCurrentPoint(x, y);
  11328. }
  11329. closePath() {
  11330. this.ctx.closePath();
  11331. }
  11332. stroke() {
  11333. let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  11334. const ctx = this.ctx;
  11335. const strokeColor = this.current.strokeColor;
  11336. ctx.globalAlpha = this.current.strokeAlpha;
  11337. if (this.contentVisible) {
  11338. if (typeof strokeColor === "object" && strokeColor?.getPattern) {
  11339. ctx.save();
  11340. ctx.strokeStyle = strokeColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.STROKE);
  11341. this.rescaleAndStroke(false);
  11342. ctx.restore();
  11343. } else {
  11344. this.rescaleAndStroke(true);
  11345. }
  11346. }
  11347. if (consumePath) {
  11348. this.consumePath(this.current.getClippedPathBoundingBox());
  11349. }
  11350. ctx.globalAlpha = this.current.fillAlpha;
  11351. }
  11352. closeStroke() {
  11353. this.closePath();
  11354. this.stroke();
  11355. }
  11356. fill() {
  11357. let consumePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  11358. const ctx = this.ctx;
  11359. const fillColor = this.current.fillColor;
  11360. const isPatternFill = this.current.patternFill;
  11361. let needRestore = false;
  11362. if (isPatternFill) {
  11363. ctx.save();
  11364. ctx.fillStyle = fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
  11365. needRestore = true;
  11366. }
  11367. const intersect = this.current.getClippedPathBoundingBox();
  11368. if (this.contentVisible && intersect !== null) {
  11369. if (this.pendingEOFill) {
  11370. ctx.fill("evenodd");
  11371. this.pendingEOFill = false;
  11372. } else {
  11373. ctx.fill();
  11374. }
  11375. }
  11376. if (needRestore) {
  11377. ctx.restore();
  11378. }
  11379. if (consumePath) {
  11380. this.consumePath(intersect);
  11381. }
  11382. }
  11383. eoFill() {
  11384. this.pendingEOFill = true;
  11385. this.fill();
  11386. }
  11387. fillStroke() {
  11388. this.fill(false);
  11389. this.stroke(false);
  11390. this.consumePath();
  11391. }
  11392. eoFillStroke() {
  11393. this.pendingEOFill = true;
  11394. this.fillStroke();
  11395. }
  11396. closeFillStroke() {
  11397. this.closePath();
  11398. this.fillStroke();
  11399. }
  11400. closeEOFillStroke() {
  11401. this.pendingEOFill = true;
  11402. this.closePath();
  11403. this.fillStroke();
  11404. }
  11405. endPath() {
  11406. this.consumePath();
  11407. }
  11408. clip() {
  11409. this.pendingClip = NORMAL_CLIP;
  11410. }
  11411. eoClip() {
  11412. this.pendingClip = EO_CLIP;
  11413. }
  11414. beginText() {
  11415. this.current.textMatrix = _util.IDENTITY_MATRIX;
  11416. this.current.textMatrixScale = 1;
  11417. this.current.x = this.current.lineX = 0;
  11418. this.current.y = this.current.lineY = 0;
  11419. }
  11420. endText() {
  11421. const paths = this.pendingTextPaths;
  11422. const ctx = this.ctx;
  11423. if (paths === undefined) {
  11424. ctx.beginPath();
  11425. return;
  11426. }
  11427. ctx.save();
  11428. ctx.beginPath();
  11429. for (const path of paths) {
  11430. ctx.setTransform(...path.transform);
  11431. ctx.translate(path.x, path.y);
  11432. path.addToPath(ctx, path.fontSize);
  11433. }
  11434. ctx.restore();
  11435. ctx.clip();
  11436. ctx.beginPath();
  11437. delete this.pendingTextPaths;
  11438. }
  11439. setCharSpacing(spacing) {
  11440. this.current.charSpacing = spacing;
  11441. }
  11442. setWordSpacing(spacing) {
  11443. this.current.wordSpacing = spacing;
  11444. }
  11445. setHScale(scale) {
  11446. this.current.textHScale = scale / 100;
  11447. }
  11448. setLeading(leading) {
  11449. this.current.leading = -leading;
  11450. }
  11451. setFont(fontRefName, size) {
  11452. const fontObj = this.commonObjs.get(fontRefName);
  11453. const current = this.current;
  11454. if (!fontObj) {
  11455. throw new Error(`Can't find font for ${fontRefName}`);
  11456. }
  11457. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  11458. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  11459. (0, _util.warn)("Invalid font matrix for font " + fontRefName);
  11460. }
  11461. if (size < 0) {
  11462. size = -size;
  11463. current.fontDirection = -1;
  11464. } else {
  11465. current.fontDirection = 1;
  11466. }
  11467. this.current.font = fontObj;
  11468. this.current.fontSize = size;
  11469. if (fontObj.isType3Font) {
  11470. return;
  11471. }
  11472. const name = fontObj.loadedName || "sans-serif";
  11473. const typeface = fontObj.systemFontInfo?.css || `"${name}", ${fontObj.fallbackName}`;
  11474. let bold = "normal";
  11475. if (fontObj.black) {
  11476. bold = "900";
  11477. } else if (fontObj.bold) {
  11478. bold = "bold";
  11479. }
  11480. const italic = fontObj.italic ? "italic" : "normal";
  11481. let browserFontSize = size;
  11482. if (size < MIN_FONT_SIZE) {
  11483. browserFontSize = MIN_FONT_SIZE;
  11484. } else if (size > MAX_FONT_SIZE) {
  11485. browserFontSize = MAX_FONT_SIZE;
  11486. }
  11487. this.current.fontSizeScale = size / browserFontSize;
  11488. this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
  11489. }
  11490. setTextRenderingMode(mode) {
  11491. this.current.textRenderingMode = mode;
  11492. }
  11493. setTextRise(rise) {
  11494. this.current.textRise = rise;
  11495. }
  11496. moveText(x, y) {
  11497. this.current.x = this.current.lineX += x;
  11498. this.current.y = this.current.lineY += y;
  11499. }
  11500. setLeadingMoveText(x, y) {
  11501. this.setLeading(-y);
  11502. this.moveText(x, y);
  11503. }
  11504. setTextMatrix(a, b, c, d, e, f) {
  11505. this.current.textMatrix = [a, b, c, d, e, f];
  11506. this.current.textMatrixScale = Math.hypot(a, b);
  11507. this.current.x = this.current.lineX = 0;
  11508. this.current.y = this.current.lineY = 0;
  11509. }
  11510. nextLine() {
  11511. this.moveText(0, this.current.leading);
  11512. }
  11513. paintChar(character, x, y, patternTransform) {
  11514. const ctx = this.ctx;
  11515. const current = this.current;
  11516. const font = current.font;
  11517. const textRenderingMode = current.textRenderingMode;
  11518. const fontSize = current.fontSize / current.fontSizeScale;
  11519. const fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  11520. const isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  11521. const patternFill = current.patternFill && !font.missingFile;
  11522. let addToPath;
  11523. if (font.disableFontFace || isAddToPathSet || patternFill) {
  11524. addToPath = font.getPathGenerator(this.commonObjs, character);
  11525. }
  11526. if (font.disableFontFace || patternFill) {
  11527. ctx.save();
  11528. ctx.translate(x, y);
  11529. ctx.beginPath();
  11530. addToPath(ctx, fontSize);
  11531. if (patternTransform) {
  11532. ctx.setTransform(...patternTransform);
  11533. }
  11534. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  11535. ctx.fill();
  11536. }
  11537. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  11538. ctx.stroke();
  11539. }
  11540. ctx.restore();
  11541. } else {
  11542. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  11543. ctx.fillText(character, x, y);
  11544. }
  11545. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  11546. ctx.strokeText(character, x, y);
  11547. }
  11548. }
  11549. if (isAddToPathSet) {
  11550. const paths = this.pendingTextPaths ||= [];
  11551. paths.push({
  11552. transform: (0, _display_utils.getCurrentTransform)(ctx),
  11553. x,
  11554. y,
  11555. fontSize,
  11556. addToPath
  11557. });
  11558. }
  11559. }
  11560. get isFontSubpixelAAEnabled() {
  11561. const {
  11562. context: ctx
  11563. } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
  11564. ctx.scale(1.5, 1);
  11565. ctx.fillText("I", 0, 10);
  11566. const data = ctx.getImageData(0, 0, 10, 10).data;
  11567. let enabled = false;
  11568. for (let i = 3; i < data.length; i += 4) {
  11569. if (data[i] > 0 && data[i] < 255) {
  11570. enabled = true;
  11571. break;
  11572. }
  11573. }
  11574. return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
  11575. }
  11576. showText(glyphs) {
  11577. const current = this.current;
  11578. const font = current.font;
  11579. if (font.isType3Font) {
  11580. return this.showType3Text(glyphs);
  11581. }
  11582. const fontSize = current.fontSize;
  11583. if (fontSize === 0) {
  11584. return undefined;
  11585. }
  11586. const ctx = this.ctx;
  11587. const fontSizeScale = current.fontSizeScale;
  11588. const charSpacing = current.charSpacing;
  11589. const wordSpacing = current.wordSpacing;
  11590. const fontDirection = current.fontDirection;
  11591. const textHScale = current.textHScale * fontDirection;
  11592. const glyphsLength = glyphs.length;
  11593. const vertical = font.vertical;
  11594. const spacingDir = vertical ? 1 : -1;
  11595. const defaultVMetrics = font.defaultVMetrics;
  11596. const widthAdvanceScale = fontSize * current.fontMatrix[0];
  11597. const simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  11598. ctx.save();
  11599. ctx.transform(...current.textMatrix);
  11600. ctx.translate(current.x, current.y + current.textRise);
  11601. if (fontDirection > 0) {
  11602. ctx.scale(textHScale, -1);
  11603. } else {
  11604. ctx.scale(textHScale, 1);
  11605. }
  11606. let patternTransform;
  11607. if (current.patternFill) {
  11608. ctx.save();
  11609. const pattern = current.fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
  11610. patternTransform = (0, _display_utils.getCurrentTransform)(ctx);
  11611. ctx.restore();
  11612. ctx.fillStyle = pattern;
  11613. }
  11614. let lineWidth = current.lineWidth;
  11615. const scale = current.textMatrixScale;
  11616. if (scale === 0 || lineWidth === 0) {
  11617. const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  11618. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  11619. lineWidth = this.getSinglePixelWidth();
  11620. }
  11621. } else {
  11622. lineWidth /= scale;
  11623. }
  11624. if (fontSizeScale !== 1.0) {
  11625. ctx.scale(fontSizeScale, fontSizeScale);
  11626. lineWidth /= fontSizeScale;
  11627. }
  11628. ctx.lineWidth = lineWidth;
  11629. if (font.isInvalidPDFjsFont) {
  11630. const chars = [];
  11631. let width = 0;
  11632. for (const glyph of glyphs) {
  11633. chars.push(glyph.unicode);
  11634. width += glyph.width;
  11635. }
  11636. ctx.fillText(chars.join(""), 0, 0);
  11637. current.x += width * widthAdvanceScale * textHScale;
  11638. ctx.restore();
  11639. this.compose();
  11640. return undefined;
  11641. }
  11642. let x = 0,
  11643. i;
  11644. for (i = 0; i < glyphsLength; ++i) {
  11645. const glyph = glyphs[i];
  11646. if (typeof glyph === "number") {
  11647. x += spacingDir * glyph * fontSize / 1000;
  11648. continue;
  11649. }
  11650. let restoreNeeded = false;
  11651. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  11652. const character = glyph.fontChar;
  11653. const accent = glyph.accent;
  11654. let scaledX, scaledY;
  11655. let width = glyph.width;
  11656. if (vertical) {
  11657. const vmetric = glyph.vmetric || defaultVMetrics;
  11658. const vx = -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
  11659. const vy = vmetric[2] * widthAdvanceScale;
  11660. width = vmetric ? -vmetric[0] : width;
  11661. scaledX = vx / fontSizeScale;
  11662. scaledY = (x + vy) / fontSizeScale;
  11663. } else {
  11664. scaledX = x / fontSizeScale;
  11665. scaledY = 0;
  11666. }
  11667. if (font.remeasure && width > 0) {
  11668. const measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  11669. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  11670. const characterScaleX = width / measuredWidth;
  11671. restoreNeeded = true;
  11672. ctx.save();
  11673. ctx.scale(characterScaleX, 1);
  11674. scaledX /= characterScaleX;
  11675. } else if (width !== measuredWidth) {
  11676. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  11677. }
  11678. }
  11679. if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
  11680. if (simpleFillText && !accent) {
  11681. ctx.fillText(character, scaledX, scaledY);
  11682. } else {
  11683. this.paintChar(character, scaledX, scaledY, patternTransform);
  11684. if (accent) {
  11685. const scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
  11686. const scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
  11687. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  11688. }
  11689. }
  11690. }
  11691. const charWidth = vertical ? width * widthAdvanceScale - spacing * fontDirection : width * widthAdvanceScale + spacing * fontDirection;
  11692. x += charWidth;
  11693. if (restoreNeeded) {
  11694. ctx.restore();
  11695. }
  11696. }
  11697. if (vertical) {
  11698. current.y -= x;
  11699. } else {
  11700. current.x += x * textHScale;
  11701. }
  11702. ctx.restore();
  11703. this.compose();
  11704. return undefined;
  11705. }
  11706. showType3Text(glyphs) {
  11707. const ctx = this.ctx;
  11708. const current = this.current;
  11709. const font = current.font;
  11710. const fontSize = current.fontSize;
  11711. const fontDirection = current.fontDirection;
  11712. const spacingDir = font.vertical ? 1 : -1;
  11713. const charSpacing = current.charSpacing;
  11714. const wordSpacing = current.wordSpacing;
  11715. const textHScale = current.textHScale * fontDirection;
  11716. const fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  11717. const glyphsLength = glyphs.length;
  11718. const isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  11719. let i, glyph, width, spacingLength;
  11720. if (isTextInvisible || fontSize === 0) {
  11721. return;
  11722. }
  11723. this._cachedScaleForStroking[0] = -1;
  11724. this._cachedGetSinglePixelWidth = null;
  11725. ctx.save();
  11726. ctx.transform(...current.textMatrix);
  11727. ctx.translate(current.x, current.y);
  11728. ctx.scale(textHScale, fontDirection);
  11729. for (i = 0; i < glyphsLength; ++i) {
  11730. glyph = glyphs[i];
  11731. if (typeof glyph === "number") {
  11732. spacingLength = spacingDir * glyph * fontSize / 1000;
  11733. this.ctx.translate(spacingLength, 0);
  11734. current.x += spacingLength * textHScale;
  11735. continue;
  11736. }
  11737. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  11738. const operatorList = font.charProcOperatorList[glyph.operatorListId];
  11739. if (!operatorList) {
  11740. (0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
  11741. continue;
  11742. }
  11743. if (this.contentVisible) {
  11744. this.processingType3 = glyph;
  11745. this.save();
  11746. ctx.scale(fontSize, fontSize);
  11747. ctx.transform(...fontMatrix);
  11748. this.executeOperatorList(operatorList);
  11749. this.restore();
  11750. }
  11751. const transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  11752. width = transformed[0] * fontSize + spacing;
  11753. ctx.translate(width, 0);
  11754. current.x += width * textHScale;
  11755. }
  11756. ctx.restore();
  11757. this.processingType3 = null;
  11758. }
  11759. setCharWidth(xWidth, yWidth) {}
  11760. setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  11761. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  11762. this.ctx.clip();
  11763. this.endPath();
  11764. }
  11765. getColorN_Pattern(IR) {
  11766. let pattern;
  11767. if (IR[0] === "TilingPattern") {
  11768. const color = IR[1];
  11769. const baseTransform = this.baseTransform || (0, _display_utils.getCurrentTransform)(this.ctx);
  11770. const canvasGraphicsFactory = {
  11771. createCanvasGraphics: ctx => {
  11772. return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.filterFactory, {
  11773. optionalContentConfig: this.optionalContentConfig,
  11774. markedContentStack: this.markedContentStack
  11775. });
  11776. }
  11777. };
  11778. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  11779. } else {
  11780. pattern = this._getPattern(IR[1], IR[2]);
  11781. }
  11782. return pattern;
  11783. }
  11784. setStrokeColorN() {
  11785. this.current.strokeColor = this.getColorN_Pattern(arguments);
  11786. }
  11787. setFillColorN() {
  11788. this.current.fillColor = this.getColorN_Pattern(arguments);
  11789. this.current.patternFill = true;
  11790. }
  11791. setStrokeRGBColor(r, g, b) {
  11792. const color = _util.Util.makeHexColor(r, g, b);
  11793. this.ctx.strokeStyle = color;
  11794. this.current.strokeColor = color;
  11795. }
  11796. setFillRGBColor(r, g, b) {
  11797. const color = _util.Util.makeHexColor(r, g, b);
  11798. this.ctx.fillStyle = color;
  11799. this.current.fillColor = color;
  11800. this.current.patternFill = false;
  11801. }
  11802. _getPattern(objId) {
  11803. let matrix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  11804. let pattern;
  11805. if (this.cachedPatterns.has(objId)) {
  11806. pattern = this.cachedPatterns.get(objId);
  11807. } else {
  11808. pattern = (0, _pattern_helper.getShadingPattern)(this.getObject(objId));
  11809. this.cachedPatterns.set(objId, pattern);
  11810. }
  11811. if (matrix) {
  11812. pattern.matrix = matrix;
  11813. }
  11814. return pattern;
  11815. }
  11816. shadingFill(objId) {
  11817. if (!this.contentVisible) {
  11818. return;
  11819. }
  11820. const ctx = this.ctx;
  11821. this.save();
  11822. const pattern = this._getPattern(objId);
  11823. ctx.fillStyle = pattern.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.SHADING);
  11824. const inv = (0, _display_utils.getCurrentTransformInverse)(ctx);
  11825. if (inv) {
  11826. const {
  11827. width,
  11828. height
  11829. } = ctx.canvas;
  11830. const [x0, y0, x1, y1] = _util.Util.getAxialAlignedBoundingBox([0, 0, width, height], inv);
  11831. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  11832. } else {
  11833. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  11834. }
  11835. this.compose(this.current.getClippedPathBoundingBox());
  11836. this.restore();
  11837. }
  11838. beginInlineImage() {
  11839. (0, _util.unreachable)("Should not call beginInlineImage");
  11840. }
  11841. beginImageData() {
  11842. (0, _util.unreachable)("Should not call beginImageData");
  11843. }
  11844. paintFormXObjectBegin(matrix, bbox) {
  11845. if (!this.contentVisible) {
  11846. return;
  11847. }
  11848. this.save();
  11849. this.baseTransformStack.push(this.baseTransform);
  11850. if (Array.isArray(matrix) && matrix.length === 6) {
  11851. this.transform(...matrix);
  11852. }
  11853. this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
  11854. if (bbox) {
  11855. const width = bbox[2] - bbox[0];
  11856. const height = bbox[3] - bbox[1];
  11857. this.ctx.rect(bbox[0], bbox[1], width, height);
  11858. this.current.updateRectMinMax((0, _display_utils.getCurrentTransform)(this.ctx), bbox);
  11859. this.clip();
  11860. this.endPath();
  11861. }
  11862. }
  11863. paintFormXObjectEnd() {
  11864. if (!this.contentVisible) {
  11865. return;
  11866. }
  11867. this.restore();
  11868. this.baseTransform = this.baseTransformStack.pop();
  11869. }
  11870. beginGroup(group) {
  11871. if (!this.contentVisible) {
  11872. return;
  11873. }
  11874. this.save();
  11875. if (this.inSMaskMode) {
  11876. this.endSMaskMode();
  11877. this.current.activeSMask = null;
  11878. }
  11879. const currentCtx = this.ctx;
  11880. if (!group.isolated) {
  11881. (0, _util.info)("TODO: Support non-isolated groups.");
  11882. }
  11883. if (group.knockout) {
  11884. (0, _util.warn)("Knockout groups not supported.");
  11885. }
  11886. const currentTransform = (0, _display_utils.getCurrentTransform)(currentCtx);
  11887. if (group.matrix) {
  11888. currentCtx.transform(...group.matrix);
  11889. }
  11890. if (!group.bbox) {
  11891. throw new Error("Bounding box is required.");
  11892. }
  11893. let bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, (0, _display_utils.getCurrentTransform)(currentCtx));
  11894. const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  11895. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  11896. const offsetX = Math.floor(bounds[0]);
  11897. const offsetY = Math.floor(bounds[1]);
  11898. let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  11899. let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  11900. let scaleX = 1,
  11901. scaleY = 1;
  11902. if (drawnWidth > MAX_GROUP_SIZE) {
  11903. scaleX = drawnWidth / MAX_GROUP_SIZE;
  11904. drawnWidth = MAX_GROUP_SIZE;
  11905. }
  11906. if (drawnHeight > MAX_GROUP_SIZE) {
  11907. scaleY = drawnHeight / MAX_GROUP_SIZE;
  11908. drawnHeight = MAX_GROUP_SIZE;
  11909. }
  11910. this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
  11911. let cacheId = "groupAt" + this.groupLevel;
  11912. if (group.smask) {
  11913. cacheId += "_smask_" + this.smaskCounter++ % 2;
  11914. }
  11915. const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
  11916. const groupCtx = scratchCanvas.context;
  11917. groupCtx.scale(1 / scaleX, 1 / scaleY);
  11918. groupCtx.translate(-offsetX, -offsetY);
  11919. groupCtx.transform(...currentTransform);
  11920. if (group.smask) {
  11921. this.smaskStack.push({
  11922. canvas: scratchCanvas.canvas,
  11923. context: groupCtx,
  11924. offsetX,
  11925. offsetY,
  11926. scaleX,
  11927. scaleY,
  11928. subtype: group.smask.subtype,
  11929. backdrop: group.smask.backdrop,
  11930. transferMap: group.smask.transferMap || null,
  11931. startTransformInverse: null
  11932. });
  11933. } else {
  11934. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  11935. currentCtx.translate(offsetX, offsetY);
  11936. currentCtx.scale(scaleX, scaleY);
  11937. currentCtx.save();
  11938. }
  11939. copyCtxState(currentCtx, groupCtx);
  11940. this.ctx = groupCtx;
  11941. this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
  11942. this.groupStack.push(currentCtx);
  11943. this.groupLevel++;
  11944. }
  11945. endGroup(group) {
  11946. if (!this.contentVisible) {
  11947. return;
  11948. }
  11949. this.groupLevel--;
  11950. const groupCtx = this.ctx;
  11951. const ctx = this.groupStack.pop();
  11952. this.ctx = ctx;
  11953. this.ctx.imageSmoothingEnabled = false;
  11954. if (group.smask) {
  11955. this.tempSMask = this.smaskStack.pop();
  11956. this.restore();
  11957. } else {
  11958. this.ctx.restore();
  11959. const currentMtx = (0, _display_utils.getCurrentTransform)(this.ctx);
  11960. this.restore();
  11961. this.ctx.save();
  11962. this.ctx.setTransform(...currentMtx);
  11963. const dirtyBox = _util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
  11964. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  11965. this.ctx.restore();
  11966. this.compose(dirtyBox);
  11967. }
  11968. }
  11969. beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
  11970. this.#restoreInitialState();
  11971. resetCtxToDefault(this.ctx);
  11972. this.ctx.save();
  11973. this.save();
  11974. if (this.baseTransform) {
  11975. this.ctx.setTransform(...this.baseTransform);
  11976. }
  11977. if (Array.isArray(rect) && rect.length === 4) {
  11978. const width = rect[2] - rect[0];
  11979. const height = rect[3] - rect[1];
  11980. if (hasOwnCanvas && this.annotationCanvasMap) {
  11981. transform = transform.slice();
  11982. transform[4] -= rect[0];
  11983. transform[5] -= rect[1];
  11984. rect = rect.slice();
  11985. rect[0] = rect[1] = 0;
  11986. rect[2] = width;
  11987. rect[3] = height;
  11988. const [scaleX, scaleY] = _util.Util.singularValueDecompose2dScale((0, _display_utils.getCurrentTransform)(this.ctx));
  11989. const {
  11990. viewportScale
  11991. } = this;
  11992. const canvasWidth = Math.ceil(width * this.outputScaleX * viewportScale);
  11993. const canvasHeight = Math.ceil(height * this.outputScaleY * viewportScale);
  11994. this.annotationCanvas = this.canvasFactory.create(canvasWidth, canvasHeight);
  11995. const {
  11996. canvas,
  11997. context
  11998. } = this.annotationCanvas;
  11999. this.annotationCanvasMap.set(id, canvas);
  12000. this.annotationCanvas.savedCtx = this.ctx;
  12001. this.ctx = context;
  12002. this.ctx.save();
  12003. this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
  12004. resetCtxToDefault(this.ctx);
  12005. } else {
  12006. resetCtxToDefault(this.ctx);
  12007. this.ctx.rect(rect[0], rect[1], width, height);
  12008. this.ctx.clip();
  12009. this.endPath();
  12010. }
  12011. }
  12012. this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
  12013. this.transform(...transform);
  12014. this.transform(...matrix);
  12015. }
  12016. endAnnotation() {
  12017. if (this.annotationCanvas) {
  12018. this.ctx.restore();
  12019. this.#drawFilter();
  12020. this.ctx = this.annotationCanvas.savedCtx;
  12021. delete this.annotationCanvas.savedCtx;
  12022. delete this.annotationCanvas;
  12023. }
  12024. }
  12025. paintImageMaskXObject(img) {
  12026. if (!this.contentVisible) {
  12027. return;
  12028. }
  12029. const count = img.count;
  12030. img = this.getObject(img.data, img);
  12031. img.count = count;
  12032. const ctx = this.ctx;
  12033. const glyph = this.processingType3;
  12034. if (glyph) {
  12035. if (glyph.compiled === undefined) {
  12036. glyph.compiled = compileType3Glyph(img);
  12037. }
  12038. if (glyph.compiled) {
  12039. glyph.compiled(ctx);
  12040. return;
  12041. }
  12042. }
  12043. const mask = this._createMaskCanvas(img);
  12044. const maskCanvas = mask.canvas;
  12045. ctx.save();
  12046. ctx.setTransform(1, 0, 0, 1, 0, 0);
  12047. ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);
  12048. ctx.restore();
  12049. this.compose();
  12050. }
  12051. paintImageMaskXObjectRepeat(img, scaleX) {
  12052. let skewX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  12053. let skewY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
  12054. let scaleY = arguments.length > 4 ? arguments[4] : undefined;
  12055. let positions = arguments.length > 5 ? arguments[5] : undefined;
  12056. if (!this.contentVisible) {
  12057. return;
  12058. }
  12059. img = this.getObject(img.data, img);
  12060. const ctx = this.ctx;
  12061. ctx.save();
  12062. const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
  12063. ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
  12064. const mask = this._createMaskCanvas(img);
  12065. ctx.setTransform(1, 0, 0, 1, mask.offsetX - currentTransform[4], mask.offsetY - currentTransform[5]);
  12066. for (let i = 0, ii = positions.length; i < ii; i += 2) {
  12067. const trans = _util.Util.transform(currentTransform, [scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]]);
  12068. const [x, y] = _util.Util.applyTransform([0, 0], trans);
  12069. ctx.drawImage(mask.canvas, x, y);
  12070. }
  12071. ctx.restore();
  12072. this.compose();
  12073. }
  12074. paintImageMaskXObjectGroup(images) {
  12075. if (!this.contentVisible) {
  12076. return;
  12077. }
  12078. const ctx = this.ctx;
  12079. const fillColor = this.current.fillColor;
  12080. const isPatternFill = this.current.patternFill;
  12081. for (const image of images) {
  12082. const {
  12083. data,
  12084. width,
  12085. height,
  12086. transform
  12087. } = image;
  12088. const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
  12089. const maskCtx = maskCanvas.context;
  12090. maskCtx.save();
  12091. const img = this.getObject(data, image);
  12092. putBinaryImageMask(maskCtx, img);
  12093. maskCtx.globalCompositeOperation = "source-in";
  12094. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL) : fillColor;
  12095. maskCtx.fillRect(0, 0, width, height);
  12096. maskCtx.restore();
  12097. ctx.save();
  12098. ctx.transform(...transform);
  12099. ctx.scale(1, -1);
  12100. drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  12101. ctx.restore();
  12102. }
  12103. this.compose();
  12104. }
  12105. paintImageXObject(objId) {
  12106. if (!this.contentVisible) {
  12107. return;
  12108. }
  12109. const imgData = this.getObject(objId);
  12110. if (!imgData) {
  12111. (0, _util.warn)("Dependent image isn't ready yet");
  12112. return;
  12113. }
  12114. this.paintInlineImageXObject(imgData);
  12115. }
  12116. paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  12117. if (!this.contentVisible) {
  12118. return;
  12119. }
  12120. const imgData = this.getObject(objId);
  12121. if (!imgData) {
  12122. (0, _util.warn)("Dependent image isn't ready yet");
  12123. return;
  12124. }
  12125. const width = imgData.width;
  12126. const height = imgData.height;
  12127. const map = [];
  12128. for (let i = 0, ii = positions.length; i < ii; i += 2) {
  12129. map.push({
  12130. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  12131. x: 0,
  12132. y: 0,
  12133. w: width,
  12134. h: height
  12135. });
  12136. }
  12137. this.paintInlineImageXObjectGroup(imgData, map);
  12138. }
  12139. applyTransferMapsToCanvas(ctx) {
  12140. if (this.current.transferMaps !== "none") {
  12141. ctx.filter = this.current.transferMaps;
  12142. ctx.drawImage(ctx.canvas, 0, 0);
  12143. ctx.filter = "none";
  12144. }
  12145. return ctx.canvas;
  12146. }
  12147. applyTransferMapsToBitmap(imgData) {
  12148. if (this.current.transferMaps === "none") {
  12149. return imgData.bitmap;
  12150. }
  12151. const {
  12152. bitmap,
  12153. width,
  12154. height
  12155. } = imgData;
  12156. const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
  12157. const tmpCtx = tmpCanvas.context;
  12158. tmpCtx.filter = this.current.transferMaps;
  12159. tmpCtx.drawImage(bitmap, 0, 0);
  12160. tmpCtx.filter = "none";
  12161. return tmpCanvas.canvas;
  12162. }
  12163. paintInlineImageXObject(imgData) {
  12164. if (!this.contentVisible) {
  12165. return;
  12166. }
  12167. const width = imgData.width;
  12168. const height = imgData.height;
  12169. const ctx = this.ctx;
  12170. this.save();
  12171. if (!_util.isNodeJS) {
  12172. const {
  12173. filter
  12174. } = ctx;
  12175. if (filter !== "none" && filter !== "") {
  12176. ctx.filter = "none";
  12177. }
  12178. }
  12179. ctx.scale(1 / width, -1 / height);
  12180. let imgToPaint;
  12181. if (imgData.bitmap) {
  12182. imgToPaint = this.applyTransferMapsToBitmap(imgData);
  12183. } else if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
  12184. imgToPaint = imgData;
  12185. } else {
  12186. const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
  12187. const tmpCtx = tmpCanvas.context;
  12188. putBinaryImageData(tmpCtx, imgData);
  12189. imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
  12190. }
  12191. const scaled = this._scaleImage(imgToPaint, (0, _display_utils.getCurrentTransformInverse)(ctx));
  12192. ctx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(ctx), imgData.interpolate);
  12193. drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
  12194. this.compose();
  12195. this.restore();
  12196. }
  12197. paintInlineImageXObjectGroup(imgData, map) {
  12198. if (!this.contentVisible) {
  12199. return;
  12200. }
  12201. const ctx = this.ctx;
  12202. let imgToPaint;
  12203. if (imgData.bitmap) {
  12204. imgToPaint = imgData.bitmap;
  12205. } else {
  12206. const w = imgData.width;
  12207. const h = imgData.height;
  12208. const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
  12209. const tmpCtx = tmpCanvas.context;
  12210. putBinaryImageData(tmpCtx, imgData);
  12211. imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);
  12212. }
  12213. for (const entry of map) {
  12214. ctx.save();
  12215. ctx.transform(...entry.transform);
  12216. ctx.scale(1, -1);
  12217. drawImageAtIntegerCoords(ctx, imgToPaint, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  12218. ctx.restore();
  12219. }
  12220. this.compose();
  12221. }
  12222. paintSolidColorImageMask() {
  12223. if (!this.contentVisible) {
  12224. return;
  12225. }
  12226. this.ctx.fillRect(0, 0, 1, 1);
  12227. this.compose();
  12228. }
  12229. markPoint(tag) {}
  12230. markPointProps(tag, properties) {}
  12231. beginMarkedContent(tag) {
  12232. this.markedContentStack.push({
  12233. visible: true
  12234. });
  12235. }
  12236. beginMarkedContentProps(tag, properties) {
  12237. if (tag === "OC") {
  12238. this.markedContentStack.push({
  12239. visible: this.optionalContentConfig.isVisible(properties)
  12240. });
  12241. } else {
  12242. this.markedContentStack.push({
  12243. visible: true
  12244. });
  12245. }
  12246. this.contentVisible = this.isContentVisible();
  12247. }
  12248. endMarkedContent() {
  12249. this.markedContentStack.pop();
  12250. this.contentVisible = this.isContentVisible();
  12251. }
  12252. beginCompat() {}
  12253. endCompat() {}
  12254. consumePath(clipBox) {
  12255. const isEmpty = this.current.isEmptyClip();
  12256. if (this.pendingClip) {
  12257. this.current.updateClipFromPath();
  12258. }
  12259. if (!this.pendingClip) {
  12260. this.compose(clipBox);
  12261. }
  12262. const ctx = this.ctx;
  12263. if (this.pendingClip) {
  12264. if (!isEmpty) {
  12265. if (this.pendingClip === EO_CLIP) {
  12266. ctx.clip("evenodd");
  12267. } else {
  12268. ctx.clip();
  12269. }
  12270. }
  12271. this.pendingClip = null;
  12272. }
  12273. this.current.startNewPathAndClipBox(this.current.clipBox);
  12274. ctx.beginPath();
  12275. }
  12276. getSinglePixelWidth() {
  12277. if (!this._cachedGetSinglePixelWidth) {
  12278. const m = (0, _display_utils.getCurrentTransform)(this.ctx);
  12279. if (m[1] === 0 && m[2] === 0) {
  12280. this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
  12281. } else {
  12282. const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);
  12283. const normX = Math.hypot(m[0], m[2]);
  12284. const normY = Math.hypot(m[1], m[3]);
  12285. this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;
  12286. }
  12287. }
  12288. return this._cachedGetSinglePixelWidth;
  12289. }
  12290. getScaleForStroking() {
  12291. if (this._cachedScaleForStroking[0] === -1) {
  12292. const {
  12293. lineWidth
  12294. } = this.current;
  12295. const {
  12296. a,
  12297. b,
  12298. c,
  12299. d
  12300. } = this.ctx.getTransform();
  12301. let scaleX, scaleY;
  12302. if (b === 0 && c === 0) {
  12303. const normX = Math.abs(a);
  12304. const normY = Math.abs(d);
  12305. if (normX === normY) {
  12306. if (lineWidth === 0) {
  12307. scaleX = scaleY = 1 / normX;
  12308. } else {
  12309. const scaledLineWidth = normX * lineWidth;
  12310. scaleX = scaleY = scaledLineWidth < 1 ? 1 / scaledLineWidth : 1;
  12311. }
  12312. } else if (lineWidth === 0) {
  12313. scaleX = 1 / normX;
  12314. scaleY = 1 / normY;
  12315. } else {
  12316. const scaledXLineWidth = normX * lineWidth;
  12317. const scaledYLineWidth = normY * lineWidth;
  12318. scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;
  12319. scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;
  12320. }
  12321. } else {
  12322. const absDet = Math.abs(a * d - b * c);
  12323. const normX = Math.hypot(a, b);
  12324. const normY = Math.hypot(c, d);
  12325. if (lineWidth === 0) {
  12326. scaleX = normY / absDet;
  12327. scaleY = normX / absDet;
  12328. } else {
  12329. const baseArea = lineWidth * absDet;
  12330. scaleX = normY > baseArea ? normY / baseArea : 1;
  12331. scaleY = normX > baseArea ? normX / baseArea : 1;
  12332. }
  12333. }
  12334. this._cachedScaleForStroking[0] = scaleX;
  12335. this._cachedScaleForStroking[1] = scaleY;
  12336. }
  12337. return this._cachedScaleForStroking;
  12338. }
  12339. rescaleAndStroke(saveRestore) {
  12340. const {
  12341. ctx
  12342. } = this;
  12343. const {
  12344. lineWidth
  12345. } = this.current;
  12346. const [scaleX, scaleY] = this.getScaleForStroking();
  12347. ctx.lineWidth = lineWidth || 1;
  12348. if (scaleX === 1 && scaleY === 1) {
  12349. ctx.stroke();
  12350. return;
  12351. }
  12352. const dashes = ctx.getLineDash();
  12353. if (saveRestore) {
  12354. ctx.save();
  12355. }
  12356. ctx.scale(scaleX, scaleY);
  12357. if (dashes.length > 0) {
  12358. const scale = Math.max(scaleX, scaleY);
  12359. ctx.setLineDash(dashes.map(x => x / scale));
  12360. ctx.lineDashOffset /= scale;
  12361. }
  12362. ctx.stroke();
  12363. if (saveRestore) {
  12364. ctx.restore();
  12365. }
  12366. }
  12367. isContentVisible() {
  12368. for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
  12369. if (!this.markedContentStack[i].visible) {
  12370. return false;
  12371. }
  12372. }
  12373. return true;
  12374. }
  12375. }
  12376. exports.CanvasGraphics = CanvasGraphics;
  12377. for (const op in _util.OPS) {
  12378. if (CanvasGraphics.prototype[op] !== undefined) {
  12379. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  12380. }
  12381. }
  12382. /***/ }),
  12383. /* 174 */
  12384. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12385. Object.defineProperty(exports, "__esModule", ({
  12386. value: true
  12387. }));
  12388. exports.TilingPattern = exports.PathType = void 0;
  12389. exports.getShadingPattern = getShadingPattern;
  12390. __w_pdfjs_require__(2);
  12391. var _util = __w_pdfjs_require__(1);
  12392. var _display_utils = __w_pdfjs_require__(168);
  12393. const PathType = {
  12394. FILL: "Fill",
  12395. STROKE: "Stroke",
  12396. SHADING: "Shading"
  12397. };
  12398. exports.PathType = PathType;
  12399. function applyBoundingBox(ctx, bbox) {
  12400. if (!bbox) {
  12401. return;
  12402. }
  12403. const width = bbox[2] - bbox[0];
  12404. const height = bbox[3] - bbox[1];
  12405. const region = new Path2D();
  12406. region.rect(bbox[0], bbox[1], width, height);
  12407. ctx.clip(region);
  12408. }
  12409. class BaseShadingPattern {
  12410. constructor() {
  12411. if (this.constructor === BaseShadingPattern) {
  12412. (0, _util.unreachable)("Cannot initialize BaseShadingPattern.");
  12413. }
  12414. }
  12415. getPattern() {
  12416. (0, _util.unreachable)("Abstract method `getPattern` called.");
  12417. }
  12418. }
  12419. class RadialAxialShadingPattern extends BaseShadingPattern {
  12420. constructor(IR) {
  12421. super();
  12422. this._type = IR[1];
  12423. this._bbox = IR[2];
  12424. this._colorStops = IR[3];
  12425. this._p0 = IR[4];
  12426. this._p1 = IR[5];
  12427. this._r0 = IR[6];
  12428. this._r1 = IR[7];
  12429. this.matrix = null;
  12430. }
  12431. _createGradient(ctx) {
  12432. let grad;
  12433. if (this._type === "axial") {
  12434. grad = ctx.createLinearGradient(this._p0[0], this._p0[1], this._p1[0], this._p1[1]);
  12435. } else if (this._type === "radial") {
  12436. grad = ctx.createRadialGradient(this._p0[0], this._p0[1], this._r0, this._p1[0], this._p1[1], this._r1);
  12437. }
  12438. for (const colorStop of this._colorStops) {
  12439. grad.addColorStop(colorStop[0], colorStop[1]);
  12440. }
  12441. return grad;
  12442. }
  12443. getPattern(ctx, owner, inverse, pathType) {
  12444. let pattern;
  12445. if (pathType === PathType.STROKE || pathType === PathType.FILL) {
  12446. const ownerBBox = owner.current.getClippedPathBoundingBox(pathType, (0, _display_utils.getCurrentTransform)(ctx)) || [0, 0, 0, 0];
  12447. const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;
  12448. const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;
  12449. const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", width, height, true);
  12450. const tmpCtx = tmpCanvas.context;
  12451. tmpCtx.clearRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
  12452. tmpCtx.beginPath();
  12453. tmpCtx.rect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);
  12454. tmpCtx.translate(-ownerBBox[0], -ownerBBox[1]);
  12455. inverse = _util.Util.transform(inverse, [1, 0, 0, 1, ownerBBox[0], ownerBBox[1]]);
  12456. tmpCtx.transform(...owner.baseTransform);
  12457. if (this.matrix) {
  12458. tmpCtx.transform(...this.matrix);
  12459. }
  12460. applyBoundingBox(tmpCtx, this._bbox);
  12461. tmpCtx.fillStyle = this._createGradient(tmpCtx);
  12462. tmpCtx.fill();
  12463. pattern = ctx.createPattern(tmpCanvas.canvas, "no-repeat");
  12464. const domMatrix = new DOMMatrix(inverse);
  12465. pattern.setTransform(domMatrix);
  12466. } else {
  12467. applyBoundingBox(ctx, this._bbox);
  12468. pattern = this._createGradient(ctx);
  12469. }
  12470. return pattern;
  12471. }
  12472. }
  12473. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  12474. const coords = context.coords,
  12475. colors = context.colors;
  12476. const bytes = data.data,
  12477. rowSize = data.width * 4;
  12478. let tmp;
  12479. if (coords[p1 + 1] > coords[p2 + 1]) {
  12480. tmp = p1;
  12481. p1 = p2;
  12482. p2 = tmp;
  12483. tmp = c1;
  12484. c1 = c2;
  12485. c2 = tmp;
  12486. }
  12487. if (coords[p2 + 1] > coords[p3 + 1]) {
  12488. tmp = p2;
  12489. p2 = p3;
  12490. p3 = tmp;
  12491. tmp = c2;
  12492. c2 = c3;
  12493. c3 = tmp;
  12494. }
  12495. if (coords[p1 + 1] > coords[p2 + 1]) {
  12496. tmp = p1;
  12497. p1 = p2;
  12498. p2 = tmp;
  12499. tmp = c1;
  12500. c1 = c2;
  12501. c2 = tmp;
  12502. }
  12503. const x1 = (coords[p1] + context.offsetX) * context.scaleX;
  12504. const y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  12505. const x2 = (coords[p2] + context.offsetX) * context.scaleX;
  12506. const y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  12507. const x3 = (coords[p3] + context.offsetX) * context.scaleX;
  12508. const y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  12509. if (y1 >= y3) {
  12510. return;
  12511. }
  12512. const c1r = colors[c1],
  12513. c1g = colors[c1 + 1],
  12514. c1b = colors[c1 + 2];
  12515. const c2r = colors[c2],
  12516. c2g = colors[c2 + 1],
  12517. c2b = colors[c2 + 2];
  12518. const c3r = colors[c3],
  12519. c3g = colors[c3 + 1],
  12520. c3b = colors[c3 + 2];
  12521. const minY = Math.round(y1),
  12522. maxY = Math.round(y3);
  12523. let xa, car, cag, cab;
  12524. let xb, cbr, cbg, cbb;
  12525. for (let y = minY; y <= maxY; y++) {
  12526. if (y < y2) {
  12527. const k = y < y1 ? 0 : (y1 - y) / (y1 - y2);
  12528. xa = x1 - (x1 - x2) * k;
  12529. car = c1r - (c1r - c2r) * k;
  12530. cag = c1g - (c1g - c2g) * k;
  12531. cab = c1b - (c1b - c2b) * k;
  12532. } else {
  12533. let k;
  12534. if (y > y3) {
  12535. k = 1;
  12536. } else if (y2 === y3) {
  12537. k = 0;
  12538. } else {
  12539. k = (y2 - y) / (y2 - y3);
  12540. }
  12541. xa = x2 - (x2 - x3) * k;
  12542. car = c2r - (c2r - c3r) * k;
  12543. cag = c2g - (c2g - c3g) * k;
  12544. cab = c2b - (c2b - c3b) * k;
  12545. }
  12546. let k;
  12547. if (y < y1) {
  12548. k = 0;
  12549. } else if (y > y3) {
  12550. k = 1;
  12551. } else {
  12552. k = (y1 - y) / (y1 - y3);
  12553. }
  12554. xb = x1 - (x1 - x3) * k;
  12555. cbr = c1r - (c1r - c3r) * k;
  12556. cbg = c1g - (c1g - c3g) * k;
  12557. cbb = c1b - (c1b - c3b) * k;
  12558. const x1_ = Math.round(Math.min(xa, xb));
  12559. const x2_ = Math.round(Math.max(xa, xb));
  12560. let j = rowSize * y + x1_ * 4;
  12561. for (let x = x1_; x <= x2_; x++) {
  12562. k = (xa - x) / (xa - xb);
  12563. if (k < 0) {
  12564. k = 0;
  12565. } else if (k > 1) {
  12566. k = 1;
  12567. }
  12568. bytes[j++] = car - (car - cbr) * k | 0;
  12569. bytes[j++] = cag - (cag - cbg) * k | 0;
  12570. bytes[j++] = cab - (cab - cbb) * k | 0;
  12571. bytes[j++] = 255;
  12572. }
  12573. }
  12574. }
  12575. function drawFigure(data, figure, context) {
  12576. const ps = figure.coords;
  12577. const cs = figure.colors;
  12578. let i, ii;
  12579. switch (figure.type) {
  12580. case "lattice":
  12581. const verticesPerRow = figure.verticesPerRow;
  12582. const rows = Math.floor(ps.length / verticesPerRow) - 1;
  12583. const cols = verticesPerRow - 1;
  12584. for (i = 0; i < rows; i++) {
  12585. let q = i * verticesPerRow;
  12586. for (let j = 0; j < cols; j++, q++) {
  12587. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  12588. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  12589. }
  12590. }
  12591. break;
  12592. case "triangles":
  12593. for (i = 0, ii = ps.length; i < ii; i += 3) {
  12594. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  12595. }
  12596. break;
  12597. default:
  12598. throw new Error("illegal figure");
  12599. }
  12600. }
  12601. class MeshShadingPattern extends BaseShadingPattern {
  12602. constructor(IR) {
  12603. super();
  12604. this._coords = IR[2];
  12605. this._colors = IR[3];
  12606. this._figures = IR[4];
  12607. this._bounds = IR[5];
  12608. this._bbox = IR[7];
  12609. this._background = IR[8];
  12610. this.matrix = null;
  12611. }
  12612. _createMeshCanvas(combinedScale, backgroundColor, cachedCanvases) {
  12613. const EXPECTED_SCALE = 1.1;
  12614. const MAX_PATTERN_SIZE = 3000;
  12615. const BORDER_SIZE = 2;
  12616. const offsetX = Math.floor(this._bounds[0]);
  12617. const offsetY = Math.floor(this._bounds[1]);
  12618. const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
  12619. const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
  12620. const width = Math.min(Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  12621. const height = Math.min(Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  12622. const scaleX = boundsWidth / width;
  12623. const scaleY = boundsHeight / height;
  12624. const context = {
  12625. coords: this._coords,
  12626. colors: this._colors,
  12627. offsetX: -offsetX,
  12628. offsetY: -offsetY,
  12629. scaleX: 1 / scaleX,
  12630. scaleY: 1 / scaleY
  12631. };
  12632. const paddedWidth = width + BORDER_SIZE * 2;
  12633. const paddedHeight = height + BORDER_SIZE * 2;
  12634. const tmpCanvas = cachedCanvases.getCanvas("mesh", paddedWidth, paddedHeight, false);
  12635. const tmpCtx = tmpCanvas.context;
  12636. const data = tmpCtx.createImageData(width, height);
  12637. if (backgroundColor) {
  12638. const bytes = data.data;
  12639. for (let i = 0, ii = bytes.length; i < ii; i += 4) {
  12640. bytes[i] = backgroundColor[0];
  12641. bytes[i + 1] = backgroundColor[1];
  12642. bytes[i + 2] = backgroundColor[2];
  12643. bytes[i + 3] = 255;
  12644. }
  12645. }
  12646. for (const figure of this._figures) {
  12647. drawFigure(data, figure, context);
  12648. }
  12649. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  12650. const canvas = tmpCanvas.canvas;
  12651. return {
  12652. canvas,
  12653. offsetX: offsetX - BORDER_SIZE * scaleX,
  12654. offsetY: offsetY - BORDER_SIZE * scaleY,
  12655. scaleX,
  12656. scaleY
  12657. };
  12658. }
  12659. getPattern(ctx, owner, inverse, pathType) {
  12660. applyBoundingBox(ctx, this._bbox);
  12661. let scale;
  12662. if (pathType === PathType.SHADING) {
  12663. scale = _util.Util.singularValueDecompose2dScale((0, _display_utils.getCurrentTransform)(ctx));
  12664. } else {
  12665. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  12666. if (this.matrix) {
  12667. const matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  12668. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  12669. }
  12670. }
  12671. const temporaryPatternCanvas = this._createMeshCanvas(scale, pathType === PathType.SHADING ? null : this._background, owner.cachedCanvases);
  12672. if (pathType !== PathType.SHADING) {
  12673. ctx.setTransform(...owner.baseTransform);
  12674. if (this.matrix) {
  12675. ctx.transform(...this.matrix);
  12676. }
  12677. }
  12678. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  12679. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  12680. return ctx.createPattern(temporaryPatternCanvas.canvas, "no-repeat");
  12681. }
  12682. }
  12683. class DummyShadingPattern extends BaseShadingPattern {
  12684. getPattern() {
  12685. return "hotpink";
  12686. }
  12687. }
  12688. function getShadingPattern(IR) {
  12689. switch (IR[0]) {
  12690. case "RadialAxial":
  12691. return new RadialAxialShadingPattern(IR);
  12692. case "Mesh":
  12693. return new MeshShadingPattern(IR);
  12694. case "Dummy":
  12695. return new DummyShadingPattern();
  12696. }
  12697. throw new Error(`Unknown IR type: ${IR[0]}`);
  12698. }
  12699. const PaintType = {
  12700. COLORED: 1,
  12701. UNCOLORED: 2
  12702. };
  12703. class TilingPattern {
  12704. static MAX_PATTERN_SIZE = 3000;
  12705. constructor(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  12706. this.operatorList = IR[2];
  12707. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  12708. this.bbox = IR[4];
  12709. this.xstep = IR[5];
  12710. this.ystep = IR[6];
  12711. this.paintType = IR[7];
  12712. this.tilingType = IR[8];
  12713. this.color = color;
  12714. this.ctx = ctx;
  12715. this.canvasGraphicsFactory = canvasGraphicsFactory;
  12716. this.baseTransform = baseTransform;
  12717. }
  12718. createPatternCanvas(owner) {
  12719. const operatorList = this.operatorList;
  12720. const bbox = this.bbox;
  12721. const xstep = this.xstep;
  12722. const ystep = this.ystep;
  12723. const paintType = this.paintType;
  12724. const tilingType = this.tilingType;
  12725. const color = this.color;
  12726. const canvasGraphicsFactory = this.canvasGraphicsFactory;
  12727. (0, _util.info)("TilingType: " + tilingType);
  12728. const x0 = bbox[0],
  12729. y0 = bbox[1],
  12730. x1 = bbox[2],
  12731. y1 = bbox[3];
  12732. const matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  12733. const curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  12734. const combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  12735. const dimx = this.getSizeAndScale(xstep, this.ctx.canvas.width, combinedScale[0]);
  12736. const dimy = this.getSizeAndScale(ystep, this.ctx.canvas.height, combinedScale[1]);
  12737. const tmpCanvas = owner.cachedCanvases.getCanvas("pattern", dimx.size, dimy.size, true);
  12738. const tmpCtx = tmpCanvas.context;
  12739. const graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  12740. graphics.groupLevel = owner.groupLevel;
  12741. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  12742. let adjustedX0 = x0;
  12743. let adjustedY0 = y0;
  12744. let adjustedX1 = x1;
  12745. let adjustedY1 = y1;
  12746. if (x0 < 0) {
  12747. adjustedX0 = 0;
  12748. adjustedX1 += Math.abs(x0);
  12749. }
  12750. if (y0 < 0) {
  12751. adjustedY0 = 0;
  12752. adjustedY1 += Math.abs(y0);
  12753. }
  12754. tmpCtx.translate(-(dimx.scale * adjustedX0), -(dimy.scale * adjustedY0));
  12755. graphics.transform(dimx.scale, 0, 0, dimy.scale, 0, 0);
  12756. tmpCtx.save();
  12757. this.clipBbox(graphics, adjustedX0, adjustedY0, adjustedX1, adjustedY1);
  12758. graphics.baseTransform = (0, _display_utils.getCurrentTransform)(graphics.ctx);
  12759. graphics.executeOperatorList(operatorList);
  12760. graphics.endDrawing();
  12761. return {
  12762. canvas: tmpCanvas.canvas,
  12763. scaleX: dimx.scale,
  12764. scaleY: dimy.scale,
  12765. offsetX: adjustedX0,
  12766. offsetY: adjustedY0
  12767. };
  12768. }
  12769. getSizeAndScale(step, realOutputSize, scale) {
  12770. step = Math.abs(step);
  12771. const maxSize = Math.max(TilingPattern.MAX_PATTERN_SIZE, realOutputSize);
  12772. let size = Math.ceil(step * scale);
  12773. if (size >= maxSize) {
  12774. size = maxSize;
  12775. } else {
  12776. scale = size / step;
  12777. }
  12778. return {
  12779. scale,
  12780. size
  12781. };
  12782. }
  12783. clipBbox(graphics, x0, y0, x1, y1) {
  12784. const bboxWidth = x1 - x0;
  12785. const bboxHeight = y1 - y0;
  12786. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  12787. graphics.current.updateRectMinMax((0, _display_utils.getCurrentTransform)(graphics.ctx), [x0, y0, x1, y1]);
  12788. graphics.clip();
  12789. graphics.endPath();
  12790. }
  12791. setFillAndStrokeStyleToContext(graphics, paintType, color) {
  12792. const context = graphics.ctx,
  12793. current = graphics.current;
  12794. switch (paintType) {
  12795. case PaintType.COLORED:
  12796. const ctx = this.ctx;
  12797. context.fillStyle = ctx.fillStyle;
  12798. context.strokeStyle = ctx.strokeStyle;
  12799. current.fillColor = ctx.fillStyle;
  12800. current.strokeColor = ctx.strokeStyle;
  12801. break;
  12802. case PaintType.UNCOLORED:
  12803. const cssColor = _util.Util.makeHexColor(color[0], color[1], color[2]);
  12804. context.fillStyle = cssColor;
  12805. context.strokeStyle = cssColor;
  12806. current.fillColor = cssColor;
  12807. current.strokeColor = cssColor;
  12808. break;
  12809. default:
  12810. throw new _util.FormatError(`Unsupported paint type: ${paintType}`);
  12811. }
  12812. }
  12813. getPattern(ctx, owner, inverse, pathType) {
  12814. let matrix = inverse;
  12815. if (pathType !== PathType.SHADING) {
  12816. matrix = _util.Util.transform(matrix, owner.baseTransform);
  12817. if (this.matrix) {
  12818. matrix = _util.Util.transform(matrix, this.matrix);
  12819. }
  12820. }
  12821. const temporaryPatternCanvas = this.createPatternCanvas(owner);
  12822. let domMatrix = new DOMMatrix(matrix);
  12823. domMatrix = domMatrix.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  12824. domMatrix = domMatrix.scale(1 / temporaryPatternCanvas.scaleX, 1 / temporaryPatternCanvas.scaleY);
  12825. const pattern = ctx.createPattern(temporaryPatternCanvas.canvas, "repeat");
  12826. pattern.setTransform(domMatrix);
  12827. return pattern;
  12828. }
  12829. }
  12830. exports.TilingPattern = TilingPattern;
  12831. /***/ }),
  12832. /* 175 */
  12833. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12834. Object.defineProperty(exports, "__esModule", ({
  12835. value: true
  12836. }));
  12837. exports.convertBlackAndWhiteToRGBA = convertBlackAndWhiteToRGBA;
  12838. exports.convertToRGBA = convertToRGBA;
  12839. exports.grayToRGBA = grayToRGBA;
  12840. __w_pdfjs_require__(93);
  12841. __w_pdfjs_require__(101);
  12842. __w_pdfjs_require__(102);
  12843. __w_pdfjs_require__(105);
  12844. __w_pdfjs_require__(107);
  12845. __w_pdfjs_require__(109);
  12846. __w_pdfjs_require__(113);
  12847. __w_pdfjs_require__(116);
  12848. __w_pdfjs_require__(123);
  12849. var _util = __w_pdfjs_require__(1);
  12850. function convertToRGBA(params) {
  12851. switch (params.kind) {
  12852. case _util.ImageKind.GRAYSCALE_1BPP:
  12853. return convertBlackAndWhiteToRGBA(params);
  12854. case _util.ImageKind.RGB_24BPP:
  12855. return convertRGBToRGBA(params);
  12856. }
  12857. return null;
  12858. }
  12859. function convertBlackAndWhiteToRGBA(_ref) {
  12860. let {
  12861. src,
  12862. srcPos = 0,
  12863. dest,
  12864. width,
  12865. height,
  12866. nonBlackColor = 0xffffffff,
  12867. inverseDecode = false
  12868. } = _ref;
  12869. const black = _util.FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
  12870. const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
  12871. const widthInSource = width >> 3;
  12872. const widthRemainder = width & 7;
  12873. const srcLength = src.length;
  12874. dest = new Uint32Array(dest.buffer);
  12875. let destPos = 0;
  12876. for (let i = 0; i < height; i++) {
  12877. for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
  12878. const elem = srcPos < srcLength ? src[srcPos] : 255;
  12879. dest[destPos++] = elem & 0b10000000 ? oneMapping : zeroMapping;
  12880. dest[destPos++] = elem & 0b1000000 ? oneMapping : zeroMapping;
  12881. dest[destPos++] = elem & 0b100000 ? oneMapping : zeroMapping;
  12882. dest[destPos++] = elem & 0b10000 ? oneMapping : zeroMapping;
  12883. dest[destPos++] = elem & 0b1000 ? oneMapping : zeroMapping;
  12884. dest[destPos++] = elem & 0b100 ? oneMapping : zeroMapping;
  12885. dest[destPos++] = elem & 0b10 ? oneMapping : zeroMapping;
  12886. dest[destPos++] = elem & 0b1 ? oneMapping : zeroMapping;
  12887. }
  12888. if (widthRemainder === 0) {
  12889. continue;
  12890. }
  12891. const elem = srcPos < srcLength ? src[srcPos++] : 255;
  12892. for (let j = 0; j < widthRemainder; j++) {
  12893. dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
  12894. }
  12895. }
  12896. return {
  12897. srcPos,
  12898. destPos
  12899. };
  12900. }
  12901. function convertRGBToRGBA(_ref2) {
  12902. let {
  12903. src,
  12904. srcPos = 0,
  12905. dest,
  12906. destPos = 0,
  12907. width,
  12908. height
  12909. } = _ref2;
  12910. let i = 0;
  12911. const len32 = src.length >> 2;
  12912. const src32 = new Uint32Array(src.buffer, srcPos, len32);
  12913. if (_util.FeatureTest.isLittleEndian) {
  12914. for (; i < len32 - 2; i += 3, destPos += 4) {
  12915. const s1 = src32[i];
  12916. const s2 = src32[i + 1];
  12917. const s3 = src32[i + 2];
  12918. dest[destPos] = s1 | 0xff000000;
  12919. dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 0xff000000;
  12920. dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 0xff000000;
  12921. dest[destPos + 3] = s3 >>> 8 | 0xff000000;
  12922. }
  12923. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  12924. dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 0xff000000;
  12925. }
  12926. } else {
  12927. for (; i < len32 - 2; i += 3, destPos += 4) {
  12928. const s1 = src32[i];
  12929. const s2 = src32[i + 1];
  12930. const s3 = src32[i + 2];
  12931. dest[destPos] = s1 | 0xff;
  12932. dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 0xff;
  12933. dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 0xff;
  12934. dest[destPos + 3] = s3 << 8 | 0xff;
  12935. }
  12936. for (let j = i * 4, jj = src.length; j < jj; j += 3) {
  12937. dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 0xff;
  12938. }
  12939. }
  12940. return {
  12941. srcPos,
  12942. destPos
  12943. };
  12944. }
  12945. function grayToRGBA(src, dest) {
  12946. if (_util.FeatureTest.isLittleEndian) {
  12947. for (let i = 0, ii = src.length; i < ii; i++) {
  12948. dest[i] = src[i] * 0x10101 | 0xff000000;
  12949. }
  12950. } else {
  12951. for (let i = 0, ii = src.length; i < ii; i++) {
  12952. dest[i] = src[i] * 0x1010100 | 0x000000ff;
  12953. }
  12954. }
  12955. }
  12956. /***/ }),
  12957. /* 176 */
  12958. /***/ ((__unused_webpack_module, exports) => {
  12959. Object.defineProperty(exports, "__esModule", ({
  12960. value: true
  12961. }));
  12962. exports.GlobalWorkerOptions = void 0;
  12963. const GlobalWorkerOptions = Object.create(null);
  12964. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  12965. GlobalWorkerOptions.workerPort = null;
  12966. GlobalWorkerOptions.workerSrc = "";
  12967. /***/ }),
  12968. /* 177 */
  12969. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  12970. Object.defineProperty(exports, "__esModule", ({
  12971. value: true
  12972. }));
  12973. exports.MessageHandler = void 0;
  12974. __w_pdfjs_require__(2);
  12975. var _util = __w_pdfjs_require__(1);
  12976. const CallbackKind = {
  12977. UNKNOWN: 0,
  12978. DATA: 1,
  12979. ERROR: 2
  12980. };
  12981. const StreamKind = {
  12982. UNKNOWN: 0,
  12983. CANCEL: 1,
  12984. CANCEL_COMPLETE: 2,
  12985. CLOSE: 3,
  12986. ENQUEUE: 4,
  12987. ERROR: 5,
  12988. PULL: 6,
  12989. PULL_COMPLETE: 7,
  12990. START_COMPLETE: 8
  12991. };
  12992. function wrapReason(reason) {
  12993. if (!(reason instanceof Error || typeof reason === "object" && reason !== null)) {
  12994. (0, _util.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
  12995. }
  12996. switch (reason.name) {
  12997. case "AbortException":
  12998. return new _util.AbortException(reason.message);
  12999. case "MissingPDFException":
  13000. return new _util.MissingPDFException(reason.message);
  13001. case "PasswordException":
  13002. return new _util.PasswordException(reason.message, reason.code);
  13003. case "UnexpectedResponseException":
  13004. return new _util.UnexpectedResponseException(reason.message, reason.status);
  13005. case "UnknownErrorException":
  13006. return new _util.UnknownErrorException(reason.message, reason.details);
  13007. default:
  13008. return new _util.UnknownErrorException(reason.message, reason.toString());
  13009. }
  13010. }
  13011. class MessageHandler {
  13012. constructor(sourceName, targetName, comObj) {
  13013. this.sourceName = sourceName;
  13014. this.targetName = targetName;
  13015. this.comObj = comObj;
  13016. this.callbackId = 1;
  13017. this.streamId = 1;
  13018. this.streamSinks = Object.create(null);
  13019. this.streamControllers = Object.create(null);
  13020. this.callbackCapabilities = Object.create(null);
  13021. this.actionHandler = Object.create(null);
  13022. this._onComObjOnMessage = event => {
  13023. const data = event.data;
  13024. if (data.targetName !== this.sourceName) {
  13025. return;
  13026. }
  13027. if (data.stream) {
  13028. this.#processStreamMessage(data);
  13029. return;
  13030. }
  13031. if (data.callback) {
  13032. const callbackId = data.callbackId;
  13033. const capability = this.callbackCapabilities[callbackId];
  13034. if (!capability) {
  13035. throw new Error(`Cannot resolve callback ${callbackId}`);
  13036. }
  13037. delete this.callbackCapabilities[callbackId];
  13038. if (data.callback === CallbackKind.DATA) {
  13039. capability.resolve(data.data);
  13040. } else if (data.callback === CallbackKind.ERROR) {
  13041. capability.reject(wrapReason(data.reason));
  13042. } else {
  13043. throw new Error("Unexpected callback case");
  13044. }
  13045. return;
  13046. }
  13047. const action = this.actionHandler[data.action];
  13048. if (!action) {
  13049. throw new Error(`Unknown action from worker: ${data.action}`);
  13050. }
  13051. if (data.callbackId) {
  13052. const cbSourceName = this.sourceName;
  13053. const cbTargetName = data.sourceName;
  13054. new Promise(function (resolve) {
  13055. resolve(action(data.data));
  13056. }).then(function (result) {
  13057. comObj.postMessage({
  13058. sourceName: cbSourceName,
  13059. targetName: cbTargetName,
  13060. callback: CallbackKind.DATA,
  13061. callbackId: data.callbackId,
  13062. data: result
  13063. });
  13064. }, function (reason) {
  13065. comObj.postMessage({
  13066. sourceName: cbSourceName,
  13067. targetName: cbTargetName,
  13068. callback: CallbackKind.ERROR,
  13069. callbackId: data.callbackId,
  13070. reason: wrapReason(reason)
  13071. });
  13072. });
  13073. return;
  13074. }
  13075. if (data.streamId) {
  13076. this.#createStreamSink(data);
  13077. return;
  13078. }
  13079. action(data.data);
  13080. };
  13081. comObj.addEventListener("message", this._onComObjOnMessage);
  13082. }
  13083. on(actionName, handler) {
  13084. const ah = this.actionHandler;
  13085. if (ah[actionName]) {
  13086. throw new Error(`There is already an actionName called "${actionName}"`);
  13087. }
  13088. ah[actionName] = handler;
  13089. }
  13090. send(actionName, data, transfers) {
  13091. this.comObj.postMessage({
  13092. sourceName: this.sourceName,
  13093. targetName: this.targetName,
  13094. action: actionName,
  13095. data
  13096. }, transfers);
  13097. }
  13098. sendWithPromise(actionName, data, transfers) {
  13099. const callbackId = this.callbackId++;
  13100. const capability = new _util.PromiseCapability();
  13101. this.callbackCapabilities[callbackId] = capability;
  13102. try {
  13103. this.comObj.postMessage({
  13104. sourceName: this.sourceName,
  13105. targetName: this.targetName,
  13106. action: actionName,
  13107. callbackId,
  13108. data
  13109. }, transfers);
  13110. } catch (ex) {
  13111. capability.reject(ex);
  13112. }
  13113. return capability.promise;
  13114. }
  13115. sendWithStream(actionName, data, queueingStrategy, transfers) {
  13116. const streamId = this.streamId++,
  13117. sourceName = this.sourceName,
  13118. targetName = this.targetName,
  13119. comObj = this.comObj;
  13120. return new ReadableStream({
  13121. start: controller => {
  13122. const startCapability = new _util.PromiseCapability();
  13123. this.streamControllers[streamId] = {
  13124. controller,
  13125. startCall: startCapability,
  13126. pullCall: null,
  13127. cancelCall: null,
  13128. isClosed: false
  13129. };
  13130. comObj.postMessage({
  13131. sourceName,
  13132. targetName,
  13133. action: actionName,
  13134. streamId,
  13135. data,
  13136. desiredSize: controller.desiredSize
  13137. }, transfers);
  13138. return startCapability.promise;
  13139. },
  13140. pull: controller => {
  13141. const pullCapability = new _util.PromiseCapability();
  13142. this.streamControllers[streamId].pullCall = pullCapability;
  13143. comObj.postMessage({
  13144. sourceName,
  13145. targetName,
  13146. stream: StreamKind.PULL,
  13147. streamId,
  13148. desiredSize: controller.desiredSize
  13149. });
  13150. return pullCapability.promise;
  13151. },
  13152. cancel: reason => {
  13153. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  13154. const cancelCapability = new _util.PromiseCapability();
  13155. this.streamControllers[streamId].cancelCall = cancelCapability;
  13156. this.streamControllers[streamId].isClosed = true;
  13157. comObj.postMessage({
  13158. sourceName,
  13159. targetName,
  13160. stream: StreamKind.CANCEL,
  13161. streamId,
  13162. reason: wrapReason(reason)
  13163. });
  13164. return cancelCapability.promise;
  13165. }
  13166. }, queueingStrategy);
  13167. }
  13168. #createStreamSink(data) {
  13169. const streamId = data.streamId,
  13170. sourceName = this.sourceName,
  13171. targetName = data.sourceName,
  13172. comObj = this.comObj;
  13173. const self = this,
  13174. action = this.actionHandler[data.action];
  13175. const streamSink = {
  13176. enqueue(chunk) {
  13177. let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  13178. let transfers = arguments.length > 2 ? arguments[2] : undefined;
  13179. if (this.isCancelled) {
  13180. return;
  13181. }
  13182. const lastDesiredSize = this.desiredSize;
  13183. this.desiredSize -= size;
  13184. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  13185. this.sinkCapability = new _util.PromiseCapability();
  13186. this.ready = this.sinkCapability.promise;
  13187. }
  13188. comObj.postMessage({
  13189. sourceName,
  13190. targetName,
  13191. stream: StreamKind.ENQUEUE,
  13192. streamId,
  13193. chunk
  13194. }, transfers);
  13195. },
  13196. close() {
  13197. if (this.isCancelled) {
  13198. return;
  13199. }
  13200. this.isCancelled = true;
  13201. comObj.postMessage({
  13202. sourceName,
  13203. targetName,
  13204. stream: StreamKind.CLOSE,
  13205. streamId
  13206. });
  13207. delete self.streamSinks[streamId];
  13208. },
  13209. error(reason) {
  13210. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  13211. if (this.isCancelled) {
  13212. return;
  13213. }
  13214. this.isCancelled = true;
  13215. comObj.postMessage({
  13216. sourceName,
  13217. targetName,
  13218. stream: StreamKind.ERROR,
  13219. streamId,
  13220. reason: wrapReason(reason)
  13221. });
  13222. },
  13223. sinkCapability: new _util.PromiseCapability(),
  13224. onPull: null,
  13225. onCancel: null,
  13226. isCancelled: false,
  13227. desiredSize: data.desiredSize,
  13228. ready: null
  13229. };
  13230. streamSink.sinkCapability.resolve();
  13231. streamSink.ready = streamSink.sinkCapability.promise;
  13232. this.streamSinks[streamId] = streamSink;
  13233. new Promise(function (resolve) {
  13234. resolve(action(data.data, streamSink));
  13235. }).then(function () {
  13236. comObj.postMessage({
  13237. sourceName,
  13238. targetName,
  13239. stream: StreamKind.START_COMPLETE,
  13240. streamId,
  13241. success: true
  13242. });
  13243. }, function (reason) {
  13244. comObj.postMessage({
  13245. sourceName,
  13246. targetName,
  13247. stream: StreamKind.START_COMPLETE,
  13248. streamId,
  13249. reason: wrapReason(reason)
  13250. });
  13251. });
  13252. }
  13253. #processStreamMessage(data) {
  13254. const streamId = data.streamId,
  13255. sourceName = this.sourceName,
  13256. targetName = data.sourceName,
  13257. comObj = this.comObj;
  13258. const streamController = this.streamControllers[streamId],
  13259. streamSink = this.streamSinks[streamId];
  13260. switch (data.stream) {
  13261. case StreamKind.START_COMPLETE:
  13262. if (data.success) {
  13263. streamController.startCall.resolve();
  13264. } else {
  13265. streamController.startCall.reject(wrapReason(data.reason));
  13266. }
  13267. break;
  13268. case StreamKind.PULL_COMPLETE:
  13269. if (data.success) {
  13270. streamController.pullCall.resolve();
  13271. } else {
  13272. streamController.pullCall.reject(wrapReason(data.reason));
  13273. }
  13274. break;
  13275. case StreamKind.PULL:
  13276. if (!streamSink) {
  13277. comObj.postMessage({
  13278. sourceName,
  13279. targetName,
  13280. stream: StreamKind.PULL_COMPLETE,
  13281. streamId,
  13282. success: true
  13283. });
  13284. break;
  13285. }
  13286. if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
  13287. streamSink.sinkCapability.resolve();
  13288. }
  13289. streamSink.desiredSize = data.desiredSize;
  13290. new Promise(function (resolve) {
  13291. resolve(streamSink.onPull?.());
  13292. }).then(function () {
  13293. comObj.postMessage({
  13294. sourceName,
  13295. targetName,
  13296. stream: StreamKind.PULL_COMPLETE,
  13297. streamId,
  13298. success: true
  13299. });
  13300. }, function (reason) {
  13301. comObj.postMessage({
  13302. sourceName,
  13303. targetName,
  13304. stream: StreamKind.PULL_COMPLETE,
  13305. streamId,
  13306. reason: wrapReason(reason)
  13307. });
  13308. });
  13309. break;
  13310. case StreamKind.ENQUEUE:
  13311. (0, _util.assert)(streamController, "enqueue should have stream controller");
  13312. if (streamController.isClosed) {
  13313. break;
  13314. }
  13315. streamController.controller.enqueue(data.chunk);
  13316. break;
  13317. case StreamKind.CLOSE:
  13318. (0, _util.assert)(streamController, "close should have stream controller");
  13319. if (streamController.isClosed) {
  13320. break;
  13321. }
  13322. streamController.isClosed = true;
  13323. streamController.controller.close();
  13324. this.#deleteStreamController(streamController, streamId);
  13325. break;
  13326. case StreamKind.ERROR:
  13327. (0, _util.assert)(streamController, "error should have stream controller");
  13328. streamController.controller.error(wrapReason(data.reason));
  13329. this.#deleteStreamController(streamController, streamId);
  13330. break;
  13331. case StreamKind.CANCEL_COMPLETE:
  13332. if (data.success) {
  13333. streamController.cancelCall.resolve();
  13334. } else {
  13335. streamController.cancelCall.reject(wrapReason(data.reason));
  13336. }
  13337. this.#deleteStreamController(streamController, streamId);
  13338. break;
  13339. case StreamKind.CANCEL:
  13340. if (!streamSink) {
  13341. break;
  13342. }
  13343. new Promise(function (resolve) {
  13344. resolve(streamSink.onCancel?.(wrapReason(data.reason)));
  13345. }).then(function () {
  13346. comObj.postMessage({
  13347. sourceName,
  13348. targetName,
  13349. stream: StreamKind.CANCEL_COMPLETE,
  13350. streamId,
  13351. success: true
  13352. });
  13353. }, function (reason) {
  13354. comObj.postMessage({
  13355. sourceName,
  13356. targetName,
  13357. stream: StreamKind.CANCEL_COMPLETE,
  13358. streamId,
  13359. reason: wrapReason(reason)
  13360. });
  13361. });
  13362. streamSink.sinkCapability.reject(wrapReason(data.reason));
  13363. streamSink.isCancelled = true;
  13364. delete this.streamSinks[streamId];
  13365. break;
  13366. default:
  13367. throw new Error("Unexpected stream case");
  13368. }
  13369. }
  13370. async #deleteStreamController(streamController, streamId) {
  13371. await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
  13372. delete this.streamControllers[streamId];
  13373. }
  13374. destroy() {
  13375. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  13376. }
  13377. }
  13378. exports.MessageHandler = MessageHandler;
  13379. /***/ }),
  13380. /* 178 */
  13381. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13382. Object.defineProperty(exports, "__esModule", ({
  13383. value: true
  13384. }));
  13385. exports.Metadata = void 0;
  13386. var _util = __w_pdfjs_require__(1);
  13387. class Metadata {
  13388. #metadataMap;
  13389. #data;
  13390. constructor(_ref) {
  13391. let {
  13392. parsedData,
  13393. rawData
  13394. } = _ref;
  13395. this.#metadataMap = parsedData;
  13396. this.#data = rawData;
  13397. }
  13398. getRaw() {
  13399. return this.#data;
  13400. }
  13401. get(name) {
  13402. return this.#metadataMap.get(name) ?? null;
  13403. }
  13404. getAll() {
  13405. return (0, _util.objectFromMap)(this.#metadataMap);
  13406. }
  13407. has(name) {
  13408. return this.#metadataMap.has(name);
  13409. }
  13410. }
  13411. exports.Metadata = Metadata;
  13412. /***/ }),
  13413. /* 179 */
  13414. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13415. Object.defineProperty(exports, "__esModule", ({
  13416. value: true
  13417. }));
  13418. exports.OptionalContentConfig = void 0;
  13419. var _util = __w_pdfjs_require__(1);
  13420. var _murmurhash = __w_pdfjs_require__(170);
  13421. const INTERNAL = Symbol("INTERNAL");
  13422. class OptionalContentGroup {
  13423. #visible = true;
  13424. constructor(name, intent) {
  13425. this.name = name;
  13426. this.intent = intent;
  13427. }
  13428. get visible() {
  13429. return this.#visible;
  13430. }
  13431. _setVisible(internal, visible) {
  13432. if (internal !== INTERNAL) {
  13433. (0, _util.unreachable)("Internal method `_setVisible` called.");
  13434. }
  13435. this.#visible = visible;
  13436. }
  13437. }
  13438. class OptionalContentConfig {
  13439. #cachedGetHash = null;
  13440. #groups = new Map();
  13441. #initialHash = null;
  13442. #order = null;
  13443. constructor(data) {
  13444. this.name = null;
  13445. this.creator = null;
  13446. if (data === null) {
  13447. return;
  13448. }
  13449. this.name = data.name;
  13450. this.creator = data.creator;
  13451. this.#order = data.order;
  13452. for (const group of data.groups) {
  13453. this.#groups.set(group.id, new OptionalContentGroup(group.name, group.intent));
  13454. }
  13455. if (data.baseState === "OFF") {
  13456. for (const group of this.#groups.values()) {
  13457. group._setVisible(INTERNAL, false);
  13458. }
  13459. }
  13460. for (const on of data.on) {
  13461. this.#groups.get(on)._setVisible(INTERNAL, true);
  13462. }
  13463. for (const off of data.off) {
  13464. this.#groups.get(off)._setVisible(INTERNAL, false);
  13465. }
  13466. this.#initialHash = this.getHash();
  13467. }
  13468. #evaluateVisibilityExpression(array) {
  13469. const length = array.length;
  13470. if (length < 2) {
  13471. return true;
  13472. }
  13473. const operator = array[0];
  13474. for (let i = 1; i < length; i++) {
  13475. const element = array[i];
  13476. let state;
  13477. if (Array.isArray(element)) {
  13478. state = this.#evaluateVisibilityExpression(element);
  13479. } else if (this.#groups.has(element)) {
  13480. state = this.#groups.get(element).visible;
  13481. } else {
  13482. (0, _util.warn)(`Optional content group not found: ${element}`);
  13483. return true;
  13484. }
  13485. switch (operator) {
  13486. case "And":
  13487. if (!state) {
  13488. return false;
  13489. }
  13490. break;
  13491. case "Or":
  13492. if (state) {
  13493. return true;
  13494. }
  13495. break;
  13496. case "Not":
  13497. return !state;
  13498. default:
  13499. return true;
  13500. }
  13501. }
  13502. return operator === "And";
  13503. }
  13504. isVisible(group) {
  13505. if (this.#groups.size === 0) {
  13506. return true;
  13507. }
  13508. if (!group) {
  13509. (0, _util.warn)("Optional content group not defined.");
  13510. return true;
  13511. }
  13512. if (group.type === "OCG") {
  13513. if (!this.#groups.has(group.id)) {
  13514. (0, _util.warn)(`Optional content group not found: ${group.id}`);
  13515. return true;
  13516. }
  13517. return this.#groups.get(group.id).visible;
  13518. } else if (group.type === "OCMD") {
  13519. if (group.expression) {
  13520. return this.#evaluateVisibilityExpression(group.expression);
  13521. }
  13522. if (!group.policy || group.policy === "AnyOn") {
  13523. for (const id of group.ids) {
  13524. if (!this.#groups.has(id)) {
  13525. (0, _util.warn)(`Optional content group not found: ${id}`);
  13526. return true;
  13527. }
  13528. if (this.#groups.get(id).visible) {
  13529. return true;
  13530. }
  13531. }
  13532. return false;
  13533. } else if (group.policy === "AllOn") {
  13534. for (const id of group.ids) {
  13535. if (!this.#groups.has(id)) {
  13536. (0, _util.warn)(`Optional content group not found: ${id}`);
  13537. return true;
  13538. }
  13539. if (!this.#groups.get(id).visible) {
  13540. return false;
  13541. }
  13542. }
  13543. return true;
  13544. } else if (group.policy === "AnyOff") {
  13545. for (const id of group.ids) {
  13546. if (!this.#groups.has(id)) {
  13547. (0, _util.warn)(`Optional content group not found: ${id}`);
  13548. return true;
  13549. }
  13550. if (!this.#groups.get(id).visible) {
  13551. return true;
  13552. }
  13553. }
  13554. return false;
  13555. } else if (group.policy === "AllOff") {
  13556. for (const id of group.ids) {
  13557. if (!this.#groups.has(id)) {
  13558. (0, _util.warn)(`Optional content group not found: ${id}`);
  13559. return true;
  13560. }
  13561. if (this.#groups.get(id).visible) {
  13562. return false;
  13563. }
  13564. }
  13565. return true;
  13566. }
  13567. (0, _util.warn)(`Unknown optional content policy ${group.policy}.`);
  13568. return true;
  13569. }
  13570. (0, _util.warn)(`Unknown group type ${group.type}.`);
  13571. return true;
  13572. }
  13573. setVisibility(id) {
  13574. let visible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  13575. if (!this.#groups.has(id)) {
  13576. (0, _util.warn)(`Optional content group not found: ${id}`);
  13577. return;
  13578. }
  13579. this.#groups.get(id)._setVisible(INTERNAL, !!visible);
  13580. this.#cachedGetHash = null;
  13581. }
  13582. get hasInitialVisibility() {
  13583. return this.#initialHash === null || this.getHash() === this.#initialHash;
  13584. }
  13585. getOrder() {
  13586. if (!this.#groups.size) {
  13587. return null;
  13588. }
  13589. if (this.#order) {
  13590. return this.#order.slice();
  13591. }
  13592. return [...this.#groups.keys()];
  13593. }
  13594. getGroups() {
  13595. return this.#groups.size > 0 ? (0, _util.objectFromMap)(this.#groups) : null;
  13596. }
  13597. getGroup(id) {
  13598. return this.#groups.get(id) || null;
  13599. }
  13600. getHash() {
  13601. if (this.#cachedGetHash !== null) {
  13602. return this.#cachedGetHash;
  13603. }
  13604. const hash = new _murmurhash.MurmurHash3_64();
  13605. for (const [id, group] of this.#groups) {
  13606. hash.update(`${id}:${group.visible}`);
  13607. }
  13608. return this.#cachedGetHash = hash.hexdigest();
  13609. }
  13610. }
  13611. exports.OptionalContentConfig = OptionalContentConfig;
  13612. /***/ }),
  13613. /* 180 */
  13614. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13615. Object.defineProperty(exports, "__esModule", ({
  13616. value: true
  13617. }));
  13618. exports.PDFDataTransportStream = void 0;
  13619. __w_pdfjs_require__(93);
  13620. __w_pdfjs_require__(101);
  13621. __w_pdfjs_require__(102);
  13622. __w_pdfjs_require__(105);
  13623. __w_pdfjs_require__(107);
  13624. __w_pdfjs_require__(109);
  13625. __w_pdfjs_require__(113);
  13626. __w_pdfjs_require__(116);
  13627. __w_pdfjs_require__(123);
  13628. __w_pdfjs_require__(89);
  13629. var _util = __w_pdfjs_require__(1);
  13630. var _display_utils = __w_pdfjs_require__(168);
  13631. class PDFDataTransportStream {
  13632. constructor(_ref, pdfDataRangeTransport) {
  13633. let {
  13634. length,
  13635. initialData,
  13636. progressiveDone = false,
  13637. contentDispositionFilename = null,
  13638. disableRange = false,
  13639. disableStream = false
  13640. } = _ref;
  13641. (0, _util.assert)(pdfDataRangeTransport, 'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');
  13642. this._queuedChunks = [];
  13643. this._progressiveDone = progressiveDone;
  13644. this._contentDispositionFilename = contentDispositionFilename;
  13645. if (initialData?.length > 0) {
  13646. const buffer = initialData instanceof Uint8Array && initialData.byteLength === initialData.buffer.byteLength ? initialData.buffer : new Uint8Array(initialData).buffer;
  13647. this._queuedChunks.push(buffer);
  13648. }
  13649. this._pdfDataRangeTransport = pdfDataRangeTransport;
  13650. this._isStreamingSupported = !disableStream;
  13651. this._isRangeSupported = !disableRange;
  13652. this._contentLength = length;
  13653. this._fullRequestReader = null;
  13654. this._rangeReaders = [];
  13655. this._pdfDataRangeTransport.addRangeListener((begin, chunk) => {
  13656. this._onReceiveData({
  13657. begin,
  13658. chunk
  13659. });
  13660. });
  13661. this._pdfDataRangeTransport.addProgressListener((loaded, total) => {
  13662. this._onProgress({
  13663. loaded,
  13664. total
  13665. });
  13666. });
  13667. this._pdfDataRangeTransport.addProgressiveReadListener(chunk => {
  13668. this._onReceiveData({
  13669. chunk
  13670. });
  13671. });
  13672. this._pdfDataRangeTransport.addProgressiveDoneListener(() => {
  13673. this._onProgressiveDone();
  13674. });
  13675. this._pdfDataRangeTransport.transportReady();
  13676. }
  13677. _onReceiveData(_ref2) {
  13678. let {
  13679. begin,
  13680. chunk
  13681. } = _ref2;
  13682. const buffer = chunk instanceof Uint8Array && chunk.byteLength === chunk.buffer.byteLength ? chunk.buffer : new Uint8Array(chunk).buffer;
  13683. if (begin === undefined) {
  13684. if (this._fullRequestReader) {
  13685. this._fullRequestReader._enqueue(buffer);
  13686. } else {
  13687. this._queuedChunks.push(buffer);
  13688. }
  13689. } else {
  13690. const found = this._rangeReaders.some(function (rangeReader) {
  13691. if (rangeReader._begin !== begin) {
  13692. return false;
  13693. }
  13694. rangeReader._enqueue(buffer);
  13695. return true;
  13696. });
  13697. (0, _util.assert)(found, "_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");
  13698. }
  13699. }
  13700. get _progressiveDataLength() {
  13701. return this._fullRequestReader?._loaded ?? 0;
  13702. }
  13703. _onProgress(evt) {
  13704. if (evt.total === undefined) {
  13705. this._rangeReaders[0]?.onProgress?.({
  13706. loaded: evt.loaded
  13707. });
  13708. } else {
  13709. this._fullRequestReader?.onProgress?.({
  13710. loaded: evt.loaded,
  13711. total: evt.total
  13712. });
  13713. }
  13714. }
  13715. _onProgressiveDone() {
  13716. this._fullRequestReader?.progressiveDone();
  13717. this._progressiveDone = true;
  13718. }
  13719. _removeRangeReader(reader) {
  13720. const i = this._rangeReaders.indexOf(reader);
  13721. if (i >= 0) {
  13722. this._rangeReaders.splice(i, 1);
  13723. }
  13724. }
  13725. getFullReader() {
  13726. (0, _util.assert)(!this._fullRequestReader, "PDFDataTransportStream.getFullReader can only be called once.");
  13727. const queuedChunks = this._queuedChunks;
  13728. this._queuedChunks = null;
  13729. return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone, this._contentDispositionFilename);
  13730. }
  13731. getRangeReader(begin, end) {
  13732. if (end <= this._progressiveDataLength) {
  13733. return null;
  13734. }
  13735. const reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  13736. this._pdfDataRangeTransport.requestDataRange(begin, end);
  13737. this._rangeReaders.push(reader);
  13738. return reader;
  13739. }
  13740. cancelAllRequests(reason) {
  13741. this._fullRequestReader?.cancel(reason);
  13742. for (const reader of this._rangeReaders.slice(0)) {
  13743. reader.cancel(reason);
  13744. }
  13745. this._pdfDataRangeTransport.abort();
  13746. }
  13747. }
  13748. exports.PDFDataTransportStream = PDFDataTransportStream;
  13749. class PDFDataTransportStreamReader {
  13750. constructor(stream, queuedChunks) {
  13751. let progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  13752. let contentDispositionFilename = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  13753. this._stream = stream;
  13754. this._done = progressiveDone || false;
  13755. this._filename = (0, _display_utils.isPdfFile)(contentDispositionFilename) ? contentDispositionFilename : null;
  13756. this._queuedChunks = queuedChunks || [];
  13757. this._loaded = 0;
  13758. for (const chunk of this._queuedChunks) {
  13759. this._loaded += chunk.byteLength;
  13760. }
  13761. this._requests = [];
  13762. this._headersReady = Promise.resolve();
  13763. stream._fullRequestReader = this;
  13764. this.onProgress = null;
  13765. }
  13766. _enqueue(chunk) {
  13767. if (this._done) {
  13768. return;
  13769. }
  13770. if (this._requests.length > 0) {
  13771. const requestCapability = this._requests.shift();
  13772. requestCapability.resolve({
  13773. value: chunk,
  13774. done: false
  13775. });
  13776. } else {
  13777. this._queuedChunks.push(chunk);
  13778. }
  13779. this._loaded += chunk.byteLength;
  13780. }
  13781. get headersReady() {
  13782. return this._headersReady;
  13783. }
  13784. get filename() {
  13785. return this._filename;
  13786. }
  13787. get isRangeSupported() {
  13788. return this._stream._isRangeSupported;
  13789. }
  13790. get isStreamingSupported() {
  13791. return this._stream._isStreamingSupported;
  13792. }
  13793. get contentLength() {
  13794. return this._stream._contentLength;
  13795. }
  13796. async read() {
  13797. if (this._queuedChunks.length > 0) {
  13798. const chunk = this._queuedChunks.shift();
  13799. return {
  13800. value: chunk,
  13801. done: false
  13802. };
  13803. }
  13804. if (this._done) {
  13805. return {
  13806. value: undefined,
  13807. done: true
  13808. };
  13809. }
  13810. const requestCapability = new _util.PromiseCapability();
  13811. this._requests.push(requestCapability);
  13812. return requestCapability.promise;
  13813. }
  13814. cancel(reason) {
  13815. this._done = true;
  13816. for (const requestCapability of this._requests) {
  13817. requestCapability.resolve({
  13818. value: undefined,
  13819. done: true
  13820. });
  13821. }
  13822. this._requests.length = 0;
  13823. }
  13824. progressiveDone() {
  13825. if (this._done) {
  13826. return;
  13827. }
  13828. this._done = true;
  13829. }
  13830. }
  13831. class PDFDataTransportStreamRangeReader {
  13832. constructor(stream, begin, end) {
  13833. this._stream = stream;
  13834. this._begin = begin;
  13835. this._end = end;
  13836. this._queuedChunk = null;
  13837. this._requests = [];
  13838. this._done = false;
  13839. this.onProgress = null;
  13840. }
  13841. _enqueue(chunk) {
  13842. if (this._done) {
  13843. return;
  13844. }
  13845. if (this._requests.length === 0) {
  13846. this._queuedChunk = chunk;
  13847. } else {
  13848. const requestsCapability = this._requests.shift();
  13849. requestsCapability.resolve({
  13850. value: chunk,
  13851. done: false
  13852. });
  13853. for (const requestCapability of this._requests) {
  13854. requestCapability.resolve({
  13855. value: undefined,
  13856. done: true
  13857. });
  13858. }
  13859. this._requests.length = 0;
  13860. }
  13861. this._done = true;
  13862. this._stream._removeRangeReader(this);
  13863. }
  13864. get isStreamingSupported() {
  13865. return false;
  13866. }
  13867. async read() {
  13868. if (this._queuedChunk) {
  13869. const chunk = this._queuedChunk;
  13870. this._queuedChunk = null;
  13871. return {
  13872. value: chunk,
  13873. done: false
  13874. };
  13875. }
  13876. if (this._done) {
  13877. return {
  13878. value: undefined,
  13879. done: true
  13880. };
  13881. }
  13882. const requestCapability = new _util.PromiseCapability();
  13883. this._requests.push(requestCapability);
  13884. return requestCapability.promise;
  13885. }
  13886. cancel(reason) {
  13887. this._done = true;
  13888. for (const requestCapability of this._requests) {
  13889. requestCapability.resolve({
  13890. value: undefined,
  13891. done: true
  13892. });
  13893. }
  13894. this._requests.length = 0;
  13895. this._stream._removeRangeReader(this);
  13896. }
  13897. }
  13898. /***/ }),
  13899. /* 181 */
  13900. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  13901. Object.defineProperty(exports, "__esModule", ({
  13902. value: true
  13903. }));
  13904. exports.PDFFetchStream = void 0;
  13905. __w_pdfjs_require__(93);
  13906. __w_pdfjs_require__(101);
  13907. __w_pdfjs_require__(102);
  13908. __w_pdfjs_require__(105);
  13909. __w_pdfjs_require__(107);
  13910. __w_pdfjs_require__(109);
  13911. __w_pdfjs_require__(113);
  13912. __w_pdfjs_require__(116);
  13913. __w_pdfjs_require__(123);
  13914. __w_pdfjs_require__(89);
  13915. var _util = __w_pdfjs_require__(1);
  13916. var _network_utils = __w_pdfjs_require__(182);
  13917. ;
  13918. function createFetchOptions(headers, withCredentials, abortController) {
  13919. return {
  13920. method: "GET",
  13921. headers,
  13922. signal: abortController.signal,
  13923. mode: "cors",
  13924. credentials: withCredentials ? "include" : "same-origin",
  13925. redirect: "follow"
  13926. };
  13927. }
  13928. function createHeaders(httpHeaders) {
  13929. const headers = new Headers();
  13930. for (const property in httpHeaders) {
  13931. const value = httpHeaders[property];
  13932. if (value === undefined) {
  13933. continue;
  13934. }
  13935. headers.append(property, value);
  13936. }
  13937. return headers;
  13938. }
  13939. function getArrayBuffer(val) {
  13940. if (val instanceof Uint8Array) {
  13941. return val.buffer;
  13942. }
  13943. if (val instanceof ArrayBuffer) {
  13944. return val;
  13945. }
  13946. (0, _util.warn)(`getArrayBuffer - unexpected data format: ${val}`);
  13947. return new Uint8Array(val).buffer;
  13948. }
  13949. class PDFFetchStream {
  13950. constructor(source) {
  13951. this.source = source;
  13952. this.isHttp = /^https?:/i.test(source.url);
  13953. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  13954. this._fullRequestReader = null;
  13955. this._rangeRequestReaders = [];
  13956. }
  13957. get _progressiveDataLength() {
  13958. return this._fullRequestReader?._loaded ?? 0;
  13959. }
  13960. getFullReader() {
  13961. (0, _util.assert)(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
  13962. this._fullRequestReader = new PDFFetchStreamReader(this);
  13963. return this._fullRequestReader;
  13964. }
  13965. getRangeReader(begin, end) {
  13966. if (end <= this._progressiveDataLength) {
  13967. return null;
  13968. }
  13969. const reader = new PDFFetchStreamRangeReader(this, begin, end);
  13970. this._rangeRequestReaders.push(reader);
  13971. return reader;
  13972. }
  13973. cancelAllRequests(reason) {
  13974. this._fullRequestReader?.cancel(reason);
  13975. for (const reader of this._rangeRequestReaders.slice(0)) {
  13976. reader.cancel(reason);
  13977. }
  13978. }
  13979. }
  13980. exports.PDFFetchStream = PDFFetchStream;
  13981. class PDFFetchStreamReader {
  13982. constructor(stream) {
  13983. this._stream = stream;
  13984. this._reader = null;
  13985. this._loaded = 0;
  13986. this._filename = null;
  13987. const source = stream.source;
  13988. this._withCredentials = source.withCredentials || false;
  13989. this._contentLength = source.length;
  13990. this._headersCapability = new _util.PromiseCapability();
  13991. this._disableRange = source.disableRange || false;
  13992. this._rangeChunkSize = source.rangeChunkSize;
  13993. if (!this._rangeChunkSize && !this._disableRange) {
  13994. this._disableRange = true;
  13995. }
  13996. this._abortController = new AbortController();
  13997. this._isStreamingSupported = !source.disableStream;
  13998. this._isRangeSupported = !source.disableRange;
  13999. this._headers = createHeaders(this._stream.httpHeaders);
  14000. const url = source.url;
  14001. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
  14002. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  14003. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  14004. }
  14005. this._reader = response.body.getReader();
  14006. this._headersCapability.resolve();
  14007. const getResponseHeader = name => {
  14008. return response.headers.get(name);
  14009. };
  14010. const {
  14011. allowRangeRequests,
  14012. suggestedLength
  14013. } = (0, _network_utils.validateRangeRequestCapabilities)({
  14014. getResponseHeader,
  14015. isHttp: this._stream.isHttp,
  14016. rangeChunkSize: this._rangeChunkSize,
  14017. disableRange: this._disableRange
  14018. });
  14019. this._isRangeSupported = allowRangeRequests;
  14020. this._contentLength = suggestedLength || this._contentLength;
  14021. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  14022. if (!this._isStreamingSupported && this._isRangeSupported) {
  14023. this.cancel(new _util.AbortException("Streaming is disabled."));
  14024. }
  14025. }).catch(this._headersCapability.reject);
  14026. this.onProgress = null;
  14027. }
  14028. get headersReady() {
  14029. return this._headersCapability.promise;
  14030. }
  14031. get filename() {
  14032. return this._filename;
  14033. }
  14034. get contentLength() {
  14035. return this._contentLength;
  14036. }
  14037. get isRangeSupported() {
  14038. return this._isRangeSupported;
  14039. }
  14040. get isStreamingSupported() {
  14041. return this._isStreamingSupported;
  14042. }
  14043. async read() {
  14044. await this._headersCapability.promise;
  14045. const {
  14046. value,
  14047. done
  14048. } = await this._reader.read();
  14049. if (done) {
  14050. return {
  14051. value,
  14052. done
  14053. };
  14054. }
  14055. this._loaded += value.byteLength;
  14056. this.onProgress?.({
  14057. loaded: this._loaded,
  14058. total: this._contentLength
  14059. });
  14060. return {
  14061. value: getArrayBuffer(value),
  14062. done: false
  14063. };
  14064. }
  14065. cancel(reason) {
  14066. this._reader?.cancel(reason);
  14067. this._abortController.abort();
  14068. }
  14069. }
  14070. class PDFFetchStreamRangeReader {
  14071. constructor(stream, begin, end) {
  14072. this._stream = stream;
  14073. this._reader = null;
  14074. this._loaded = 0;
  14075. const source = stream.source;
  14076. this._withCredentials = source.withCredentials || false;
  14077. this._readCapability = new _util.PromiseCapability();
  14078. this._isStreamingSupported = !source.disableStream;
  14079. this._abortController = new AbortController();
  14080. this._headers = createHeaders(this._stream.httpHeaders);
  14081. this._headers.append("Range", `bytes=${begin}-${end - 1}`);
  14082. const url = source.url;
  14083. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
  14084. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  14085. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  14086. }
  14087. this._readCapability.resolve();
  14088. this._reader = response.body.getReader();
  14089. }).catch(this._readCapability.reject);
  14090. this.onProgress = null;
  14091. }
  14092. get isStreamingSupported() {
  14093. return this._isStreamingSupported;
  14094. }
  14095. async read() {
  14096. await this._readCapability.promise;
  14097. const {
  14098. value,
  14099. done
  14100. } = await this._reader.read();
  14101. if (done) {
  14102. return {
  14103. value,
  14104. done
  14105. };
  14106. }
  14107. this._loaded += value.byteLength;
  14108. this.onProgress?.({
  14109. loaded: this._loaded
  14110. });
  14111. return {
  14112. value: getArrayBuffer(value),
  14113. done: false
  14114. };
  14115. }
  14116. cancel(reason) {
  14117. this._reader?.cancel(reason);
  14118. this._abortController.abort();
  14119. }
  14120. }
  14121. /***/ }),
  14122. /* 182 */
  14123. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14124. Object.defineProperty(exports, "__esModule", ({
  14125. value: true
  14126. }));
  14127. exports.createResponseStatusError = createResponseStatusError;
  14128. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  14129. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  14130. exports.validateResponseStatus = validateResponseStatus;
  14131. var _util = __w_pdfjs_require__(1);
  14132. var _content_disposition = __w_pdfjs_require__(183);
  14133. var _display_utils = __w_pdfjs_require__(168);
  14134. function validateRangeRequestCapabilities(_ref) {
  14135. let {
  14136. getResponseHeader,
  14137. isHttp,
  14138. rangeChunkSize,
  14139. disableRange
  14140. } = _ref;
  14141. const returnValues = {
  14142. allowRangeRequests: false,
  14143. suggestedLength: undefined
  14144. };
  14145. const length = parseInt(getResponseHeader("Content-Length"), 10);
  14146. if (!Number.isInteger(length)) {
  14147. return returnValues;
  14148. }
  14149. returnValues.suggestedLength = length;
  14150. if (length <= 2 * rangeChunkSize) {
  14151. return returnValues;
  14152. }
  14153. if (disableRange || !isHttp) {
  14154. return returnValues;
  14155. }
  14156. if (getResponseHeader("Accept-Ranges") !== "bytes") {
  14157. return returnValues;
  14158. }
  14159. const contentEncoding = getResponseHeader("Content-Encoding") || "identity";
  14160. if (contentEncoding !== "identity") {
  14161. return returnValues;
  14162. }
  14163. returnValues.allowRangeRequests = true;
  14164. return returnValues;
  14165. }
  14166. function extractFilenameFromHeader(getResponseHeader) {
  14167. const contentDisposition = getResponseHeader("Content-Disposition");
  14168. if (contentDisposition) {
  14169. let filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  14170. if (filename.includes("%")) {
  14171. try {
  14172. filename = decodeURIComponent(filename);
  14173. } catch {}
  14174. }
  14175. if ((0, _display_utils.isPdfFile)(filename)) {
  14176. return filename;
  14177. }
  14178. }
  14179. return null;
  14180. }
  14181. function createResponseStatusError(status, url) {
  14182. if (status === 404 || status === 0 && url.startsWith("file:")) {
  14183. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  14184. }
  14185. return new _util.UnexpectedResponseException(`Unexpected server response (${status}) while retrieving PDF "${url}".`, status);
  14186. }
  14187. function validateResponseStatus(status) {
  14188. return status === 200 || status === 206;
  14189. }
  14190. /***/ }),
  14191. /* 183 */
  14192. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14193. Object.defineProperty(exports, "__esModule", ({
  14194. value: true
  14195. }));
  14196. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  14197. __w_pdfjs_require__(89);
  14198. __w_pdfjs_require__(149);
  14199. var _util = __w_pdfjs_require__(1);
  14200. function getFilenameFromContentDispositionHeader(contentDisposition) {
  14201. let needsEncodingFixup = true;
  14202. let tmp = toParamRegExp("filename\\*", "i").exec(contentDisposition);
  14203. if (tmp) {
  14204. tmp = tmp[1];
  14205. let filename = rfc2616unquote(tmp);
  14206. filename = unescape(filename);
  14207. filename = rfc5987decode(filename);
  14208. filename = rfc2047decode(filename);
  14209. return fixupEncoding(filename);
  14210. }
  14211. tmp = rfc2231getparam(contentDisposition);
  14212. if (tmp) {
  14213. const filename = rfc2047decode(tmp);
  14214. return fixupEncoding(filename);
  14215. }
  14216. tmp = toParamRegExp("filename", "i").exec(contentDisposition);
  14217. if (tmp) {
  14218. tmp = tmp[1];
  14219. let filename = rfc2616unquote(tmp);
  14220. filename = rfc2047decode(filename);
  14221. return fixupEncoding(filename);
  14222. }
  14223. function toParamRegExp(attributePattern, flags) {
  14224. return new RegExp("(?:^|;)\\s*" + attributePattern + "\\s*=\\s*" + "(" + '[^";\\s][^;\\s]*' + "|" + '"(?:[^"\\\\]|\\\\"?)+"?' + ")", flags);
  14225. }
  14226. function textdecode(encoding, value) {
  14227. if (encoding) {
  14228. if (!/^[\x00-\xFF]+$/.test(value)) {
  14229. return value;
  14230. }
  14231. try {
  14232. const decoder = new TextDecoder(encoding, {
  14233. fatal: true
  14234. });
  14235. const buffer = (0, _util.stringToBytes)(value);
  14236. value = decoder.decode(buffer);
  14237. needsEncodingFixup = false;
  14238. } catch {}
  14239. }
  14240. return value;
  14241. }
  14242. function fixupEncoding(value) {
  14243. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  14244. value = textdecode("utf-8", value);
  14245. if (needsEncodingFixup) {
  14246. value = textdecode("iso-8859-1", value);
  14247. }
  14248. }
  14249. return value;
  14250. }
  14251. function rfc2231getparam(contentDispositionStr) {
  14252. const matches = [];
  14253. let match;
  14254. const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
  14255. while ((match = iter.exec(contentDispositionStr)) !== null) {
  14256. let [, n, quot, part] = match;
  14257. n = parseInt(n, 10);
  14258. if (n in matches) {
  14259. if (n === 0) {
  14260. break;
  14261. }
  14262. continue;
  14263. }
  14264. matches[n] = [quot, part];
  14265. }
  14266. const parts = [];
  14267. for (let n = 0; n < matches.length; ++n) {
  14268. if (!(n in matches)) {
  14269. break;
  14270. }
  14271. let [quot, part] = matches[n];
  14272. part = rfc2616unquote(part);
  14273. if (quot) {
  14274. part = unescape(part);
  14275. if (n === 0) {
  14276. part = rfc5987decode(part);
  14277. }
  14278. }
  14279. parts.push(part);
  14280. }
  14281. return parts.join("");
  14282. }
  14283. function rfc2616unquote(value) {
  14284. if (value.startsWith('"')) {
  14285. const parts = value.slice(1).split('\\"');
  14286. for (let i = 0; i < parts.length; ++i) {
  14287. const quotindex = parts[i].indexOf('"');
  14288. if (quotindex !== -1) {
  14289. parts[i] = parts[i].slice(0, quotindex);
  14290. parts.length = i + 1;
  14291. }
  14292. parts[i] = parts[i].replaceAll(/\\(.)/g, "$1");
  14293. }
  14294. value = parts.join('"');
  14295. }
  14296. return value;
  14297. }
  14298. function rfc5987decode(extvalue) {
  14299. const encodingend = extvalue.indexOf("'");
  14300. if (encodingend === -1) {
  14301. return extvalue;
  14302. }
  14303. const encoding = extvalue.slice(0, encodingend);
  14304. const langvalue = extvalue.slice(encodingend + 1);
  14305. const value = langvalue.replace(/^[^']*'/, "");
  14306. return textdecode(encoding, value);
  14307. }
  14308. function rfc2047decode(value) {
  14309. if (!value.startsWith("=?") || /[\x00-\x19\x80-\xff]/.test(value)) {
  14310. return value;
  14311. }
  14312. return value.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (matches, charset, encoding, text) {
  14313. if (encoding === "q" || encoding === "Q") {
  14314. text = text.replaceAll("_", " ");
  14315. text = text.replaceAll(/=([0-9a-fA-F]{2})/g, function (match, hex) {
  14316. return String.fromCharCode(parseInt(hex, 16));
  14317. });
  14318. return textdecode(charset, text);
  14319. }
  14320. try {
  14321. text = atob(text);
  14322. } catch {}
  14323. return textdecode(charset, text);
  14324. });
  14325. }
  14326. return "";
  14327. }
  14328. /***/ }),
  14329. /* 184 */
  14330. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14331. Object.defineProperty(exports, "__esModule", ({
  14332. value: true
  14333. }));
  14334. exports.PDFNetworkStream = void 0;
  14335. __w_pdfjs_require__(89);
  14336. var _util = __w_pdfjs_require__(1);
  14337. var _network_utils = __w_pdfjs_require__(182);
  14338. ;
  14339. const OK_RESPONSE = 200;
  14340. const PARTIAL_CONTENT_RESPONSE = 206;
  14341. function getArrayBuffer(xhr) {
  14342. const data = xhr.response;
  14343. if (typeof data !== "string") {
  14344. return data;
  14345. }
  14346. return (0, _util.stringToBytes)(data).buffer;
  14347. }
  14348. class NetworkManager {
  14349. constructor(url) {
  14350. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14351. this.url = url;
  14352. this.isHttp = /^https?:/i.test(url);
  14353. this.httpHeaders = this.isHttp && args.httpHeaders || Object.create(null);
  14354. this.withCredentials = args.withCredentials || false;
  14355. this.currXhrId = 0;
  14356. this.pendingRequests = Object.create(null);
  14357. }
  14358. requestRange(begin, end, listeners) {
  14359. const args = {
  14360. begin,
  14361. end
  14362. };
  14363. for (const prop in listeners) {
  14364. args[prop] = listeners[prop];
  14365. }
  14366. return this.request(args);
  14367. }
  14368. requestFull(listeners) {
  14369. return this.request(listeners);
  14370. }
  14371. request(args) {
  14372. const xhr = new XMLHttpRequest();
  14373. const xhrId = this.currXhrId++;
  14374. const pendingRequest = this.pendingRequests[xhrId] = {
  14375. xhr
  14376. };
  14377. xhr.open("GET", this.url);
  14378. xhr.withCredentials = this.withCredentials;
  14379. for (const property in this.httpHeaders) {
  14380. const value = this.httpHeaders[property];
  14381. if (value === undefined) {
  14382. continue;
  14383. }
  14384. xhr.setRequestHeader(property, value);
  14385. }
  14386. if (this.isHttp && "begin" in args && "end" in args) {
  14387. xhr.setRequestHeader("Range", `bytes=${args.begin}-${args.end - 1}`);
  14388. pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
  14389. } else {
  14390. pendingRequest.expectedStatus = OK_RESPONSE;
  14391. }
  14392. xhr.responseType = "arraybuffer";
  14393. if (args.onError) {
  14394. xhr.onerror = function (evt) {
  14395. args.onError(xhr.status);
  14396. };
  14397. }
  14398. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  14399. xhr.onprogress = this.onProgress.bind(this, xhrId);
  14400. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  14401. pendingRequest.onDone = args.onDone;
  14402. pendingRequest.onError = args.onError;
  14403. pendingRequest.onProgress = args.onProgress;
  14404. xhr.send(null);
  14405. return xhrId;
  14406. }
  14407. onProgress(xhrId, evt) {
  14408. const pendingRequest = this.pendingRequests[xhrId];
  14409. if (!pendingRequest) {
  14410. return;
  14411. }
  14412. pendingRequest.onProgress?.(evt);
  14413. }
  14414. onStateChange(xhrId, evt) {
  14415. const pendingRequest = this.pendingRequests[xhrId];
  14416. if (!pendingRequest) {
  14417. return;
  14418. }
  14419. const xhr = pendingRequest.xhr;
  14420. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  14421. pendingRequest.onHeadersReceived();
  14422. delete pendingRequest.onHeadersReceived;
  14423. }
  14424. if (xhr.readyState !== 4) {
  14425. return;
  14426. }
  14427. if (!(xhrId in this.pendingRequests)) {
  14428. return;
  14429. }
  14430. delete this.pendingRequests[xhrId];
  14431. if (xhr.status === 0 && this.isHttp) {
  14432. pendingRequest.onError?.(xhr.status);
  14433. return;
  14434. }
  14435. const xhrStatus = xhr.status || OK_RESPONSE;
  14436. const ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  14437. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  14438. pendingRequest.onError?.(xhr.status);
  14439. return;
  14440. }
  14441. const chunk = getArrayBuffer(xhr);
  14442. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  14443. const rangeHeader = xhr.getResponseHeader("Content-Range");
  14444. const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  14445. pendingRequest.onDone({
  14446. begin: parseInt(matches[1], 10),
  14447. chunk
  14448. });
  14449. } else if (chunk) {
  14450. pendingRequest.onDone({
  14451. begin: 0,
  14452. chunk
  14453. });
  14454. } else {
  14455. pendingRequest.onError?.(xhr.status);
  14456. }
  14457. }
  14458. getRequestXhr(xhrId) {
  14459. return this.pendingRequests[xhrId].xhr;
  14460. }
  14461. isPendingRequest(xhrId) {
  14462. return xhrId in this.pendingRequests;
  14463. }
  14464. abortRequest(xhrId) {
  14465. const xhr = this.pendingRequests[xhrId].xhr;
  14466. delete this.pendingRequests[xhrId];
  14467. xhr.abort();
  14468. }
  14469. }
  14470. class PDFNetworkStream {
  14471. constructor(source) {
  14472. this._source = source;
  14473. this._manager = new NetworkManager(source.url, {
  14474. httpHeaders: source.httpHeaders,
  14475. withCredentials: source.withCredentials
  14476. });
  14477. this._rangeChunkSize = source.rangeChunkSize;
  14478. this._fullRequestReader = null;
  14479. this._rangeRequestReaders = [];
  14480. }
  14481. _onRangeRequestReaderClosed(reader) {
  14482. const i = this._rangeRequestReaders.indexOf(reader);
  14483. if (i >= 0) {
  14484. this._rangeRequestReaders.splice(i, 1);
  14485. }
  14486. }
  14487. getFullReader() {
  14488. (0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
  14489. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  14490. return this._fullRequestReader;
  14491. }
  14492. getRangeReader(begin, end) {
  14493. const reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  14494. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  14495. this._rangeRequestReaders.push(reader);
  14496. return reader;
  14497. }
  14498. cancelAllRequests(reason) {
  14499. this._fullRequestReader?.cancel(reason);
  14500. for (const reader of this._rangeRequestReaders.slice(0)) {
  14501. reader.cancel(reason);
  14502. }
  14503. }
  14504. }
  14505. exports.PDFNetworkStream = PDFNetworkStream;
  14506. class PDFNetworkStreamFullRequestReader {
  14507. constructor(manager, source) {
  14508. this._manager = manager;
  14509. const args = {
  14510. onHeadersReceived: this._onHeadersReceived.bind(this),
  14511. onDone: this._onDone.bind(this),
  14512. onError: this._onError.bind(this),
  14513. onProgress: this._onProgress.bind(this)
  14514. };
  14515. this._url = source.url;
  14516. this._fullRequestId = manager.requestFull(args);
  14517. this._headersReceivedCapability = new _util.PromiseCapability();
  14518. this._disableRange = source.disableRange || false;
  14519. this._contentLength = source.length;
  14520. this._rangeChunkSize = source.rangeChunkSize;
  14521. if (!this._rangeChunkSize && !this._disableRange) {
  14522. this._disableRange = true;
  14523. }
  14524. this._isStreamingSupported = false;
  14525. this._isRangeSupported = false;
  14526. this._cachedChunks = [];
  14527. this._requests = [];
  14528. this._done = false;
  14529. this._storedError = undefined;
  14530. this._filename = null;
  14531. this.onProgress = null;
  14532. }
  14533. _onHeadersReceived() {
  14534. const fullRequestXhrId = this._fullRequestId;
  14535. const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  14536. const getResponseHeader = name => {
  14537. return fullRequestXhr.getResponseHeader(name);
  14538. };
  14539. const {
  14540. allowRangeRequests,
  14541. suggestedLength
  14542. } = (0, _network_utils.validateRangeRequestCapabilities)({
  14543. getResponseHeader,
  14544. isHttp: this._manager.isHttp,
  14545. rangeChunkSize: this._rangeChunkSize,
  14546. disableRange: this._disableRange
  14547. });
  14548. if (allowRangeRequests) {
  14549. this._isRangeSupported = true;
  14550. }
  14551. this._contentLength = suggestedLength || this._contentLength;
  14552. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  14553. if (this._isRangeSupported) {
  14554. this._manager.abortRequest(fullRequestXhrId);
  14555. }
  14556. this._headersReceivedCapability.resolve();
  14557. }
  14558. _onDone(data) {
  14559. if (data) {
  14560. if (this._requests.length > 0) {
  14561. const requestCapability = this._requests.shift();
  14562. requestCapability.resolve({
  14563. value: data.chunk,
  14564. done: false
  14565. });
  14566. } else {
  14567. this._cachedChunks.push(data.chunk);
  14568. }
  14569. }
  14570. this._done = true;
  14571. if (this._cachedChunks.length > 0) {
  14572. return;
  14573. }
  14574. for (const requestCapability of this._requests) {
  14575. requestCapability.resolve({
  14576. value: undefined,
  14577. done: true
  14578. });
  14579. }
  14580. this._requests.length = 0;
  14581. }
  14582. _onError(status) {
  14583. this._storedError = (0, _network_utils.createResponseStatusError)(status, this._url);
  14584. this._headersReceivedCapability.reject(this._storedError);
  14585. for (const requestCapability of this._requests) {
  14586. requestCapability.reject(this._storedError);
  14587. }
  14588. this._requests.length = 0;
  14589. this._cachedChunks.length = 0;
  14590. }
  14591. _onProgress(evt) {
  14592. this.onProgress?.({
  14593. loaded: evt.loaded,
  14594. total: evt.lengthComputable ? evt.total : this._contentLength
  14595. });
  14596. }
  14597. get filename() {
  14598. return this._filename;
  14599. }
  14600. get isRangeSupported() {
  14601. return this._isRangeSupported;
  14602. }
  14603. get isStreamingSupported() {
  14604. return this._isStreamingSupported;
  14605. }
  14606. get contentLength() {
  14607. return this._contentLength;
  14608. }
  14609. get headersReady() {
  14610. return this._headersReceivedCapability.promise;
  14611. }
  14612. async read() {
  14613. if (this._storedError) {
  14614. throw this._storedError;
  14615. }
  14616. if (this._cachedChunks.length > 0) {
  14617. const chunk = this._cachedChunks.shift();
  14618. return {
  14619. value: chunk,
  14620. done: false
  14621. };
  14622. }
  14623. if (this._done) {
  14624. return {
  14625. value: undefined,
  14626. done: true
  14627. };
  14628. }
  14629. const requestCapability = new _util.PromiseCapability();
  14630. this._requests.push(requestCapability);
  14631. return requestCapability.promise;
  14632. }
  14633. cancel(reason) {
  14634. this._done = true;
  14635. this._headersReceivedCapability.reject(reason);
  14636. for (const requestCapability of this._requests) {
  14637. requestCapability.resolve({
  14638. value: undefined,
  14639. done: true
  14640. });
  14641. }
  14642. this._requests.length = 0;
  14643. if (this._manager.isPendingRequest(this._fullRequestId)) {
  14644. this._manager.abortRequest(this._fullRequestId);
  14645. }
  14646. this._fullRequestReader = null;
  14647. }
  14648. }
  14649. class PDFNetworkStreamRangeRequestReader {
  14650. constructor(manager, begin, end) {
  14651. this._manager = manager;
  14652. const args = {
  14653. onDone: this._onDone.bind(this),
  14654. onError: this._onError.bind(this),
  14655. onProgress: this._onProgress.bind(this)
  14656. };
  14657. this._url = manager.url;
  14658. this._requestId = manager.requestRange(begin, end, args);
  14659. this._requests = [];
  14660. this._queuedChunk = null;
  14661. this._done = false;
  14662. this._storedError = undefined;
  14663. this.onProgress = null;
  14664. this.onClosed = null;
  14665. }
  14666. _close() {
  14667. this.onClosed?.(this);
  14668. }
  14669. _onDone(data) {
  14670. const chunk = data.chunk;
  14671. if (this._requests.length > 0) {
  14672. const requestCapability = this._requests.shift();
  14673. requestCapability.resolve({
  14674. value: chunk,
  14675. done: false
  14676. });
  14677. } else {
  14678. this._queuedChunk = chunk;
  14679. }
  14680. this._done = true;
  14681. for (const requestCapability of this._requests) {
  14682. requestCapability.resolve({
  14683. value: undefined,
  14684. done: true
  14685. });
  14686. }
  14687. this._requests.length = 0;
  14688. this._close();
  14689. }
  14690. _onError(status) {
  14691. this._storedError = (0, _network_utils.createResponseStatusError)(status, this._url);
  14692. for (const requestCapability of this._requests) {
  14693. requestCapability.reject(this._storedError);
  14694. }
  14695. this._requests.length = 0;
  14696. this._queuedChunk = null;
  14697. }
  14698. _onProgress(evt) {
  14699. if (!this.isStreamingSupported) {
  14700. this.onProgress?.({
  14701. loaded: evt.loaded
  14702. });
  14703. }
  14704. }
  14705. get isStreamingSupported() {
  14706. return false;
  14707. }
  14708. async read() {
  14709. if (this._storedError) {
  14710. throw this._storedError;
  14711. }
  14712. if (this._queuedChunk !== null) {
  14713. const chunk = this._queuedChunk;
  14714. this._queuedChunk = null;
  14715. return {
  14716. value: chunk,
  14717. done: false
  14718. };
  14719. }
  14720. if (this._done) {
  14721. return {
  14722. value: undefined,
  14723. done: true
  14724. };
  14725. }
  14726. const requestCapability = new _util.PromiseCapability();
  14727. this._requests.push(requestCapability);
  14728. return requestCapability.promise;
  14729. }
  14730. cancel(reason) {
  14731. this._done = true;
  14732. for (const requestCapability of this._requests) {
  14733. requestCapability.resolve({
  14734. value: undefined,
  14735. done: true
  14736. });
  14737. }
  14738. this._requests.length = 0;
  14739. if (this._manager.isPendingRequest(this._requestId)) {
  14740. this._manager.abortRequest(this._requestId);
  14741. }
  14742. this._close();
  14743. }
  14744. }
  14745. /***/ }),
  14746. /* 185 */
  14747. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  14748. Object.defineProperty(exports, "__esModule", ({
  14749. value: true
  14750. }));
  14751. exports.PDFNodeStream = void 0;
  14752. __w_pdfjs_require__(89);
  14753. __w_pdfjs_require__(93);
  14754. __w_pdfjs_require__(101);
  14755. __w_pdfjs_require__(102);
  14756. __w_pdfjs_require__(105);
  14757. __w_pdfjs_require__(107);
  14758. __w_pdfjs_require__(109);
  14759. __w_pdfjs_require__(113);
  14760. __w_pdfjs_require__(116);
  14761. __w_pdfjs_require__(123);
  14762. var _util = __w_pdfjs_require__(1);
  14763. var _network_utils = __w_pdfjs_require__(182);
  14764. ;
  14765. const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  14766. function parseUrl(sourceUrl) {
  14767. const url = require("url");
  14768. const parsedUrl = url.parse(sourceUrl);
  14769. if (parsedUrl.protocol === "file:" || parsedUrl.host) {
  14770. return parsedUrl;
  14771. }
  14772. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  14773. return url.parse(`file:///${sourceUrl}`);
  14774. }
  14775. if (!parsedUrl.host) {
  14776. parsedUrl.protocol = "file:";
  14777. }
  14778. return parsedUrl;
  14779. }
  14780. class PDFNodeStream {
  14781. constructor(source) {
  14782. this.source = source;
  14783. this.url = parseUrl(source.url);
  14784. this.isHttp = this.url.protocol === "http:" || this.url.protocol === "https:";
  14785. this.isFsUrl = this.url.protocol === "file:";
  14786. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  14787. this._fullRequestReader = null;
  14788. this._rangeRequestReaders = [];
  14789. }
  14790. get _progressiveDataLength() {
  14791. return this._fullRequestReader?._loaded ?? 0;
  14792. }
  14793. getFullReader() {
  14794. (0, _util.assert)(!this._fullRequestReader, "PDFNodeStream.getFullReader can only be called once.");
  14795. this._fullRequestReader = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  14796. return this._fullRequestReader;
  14797. }
  14798. getRangeReader(start, end) {
  14799. if (end <= this._progressiveDataLength) {
  14800. return null;
  14801. }
  14802. const rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  14803. this._rangeRequestReaders.push(rangeReader);
  14804. return rangeReader;
  14805. }
  14806. cancelAllRequests(reason) {
  14807. this._fullRequestReader?.cancel(reason);
  14808. for (const reader of this._rangeRequestReaders.slice(0)) {
  14809. reader.cancel(reason);
  14810. }
  14811. }
  14812. }
  14813. exports.PDFNodeStream = PDFNodeStream;
  14814. class BaseFullReader {
  14815. constructor(stream) {
  14816. this._url = stream.url;
  14817. this._done = false;
  14818. this._storedError = null;
  14819. this.onProgress = null;
  14820. const source = stream.source;
  14821. this._contentLength = source.length;
  14822. this._loaded = 0;
  14823. this._filename = null;
  14824. this._disableRange = source.disableRange || false;
  14825. this._rangeChunkSize = source.rangeChunkSize;
  14826. if (!this._rangeChunkSize && !this._disableRange) {
  14827. this._disableRange = true;
  14828. }
  14829. this._isStreamingSupported = !source.disableStream;
  14830. this._isRangeSupported = !source.disableRange;
  14831. this._readableStream = null;
  14832. this._readCapability = new _util.PromiseCapability();
  14833. this._headersCapability = new _util.PromiseCapability();
  14834. }
  14835. get headersReady() {
  14836. return this._headersCapability.promise;
  14837. }
  14838. get filename() {
  14839. return this._filename;
  14840. }
  14841. get contentLength() {
  14842. return this._contentLength;
  14843. }
  14844. get isRangeSupported() {
  14845. return this._isRangeSupported;
  14846. }
  14847. get isStreamingSupported() {
  14848. return this._isStreamingSupported;
  14849. }
  14850. async read() {
  14851. await this._readCapability.promise;
  14852. if (this._done) {
  14853. return {
  14854. value: undefined,
  14855. done: true
  14856. };
  14857. }
  14858. if (this._storedError) {
  14859. throw this._storedError;
  14860. }
  14861. const chunk = this._readableStream.read();
  14862. if (chunk === null) {
  14863. this._readCapability = new _util.PromiseCapability();
  14864. return this.read();
  14865. }
  14866. this._loaded += chunk.length;
  14867. this.onProgress?.({
  14868. loaded: this._loaded,
  14869. total: this._contentLength
  14870. });
  14871. const buffer = new Uint8Array(chunk).buffer;
  14872. return {
  14873. value: buffer,
  14874. done: false
  14875. };
  14876. }
  14877. cancel(reason) {
  14878. if (!this._readableStream) {
  14879. this._error(reason);
  14880. return;
  14881. }
  14882. this._readableStream.destroy(reason);
  14883. }
  14884. _error(reason) {
  14885. this._storedError = reason;
  14886. this._readCapability.resolve();
  14887. }
  14888. _setReadableStream(readableStream) {
  14889. this._readableStream = readableStream;
  14890. readableStream.on("readable", () => {
  14891. this._readCapability.resolve();
  14892. });
  14893. readableStream.on("end", () => {
  14894. readableStream.destroy();
  14895. this._done = true;
  14896. this._readCapability.resolve();
  14897. });
  14898. readableStream.on("error", reason => {
  14899. this._error(reason);
  14900. });
  14901. if (!this._isStreamingSupported && this._isRangeSupported) {
  14902. this._error(new _util.AbortException("streaming is disabled"));
  14903. }
  14904. if (this._storedError) {
  14905. this._readableStream.destroy(this._storedError);
  14906. }
  14907. }
  14908. }
  14909. class BaseRangeReader {
  14910. constructor(stream) {
  14911. this._url = stream.url;
  14912. this._done = false;
  14913. this._storedError = null;
  14914. this.onProgress = null;
  14915. this._loaded = 0;
  14916. this._readableStream = null;
  14917. this._readCapability = new _util.PromiseCapability();
  14918. const source = stream.source;
  14919. this._isStreamingSupported = !source.disableStream;
  14920. }
  14921. get isStreamingSupported() {
  14922. return this._isStreamingSupported;
  14923. }
  14924. async read() {
  14925. await this._readCapability.promise;
  14926. if (this._done) {
  14927. return {
  14928. value: undefined,
  14929. done: true
  14930. };
  14931. }
  14932. if (this._storedError) {
  14933. throw this._storedError;
  14934. }
  14935. const chunk = this._readableStream.read();
  14936. if (chunk === null) {
  14937. this._readCapability = new _util.PromiseCapability();
  14938. return this.read();
  14939. }
  14940. this._loaded += chunk.length;
  14941. this.onProgress?.({
  14942. loaded: this._loaded
  14943. });
  14944. const buffer = new Uint8Array(chunk).buffer;
  14945. return {
  14946. value: buffer,
  14947. done: false
  14948. };
  14949. }
  14950. cancel(reason) {
  14951. if (!this._readableStream) {
  14952. this._error(reason);
  14953. return;
  14954. }
  14955. this._readableStream.destroy(reason);
  14956. }
  14957. _error(reason) {
  14958. this._storedError = reason;
  14959. this._readCapability.resolve();
  14960. }
  14961. _setReadableStream(readableStream) {
  14962. this._readableStream = readableStream;
  14963. readableStream.on("readable", () => {
  14964. this._readCapability.resolve();
  14965. });
  14966. readableStream.on("end", () => {
  14967. readableStream.destroy();
  14968. this._done = true;
  14969. this._readCapability.resolve();
  14970. });
  14971. readableStream.on("error", reason => {
  14972. this._error(reason);
  14973. });
  14974. if (this._storedError) {
  14975. this._readableStream.destroy(this._storedError);
  14976. }
  14977. }
  14978. }
  14979. function createRequestOptions(parsedUrl, headers) {
  14980. return {
  14981. protocol: parsedUrl.protocol,
  14982. auth: parsedUrl.auth,
  14983. host: parsedUrl.hostname,
  14984. port: parsedUrl.port,
  14985. path: parsedUrl.path,
  14986. method: "GET",
  14987. headers
  14988. };
  14989. }
  14990. class PDFNodeStreamFullReader extends BaseFullReader {
  14991. constructor(stream) {
  14992. super(stream);
  14993. const handleResponse = response => {
  14994. if (response.statusCode === 404) {
  14995. const error = new _util.MissingPDFException(`Missing PDF "${this._url}".`);
  14996. this._storedError = error;
  14997. this._headersCapability.reject(error);
  14998. return;
  14999. }
  15000. this._headersCapability.resolve();
  15001. this._setReadableStream(response);
  15002. const getResponseHeader = name => {
  15003. return this._readableStream.headers[name.toLowerCase()];
  15004. };
  15005. const {
  15006. allowRangeRequests,
  15007. suggestedLength
  15008. } = (0, _network_utils.validateRangeRequestCapabilities)({
  15009. getResponseHeader,
  15010. isHttp: stream.isHttp,
  15011. rangeChunkSize: this._rangeChunkSize,
  15012. disableRange: this._disableRange
  15013. });
  15014. this._isRangeSupported = allowRangeRequests;
  15015. this._contentLength = suggestedLength || this._contentLength;
  15016. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  15017. };
  15018. this._request = null;
  15019. if (this._url.protocol === "http:") {
  15020. const http = require("http");
  15021. this._request = http.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
  15022. } else {
  15023. const https = require("https");
  15024. this._request = https.request(createRequestOptions(this._url, stream.httpHeaders), handleResponse);
  15025. }
  15026. this._request.on("error", reason => {
  15027. this._storedError = reason;
  15028. this._headersCapability.reject(reason);
  15029. });
  15030. this._request.end();
  15031. }
  15032. }
  15033. class PDFNodeStreamRangeReader extends BaseRangeReader {
  15034. constructor(stream, start, end) {
  15035. super(stream);
  15036. this._httpHeaders = {};
  15037. for (const property in stream.httpHeaders) {
  15038. const value = stream.httpHeaders[property];
  15039. if (value === undefined) {
  15040. continue;
  15041. }
  15042. this._httpHeaders[property] = value;
  15043. }
  15044. this._httpHeaders.Range = `bytes=${start}-${end - 1}`;
  15045. const handleResponse = response => {
  15046. if (response.statusCode === 404) {
  15047. const error = new _util.MissingPDFException(`Missing PDF "${this._url}".`);
  15048. this._storedError = error;
  15049. return;
  15050. }
  15051. this._setReadableStream(response);
  15052. };
  15053. this._request = null;
  15054. if (this._url.protocol === "http:") {
  15055. const http = require("http");
  15056. this._request = http.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
  15057. } else {
  15058. const https = require("https");
  15059. this._request = https.request(createRequestOptions(this._url, this._httpHeaders), handleResponse);
  15060. }
  15061. this._request.on("error", reason => {
  15062. this._storedError = reason;
  15063. });
  15064. this._request.end();
  15065. }
  15066. }
  15067. class PDFNodeStreamFsFullReader extends BaseFullReader {
  15068. constructor(stream) {
  15069. super(stream);
  15070. let path = decodeURIComponent(this._url.path);
  15071. if (fileUriRegex.test(this._url.href)) {
  15072. path = path.replace(/^\//, "");
  15073. }
  15074. const fs = require("fs");
  15075. fs.lstat(path, (error, stat) => {
  15076. if (error) {
  15077. if (error.code === "ENOENT") {
  15078. error = new _util.MissingPDFException(`Missing PDF "${path}".`);
  15079. }
  15080. this._storedError = error;
  15081. this._headersCapability.reject(error);
  15082. return;
  15083. }
  15084. this._contentLength = stat.size;
  15085. this._setReadableStream(fs.createReadStream(path));
  15086. this._headersCapability.resolve();
  15087. });
  15088. }
  15089. }
  15090. class PDFNodeStreamFsRangeReader extends BaseRangeReader {
  15091. constructor(stream, start, end) {
  15092. super(stream);
  15093. let path = decodeURIComponent(this._url.path);
  15094. if (fileUriRegex.test(this._url.href)) {
  15095. path = path.replace(/^\//, "");
  15096. }
  15097. const fs = require("fs");
  15098. this._setReadableStream(fs.createReadStream(path, {
  15099. start,
  15100. end: end - 1
  15101. }));
  15102. }
  15103. }
  15104. /***/ }),
  15105. /* 186 */
  15106. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  15107. Object.defineProperty(exports, "__esModule", ({
  15108. value: true
  15109. }));
  15110. exports.SVGGraphics = void 0;
  15111. __w_pdfjs_require__(84);
  15112. __w_pdfjs_require__(86);
  15113. __w_pdfjs_require__(87);
  15114. __w_pdfjs_require__(93);
  15115. __w_pdfjs_require__(101);
  15116. __w_pdfjs_require__(102);
  15117. __w_pdfjs_require__(105);
  15118. __w_pdfjs_require__(107);
  15119. __w_pdfjs_require__(109);
  15120. __w_pdfjs_require__(113);
  15121. __w_pdfjs_require__(116);
  15122. __w_pdfjs_require__(123);
  15123. __w_pdfjs_require__(2);
  15124. __w_pdfjs_require__(89);
  15125. __w_pdfjs_require__(187);
  15126. var _display_utils = __w_pdfjs_require__(168);
  15127. var _util = __w_pdfjs_require__(1);
  15128. ;
  15129. const SVG_DEFAULTS = {
  15130. fontStyle: "normal",
  15131. fontWeight: "normal",
  15132. fillColor: "#000000"
  15133. };
  15134. const XML_NS = "http://www.w3.org/XML/1998/namespace";
  15135. const XLINK_NS = "http://www.w3.org/1999/xlink";
  15136. const LINE_CAP_STYLES = ["butt", "round", "square"];
  15137. const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
  15138. const createObjectURL = function (data) {
  15139. let contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  15140. let forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15141. if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) {
  15142. return URL.createObjectURL(new Blob([data], {
  15143. type: contentType
  15144. }));
  15145. }
  15146. const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  15147. let buffer = `data:${contentType};base64,`;
  15148. for (let i = 0, ii = data.length; i < ii; i += 3) {
  15149. const b1 = data[i] & 0xff;
  15150. const b2 = data[i + 1] & 0xff;
  15151. const b3 = data[i + 2] & 0xff;
  15152. const d1 = b1 >> 2,
  15153. d2 = (b1 & 3) << 4 | b2 >> 4;
  15154. const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  15155. const d4 = i + 2 < ii ? b3 & 0x3f : 64;
  15156. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  15157. }
  15158. return buffer;
  15159. };
  15160. const convertImgDataToPng = function () {
  15161. const PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  15162. const CHUNK_WRAPPER_SIZE = 12;
  15163. const crcTable = new Int32Array(256);
  15164. for (let i = 0; i < 256; i++) {
  15165. let c = i;
  15166. for (let h = 0; h < 8; h++) {
  15167. c = c & 1 ? 0xedb88320 ^ c >> 1 & 0x7fffffff : c >> 1 & 0x7fffffff;
  15168. }
  15169. crcTable[i] = c;
  15170. }
  15171. function crc32(data, start, end) {
  15172. let crc = -1;
  15173. for (let i = start; i < end; i++) {
  15174. const a = (crc ^ data[i]) & 0xff;
  15175. const b = crcTable[a];
  15176. crc = crc >>> 8 ^ b;
  15177. }
  15178. return crc ^ -1;
  15179. }
  15180. function writePngChunk(type, body, data, offset) {
  15181. let p = offset;
  15182. const len = body.length;
  15183. data[p] = len >> 24 & 0xff;
  15184. data[p + 1] = len >> 16 & 0xff;
  15185. data[p + 2] = len >> 8 & 0xff;
  15186. data[p + 3] = len & 0xff;
  15187. p += 4;
  15188. data[p] = type.charCodeAt(0) & 0xff;
  15189. data[p + 1] = type.charCodeAt(1) & 0xff;
  15190. data[p + 2] = type.charCodeAt(2) & 0xff;
  15191. data[p + 3] = type.charCodeAt(3) & 0xff;
  15192. p += 4;
  15193. data.set(body, p);
  15194. p += body.length;
  15195. const crc = crc32(data, offset + 4, p);
  15196. data[p] = crc >> 24 & 0xff;
  15197. data[p + 1] = crc >> 16 & 0xff;
  15198. data[p + 2] = crc >> 8 & 0xff;
  15199. data[p + 3] = crc & 0xff;
  15200. }
  15201. function adler32(data, start, end) {
  15202. let a = 1;
  15203. let b = 0;
  15204. for (let i = start; i < end; ++i) {
  15205. a = (a + (data[i] & 0xff)) % 65521;
  15206. b = (b + a) % 65521;
  15207. }
  15208. return b << 16 | a;
  15209. }
  15210. function deflateSync(literals) {
  15211. if (!_util.isNodeJS) {
  15212. return deflateSyncUncompressed(literals);
  15213. }
  15214. try {
  15215. const input = parseInt(process.versions.node) >= 8 ? literals : Buffer.from(literals);
  15216. const output = require("zlib").deflateSync(input, {
  15217. level: 9
  15218. });
  15219. return output instanceof Uint8Array ? output : new Uint8Array(output);
  15220. } catch (e) {
  15221. (0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
  15222. }
  15223. return deflateSyncUncompressed(literals);
  15224. }
  15225. function deflateSyncUncompressed(literals) {
  15226. let len = literals.length;
  15227. const maxBlockLength = 0xffff;
  15228. const deflateBlocks = Math.ceil(len / maxBlockLength);
  15229. const idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  15230. let pi = 0;
  15231. idat[pi++] = 0x78;
  15232. idat[pi++] = 0x9c;
  15233. let pos = 0;
  15234. while (len > maxBlockLength) {
  15235. idat[pi++] = 0x00;
  15236. idat[pi++] = 0xff;
  15237. idat[pi++] = 0xff;
  15238. idat[pi++] = 0x00;
  15239. idat[pi++] = 0x00;
  15240. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  15241. pi += maxBlockLength;
  15242. pos += maxBlockLength;
  15243. len -= maxBlockLength;
  15244. }
  15245. idat[pi++] = 0x01;
  15246. idat[pi++] = len & 0xff;
  15247. idat[pi++] = len >> 8 & 0xff;
  15248. idat[pi++] = ~len & 0xffff & 0xff;
  15249. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  15250. idat.set(literals.subarray(pos), pi);
  15251. pi += literals.length - pos;
  15252. const adler = adler32(literals, 0, literals.length);
  15253. idat[pi++] = adler >> 24 & 0xff;
  15254. idat[pi++] = adler >> 16 & 0xff;
  15255. idat[pi++] = adler >> 8 & 0xff;
  15256. idat[pi++] = adler & 0xff;
  15257. return idat;
  15258. }
  15259. function encode(imgData, kind, forceDataSchema, isMask) {
  15260. const width = imgData.width;
  15261. const height = imgData.height;
  15262. let bitDepth, colorType, lineSize;
  15263. const bytes = imgData.data;
  15264. switch (kind) {
  15265. case _util.ImageKind.GRAYSCALE_1BPP:
  15266. colorType = 0;
  15267. bitDepth = 1;
  15268. lineSize = width + 7 >> 3;
  15269. break;
  15270. case _util.ImageKind.RGB_24BPP:
  15271. colorType = 2;
  15272. bitDepth = 8;
  15273. lineSize = width * 3;
  15274. break;
  15275. case _util.ImageKind.RGBA_32BPP:
  15276. colorType = 6;
  15277. bitDepth = 8;
  15278. lineSize = width * 4;
  15279. break;
  15280. default:
  15281. throw new Error("invalid format");
  15282. }
  15283. const literals = new Uint8Array((1 + lineSize) * height);
  15284. let offsetLiterals = 0,
  15285. offsetBytes = 0;
  15286. for (let y = 0; y < height; ++y) {
  15287. literals[offsetLiterals++] = 0;
  15288. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  15289. offsetBytes += lineSize;
  15290. offsetLiterals += lineSize;
  15291. }
  15292. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  15293. offsetLiterals = 0;
  15294. for (let y = 0; y < height; y++) {
  15295. offsetLiterals++;
  15296. for (let i = 0; i < lineSize; i++) {
  15297. literals[offsetLiterals++] ^= 0xff;
  15298. }
  15299. }
  15300. }
  15301. const 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]);
  15302. const idat = deflateSync(literals);
  15303. const pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  15304. const data = new Uint8Array(pngLength);
  15305. let offset = 0;
  15306. data.set(PNG_HEADER, offset);
  15307. offset += PNG_HEADER.length;
  15308. writePngChunk("IHDR", ihdr, data, offset);
  15309. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  15310. writePngChunk("IDATA", idat, data, offset);
  15311. offset += CHUNK_WRAPPER_SIZE + idat.length;
  15312. writePngChunk("IEND", new Uint8Array(0), data, offset);
  15313. return createObjectURL(data, "image/png", forceDataSchema);
  15314. }
  15315. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  15316. const kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  15317. return encode(imgData, kind, forceDataSchema, isMask);
  15318. };
  15319. }();
  15320. class SVGExtraState {
  15321. constructor() {
  15322. this.fontSizeScale = 1;
  15323. this.fontWeight = SVG_DEFAULTS.fontWeight;
  15324. this.fontSize = 0;
  15325. this.textMatrix = _util.IDENTITY_MATRIX;
  15326. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  15327. this.leading = 0;
  15328. this.textRenderingMode = _util.TextRenderingMode.FILL;
  15329. this.textMatrixScale = 1;
  15330. this.x = 0;
  15331. this.y = 0;
  15332. this.lineX = 0;
  15333. this.lineY = 0;
  15334. this.charSpacing = 0;
  15335. this.wordSpacing = 0;
  15336. this.textHScale = 1;
  15337. this.textRise = 0;
  15338. this.fillColor = SVG_DEFAULTS.fillColor;
  15339. this.strokeColor = "#000000";
  15340. this.fillAlpha = 1;
  15341. this.strokeAlpha = 1;
  15342. this.lineWidth = 1;
  15343. this.lineJoin = "";
  15344. this.lineCap = "";
  15345. this.miterLimit = 0;
  15346. this.dashArray = [];
  15347. this.dashPhase = 0;
  15348. this.dependencies = [];
  15349. this.activeClipUrl = null;
  15350. this.clipGroup = null;
  15351. this.maskId = "";
  15352. }
  15353. clone() {
  15354. return Object.create(this);
  15355. }
  15356. setCurrentPoint(x, y) {
  15357. this.x = x;
  15358. this.y = y;
  15359. }
  15360. }
  15361. function opListToTree(opList) {
  15362. let opTree = [];
  15363. const tmp = [];
  15364. for (const opListElement of opList) {
  15365. if (opListElement.fn === "save") {
  15366. opTree.push({
  15367. fnId: 92,
  15368. fn: "group",
  15369. items: []
  15370. });
  15371. tmp.push(opTree);
  15372. opTree = opTree.at(-1).items;
  15373. continue;
  15374. }
  15375. if (opListElement.fn === "restore") {
  15376. opTree = tmp.pop();
  15377. } else {
  15378. opTree.push(opListElement);
  15379. }
  15380. }
  15381. return opTree;
  15382. }
  15383. function pf(value) {
  15384. if (Number.isInteger(value)) {
  15385. return value.toString();
  15386. }
  15387. const s = value.toFixed(10);
  15388. let i = s.length - 1;
  15389. if (s[i] !== "0") {
  15390. return s;
  15391. }
  15392. do {
  15393. i--;
  15394. } while (s[i] === "0");
  15395. return s.substring(0, s[i] === "." ? i : i + 1);
  15396. }
  15397. function pm(m) {
  15398. if (m[4] === 0 && m[5] === 0) {
  15399. if (m[1] === 0 && m[2] === 0) {
  15400. if (m[0] === 1 && m[3] === 1) {
  15401. return "";
  15402. }
  15403. return `scale(${pf(m[0])} ${pf(m[3])})`;
  15404. }
  15405. if (m[0] === m[3] && m[1] === -m[2]) {
  15406. const a = Math.acos(m[0]) * 180 / Math.PI;
  15407. return `rotate(${pf(a)})`;
  15408. }
  15409. } else if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  15410. return `translate(${pf(m[4])} ${pf(m[5])})`;
  15411. }
  15412. return `matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` + `${pf(m[5])})`;
  15413. }
  15414. let clipCount = 0;
  15415. let maskCount = 0;
  15416. let shadingCount = 0;
  15417. class SVGGraphics {
  15418. constructor(commonObjs, objs) {
  15419. let forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15420. (0, _display_utils.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future.");
  15421. this.svgFactory = new _display_utils.DOMSVGFactory();
  15422. this.current = new SVGExtraState();
  15423. this.transformMatrix = _util.IDENTITY_MATRIX;
  15424. this.transformStack = [];
  15425. this.extraStack = [];
  15426. this.commonObjs = commonObjs;
  15427. this.objs = objs;
  15428. this.pendingClip = null;
  15429. this.pendingEOFill = false;
  15430. this.embedFonts = false;
  15431. this.embeddedFonts = Object.create(null);
  15432. this.cssStyle = null;
  15433. this.forceDataSchema = !!forceDataSchema;
  15434. this._operatorIdMapping = [];
  15435. for (const op in _util.OPS) {
  15436. this._operatorIdMapping[_util.OPS[op]] = op;
  15437. }
  15438. }
  15439. getObject(data) {
  15440. let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  15441. if (typeof data === "string") {
  15442. return data.startsWith("g_") ? this.commonObjs.get(data) : this.objs.get(data);
  15443. }
  15444. return fallback;
  15445. }
  15446. save() {
  15447. this.transformStack.push(this.transformMatrix);
  15448. const old = this.current;
  15449. this.extraStack.push(old);
  15450. this.current = old.clone();
  15451. }
  15452. restore() {
  15453. this.transformMatrix = this.transformStack.pop();
  15454. this.current = this.extraStack.pop();
  15455. this.pendingClip = null;
  15456. this.tgrp = null;
  15457. }
  15458. group(items) {
  15459. this.save();
  15460. this.executeOpTree(items);
  15461. this.restore();
  15462. }
  15463. loadDependencies(operatorList) {
  15464. const fnArray = operatorList.fnArray;
  15465. const argsArray = operatorList.argsArray;
  15466. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  15467. if (fnArray[i] !== _util.OPS.dependency) {
  15468. continue;
  15469. }
  15470. for (const obj of argsArray[i]) {
  15471. const objsPool = obj.startsWith("g_") ? this.commonObjs : this.objs;
  15472. const promise = new Promise(resolve => {
  15473. objsPool.get(obj, resolve);
  15474. });
  15475. this.current.dependencies.push(promise);
  15476. }
  15477. }
  15478. return Promise.all(this.current.dependencies);
  15479. }
  15480. transform(a, b, c, d, e, f) {
  15481. const transformMatrix = [a, b, c, d, e, f];
  15482. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  15483. this.tgrp = null;
  15484. }
  15485. getSVG(operatorList, viewport) {
  15486. this.viewport = viewport;
  15487. const svgElement = this._initialize(viewport);
  15488. return this.loadDependencies(operatorList).then(() => {
  15489. this.transformMatrix = _util.IDENTITY_MATRIX;
  15490. this.executeOpTree(this.convertOpList(operatorList));
  15491. return svgElement;
  15492. });
  15493. }
  15494. convertOpList(operatorList) {
  15495. const operatorIdMapping = this._operatorIdMapping;
  15496. const argsArray = operatorList.argsArray;
  15497. const fnArray = operatorList.fnArray;
  15498. const opList = [];
  15499. for (let i = 0, ii = fnArray.length; i < ii; i++) {
  15500. const fnId = fnArray[i];
  15501. opList.push({
  15502. fnId,
  15503. fn: operatorIdMapping[fnId],
  15504. args: argsArray[i]
  15505. });
  15506. }
  15507. return opListToTree(opList);
  15508. }
  15509. executeOpTree(opTree) {
  15510. for (const opTreeElement of opTree) {
  15511. const fn = opTreeElement.fn;
  15512. const fnId = opTreeElement.fnId;
  15513. const args = opTreeElement.args;
  15514. switch (fnId | 0) {
  15515. case _util.OPS.beginText:
  15516. this.beginText();
  15517. break;
  15518. case _util.OPS.dependency:
  15519. break;
  15520. case _util.OPS.setLeading:
  15521. this.setLeading(args);
  15522. break;
  15523. case _util.OPS.setLeadingMoveText:
  15524. this.setLeadingMoveText(args[0], args[1]);
  15525. break;
  15526. case _util.OPS.setFont:
  15527. this.setFont(args);
  15528. break;
  15529. case _util.OPS.showText:
  15530. this.showText(args[0]);
  15531. break;
  15532. case _util.OPS.showSpacedText:
  15533. this.showText(args[0]);
  15534. break;
  15535. case _util.OPS.endText:
  15536. this.endText();
  15537. break;
  15538. case _util.OPS.moveText:
  15539. this.moveText(args[0], args[1]);
  15540. break;
  15541. case _util.OPS.setCharSpacing:
  15542. this.setCharSpacing(args[0]);
  15543. break;
  15544. case _util.OPS.setWordSpacing:
  15545. this.setWordSpacing(args[0]);
  15546. break;
  15547. case _util.OPS.setHScale:
  15548. this.setHScale(args[0]);
  15549. break;
  15550. case _util.OPS.setTextMatrix:
  15551. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  15552. break;
  15553. case _util.OPS.setTextRise:
  15554. this.setTextRise(args[0]);
  15555. break;
  15556. case _util.OPS.setTextRenderingMode:
  15557. this.setTextRenderingMode(args[0]);
  15558. break;
  15559. case _util.OPS.setLineWidth:
  15560. this.setLineWidth(args[0]);
  15561. break;
  15562. case _util.OPS.setLineJoin:
  15563. this.setLineJoin(args[0]);
  15564. break;
  15565. case _util.OPS.setLineCap:
  15566. this.setLineCap(args[0]);
  15567. break;
  15568. case _util.OPS.setMiterLimit:
  15569. this.setMiterLimit(args[0]);
  15570. break;
  15571. case _util.OPS.setFillRGBColor:
  15572. this.setFillRGBColor(args[0], args[1], args[2]);
  15573. break;
  15574. case _util.OPS.setStrokeRGBColor:
  15575. this.setStrokeRGBColor(args[0], args[1], args[2]);
  15576. break;
  15577. case _util.OPS.setStrokeColorN:
  15578. this.setStrokeColorN(args);
  15579. break;
  15580. case _util.OPS.setFillColorN:
  15581. this.setFillColorN(args);
  15582. break;
  15583. case _util.OPS.shadingFill:
  15584. this.shadingFill(args[0]);
  15585. break;
  15586. case _util.OPS.setDash:
  15587. this.setDash(args[0], args[1]);
  15588. break;
  15589. case _util.OPS.setRenderingIntent:
  15590. this.setRenderingIntent(args[0]);
  15591. break;
  15592. case _util.OPS.setFlatness:
  15593. this.setFlatness(args[0]);
  15594. break;
  15595. case _util.OPS.setGState:
  15596. this.setGState(args[0]);
  15597. break;
  15598. case _util.OPS.fill:
  15599. this.fill();
  15600. break;
  15601. case _util.OPS.eoFill:
  15602. this.eoFill();
  15603. break;
  15604. case _util.OPS.stroke:
  15605. this.stroke();
  15606. break;
  15607. case _util.OPS.fillStroke:
  15608. this.fillStroke();
  15609. break;
  15610. case _util.OPS.eoFillStroke:
  15611. this.eoFillStroke();
  15612. break;
  15613. case _util.OPS.clip:
  15614. this.clip("nonzero");
  15615. break;
  15616. case _util.OPS.eoClip:
  15617. this.clip("evenodd");
  15618. break;
  15619. case _util.OPS.paintSolidColorImageMask:
  15620. this.paintSolidColorImageMask();
  15621. break;
  15622. case _util.OPS.paintImageXObject:
  15623. this.paintImageXObject(args[0]);
  15624. break;
  15625. case _util.OPS.paintInlineImageXObject:
  15626. this.paintInlineImageXObject(args[0]);
  15627. break;
  15628. case _util.OPS.paintImageMaskXObject:
  15629. this.paintImageMaskXObject(args[0]);
  15630. break;
  15631. case _util.OPS.paintFormXObjectBegin:
  15632. this.paintFormXObjectBegin(args[0], args[1]);
  15633. break;
  15634. case _util.OPS.paintFormXObjectEnd:
  15635. this.paintFormXObjectEnd();
  15636. break;
  15637. case _util.OPS.closePath:
  15638. this.closePath();
  15639. break;
  15640. case _util.OPS.closeStroke:
  15641. this.closeStroke();
  15642. break;
  15643. case _util.OPS.closeFillStroke:
  15644. this.closeFillStroke();
  15645. break;
  15646. case _util.OPS.closeEOFillStroke:
  15647. this.closeEOFillStroke();
  15648. break;
  15649. case _util.OPS.nextLine:
  15650. this.nextLine();
  15651. break;
  15652. case _util.OPS.transform:
  15653. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  15654. break;
  15655. case _util.OPS.constructPath:
  15656. this.constructPath(args[0], args[1]);
  15657. break;
  15658. case _util.OPS.endPath:
  15659. this.endPath();
  15660. break;
  15661. case 92:
  15662. this.group(opTreeElement.items);
  15663. break;
  15664. default:
  15665. (0, _util.warn)(`Unimplemented operator ${fn}`);
  15666. break;
  15667. }
  15668. }
  15669. }
  15670. setWordSpacing(wordSpacing) {
  15671. this.current.wordSpacing = wordSpacing;
  15672. }
  15673. setCharSpacing(charSpacing) {
  15674. this.current.charSpacing = charSpacing;
  15675. }
  15676. nextLine() {
  15677. this.moveText(0, this.current.leading);
  15678. }
  15679. setTextMatrix(a, b, c, d, e, f) {
  15680. const current = this.current;
  15681. current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
  15682. current.textMatrixScale = Math.hypot(a, b);
  15683. current.x = current.lineX = 0;
  15684. current.y = current.lineY = 0;
  15685. current.xcoords = [];
  15686. current.ycoords = [];
  15687. current.tspan = this.svgFactory.createElement("svg:tspan");
  15688. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  15689. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  15690. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  15691. current.txtElement = this.svgFactory.createElement("svg:text");
  15692. current.txtElement.append(current.tspan);
  15693. }
  15694. beginText() {
  15695. const current = this.current;
  15696. current.x = current.lineX = 0;
  15697. current.y = current.lineY = 0;
  15698. current.textMatrix = _util.IDENTITY_MATRIX;
  15699. current.lineMatrix = _util.IDENTITY_MATRIX;
  15700. current.textMatrixScale = 1;
  15701. current.tspan = this.svgFactory.createElement("svg:tspan");
  15702. current.txtElement = this.svgFactory.createElement("svg:text");
  15703. current.txtgrp = this.svgFactory.createElement("svg:g");
  15704. current.xcoords = [];
  15705. current.ycoords = [];
  15706. }
  15707. moveText(x, y) {
  15708. const current = this.current;
  15709. current.x = current.lineX += x;
  15710. current.y = current.lineY += y;
  15711. current.xcoords = [];
  15712. current.ycoords = [];
  15713. current.tspan = this.svgFactory.createElement("svg:tspan");
  15714. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  15715. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  15716. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  15717. }
  15718. showText(glyphs) {
  15719. const current = this.current;
  15720. const font = current.font;
  15721. const fontSize = current.fontSize;
  15722. if (fontSize === 0) {
  15723. return;
  15724. }
  15725. const fontSizeScale = current.fontSizeScale;
  15726. const charSpacing = current.charSpacing;
  15727. const wordSpacing = current.wordSpacing;
  15728. const fontDirection = current.fontDirection;
  15729. const textHScale = current.textHScale * fontDirection;
  15730. const vertical = font.vertical;
  15731. const spacingDir = vertical ? 1 : -1;
  15732. const defaultVMetrics = font.defaultVMetrics;
  15733. const widthAdvanceScale = fontSize * current.fontMatrix[0];
  15734. let x = 0;
  15735. for (const glyph of glyphs) {
  15736. if (glyph === null) {
  15737. x += fontDirection * wordSpacing;
  15738. continue;
  15739. } else if (typeof glyph === "number") {
  15740. x += spacingDir * glyph * fontSize / 1000;
  15741. continue;
  15742. }
  15743. const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  15744. const character = glyph.fontChar;
  15745. let scaledX, scaledY;
  15746. let width = glyph.width;
  15747. if (vertical) {
  15748. let vx;
  15749. const vmetric = glyph.vmetric || defaultVMetrics;
  15750. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  15751. vx = -vx * widthAdvanceScale;
  15752. const vy = vmetric[2] * widthAdvanceScale;
  15753. width = vmetric ? -vmetric[0] : width;
  15754. scaledX = vx / fontSizeScale;
  15755. scaledY = (x + vy) / fontSizeScale;
  15756. } else {
  15757. scaledX = x / fontSizeScale;
  15758. scaledY = 0;
  15759. }
  15760. if (glyph.isInFont || font.missingFile) {
  15761. current.xcoords.push(current.x + scaledX);
  15762. if (vertical) {
  15763. current.ycoords.push(-current.y + scaledY);
  15764. }
  15765. current.tspan.textContent += character;
  15766. } else {}
  15767. const charWidth = vertical ? width * widthAdvanceScale - spacing * fontDirection : width * widthAdvanceScale + spacing * fontDirection;
  15768. x += charWidth;
  15769. }
  15770. current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
  15771. if (vertical) {
  15772. current.tspan.setAttributeNS(null, "y", current.ycoords.map(pf).join(" "));
  15773. } else {
  15774. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  15775. }
  15776. if (vertical) {
  15777. current.y -= x;
  15778. } else {
  15779. current.x += x * textHScale;
  15780. }
  15781. current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
  15782. current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
  15783. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  15784. current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
  15785. }
  15786. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  15787. current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
  15788. }
  15789. const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  15790. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15791. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  15792. current.tspan.setAttributeNS(null, "fill", current.fillColor);
  15793. }
  15794. if (current.fillAlpha < 1) {
  15795. current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  15796. }
  15797. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  15798. current.tspan.setAttributeNS(null, "fill", "transparent");
  15799. } else {
  15800. current.tspan.setAttributeNS(null, "fill", "none");
  15801. }
  15802. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15803. const lineWidthScale = 1 / (current.textMatrixScale || 1);
  15804. this._setStrokeAttributes(current.tspan, lineWidthScale);
  15805. }
  15806. let textMatrix = current.textMatrix;
  15807. if (current.textRise !== 0) {
  15808. textMatrix = textMatrix.slice();
  15809. textMatrix[5] += current.textRise;
  15810. }
  15811. current.txtElement.setAttributeNS(null, "transform", `${pm(textMatrix)} scale(${pf(textHScale)}, -1)`);
  15812. current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
  15813. current.txtElement.append(current.tspan);
  15814. current.txtgrp.append(current.txtElement);
  15815. this._ensureTransformGroup().append(current.txtElement);
  15816. }
  15817. setLeadingMoveText(x, y) {
  15818. this.setLeading(-y);
  15819. this.moveText(x, y);
  15820. }
  15821. addFontStyle(fontObj) {
  15822. if (!fontObj.data) {
  15823. throw new Error("addFontStyle: No font data available, " + 'ensure that the "fontExtraProperties" API parameter is set.');
  15824. }
  15825. if (!this.cssStyle) {
  15826. this.cssStyle = this.svgFactory.createElement("svg:style");
  15827. this.cssStyle.setAttributeNS(null, "type", "text/css");
  15828. this.defs.append(this.cssStyle);
  15829. }
  15830. const url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  15831. this.cssStyle.textContent += `@font-face { font-family: "${fontObj.loadedName}";` + ` src: url(${url}); }\n`;
  15832. }
  15833. setFont(details) {
  15834. const current = this.current;
  15835. const fontObj = this.commonObjs.get(details[0]);
  15836. let size = details[1];
  15837. current.font = fontObj;
  15838. if (this.embedFonts && !fontObj.missingFile && !this.embeddedFonts[fontObj.loadedName]) {
  15839. this.addFontStyle(fontObj);
  15840. this.embeddedFonts[fontObj.loadedName] = fontObj;
  15841. }
  15842. current.fontMatrix = fontObj.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  15843. let bold = "normal";
  15844. if (fontObj.black) {
  15845. bold = "900";
  15846. } else if (fontObj.bold) {
  15847. bold = "bold";
  15848. }
  15849. const italic = fontObj.italic ? "italic" : "normal";
  15850. if (size < 0) {
  15851. size = -size;
  15852. current.fontDirection = -1;
  15853. } else {
  15854. current.fontDirection = 1;
  15855. }
  15856. current.fontSize = size;
  15857. current.fontFamily = fontObj.loadedName;
  15858. current.fontWeight = bold;
  15859. current.fontStyle = italic;
  15860. current.tspan = this.svgFactory.createElement("svg:tspan");
  15861. current.tspan.setAttributeNS(null, "y", pf(-current.y));
  15862. current.xcoords = [];
  15863. current.ycoords = [];
  15864. }
  15865. endText() {
  15866. const current = this.current;
  15867. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement?.hasChildNodes()) {
  15868. current.element = current.txtElement;
  15869. this.clip("nonzero");
  15870. this.endPath();
  15871. }
  15872. }
  15873. setLineWidth(width) {
  15874. if (width > 0) {
  15875. this.current.lineWidth = width;
  15876. }
  15877. }
  15878. setLineCap(style) {
  15879. this.current.lineCap = LINE_CAP_STYLES[style];
  15880. }
  15881. setLineJoin(style) {
  15882. this.current.lineJoin = LINE_JOIN_STYLES[style];
  15883. }
  15884. setMiterLimit(limit) {
  15885. this.current.miterLimit = limit;
  15886. }
  15887. setStrokeAlpha(strokeAlpha) {
  15888. this.current.strokeAlpha = strokeAlpha;
  15889. }
  15890. setStrokeRGBColor(r, g, b) {
  15891. this.current.strokeColor = _util.Util.makeHexColor(r, g, b);
  15892. }
  15893. setFillAlpha(fillAlpha) {
  15894. this.current.fillAlpha = fillAlpha;
  15895. }
  15896. setFillRGBColor(r, g, b) {
  15897. this.current.fillColor = _util.Util.makeHexColor(r, g, b);
  15898. this.current.tspan = this.svgFactory.createElement("svg:tspan");
  15899. this.current.xcoords = [];
  15900. this.current.ycoords = [];
  15901. }
  15902. setStrokeColorN(args) {
  15903. this.current.strokeColor = this._makeColorN_Pattern(args);
  15904. }
  15905. setFillColorN(args) {
  15906. this.current.fillColor = this._makeColorN_Pattern(args);
  15907. }
  15908. shadingFill(args) {
  15909. const {
  15910. width,
  15911. height
  15912. } = this.viewport;
  15913. const inv = _util.Util.inverseTransform(this.transformMatrix);
  15914. const [x0, y0, x1, y1] = _util.Util.getAxialAlignedBoundingBox([0, 0, width, height], inv);
  15915. const rect = this.svgFactory.createElement("svg:rect");
  15916. rect.setAttributeNS(null, "x", x0);
  15917. rect.setAttributeNS(null, "y", y0);
  15918. rect.setAttributeNS(null, "width", x1 - x0);
  15919. rect.setAttributeNS(null, "height", y1 - y0);
  15920. rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
  15921. if (this.current.fillAlpha < 1) {
  15922. rect.setAttributeNS(null, "fill-opacity", this.current.fillAlpha);
  15923. }
  15924. this._ensureTransformGroup().append(rect);
  15925. }
  15926. _makeColorN_Pattern(args) {
  15927. if (args[0] === "TilingPattern") {
  15928. return this._makeTilingPattern(args);
  15929. }
  15930. return this._makeShadingPattern(args);
  15931. }
  15932. _makeTilingPattern(args) {
  15933. const color = args[1];
  15934. const operatorList = args[2];
  15935. const matrix = args[3] || _util.IDENTITY_MATRIX;
  15936. const [x0, y0, x1, y1] = args[4];
  15937. const xstep = args[5];
  15938. const ystep = args[6];
  15939. const paintType = args[7];
  15940. const tilingId = `shading${shadingCount++}`;
  15941. const [tx0, ty0, tx1, ty1] = _util.Util.normalizeRect([..._util.Util.applyTransform([x0, y0], matrix), ..._util.Util.applyTransform([x1, y1], matrix)]);
  15942. const [xscale, yscale] = _util.Util.singularValueDecompose2dScale(matrix);
  15943. const txstep = xstep * xscale;
  15944. const tystep = ystep * yscale;
  15945. const tiling = this.svgFactory.createElement("svg:pattern");
  15946. tiling.setAttributeNS(null, "id", tilingId);
  15947. tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
  15948. tiling.setAttributeNS(null, "width", txstep);
  15949. tiling.setAttributeNS(null, "height", tystep);
  15950. tiling.setAttributeNS(null, "x", `${tx0}`);
  15951. tiling.setAttributeNS(null, "y", `${ty0}`);
  15952. const svg = this.svg;
  15953. const transformMatrix = this.transformMatrix;
  15954. const fillColor = this.current.fillColor;
  15955. const strokeColor = this.current.strokeColor;
  15956. const bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
  15957. this.svg = bbox;
  15958. this.transformMatrix = matrix;
  15959. if (paintType === 2) {
  15960. const cssColor = _util.Util.makeHexColor(...color);
  15961. this.current.fillColor = cssColor;
  15962. this.current.strokeColor = cssColor;
  15963. }
  15964. this.executeOpTree(this.convertOpList(operatorList));
  15965. this.svg = svg;
  15966. this.transformMatrix = transformMatrix;
  15967. this.current.fillColor = fillColor;
  15968. this.current.strokeColor = strokeColor;
  15969. tiling.append(bbox.childNodes[0]);
  15970. this.defs.append(tiling);
  15971. return `url(#${tilingId})`;
  15972. }
  15973. _makeShadingPattern(args) {
  15974. if (typeof args === "string") {
  15975. args = this.objs.get(args);
  15976. }
  15977. switch (args[0]) {
  15978. case "RadialAxial":
  15979. const shadingId = `shading${shadingCount++}`;
  15980. const colorStops = args[3];
  15981. let gradient;
  15982. switch (args[1]) {
  15983. case "axial":
  15984. const point0 = args[4];
  15985. const point1 = args[5];
  15986. gradient = this.svgFactory.createElement("svg:linearGradient");
  15987. gradient.setAttributeNS(null, "id", shadingId);
  15988. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  15989. gradient.setAttributeNS(null, "x1", point0[0]);
  15990. gradient.setAttributeNS(null, "y1", point0[1]);
  15991. gradient.setAttributeNS(null, "x2", point1[0]);
  15992. gradient.setAttributeNS(null, "y2", point1[1]);
  15993. break;
  15994. case "radial":
  15995. const focalPoint = args[4];
  15996. const circlePoint = args[5];
  15997. const focalRadius = args[6];
  15998. const circleRadius = args[7];
  15999. gradient = this.svgFactory.createElement("svg:radialGradient");
  16000. gradient.setAttributeNS(null, "id", shadingId);
  16001. gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
  16002. gradient.setAttributeNS(null, "cx", circlePoint[0]);
  16003. gradient.setAttributeNS(null, "cy", circlePoint[1]);
  16004. gradient.setAttributeNS(null, "r", circleRadius);
  16005. gradient.setAttributeNS(null, "fx", focalPoint[0]);
  16006. gradient.setAttributeNS(null, "fy", focalPoint[1]);
  16007. gradient.setAttributeNS(null, "fr", focalRadius);
  16008. break;
  16009. default:
  16010. throw new Error(`Unknown RadialAxial type: ${args[1]}`);
  16011. }
  16012. for (const colorStop of colorStops) {
  16013. const stop = this.svgFactory.createElement("svg:stop");
  16014. stop.setAttributeNS(null, "offset", colorStop[0]);
  16015. stop.setAttributeNS(null, "stop-color", colorStop[1]);
  16016. gradient.append(stop);
  16017. }
  16018. this.defs.append(gradient);
  16019. return `url(#${shadingId})`;
  16020. case "Mesh":
  16021. (0, _util.warn)("Unimplemented pattern Mesh");
  16022. return null;
  16023. case "Dummy":
  16024. return "hotpink";
  16025. default:
  16026. throw new Error(`Unknown IR type: ${args[0]}`);
  16027. }
  16028. }
  16029. setDash(dashArray, dashPhase) {
  16030. this.current.dashArray = dashArray;
  16031. this.current.dashPhase = dashPhase;
  16032. }
  16033. constructPath(ops, args) {
  16034. const current = this.current;
  16035. let x = current.x,
  16036. y = current.y;
  16037. let d = [];
  16038. let j = 0;
  16039. for (const op of ops) {
  16040. switch (op | 0) {
  16041. case _util.OPS.rectangle:
  16042. x = args[j++];
  16043. y = args[j++];
  16044. const width = args[j++];
  16045. const height = args[j++];
  16046. const xw = x + width;
  16047. const yh = y + height;
  16048. d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
  16049. break;
  16050. case _util.OPS.moveTo:
  16051. x = args[j++];
  16052. y = args[j++];
  16053. d.push("M", pf(x), pf(y));
  16054. break;
  16055. case _util.OPS.lineTo:
  16056. x = args[j++];
  16057. y = args[j++];
  16058. d.push("L", pf(x), pf(y));
  16059. break;
  16060. case _util.OPS.curveTo:
  16061. x = args[j + 4];
  16062. y = args[j + 5];
  16063. d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  16064. j += 6;
  16065. break;
  16066. case _util.OPS.curveTo2:
  16067. d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  16068. x = args[j + 2];
  16069. y = args[j + 3];
  16070. j += 4;
  16071. break;
  16072. case _util.OPS.curveTo3:
  16073. x = args[j + 2];
  16074. y = args[j + 3];
  16075. d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  16076. j += 4;
  16077. break;
  16078. case _util.OPS.closePath:
  16079. d.push("Z");
  16080. break;
  16081. }
  16082. }
  16083. d = d.join(" ");
  16084. if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
  16085. d = current.path.getAttributeNS(null, "d") + d;
  16086. } else {
  16087. current.path = this.svgFactory.createElement("svg:path");
  16088. this._ensureTransformGroup().append(current.path);
  16089. }
  16090. current.path.setAttributeNS(null, "d", d);
  16091. current.path.setAttributeNS(null, "fill", "none");
  16092. current.element = current.path;
  16093. current.setCurrentPoint(x, y);
  16094. }
  16095. endPath() {
  16096. const current = this.current;
  16097. current.path = null;
  16098. if (!this.pendingClip) {
  16099. return;
  16100. }
  16101. if (!current.element) {
  16102. this.pendingClip = null;
  16103. return;
  16104. }
  16105. const clipId = `clippath${clipCount++}`;
  16106. const clipPath = this.svgFactory.createElement("svg:clipPath");
  16107. clipPath.setAttributeNS(null, "id", clipId);
  16108. clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
  16109. const clipElement = current.element.cloneNode(true);
  16110. if (this.pendingClip === "evenodd") {
  16111. clipElement.setAttributeNS(null, "clip-rule", "evenodd");
  16112. } else {
  16113. clipElement.setAttributeNS(null, "clip-rule", "nonzero");
  16114. }
  16115. this.pendingClip = null;
  16116. clipPath.append(clipElement);
  16117. this.defs.append(clipPath);
  16118. if (current.activeClipUrl) {
  16119. current.clipGroup = null;
  16120. for (const prev of this.extraStack) {
  16121. prev.clipGroup = null;
  16122. }
  16123. clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
  16124. }
  16125. current.activeClipUrl = `url(#${clipId})`;
  16126. this.tgrp = null;
  16127. }
  16128. clip(type) {
  16129. this.pendingClip = type;
  16130. }
  16131. closePath() {
  16132. const current = this.current;
  16133. if (current.path) {
  16134. const d = `${current.path.getAttributeNS(null, "d")}Z`;
  16135. current.path.setAttributeNS(null, "d", d);
  16136. }
  16137. }
  16138. setLeading(leading) {
  16139. this.current.leading = -leading;
  16140. }
  16141. setTextRise(textRise) {
  16142. this.current.textRise = textRise;
  16143. }
  16144. setTextRenderingMode(textRenderingMode) {
  16145. this.current.textRenderingMode = textRenderingMode;
  16146. }
  16147. setHScale(scale) {
  16148. this.current.textHScale = scale / 100;
  16149. }
  16150. setRenderingIntent(intent) {}
  16151. setFlatness(flatness) {}
  16152. setGState(states) {
  16153. for (const [key, value] of states) {
  16154. switch (key) {
  16155. case "LW":
  16156. this.setLineWidth(value);
  16157. break;
  16158. case "LC":
  16159. this.setLineCap(value);
  16160. break;
  16161. case "LJ":
  16162. this.setLineJoin(value);
  16163. break;
  16164. case "ML":
  16165. this.setMiterLimit(value);
  16166. break;
  16167. case "D":
  16168. this.setDash(value[0], value[1]);
  16169. break;
  16170. case "RI":
  16171. this.setRenderingIntent(value);
  16172. break;
  16173. case "FL":
  16174. this.setFlatness(value);
  16175. break;
  16176. case "Font":
  16177. this.setFont(value);
  16178. break;
  16179. case "CA":
  16180. this.setStrokeAlpha(value);
  16181. break;
  16182. case "ca":
  16183. this.setFillAlpha(value);
  16184. break;
  16185. default:
  16186. (0, _util.warn)(`Unimplemented graphic state operator ${key}`);
  16187. break;
  16188. }
  16189. }
  16190. }
  16191. fill() {
  16192. const current = this.current;
  16193. if (current.element) {
  16194. current.element.setAttributeNS(null, "fill", current.fillColor);
  16195. current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
  16196. this.endPath();
  16197. }
  16198. }
  16199. stroke() {
  16200. const current = this.current;
  16201. if (current.element) {
  16202. this._setStrokeAttributes(current.element);
  16203. current.element.setAttributeNS(null, "fill", "none");
  16204. this.endPath();
  16205. }
  16206. }
  16207. _setStrokeAttributes(element) {
  16208. let lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  16209. const current = this.current;
  16210. let dashArray = current.dashArray;
  16211. if (lineWidthScale !== 1 && dashArray.length > 0) {
  16212. dashArray = dashArray.map(function (value) {
  16213. return lineWidthScale * value;
  16214. });
  16215. }
  16216. element.setAttributeNS(null, "stroke", current.strokeColor);
  16217. element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
  16218. element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
  16219. element.setAttributeNS(null, "stroke-linecap", current.lineCap);
  16220. element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
  16221. element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
  16222. element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
  16223. element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
  16224. }
  16225. eoFill() {
  16226. this.current.element?.setAttributeNS(null, "fill-rule", "evenodd");
  16227. this.fill();
  16228. }
  16229. fillStroke() {
  16230. this.stroke();
  16231. this.fill();
  16232. }
  16233. eoFillStroke() {
  16234. this.current.element?.setAttributeNS(null, "fill-rule", "evenodd");
  16235. this.fillStroke();
  16236. }
  16237. closeStroke() {
  16238. this.closePath();
  16239. this.stroke();
  16240. }
  16241. closeFillStroke() {
  16242. this.closePath();
  16243. this.fillStroke();
  16244. }
  16245. closeEOFillStroke() {
  16246. this.closePath();
  16247. this.eoFillStroke();
  16248. }
  16249. paintSolidColorImageMask() {
  16250. const rect = this.svgFactory.createElement("svg:rect");
  16251. rect.setAttributeNS(null, "x", "0");
  16252. rect.setAttributeNS(null, "y", "0");
  16253. rect.setAttributeNS(null, "width", "1px");
  16254. rect.setAttributeNS(null, "height", "1px");
  16255. rect.setAttributeNS(null, "fill", this.current.fillColor);
  16256. this._ensureTransformGroup().append(rect);
  16257. }
  16258. paintImageXObject(objId) {
  16259. const imgData = this.getObject(objId);
  16260. if (!imgData) {
  16261. (0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
  16262. return;
  16263. }
  16264. this.paintInlineImageXObject(imgData);
  16265. }
  16266. paintInlineImageXObject(imgData, mask) {
  16267. const width = imgData.width;
  16268. const height = imgData.height;
  16269. const imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  16270. const cliprect = this.svgFactory.createElement("svg:rect");
  16271. cliprect.setAttributeNS(null, "x", "0");
  16272. cliprect.setAttributeNS(null, "y", "0");
  16273. cliprect.setAttributeNS(null, "width", pf(width));
  16274. cliprect.setAttributeNS(null, "height", pf(height));
  16275. this.current.element = cliprect;
  16276. this.clip("nonzero");
  16277. const imgEl = this.svgFactory.createElement("svg:image");
  16278. imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
  16279. imgEl.setAttributeNS(null, "x", "0");
  16280. imgEl.setAttributeNS(null, "y", pf(-height));
  16281. imgEl.setAttributeNS(null, "width", pf(width) + "px");
  16282. imgEl.setAttributeNS(null, "height", pf(height) + "px");
  16283. imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / width)} ${pf(-1 / height)})`);
  16284. if (mask) {
  16285. mask.append(imgEl);
  16286. } else {
  16287. this._ensureTransformGroup().append(imgEl);
  16288. }
  16289. }
  16290. paintImageMaskXObject(img) {
  16291. const imgData = this.getObject(img.data, img);
  16292. if (imgData.bitmap) {
  16293. (0, _util.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, " + "ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");
  16294. return;
  16295. }
  16296. const current = this.current;
  16297. const width = imgData.width;
  16298. const height = imgData.height;
  16299. const fillColor = current.fillColor;
  16300. current.maskId = `mask${maskCount++}`;
  16301. const mask = this.svgFactory.createElement("svg:mask");
  16302. mask.setAttributeNS(null, "id", current.maskId);
  16303. const rect = this.svgFactory.createElement("svg:rect");
  16304. rect.setAttributeNS(null, "x", "0");
  16305. rect.setAttributeNS(null, "y", "0");
  16306. rect.setAttributeNS(null, "width", pf(width));
  16307. rect.setAttributeNS(null, "height", pf(height));
  16308. rect.setAttributeNS(null, "fill", fillColor);
  16309. rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
  16310. this.defs.append(mask);
  16311. this._ensureTransformGroup().append(rect);
  16312. this.paintInlineImageXObject(imgData, mask);
  16313. }
  16314. paintFormXObjectBegin(matrix, bbox) {
  16315. if (Array.isArray(matrix) && matrix.length === 6) {
  16316. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  16317. }
  16318. if (bbox) {
  16319. const width = bbox[2] - bbox[0];
  16320. const height = bbox[3] - bbox[1];
  16321. const cliprect = this.svgFactory.createElement("svg:rect");
  16322. cliprect.setAttributeNS(null, "x", bbox[0]);
  16323. cliprect.setAttributeNS(null, "y", bbox[1]);
  16324. cliprect.setAttributeNS(null, "width", pf(width));
  16325. cliprect.setAttributeNS(null, "height", pf(height));
  16326. this.current.element = cliprect;
  16327. this.clip("nonzero");
  16328. this.endPath();
  16329. }
  16330. }
  16331. paintFormXObjectEnd() {}
  16332. _initialize(viewport) {
  16333. const svg = this.svgFactory.create(viewport.width, viewport.height);
  16334. const definitions = this.svgFactory.createElement("svg:defs");
  16335. svg.append(definitions);
  16336. this.defs = definitions;
  16337. const rootGroup = this.svgFactory.createElement("svg:g");
  16338. rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
  16339. svg.append(rootGroup);
  16340. this.svg = rootGroup;
  16341. return svg;
  16342. }
  16343. _ensureClipGroup() {
  16344. if (!this.current.clipGroup) {
  16345. const clipGroup = this.svgFactory.createElement("svg:g");
  16346. clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
  16347. this.svg.append(clipGroup);
  16348. this.current.clipGroup = clipGroup;
  16349. }
  16350. return this.current.clipGroup;
  16351. }
  16352. _ensureTransformGroup() {
  16353. if (!this.tgrp) {
  16354. this.tgrp = this.svgFactory.createElement("svg:g");
  16355. this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
  16356. if (this.current.activeClipUrl) {
  16357. this._ensureClipGroup().append(this.tgrp);
  16358. } else {
  16359. this.svg.append(this.tgrp);
  16360. }
  16361. }
  16362. return this.tgrp;
  16363. }
  16364. }
  16365. exports.SVGGraphics = SVGGraphics;
  16366. /***/ }),
  16367. /* 187 */
  16368. /***/ ((__unused_webpack_module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16369. var $ = __w_pdfjs_require__(3);
  16370. var $group = __w_pdfjs_require__(188);
  16371. var addToUnscopables = __w_pdfjs_require__(193);
  16372. $({
  16373. target: 'Array',
  16374. proto: true
  16375. }, {
  16376. group: function group(callbackfn) {
  16377. var thisArg = arguments.length > 1 ? arguments[1] : undefined;
  16378. return $group(this, callbackfn, thisArg);
  16379. }
  16380. });
  16381. addToUnscopables('group');
  16382. /***/ }),
  16383. /* 188 */
  16384. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16385. var bind = __w_pdfjs_require__(99);
  16386. var uncurryThis = __w_pdfjs_require__(14);
  16387. var IndexedObject = __w_pdfjs_require__(13);
  16388. var toObject = __w_pdfjs_require__(40);
  16389. var toPropertyKey = __w_pdfjs_require__(18);
  16390. var lengthOfArrayLike = __w_pdfjs_require__(64);
  16391. var objectCreate = __w_pdfjs_require__(189);
  16392. var arrayFromConstructorAndList = __w_pdfjs_require__(108);
  16393. var $Array = Array;
  16394. var push = uncurryThis([].push);
  16395. module.exports = function ($this, callbackfn, that, specificConstructor) {
  16396. var O = toObject($this);
  16397. var self = IndexedObject(O);
  16398. var boundFunction = bind(callbackfn, that);
  16399. var target = objectCreate(null);
  16400. var length = lengthOfArrayLike(self);
  16401. var index = 0;
  16402. var Constructor, key, value;
  16403. for (; length > index; index++) {
  16404. value = self[index];
  16405. key = toPropertyKey(boundFunction(value, index, O));
  16406. if (key in target)
  16407. push(target[key], value);
  16408. else
  16409. target[key] = [value];
  16410. }
  16411. if (specificConstructor) {
  16412. Constructor = specificConstructor(O);
  16413. if (Constructor !== $Array) {
  16414. for (key in target)
  16415. target[key] = arrayFromConstructorAndList(Constructor, target[key]);
  16416. }
  16417. }
  16418. return target;
  16419. };
  16420. /***/ }),
  16421. /* 189 */
  16422. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16423. var anObject = __w_pdfjs_require__(47);
  16424. var definePropertiesModule = __w_pdfjs_require__(190);
  16425. var enumBugKeys = __w_pdfjs_require__(66);
  16426. var hiddenKeys = __w_pdfjs_require__(55);
  16427. var html = __w_pdfjs_require__(192);
  16428. var documentCreateElement = __w_pdfjs_require__(43);
  16429. var sharedKey = __w_pdfjs_require__(54);
  16430. var GT = '>';
  16431. var LT = '<';
  16432. var PROTOTYPE = 'prototype';
  16433. var SCRIPT = 'script';
  16434. var IE_PROTO = sharedKey('IE_PROTO');
  16435. var EmptyConstructor = function () {
  16436. };
  16437. var scriptTag = function (content) {
  16438. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  16439. };
  16440. var NullProtoObjectViaActiveX = function (activeXDocument) {
  16441. activeXDocument.write(scriptTag(''));
  16442. activeXDocument.close();
  16443. var temp = activeXDocument.parentWindow.Object;
  16444. activeXDocument = null;
  16445. return temp;
  16446. };
  16447. var NullProtoObjectViaIFrame = function () {
  16448. var iframe = documentCreateElement('iframe');
  16449. var JS = 'java' + SCRIPT + ':';
  16450. var iframeDocument;
  16451. iframe.style.display = 'none';
  16452. html.appendChild(iframe);
  16453. iframe.src = String(JS);
  16454. iframeDocument = iframe.contentWindow.document;
  16455. iframeDocument.open();
  16456. iframeDocument.write(scriptTag('document.F=Object'));
  16457. iframeDocument.close();
  16458. return iframeDocument.F;
  16459. };
  16460. var activeXDocument;
  16461. var NullProtoObject = function () {
  16462. try {
  16463. activeXDocument = new ActiveXObject('htmlfile');
  16464. } catch (error) {
  16465. }
  16466. NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument);
  16467. var length = enumBugKeys.length;
  16468. while (length--)
  16469. delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  16470. return NullProtoObject();
  16471. };
  16472. hiddenKeys[IE_PROTO] = true;
  16473. module.exports = Object.create || function create(O, Properties) {
  16474. var result;
  16475. if (O !== null) {
  16476. EmptyConstructor[PROTOTYPE] = anObject(O);
  16477. result = new EmptyConstructor();
  16478. EmptyConstructor[PROTOTYPE] = null;
  16479. result[IE_PROTO] = O;
  16480. } else
  16481. result = NullProtoObject();
  16482. return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
  16483. };
  16484. /***/ }),
  16485. /* 190 */
  16486. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16487. var DESCRIPTORS = __w_pdfjs_require__(6);
  16488. var V8_PROTOTYPE_DEFINE_BUG = __w_pdfjs_require__(46);
  16489. var definePropertyModule = __w_pdfjs_require__(45);
  16490. var anObject = __w_pdfjs_require__(47);
  16491. var toIndexedObject = __w_pdfjs_require__(12);
  16492. var objectKeys = __w_pdfjs_require__(191);
  16493. exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
  16494. anObject(O);
  16495. var props = toIndexedObject(Properties);
  16496. var keys = objectKeys(Properties);
  16497. var length = keys.length;
  16498. var index = 0;
  16499. var key;
  16500. while (length > index)
  16501. definePropertyModule.f(O, key = keys[index++], props[key]);
  16502. return O;
  16503. };
  16504. /***/ }),
  16505. /* 191 */
  16506. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16507. var internalObjectKeys = __w_pdfjs_require__(59);
  16508. var enumBugKeys = __w_pdfjs_require__(66);
  16509. module.exports = Object.keys || function keys(O) {
  16510. return internalObjectKeys(O, enumBugKeys);
  16511. };
  16512. /***/ }),
  16513. /* 192 */
  16514. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16515. var getBuiltIn = __w_pdfjs_require__(24);
  16516. module.exports = getBuiltIn('document', 'documentElement');
  16517. /***/ }),
  16518. /* 193 */
  16519. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  16520. var wellKnownSymbol = __w_pdfjs_require__(34);
  16521. var create = __w_pdfjs_require__(189);
  16522. var defineProperty = (__w_pdfjs_require__(45).f);
  16523. var UNSCOPABLES = wellKnownSymbol('unscopables');
  16524. var ArrayPrototype = Array.prototype;
  16525. if (ArrayPrototype[UNSCOPABLES] === undefined) {
  16526. defineProperty(ArrayPrototype, UNSCOPABLES, {
  16527. configurable: true,
  16528. value: create(null)
  16529. });
  16530. }
  16531. module.exports = function (key) {
  16532. ArrayPrototype[UNSCOPABLES][key] = true;
  16533. };
  16534. /***/ }),
  16535. /* 194 */
  16536. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16537. Object.defineProperty(exports, "__esModule", ({
  16538. value: true
  16539. }));
  16540. exports.XfaText = void 0;
  16541. __w_pdfjs_require__(89);
  16542. class XfaText {
  16543. static textContent(xfa) {
  16544. const items = [];
  16545. const output = {
  16546. items,
  16547. styles: Object.create(null)
  16548. };
  16549. function walk(node) {
  16550. if (!node) {
  16551. return;
  16552. }
  16553. let str = null;
  16554. const name = node.name;
  16555. if (name === "#text") {
  16556. str = node.value;
  16557. } else if (!XfaText.shouldBuildText(name)) {
  16558. return;
  16559. } else if (node?.attributes?.textContent) {
  16560. str = node.attributes.textContent;
  16561. } else if (node.value) {
  16562. str = node.value;
  16563. }
  16564. if (str !== null) {
  16565. items.push({
  16566. str
  16567. });
  16568. }
  16569. if (!node.children) {
  16570. return;
  16571. }
  16572. for (const child of node.children) {
  16573. walk(child);
  16574. }
  16575. }
  16576. walk(xfa);
  16577. return output;
  16578. }
  16579. static shouldBuildText(name) {
  16580. return !(name === "textarea" || name === "input" || name === "option" || name === "select");
  16581. }
  16582. }
  16583. exports.XfaText = XfaText;
  16584. /***/ }),
  16585. /* 195 */
  16586. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16587. Object.defineProperty(exports, "__esModule", ({
  16588. value: true
  16589. }));
  16590. exports.TextLayerRenderTask = void 0;
  16591. exports.renderTextLayer = renderTextLayer;
  16592. exports.updateTextLayer = updateTextLayer;
  16593. __w_pdfjs_require__(89);
  16594. __w_pdfjs_require__(2);
  16595. var _util = __w_pdfjs_require__(1);
  16596. var _display_utils = __w_pdfjs_require__(168);
  16597. const MAX_TEXT_DIVS_TO_RENDER = 100000;
  16598. const DEFAULT_FONT_SIZE = 30;
  16599. const DEFAULT_FONT_ASCENT = 0.8;
  16600. const ascentCache = new Map();
  16601. function getCtx(size, isOffscreenCanvasSupported) {
  16602. let ctx;
  16603. if (isOffscreenCanvasSupported && _util.FeatureTest.isOffscreenCanvasSupported) {
  16604. ctx = new OffscreenCanvas(size, size).getContext("2d", {
  16605. alpha: false
  16606. });
  16607. } else {
  16608. const canvas = document.createElement("canvas");
  16609. canvas.width = canvas.height = size;
  16610. ctx = canvas.getContext("2d", {
  16611. alpha: false
  16612. });
  16613. }
  16614. return ctx;
  16615. }
  16616. function getAscent(fontFamily, isOffscreenCanvasSupported) {
  16617. const cachedAscent = ascentCache.get(fontFamily);
  16618. if (cachedAscent) {
  16619. return cachedAscent;
  16620. }
  16621. const ctx = getCtx(DEFAULT_FONT_SIZE, isOffscreenCanvasSupported);
  16622. ctx.font = `${DEFAULT_FONT_SIZE}px ${fontFamily}`;
  16623. const metrics = ctx.measureText("");
  16624. let ascent = metrics.fontBoundingBoxAscent;
  16625. let descent = Math.abs(metrics.fontBoundingBoxDescent);
  16626. if (ascent) {
  16627. const ratio = ascent / (ascent + descent);
  16628. ascentCache.set(fontFamily, ratio);
  16629. ctx.canvas.width = ctx.canvas.height = 0;
  16630. return ratio;
  16631. }
  16632. ctx.strokeStyle = "red";
  16633. ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
  16634. ctx.strokeText("g", 0, 0);
  16635. let pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
  16636. descent = 0;
  16637. for (let i = pixels.length - 1 - 3; i >= 0; i -= 4) {
  16638. if (pixels[i] > 0) {
  16639. descent = Math.ceil(i / 4 / DEFAULT_FONT_SIZE);
  16640. break;
  16641. }
  16642. }
  16643. ctx.clearRect(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
  16644. ctx.strokeText("A", 0, DEFAULT_FONT_SIZE);
  16645. pixels = ctx.getImageData(0, 0, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE).data;
  16646. ascent = 0;
  16647. for (let i = 0, ii = pixels.length; i < ii; i += 4) {
  16648. if (pixels[i] > 0) {
  16649. ascent = DEFAULT_FONT_SIZE - Math.floor(i / 4 / DEFAULT_FONT_SIZE);
  16650. break;
  16651. }
  16652. }
  16653. ctx.canvas.width = ctx.canvas.height = 0;
  16654. if (ascent) {
  16655. const ratio = ascent / (ascent + descent);
  16656. ascentCache.set(fontFamily, ratio);
  16657. return ratio;
  16658. }
  16659. ascentCache.set(fontFamily, DEFAULT_FONT_ASCENT);
  16660. return DEFAULT_FONT_ASCENT;
  16661. }
  16662. function appendText(task, geom, styles) {
  16663. const textDiv = document.createElement("span");
  16664. const textDivProperties = {
  16665. angle: 0,
  16666. canvasWidth: 0,
  16667. hasText: geom.str !== "",
  16668. hasEOL: geom.hasEOL,
  16669. fontSize: 0
  16670. };
  16671. task._textDivs.push(textDiv);
  16672. const tx = _util.Util.transform(task._transform, geom.transform);
  16673. let angle = Math.atan2(tx[1], tx[0]);
  16674. const style = styles[geom.fontName];
  16675. if (style.vertical) {
  16676. angle += Math.PI / 2;
  16677. }
  16678. const fontHeight = Math.hypot(tx[2], tx[3]);
  16679. const fontAscent = fontHeight * getAscent(style.fontFamily, task._isOffscreenCanvasSupported);
  16680. let left, top;
  16681. if (angle === 0) {
  16682. left = tx[4];
  16683. top = tx[5] - fontAscent;
  16684. } else {
  16685. left = tx[4] + fontAscent * Math.sin(angle);
  16686. top = tx[5] - fontAscent * Math.cos(angle);
  16687. }
  16688. const scaleFactorStr = "calc(var(--scale-factor)*";
  16689. const divStyle = textDiv.style;
  16690. if (task._container === task._rootContainer) {
  16691. divStyle.left = `${(100 * left / task._pageWidth).toFixed(2)}%`;
  16692. divStyle.top = `${(100 * top / task._pageHeight).toFixed(2)}%`;
  16693. } else {
  16694. divStyle.left = `${scaleFactorStr}${left.toFixed(2)}px)`;
  16695. divStyle.top = `${scaleFactorStr}${top.toFixed(2)}px)`;
  16696. }
  16697. divStyle.fontSize = `${scaleFactorStr}${fontHeight.toFixed(2)}px)`;
  16698. divStyle.fontFamily = style.fontFamily;
  16699. textDivProperties.fontSize = fontHeight;
  16700. textDiv.setAttribute("role", "presentation");
  16701. textDiv.textContent = geom.str;
  16702. textDiv.dir = geom.dir;
  16703. if (task._fontInspectorEnabled) {
  16704. textDiv.dataset.fontName = geom.fontName;
  16705. }
  16706. if (angle !== 0) {
  16707. textDivProperties.angle = angle * (180 / Math.PI);
  16708. }
  16709. let shouldScaleText = false;
  16710. if (geom.str.length > 1) {
  16711. shouldScaleText = true;
  16712. } else if (geom.str !== " " && geom.transform[0] !== geom.transform[3]) {
  16713. const absScaleX = Math.abs(geom.transform[0]),
  16714. absScaleY = Math.abs(geom.transform[3]);
  16715. if (absScaleX !== absScaleY && Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5) {
  16716. shouldScaleText = true;
  16717. }
  16718. }
  16719. if (shouldScaleText) {
  16720. textDivProperties.canvasWidth = style.vertical ? geom.height : geom.width;
  16721. }
  16722. task._textDivProperties.set(textDiv, textDivProperties);
  16723. if (task._isReadableStream) {
  16724. task._layoutText(textDiv);
  16725. }
  16726. }
  16727. function layout(params) {
  16728. const {
  16729. div,
  16730. scale,
  16731. properties,
  16732. ctx,
  16733. prevFontSize,
  16734. prevFontFamily
  16735. } = params;
  16736. const {
  16737. style
  16738. } = div;
  16739. let transform = "";
  16740. if (properties.canvasWidth !== 0 && properties.hasText) {
  16741. const {
  16742. fontFamily
  16743. } = style;
  16744. const {
  16745. canvasWidth,
  16746. fontSize
  16747. } = properties;
  16748. if (prevFontSize !== fontSize || prevFontFamily !== fontFamily) {
  16749. ctx.font = `${fontSize * scale}px ${fontFamily}`;
  16750. params.prevFontSize = fontSize;
  16751. params.prevFontFamily = fontFamily;
  16752. }
  16753. const {
  16754. width
  16755. } = ctx.measureText(div.textContent);
  16756. if (width > 0) {
  16757. transform = `scaleX(${canvasWidth * scale / width})`;
  16758. }
  16759. }
  16760. if (properties.angle !== 0) {
  16761. transform = `rotate(${properties.angle}deg) ${transform}`;
  16762. }
  16763. if (transform.length > 0) {
  16764. style.transform = transform;
  16765. }
  16766. }
  16767. function render(task) {
  16768. if (task._canceled) {
  16769. return;
  16770. }
  16771. const textDivs = task._textDivs;
  16772. const capability = task._capability;
  16773. const textDivsLength = textDivs.length;
  16774. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  16775. capability.resolve();
  16776. return;
  16777. }
  16778. if (!task._isReadableStream) {
  16779. for (const textDiv of textDivs) {
  16780. task._layoutText(textDiv);
  16781. }
  16782. }
  16783. capability.resolve();
  16784. }
  16785. class TextLayerRenderTask {
  16786. constructor(_ref) {
  16787. let {
  16788. textContentSource,
  16789. container,
  16790. viewport,
  16791. textDivs,
  16792. textDivProperties,
  16793. textContentItemsStr,
  16794. isOffscreenCanvasSupported
  16795. } = _ref;
  16796. this._textContentSource = textContentSource;
  16797. this._isReadableStream = textContentSource instanceof ReadableStream;
  16798. this._container = this._rootContainer = container;
  16799. this._textDivs = textDivs || [];
  16800. this._textContentItemsStr = textContentItemsStr || [];
  16801. this._isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  16802. this._fontInspectorEnabled = !!globalThis.FontInspector?.enabled;
  16803. this._reader = null;
  16804. this._textDivProperties = textDivProperties || new WeakMap();
  16805. this._canceled = false;
  16806. this._capability = new _util.PromiseCapability();
  16807. this._layoutTextParams = {
  16808. prevFontSize: null,
  16809. prevFontFamily: null,
  16810. div: null,
  16811. scale: viewport.scale * (globalThis.devicePixelRatio || 1),
  16812. properties: null,
  16813. ctx: getCtx(0, isOffscreenCanvasSupported)
  16814. };
  16815. const {
  16816. pageWidth,
  16817. pageHeight,
  16818. pageX,
  16819. pageY
  16820. } = viewport.rawDims;
  16821. this._transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];
  16822. this._pageWidth = pageWidth;
  16823. this._pageHeight = pageHeight;
  16824. (0, _display_utils.setLayerDimensions)(container, viewport);
  16825. this._capability.promise.finally(() => {
  16826. this._layoutTextParams = null;
  16827. }).catch(() => {});
  16828. }
  16829. get promise() {
  16830. return this._capability.promise;
  16831. }
  16832. cancel() {
  16833. this._canceled = true;
  16834. if (this._reader) {
  16835. this._reader.cancel(new _util.AbortException("TextLayer task cancelled.")).catch(() => {});
  16836. this._reader = null;
  16837. }
  16838. this._capability.reject(new _util.AbortException("TextLayer task cancelled."));
  16839. }
  16840. _processItems(items, styleCache) {
  16841. for (const item of items) {
  16842. if (item.str === undefined) {
  16843. if (item.type === "beginMarkedContentProps" || item.type === "beginMarkedContent") {
  16844. const parent = this._container;
  16845. this._container = document.createElement("span");
  16846. this._container.classList.add("markedContent");
  16847. if (item.id !== null) {
  16848. this._container.setAttribute("id", `${item.id}`);
  16849. }
  16850. parent.append(this._container);
  16851. } else if (item.type === "endMarkedContent") {
  16852. this._container = this._container.parentNode;
  16853. }
  16854. continue;
  16855. }
  16856. this._textContentItemsStr.push(item.str);
  16857. appendText(this, item, styleCache);
  16858. }
  16859. }
  16860. _layoutText(textDiv) {
  16861. const textDivProperties = this._layoutTextParams.properties = this._textDivProperties.get(textDiv);
  16862. this._layoutTextParams.div = textDiv;
  16863. layout(this._layoutTextParams);
  16864. if (textDivProperties.hasText) {
  16865. this._container.append(textDiv);
  16866. }
  16867. if (textDivProperties.hasEOL) {
  16868. const br = document.createElement("br");
  16869. br.setAttribute("role", "presentation");
  16870. this._container.append(br);
  16871. }
  16872. }
  16873. _render() {
  16874. const capability = new _util.PromiseCapability();
  16875. let styleCache = Object.create(null);
  16876. if (this._isReadableStream) {
  16877. const pump = () => {
  16878. this._reader.read().then(_ref2 => {
  16879. let {
  16880. value,
  16881. done
  16882. } = _ref2;
  16883. if (done) {
  16884. capability.resolve();
  16885. return;
  16886. }
  16887. Object.assign(styleCache, value.styles);
  16888. this._processItems(value.items, styleCache);
  16889. pump();
  16890. }, capability.reject);
  16891. };
  16892. this._reader = this._textContentSource.getReader();
  16893. pump();
  16894. } else if (this._textContentSource) {
  16895. const {
  16896. items,
  16897. styles
  16898. } = this._textContentSource;
  16899. this._processItems(items, styles);
  16900. capability.resolve();
  16901. } else {
  16902. throw new Error('No "textContentSource" parameter specified.');
  16903. }
  16904. capability.promise.then(() => {
  16905. styleCache = null;
  16906. render(this);
  16907. }, this._capability.reject);
  16908. }
  16909. }
  16910. exports.TextLayerRenderTask = TextLayerRenderTask;
  16911. function renderTextLayer(params) {
  16912. if (!params.textContentSource && (params.textContent || params.textContentStream)) {
  16913. (0, _display_utils.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters " + "will be removed in the future, please use `textContentSource` instead.");
  16914. params.textContentSource = params.textContent || params.textContentStream;
  16915. }
  16916. const {
  16917. container,
  16918. viewport
  16919. } = params;
  16920. const style = getComputedStyle(container);
  16921. const visibility = style.getPropertyValue("visibility");
  16922. const scaleFactor = parseFloat(style.getPropertyValue("--scale-factor"));
  16923. if (visibility === "visible" && (!scaleFactor || Math.abs(scaleFactor - viewport.scale) > 1e-5)) {
  16924. console.error("The `--scale-factor` CSS-variable must be set, " + "to the same value as `viewport.scale`, " + "either on the `container`-element itself or higher up in the DOM.");
  16925. }
  16926. const task = new TextLayerRenderTask(params);
  16927. task._render();
  16928. return task;
  16929. }
  16930. function updateTextLayer(_ref3) {
  16931. let {
  16932. container,
  16933. viewport,
  16934. textDivs,
  16935. textDivProperties,
  16936. isOffscreenCanvasSupported,
  16937. mustRotate = true,
  16938. mustRescale = true
  16939. } = _ref3;
  16940. if (mustRotate) {
  16941. (0, _display_utils.setLayerDimensions)(container, {
  16942. rotation: viewport.rotation
  16943. });
  16944. }
  16945. if (mustRescale) {
  16946. const ctx = getCtx(0, isOffscreenCanvasSupported);
  16947. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  16948. const params = {
  16949. prevFontSize: null,
  16950. prevFontFamily: null,
  16951. div: null,
  16952. scale,
  16953. properties: null,
  16954. ctx
  16955. };
  16956. for (const div of textDivs) {
  16957. params.properties = textDivProperties.get(div);
  16958. params.div = div;
  16959. layout(params);
  16960. }
  16961. }
  16962. }
  16963. /***/ }),
  16964. /* 196 */
  16965. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  16966. Object.defineProperty(exports, "__esModule", ({
  16967. value: true
  16968. }));
  16969. exports.AnnotationEditorLayer = void 0;
  16970. __w_pdfjs_require__(125);
  16971. __w_pdfjs_require__(136);
  16972. __w_pdfjs_require__(138);
  16973. __w_pdfjs_require__(141);
  16974. __w_pdfjs_require__(143);
  16975. __w_pdfjs_require__(145);
  16976. __w_pdfjs_require__(147);
  16977. var _util = __w_pdfjs_require__(1);
  16978. var _editor = __w_pdfjs_require__(164);
  16979. var _freetext = __w_pdfjs_require__(197);
  16980. var _ink = __w_pdfjs_require__(202);
  16981. var _display_utils = __w_pdfjs_require__(168);
  16982. var _stamp = __w_pdfjs_require__(203);
  16983. class AnnotationEditorLayer {
  16984. #accessibilityManager;
  16985. #allowClick = false;
  16986. #annotationLayer = null;
  16987. #boundPointerup = this.pointerup.bind(this);
  16988. #boundPointerdown = this.pointerdown.bind(this);
  16989. #editors = new Map();
  16990. #hadPointerDown = false;
  16991. #isCleaningUp = false;
  16992. #isDisabling = false;
  16993. #uiManager;
  16994. static _initialized = false;
  16995. constructor(_ref) {
  16996. let {
  16997. uiManager,
  16998. pageIndex,
  16999. div,
  17000. accessibilityManager,
  17001. annotationLayer,
  17002. viewport,
  17003. l10n
  17004. } = _ref;
  17005. const editorTypes = [_freetext.FreeTextEditor, _ink.InkEditor, _stamp.StampEditor];
  17006. if (!AnnotationEditorLayer._initialized) {
  17007. AnnotationEditorLayer._initialized = true;
  17008. for (const editorType of editorTypes) {
  17009. editorType.initialize(l10n);
  17010. }
  17011. }
  17012. uiManager.registerEditorTypes(editorTypes);
  17013. this.#uiManager = uiManager;
  17014. this.pageIndex = pageIndex;
  17015. this.div = div;
  17016. this.#accessibilityManager = accessibilityManager;
  17017. this.#annotationLayer = annotationLayer;
  17018. this.viewport = viewport;
  17019. this.#uiManager.addLayer(this);
  17020. }
  17021. get isEmpty() {
  17022. return this.#editors.size === 0;
  17023. }
  17024. updateToolbar(mode) {
  17025. this.#uiManager.updateToolbar(mode);
  17026. }
  17027. updateMode() {
  17028. let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#uiManager.getMode();
  17029. this.#cleanup();
  17030. if (mode === _util.AnnotationEditorType.INK) {
  17031. this.addInkEditorIfNeeded(false);
  17032. this.disableClick();
  17033. } else {
  17034. this.enableClick();
  17035. }
  17036. if (mode !== _util.AnnotationEditorType.NONE) {
  17037. this.div.classList.toggle("freeTextEditing", mode === _util.AnnotationEditorType.FREETEXT);
  17038. this.div.classList.toggle("inkEditing", mode === _util.AnnotationEditorType.INK);
  17039. this.div.classList.toggle("stampEditing", mode === _util.AnnotationEditorType.STAMP);
  17040. this.div.hidden = false;
  17041. }
  17042. }
  17043. addInkEditorIfNeeded(isCommitting) {
  17044. if (!isCommitting && this.#uiManager.getMode() !== _util.AnnotationEditorType.INK) {
  17045. return;
  17046. }
  17047. if (!isCommitting) {
  17048. for (const editor of this.#editors.values()) {
  17049. if (editor.isEmpty()) {
  17050. editor.setInBackground();
  17051. return;
  17052. }
  17053. }
  17054. }
  17055. const editor = this.#createAndAddNewEditor({
  17056. offsetX: 0,
  17057. offsetY: 0
  17058. }, false);
  17059. editor.setInBackground();
  17060. }
  17061. setEditingState(isEditing) {
  17062. this.#uiManager.setEditingState(isEditing);
  17063. }
  17064. addCommands(params) {
  17065. this.#uiManager.addCommands(params);
  17066. }
  17067. enable() {
  17068. this.div.style.pointerEvents = "auto";
  17069. const annotationElementIds = new Set();
  17070. for (const editor of this.#editors.values()) {
  17071. editor.enableEditing();
  17072. if (editor.annotationElementId) {
  17073. annotationElementIds.add(editor.annotationElementId);
  17074. }
  17075. }
  17076. if (!this.#annotationLayer) {
  17077. return;
  17078. }
  17079. const editables = this.#annotationLayer.getEditableAnnotations();
  17080. for (const editable of editables) {
  17081. editable.hide();
  17082. if (this.#uiManager.isDeletedAnnotationElement(editable.data.id)) {
  17083. continue;
  17084. }
  17085. if (annotationElementIds.has(editable.data.id)) {
  17086. continue;
  17087. }
  17088. const editor = this.deserialize(editable);
  17089. if (!editor) {
  17090. continue;
  17091. }
  17092. this.addOrRebuild(editor);
  17093. editor.enableEditing();
  17094. }
  17095. }
  17096. disable() {
  17097. this.#isDisabling = true;
  17098. this.div.style.pointerEvents = "none";
  17099. const hiddenAnnotationIds = new Set();
  17100. for (const editor of this.#editors.values()) {
  17101. editor.disableEditing();
  17102. if (!editor.annotationElementId || editor.serialize() !== null) {
  17103. hiddenAnnotationIds.add(editor.annotationElementId);
  17104. continue;
  17105. }
  17106. this.getEditableAnnotation(editor.annotationElementId)?.show();
  17107. editor.remove();
  17108. }
  17109. if (this.#annotationLayer) {
  17110. const editables = this.#annotationLayer.getEditableAnnotations();
  17111. for (const editable of editables) {
  17112. const {
  17113. id
  17114. } = editable.data;
  17115. if (hiddenAnnotationIds.has(id) || this.#uiManager.isDeletedAnnotationElement(id)) {
  17116. continue;
  17117. }
  17118. editable.show();
  17119. }
  17120. }
  17121. this.#cleanup();
  17122. if (this.isEmpty) {
  17123. this.div.hidden = true;
  17124. }
  17125. this.#isDisabling = false;
  17126. }
  17127. getEditableAnnotation(id) {
  17128. return this.#annotationLayer?.getEditableAnnotation(id) || null;
  17129. }
  17130. setActiveEditor(editor) {
  17131. const currentActive = this.#uiManager.getActive();
  17132. if (currentActive === editor) {
  17133. return;
  17134. }
  17135. this.#uiManager.setActiveEditor(editor);
  17136. }
  17137. enableClick() {
  17138. this.div.addEventListener("pointerdown", this.#boundPointerdown);
  17139. this.div.addEventListener("pointerup", this.#boundPointerup);
  17140. }
  17141. disableClick() {
  17142. this.div.removeEventListener("pointerdown", this.#boundPointerdown);
  17143. this.div.removeEventListener("pointerup", this.#boundPointerup);
  17144. }
  17145. attach(editor) {
  17146. this.#editors.set(editor.id, editor);
  17147. const {
  17148. annotationElementId
  17149. } = editor;
  17150. if (annotationElementId && this.#uiManager.isDeletedAnnotationElement(annotationElementId)) {
  17151. this.#uiManager.removeDeletedAnnotationElement(editor);
  17152. }
  17153. }
  17154. detach(editor) {
  17155. this.#editors.delete(editor.id);
  17156. this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);
  17157. if (!this.#isDisabling && editor.annotationElementId) {
  17158. this.#uiManager.addDeletedAnnotationElement(editor);
  17159. }
  17160. }
  17161. remove(editor) {
  17162. this.detach(editor);
  17163. this.#uiManager.removeEditor(editor);
  17164. if (editor.div.contains(document.activeElement)) {
  17165. setTimeout(() => {
  17166. this.#uiManager.focusMainContainer();
  17167. }, 0);
  17168. }
  17169. editor.div.remove();
  17170. editor.isAttachedToDOM = false;
  17171. if (!this.#isCleaningUp) {
  17172. this.addInkEditorIfNeeded(false);
  17173. }
  17174. }
  17175. changeParent(editor) {
  17176. if (editor.parent === this) {
  17177. return;
  17178. }
  17179. if (editor.annotationElementId) {
  17180. this.#uiManager.addDeletedAnnotationElement(editor.annotationElementId);
  17181. _editor.AnnotationEditor.deleteAnnotationElement(editor);
  17182. editor.annotationElementId = null;
  17183. }
  17184. this.attach(editor);
  17185. editor.parent?.detach(editor);
  17186. editor.setParent(this);
  17187. if (editor.div && editor.isAttachedToDOM) {
  17188. editor.div.remove();
  17189. this.div.append(editor.div);
  17190. }
  17191. }
  17192. add(editor) {
  17193. this.changeParent(editor);
  17194. this.#uiManager.addEditor(editor);
  17195. this.attach(editor);
  17196. if (!editor.isAttachedToDOM) {
  17197. const div = editor.render();
  17198. this.div.append(div);
  17199. editor.isAttachedToDOM = true;
  17200. }
  17201. this.moveEditorInDOM(editor);
  17202. editor.onceAdded();
  17203. this.#uiManager.addToAnnotationStorage(editor);
  17204. }
  17205. moveEditorInDOM(editor) {
  17206. if (!editor.isAttachedToDOM) {
  17207. return;
  17208. }
  17209. const {
  17210. activeElement
  17211. } = document;
  17212. if (editor.div.contains(activeElement)) {
  17213. editor._focusEventsAllowed = false;
  17214. setTimeout(() => {
  17215. editor.div.addEventListener("focusin", () => {
  17216. editor._focusEventsAllowed = true;
  17217. }, {
  17218. once: true
  17219. });
  17220. activeElement.focus();
  17221. }, 0);
  17222. }
  17223. this.#accessibilityManager?.moveElementInDOM(this.div, editor.div, editor.contentDiv, true);
  17224. }
  17225. addOrRebuild(editor) {
  17226. if (editor.needsToBeRebuilt()) {
  17227. editor.rebuild();
  17228. } else {
  17229. this.add(editor);
  17230. }
  17231. }
  17232. addUndoableEditor(editor) {
  17233. const cmd = () => editor._uiManager.rebuild(editor);
  17234. const undo = () => {
  17235. editor.remove();
  17236. };
  17237. this.addCommands({
  17238. cmd,
  17239. undo,
  17240. mustExec: false
  17241. });
  17242. }
  17243. getNextId() {
  17244. return this.#uiManager.getId();
  17245. }
  17246. #createNewEditor(params) {
  17247. switch (this.#uiManager.getMode()) {
  17248. case _util.AnnotationEditorType.FREETEXT:
  17249. return new _freetext.FreeTextEditor(params);
  17250. case _util.AnnotationEditorType.INK:
  17251. return new _ink.InkEditor(params);
  17252. case _util.AnnotationEditorType.STAMP:
  17253. return new _stamp.StampEditor(params);
  17254. }
  17255. return null;
  17256. }
  17257. pasteEditor(mode, params) {
  17258. this.#uiManager.updateToolbar(mode);
  17259. this.#uiManager.updateMode(mode);
  17260. const {
  17261. offsetX,
  17262. offsetY
  17263. } = this.#getCenterPoint();
  17264. const id = this.getNextId();
  17265. const editor = this.#createNewEditor({
  17266. parent: this,
  17267. id,
  17268. x: offsetX,
  17269. y: offsetY,
  17270. uiManager: this.#uiManager,
  17271. isCentered: true,
  17272. ...params
  17273. });
  17274. if (editor) {
  17275. this.add(editor);
  17276. }
  17277. }
  17278. deserialize(data) {
  17279. switch (data.annotationType ?? data.annotationEditorType) {
  17280. case _util.AnnotationEditorType.FREETEXT:
  17281. return _freetext.FreeTextEditor.deserialize(data, this, this.#uiManager);
  17282. case _util.AnnotationEditorType.INK:
  17283. return _ink.InkEditor.deserialize(data, this, this.#uiManager);
  17284. case _util.AnnotationEditorType.STAMP:
  17285. return _stamp.StampEditor.deserialize(data, this, this.#uiManager);
  17286. }
  17287. return null;
  17288. }
  17289. #createAndAddNewEditor(event, isCentered) {
  17290. const id = this.getNextId();
  17291. const editor = this.#createNewEditor({
  17292. parent: this,
  17293. id,
  17294. x: event.offsetX,
  17295. y: event.offsetY,
  17296. uiManager: this.#uiManager,
  17297. isCentered
  17298. });
  17299. if (editor) {
  17300. this.add(editor);
  17301. }
  17302. return editor;
  17303. }
  17304. #getCenterPoint() {
  17305. const {
  17306. x,
  17307. y,
  17308. width,
  17309. height
  17310. } = this.div.getBoundingClientRect();
  17311. const tlX = Math.max(0, x);
  17312. const tlY = Math.max(0, y);
  17313. const brX = Math.min(window.innerWidth, x + width);
  17314. const brY = Math.min(window.innerHeight, y + height);
  17315. const centerX = (tlX + brX) / 2 - x;
  17316. const centerY = (tlY + brY) / 2 - y;
  17317. const [offsetX, offsetY] = this.viewport.rotation % 180 === 0 ? [centerX, centerY] : [centerY, centerX];
  17318. return {
  17319. offsetX,
  17320. offsetY
  17321. };
  17322. }
  17323. addNewEditor() {
  17324. this.#createAndAddNewEditor(this.#getCenterPoint(), true);
  17325. }
  17326. setSelected(editor) {
  17327. this.#uiManager.setSelected(editor);
  17328. }
  17329. toggleSelected(editor) {
  17330. this.#uiManager.toggleSelected(editor);
  17331. }
  17332. isSelected(editor) {
  17333. return this.#uiManager.isSelected(editor);
  17334. }
  17335. unselect(editor) {
  17336. this.#uiManager.unselect(editor);
  17337. }
  17338. pointerup(event) {
  17339. const {
  17340. isMac
  17341. } = _util.FeatureTest.platform;
  17342. if (event.button !== 0 || event.ctrlKey && isMac) {
  17343. return;
  17344. }
  17345. if (event.target !== this.div) {
  17346. return;
  17347. }
  17348. if (!this.#hadPointerDown) {
  17349. return;
  17350. }
  17351. this.#hadPointerDown = false;
  17352. if (!this.#allowClick) {
  17353. this.#allowClick = true;
  17354. return;
  17355. }
  17356. if (this.#uiManager.getMode() === _util.AnnotationEditorType.STAMP) {
  17357. this.#uiManager.unselectAll();
  17358. return;
  17359. }
  17360. this.#createAndAddNewEditor(event, false);
  17361. }
  17362. pointerdown(event) {
  17363. if (this.#hadPointerDown) {
  17364. this.#hadPointerDown = false;
  17365. return;
  17366. }
  17367. const {
  17368. isMac
  17369. } = _util.FeatureTest.platform;
  17370. if (event.button !== 0 || event.ctrlKey && isMac) {
  17371. return;
  17372. }
  17373. if (event.target !== this.div) {
  17374. return;
  17375. }
  17376. this.#hadPointerDown = true;
  17377. const editor = this.#uiManager.getActive();
  17378. this.#allowClick = !editor || editor.isEmpty();
  17379. }
  17380. findNewParent(editor, x, y) {
  17381. const layer = this.#uiManager.findParent(x, y);
  17382. if (layer === null || layer === this) {
  17383. return false;
  17384. }
  17385. layer.changeParent(editor);
  17386. return true;
  17387. }
  17388. destroy() {
  17389. if (this.#uiManager.getActive()?.parent === this) {
  17390. this.#uiManager.setActiveEditor(null);
  17391. }
  17392. for (const editor of this.#editors.values()) {
  17393. this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);
  17394. editor.setParent(null);
  17395. editor.isAttachedToDOM = false;
  17396. editor.div.remove();
  17397. }
  17398. this.div = null;
  17399. this.#editors.clear();
  17400. this.#uiManager.removeLayer(this);
  17401. }
  17402. #cleanup() {
  17403. this.#isCleaningUp = true;
  17404. for (const editor of this.#editors.values()) {
  17405. if (editor.isEmpty()) {
  17406. editor.remove();
  17407. }
  17408. }
  17409. this.#isCleaningUp = false;
  17410. }
  17411. render(_ref2) {
  17412. let {
  17413. viewport
  17414. } = _ref2;
  17415. this.viewport = viewport;
  17416. (0, _display_utils.setLayerDimensions)(this.div, viewport);
  17417. for (const editor of this.#uiManager.getEditors(this.pageIndex)) {
  17418. this.add(editor);
  17419. }
  17420. this.updateMode();
  17421. }
  17422. update(_ref3) {
  17423. let {
  17424. viewport
  17425. } = _ref3;
  17426. this.#uiManager.commitOrRemove();
  17427. this.viewport = viewport;
  17428. (0, _display_utils.setLayerDimensions)(this.div, {
  17429. rotation: viewport.rotation
  17430. });
  17431. this.updateMode();
  17432. }
  17433. get pageDimensions() {
  17434. const {
  17435. pageWidth,
  17436. pageHeight
  17437. } = this.viewport.rawDims;
  17438. return [pageWidth, pageHeight];
  17439. }
  17440. }
  17441. exports.AnnotationEditorLayer = AnnotationEditorLayer;
  17442. /***/ }),
  17443. /* 197 */
  17444. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17445. Object.defineProperty(exports, "__esModule", ({
  17446. value: true
  17447. }));
  17448. exports.FreeTextEditor = void 0;
  17449. __w_pdfjs_require__(89);
  17450. var _util = __w_pdfjs_require__(1);
  17451. var _tools = __w_pdfjs_require__(165);
  17452. var _editor = __w_pdfjs_require__(164);
  17453. var _annotation_layer = __w_pdfjs_require__(198);
  17454. class FreeTextEditor extends _editor.AnnotationEditor {
  17455. #boundEditorDivBlur = this.editorDivBlur.bind(this);
  17456. #boundEditorDivFocus = this.editorDivFocus.bind(this);
  17457. #boundEditorDivInput = this.editorDivInput.bind(this);
  17458. #boundEditorDivKeydown = this.editorDivKeydown.bind(this);
  17459. #color;
  17460. #content = "";
  17461. #editorDivId = `${this.id}-editor`;
  17462. #fontSize;
  17463. #initialData = null;
  17464. static _freeTextDefaultContent = "";
  17465. static _l10nPromise;
  17466. static _internalPadding = 0;
  17467. static _defaultColor = null;
  17468. static _defaultFontSize = 10;
  17469. static get _keyboardManager() {
  17470. const proto = FreeTextEditor.prototype;
  17471. const arrowChecker = self => self.isEmpty();
  17472. const small = _tools.AnnotationEditorUIManager.TRANSLATE_SMALL;
  17473. const big = _tools.AnnotationEditorUIManager.TRANSLATE_BIG;
  17474. return (0, _util.shadow)(this, "_keyboardManager", new _tools.KeyboardManager([[["ctrl+s", "mac+meta+s", "ctrl+p", "mac+meta+p"], proto.commitOrRemove, {
  17475. bubbles: true
  17476. }], [["ctrl+Enter", "mac+meta+Enter", "Escape", "mac+Escape"], proto.commitOrRemove], [["ArrowLeft", "mac+ArrowLeft"], proto._translateEmpty, {
  17477. args: [-small, 0],
  17478. checker: arrowChecker
  17479. }], [["ctrl+ArrowLeft", "mac+shift+ArrowLeft"], proto._translateEmpty, {
  17480. args: [-big, 0],
  17481. checker: arrowChecker
  17482. }], [["ArrowRight", "mac+ArrowRight"], proto._translateEmpty, {
  17483. args: [small, 0],
  17484. checker: arrowChecker
  17485. }], [["ctrl+ArrowRight", "mac+shift+ArrowRight"], proto._translateEmpty, {
  17486. args: [big, 0],
  17487. checker: arrowChecker
  17488. }], [["ArrowUp", "mac+ArrowUp"], proto._translateEmpty, {
  17489. args: [0, -small],
  17490. checker: arrowChecker
  17491. }], [["ctrl+ArrowUp", "mac+shift+ArrowUp"], proto._translateEmpty, {
  17492. args: [0, -big],
  17493. checker: arrowChecker
  17494. }], [["ArrowDown", "mac+ArrowDown"], proto._translateEmpty, {
  17495. args: [0, small],
  17496. checker: arrowChecker
  17497. }], [["ctrl+ArrowDown", "mac+shift+ArrowDown"], proto._translateEmpty, {
  17498. args: [0, big],
  17499. checker: arrowChecker
  17500. }]]));
  17501. }
  17502. static _type = "freetext";
  17503. constructor(params) {
  17504. super({
  17505. ...params,
  17506. name: "freeTextEditor"
  17507. });
  17508. this.#color = params.color || FreeTextEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor;
  17509. this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;
  17510. }
  17511. static initialize(l10n) {
  17512. this._l10nPromise = new Map(["free_text2_default_content", "editor_free_text2_aria_label"].map(str => [str, l10n.get(str)]));
  17513. const style = getComputedStyle(document.documentElement);
  17514. this._internalPadding = parseFloat(style.getPropertyValue("--freetext-padding"));
  17515. }
  17516. static updateDefaultParams(type, value) {
  17517. switch (type) {
  17518. case _util.AnnotationEditorParamsType.FREETEXT_SIZE:
  17519. FreeTextEditor._defaultFontSize = value;
  17520. break;
  17521. case _util.AnnotationEditorParamsType.FREETEXT_COLOR:
  17522. FreeTextEditor._defaultColor = value;
  17523. break;
  17524. }
  17525. }
  17526. updateParams(type, value) {
  17527. switch (type) {
  17528. case _util.AnnotationEditorParamsType.FREETEXT_SIZE:
  17529. this.#updateFontSize(value);
  17530. break;
  17531. case _util.AnnotationEditorParamsType.FREETEXT_COLOR:
  17532. this.#updateColor(value);
  17533. break;
  17534. }
  17535. }
  17536. static get defaultPropertiesToUpdate() {
  17537. return [[_util.AnnotationEditorParamsType.FREETEXT_SIZE, FreeTextEditor._defaultFontSize], [_util.AnnotationEditorParamsType.FREETEXT_COLOR, FreeTextEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor]];
  17538. }
  17539. get propertiesToUpdate() {
  17540. return [[_util.AnnotationEditorParamsType.FREETEXT_SIZE, this.#fontSize], [_util.AnnotationEditorParamsType.FREETEXT_COLOR, this.#color]];
  17541. }
  17542. #updateFontSize(fontSize) {
  17543. const setFontsize = size => {
  17544. this.editorDiv.style.fontSize = `calc(${size}px * var(--scale-factor))`;
  17545. this.translate(0, -(size - this.#fontSize) * this.parentScale);
  17546. this.#fontSize = size;
  17547. this.#setEditorDimensions();
  17548. };
  17549. const savedFontsize = this.#fontSize;
  17550. this.addCommands({
  17551. cmd: () => {
  17552. setFontsize(fontSize);
  17553. },
  17554. undo: () => {
  17555. setFontsize(savedFontsize);
  17556. },
  17557. mustExec: true,
  17558. type: _util.AnnotationEditorParamsType.FREETEXT_SIZE,
  17559. overwriteIfSameType: true,
  17560. keepUndo: true
  17561. });
  17562. }
  17563. #updateColor(color) {
  17564. const savedColor = this.#color;
  17565. this.addCommands({
  17566. cmd: () => {
  17567. this.#color = this.editorDiv.style.color = color;
  17568. },
  17569. undo: () => {
  17570. this.#color = this.editorDiv.style.color = savedColor;
  17571. },
  17572. mustExec: true,
  17573. type: _util.AnnotationEditorParamsType.FREETEXT_COLOR,
  17574. overwriteIfSameType: true,
  17575. keepUndo: true
  17576. });
  17577. }
  17578. _translateEmpty(x, y) {
  17579. this._uiManager.translateSelectedEditors(x, y, true);
  17580. }
  17581. getInitialTranslation() {
  17582. const scale = this.parentScale;
  17583. return [-FreeTextEditor._internalPadding * scale, -(FreeTextEditor._internalPadding + this.#fontSize) * scale];
  17584. }
  17585. rebuild() {
  17586. if (!this.parent) {
  17587. return;
  17588. }
  17589. super.rebuild();
  17590. if (this.div === null) {
  17591. return;
  17592. }
  17593. if (!this.isAttachedToDOM) {
  17594. this.parent.add(this);
  17595. }
  17596. }
  17597. enableEditMode() {
  17598. if (this.isInEditMode()) {
  17599. return;
  17600. }
  17601. this.parent.setEditingState(false);
  17602. this.parent.updateToolbar(_util.AnnotationEditorType.FREETEXT);
  17603. super.enableEditMode();
  17604. this.overlayDiv.classList.remove("enabled");
  17605. this.editorDiv.contentEditable = true;
  17606. this._isDraggable = false;
  17607. this.div.removeAttribute("aria-activedescendant");
  17608. this.editorDiv.addEventListener("keydown", this.#boundEditorDivKeydown);
  17609. this.editorDiv.addEventListener("focus", this.#boundEditorDivFocus);
  17610. this.editorDiv.addEventListener("blur", this.#boundEditorDivBlur);
  17611. this.editorDiv.addEventListener("input", this.#boundEditorDivInput);
  17612. }
  17613. disableEditMode() {
  17614. if (!this.isInEditMode()) {
  17615. return;
  17616. }
  17617. this.parent.setEditingState(true);
  17618. super.disableEditMode();
  17619. this.overlayDiv.classList.add("enabled");
  17620. this.editorDiv.contentEditable = false;
  17621. this.div.setAttribute("aria-activedescendant", this.#editorDivId);
  17622. this._isDraggable = true;
  17623. this.editorDiv.removeEventListener("keydown", this.#boundEditorDivKeydown);
  17624. this.editorDiv.removeEventListener("focus", this.#boundEditorDivFocus);
  17625. this.editorDiv.removeEventListener("blur", this.#boundEditorDivBlur);
  17626. this.editorDiv.removeEventListener("input", this.#boundEditorDivInput);
  17627. this.div.focus({
  17628. preventScroll: true
  17629. });
  17630. this.isEditing = false;
  17631. this.parent.div.classList.add("freeTextEditing");
  17632. }
  17633. focusin(event) {
  17634. if (!this._focusEventsAllowed) {
  17635. return;
  17636. }
  17637. super.focusin(event);
  17638. if (event.target !== this.editorDiv) {
  17639. this.editorDiv.focus();
  17640. }
  17641. }
  17642. onceAdded() {
  17643. if (this.width) {
  17644. this.#cheatInitialRect();
  17645. return;
  17646. }
  17647. this.enableEditMode();
  17648. this.editorDiv.focus();
  17649. if (this._initialOptions?.isCentered) {
  17650. this.center();
  17651. }
  17652. this._initialOptions = null;
  17653. }
  17654. isEmpty() {
  17655. return !this.editorDiv || this.editorDiv.innerText.trim() === "";
  17656. }
  17657. remove() {
  17658. this.isEditing = false;
  17659. if (this.parent) {
  17660. this.parent.setEditingState(true);
  17661. this.parent.div.classList.add("freeTextEditing");
  17662. }
  17663. super.remove();
  17664. }
  17665. #extractText() {
  17666. const divs = this.editorDiv.getElementsByTagName("div");
  17667. if (divs.length === 0) {
  17668. return this.editorDiv.innerText;
  17669. }
  17670. const buffer = [];
  17671. for (const div of divs) {
  17672. buffer.push(div.innerText.replace(/\r\n?|\n/, ""));
  17673. }
  17674. return buffer.join("\n");
  17675. }
  17676. #setEditorDimensions() {
  17677. const [parentWidth, parentHeight] = this.parentDimensions;
  17678. let rect;
  17679. if (this.isAttachedToDOM) {
  17680. rect = this.div.getBoundingClientRect();
  17681. } else {
  17682. const {
  17683. currentLayer,
  17684. div
  17685. } = this;
  17686. const savedDisplay = div.style.display;
  17687. div.style.display = "hidden";
  17688. currentLayer.div.append(this.div);
  17689. rect = div.getBoundingClientRect();
  17690. div.remove();
  17691. div.style.display = savedDisplay;
  17692. }
  17693. if (this.rotation % 180 === this.parentRotation % 180) {
  17694. this.width = rect.width / parentWidth;
  17695. this.height = rect.height / parentHeight;
  17696. } else {
  17697. this.width = rect.height / parentWidth;
  17698. this.height = rect.width / parentHeight;
  17699. }
  17700. this.fixAndSetPosition();
  17701. }
  17702. commit() {
  17703. if (!this.isInEditMode()) {
  17704. return;
  17705. }
  17706. super.commit();
  17707. this.disableEditMode();
  17708. const savedText = this.#content;
  17709. const newText = this.#content = this.#extractText().trimEnd();
  17710. if (savedText === newText) {
  17711. return;
  17712. }
  17713. const setText = text => {
  17714. this.#content = text;
  17715. if (!text) {
  17716. this.remove();
  17717. return;
  17718. }
  17719. this.#setContent();
  17720. this._uiManager.rebuild(this);
  17721. this.#setEditorDimensions();
  17722. };
  17723. this.addCommands({
  17724. cmd: () => {
  17725. setText(newText);
  17726. },
  17727. undo: () => {
  17728. setText(savedText);
  17729. },
  17730. mustExec: false
  17731. });
  17732. this.#setEditorDimensions();
  17733. }
  17734. shouldGetKeyboardEvents() {
  17735. return this.isInEditMode();
  17736. }
  17737. enterInEditMode() {
  17738. this.enableEditMode();
  17739. this.editorDiv.focus();
  17740. }
  17741. dblclick(event) {
  17742. this.enterInEditMode();
  17743. }
  17744. keydown(event) {
  17745. if (event.target === this.div && event.key === "Enter") {
  17746. this.enterInEditMode();
  17747. event.preventDefault();
  17748. }
  17749. }
  17750. editorDivKeydown(event) {
  17751. FreeTextEditor._keyboardManager.exec(this, event);
  17752. }
  17753. editorDivFocus(event) {
  17754. this.isEditing = true;
  17755. }
  17756. editorDivBlur(event) {
  17757. this.isEditing = false;
  17758. }
  17759. editorDivInput(event) {
  17760. this.parent.div.classList.toggle("freeTextEditing", this.isEmpty());
  17761. }
  17762. disableEditing() {
  17763. this.editorDiv.setAttribute("role", "comment");
  17764. this.editorDiv.removeAttribute("aria-multiline");
  17765. }
  17766. enableEditing() {
  17767. this.editorDiv.setAttribute("role", "textbox");
  17768. this.editorDiv.setAttribute("aria-multiline", true);
  17769. }
  17770. render() {
  17771. if (this.div) {
  17772. return this.div;
  17773. }
  17774. let baseX, baseY;
  17775. if (this.width) {
  17776. baseX = this.x;
  17777. baseY = this.y;
  17778. }
  17779. super.render();
  17780. this.editorDiv = document.createElement("div");
  17781. this.editorDiv.className = "internal";
  17782. this.editorDiv.setAttribute("id", this.#editorDivId);
  17783. this.enableEditing();
  17784. FreeTextEditor._l10nPromise.get("editor_free_text2_aria_label").then(msg => this.editorDiv?.setAttribute("aria-label", msg));
  17785. FreeTextEditor._l10nPromise.get("free_text2_default_content").then(msg => this.editorDiv?.setAttribute("default-content", msg));
  17786. this.editorDiv.contentEditable = true;
  17787. const {
  17788. style
  17789. } = this.editorDiv;
  17790. style.fontSize = `calc(${this.#fontSize}px * var(--scale-factor))`;
  17791. style.color = this.#color;
  17792. this.div.append(this.editorDiv);
  17793. this.overlayDiv = document.createElement("div");
  17794. this.overlayDiv.classList.add("overlay", "enabled");
  17795. this.div.append(this.overlayDiv);
  17796. (0, _tools.bindEvents)(this, this.div, ["dblclick", "keydown"]);
  17797. if (this.width) {
  17798. const [parentWidth, parentHeight] = this.parentDimensions;
  17799. if (this.annotationElementId) {
  17800. const {
  17801. position
  17802. } = this.#initialData;
  17803. let [tx, ty] = this.getInitialTranslation();
  17804. [tx, ty] = this.pageTranslationToScreen(tx, ty);
  17805. const [pageWidth, pageHeight] = this.pageDimensions;
  17806. const [pageX, pageY] = this.pageTranslation;
  17807. let posX, posY;
  17808. switch (this.rotation) {
  17809. case 0:
  17810. posX = baseX + (position[0] - pageX) / pageWidth;
  17811. posY = baseY + this.height - (position[1] - pageY) / pageHeight;
  17812. break;
  17813. case 90:
  17814. posX = baseX + (position[0] - pageX) / pageWidth;
  17815. posY = baseY - (position[1] - pageY) / pageHeight;
  17816. [tx, ty] = [ty, -tx];
  17817. break;
  17818. case 180:
  17819. posX = baseX - this.width + (position[0] - pageX) / pageWidth;
  17820. posY = baseY - (position[1] - pageY) / pageHeight;
  17821. [tx, ty] = [-tx, -ty];
  17822. break;
  17823. case 270:
  17824. posX = baseX + (position[0] - pageX - this.height * pageHeight) / pageWidth;
  17825. posY = baseY + (position[1] - pageY - this.width * pageWidth) / pageHeight;
  17826. [tx, ty] = [-ty, tx];
  17827. break;
  17828. }
  17829. this.setAt(posX * parentWidth, posY * parentHeight, tx, ty);
  17830. } else {
  17831. this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
  17832. }
  17833. this.#setContent();
  17834. this._isDraggable = true;
  17835. this.editorDiv.contentEditable = false;
  17836. } else {
  17837. this._isDraggable = false;
  17838. this.editorDiv.contentEditable = true;
  17839. }
  17840. return this.div;
  17841. }
  17842. #setContent() {
  17843. this.editorDiv.replaceChildren();
  17844. if (!this.#content) {
  17845. return;
  17846. }
  17847. for (const line of this.#content.split("\n")) {
  17848. const div = document.createElement("div");
  17849. div.append(line ? document.createTextNode(line) : document.createElement("br"));
  17850. this.editorDiv.append(div);
  17851. }
  17852. }
  17853. get contentDiv() {
  17854. return this.editorDiv;
  17855. }
  17856. static deserialize(data, parent, uiManager) {
  17857. let initialData = null;
  17858. if (data instanceof _annotation_layer.FreeTextAnnotationElement) {
  17859. const {
  17860. data: {
  17861. defaultAppearanceData: {
  17862. fontSize,
  17863. fontColor
  17864. },
  17865. rect,
  17866. rotation,
  17867. id
  17868. },
  17869. textContent,
  17870. textPosition,
  17871. parent: {
  17872. page: {
  17873. pageNumber
  17874. }
  17875. }
  17876. } = data;
  17877. if (!textContent || textContent.length === 0) {
  17878. return null;
  17879. }
  17880. initialData = data = {
  17881. annotationType: _util.AnnotationEditorType.FREETEXT,
  17882. color: Array.from(fontColor),
  17883. fontSize,
  17884. value: textContent.join("\n"),
  17885. position: textPosition,
  17886. pageIndex: pageNumber - 1,
  17887. rect,
  17888. rotation,
  17889. id,
  17890. deleted: false
  17891. };
  17892. }
  17893. const editor = super.deserialize(data, parent, uiManager);
  17894. editor.#fontSize = data.fontSize;
  17895. editor.#color = _util.Util.makeHexColor(...data.color);
  17896. editor.#content = data.value;
  17897. editor.annotationElementId = data.id || null;
  17898. editor.#initialData = initialData;
  17899. return editor;
  17900. }
  17901. serialize() {
  17902. let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17903. if (this.isEmpty()) {
  17904. return null;
  17905. }
  17906. if (this.deleted) {
  17907. return {
  17908. pageIndex: this.pageIndex,
  17909. id: this.annotationElementId,
  17910. deleted: true
  17911. };
  17912. }
  17913. const padding = FreeTextEditor._internalPadding * this.parentScale;
  17914. const rect = this.getRect(padding, padding);
  17915. const color = _editor.AnnotationEditor._colorManager.convert(this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.#color);
  17916. const serialized = {
  17917. annotationType: _util.AnnotationEditorType.FREETEXT,
  17918. color,
  17919. fontSize: this.#fontSize,
  17920. value: this.#content,
  17921. pageIndex: this.pageIndex,
  17922. rect,
  17923. rotation: this.rotation
  17924. };
  17925. if (isForCopying) {
  17926. return serialized;
  17927. }
  17928. if (this.annotationElementId && !this.#hasElementChanged(serialized)) {
  17929. return null;
  17930. }
  17931. serialized.id = this.annotationElementId;
  17932. return serialized;
  17933. }
  17934. #hasElementChanged(serialized) {
  17935. const {
  17936. value,
  17937. fontSize,
  17938. color,
  17939. rect,
  17940. pageIndex
  17941. } = this.#initialData;
  17942. return serialized.value !== value || serialized.fontSize !== fontSize || serialized.rect.some((x, i) => Math.abs(x - rect[i]) >= 1) || serialized.color.some((c, i) => c !== color[i]) || serialized.pageIndex !== pageIndex;
  17943. }
  17944. #cheatInitialRect() {
  17945. let delayed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17946. if (!this.annotationElementId) {
  17947. return;
  17948. }
  17949. this.#setEditorDimensions();
  17950. if (!delayed && (this.width === 0 || this.height === 0)) {
  17951. setTimeout(() => this.#cheatInitialRect(true), 0);
  17952. return;
  17953. }
  17954. const padding = FreeTextEditor._internalPadding * this.parentScale;
  17955. this.#initialData.rect = this.getRect(padding, padding);
  17956. }
  17957. }
  17958. exports.FreeTextEditor = FreeTextEditor;
  17959. /***/ }),
  17960. /* 198 */
  17961. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  17962. Object.defineProperty(exports, "__esModule", ({
  17963. value: true
  17964. }));
  17965. exports.StampAnnotationElement = exports.InkAnnotationElement = exports.FreeTextAnnotationElement = exports.AnnotationLayer = void 0;
  17966. __w_pdfjs_require__(89);
  17967. __w_pdfjs_require__(125);
  17968. __w_pdfjs_require__(136);
  17969. __w_pdfjs_require__(138);
  17970. __w_pdfjs_require__(141);
  17971. __w_pdfjs_require__(143);
  17972. __w_pdfjs_require__(145);
  17973. __w_pdfjs_require__(147);
  17974. var _util = __w_pdfjs_require__(1);
  17975. var _display_utils = __w_pdfjs_require__(168);
  17976. var _annotation_storage = __w_pdfjs_require__(163);
  17977. var _scripting_utils = __w_pdfjs_require__(199);
  17978. var _displayL10n_utils = __w_pdfjs_require__(200);
  17979. var _xfa_layer = __w_pdfjs_require__(201);
  17980. const DEFAULT_TAB_INDEX = 1000;
  17981. const DEFAULT_FONT_SIZE = 9;
  17982. const GetElementsByNameSet = new WeakSet();
  17983. function getRectDims(rect) {
  17984. return {
  17985. width: rect[2] - rect[0],
  17986. height: rect[3] - rect[1]
  17987. };
  17988. }
  17989. class AnnotationElementFactory {
  17990. static create(parameters) {
  17991. const subtype = parameters.data.annotationType;
  17992. switch (subtype) {
  17993. case _util.AnnotationType.LINK:
  17994. return new LinkAnnotationElement(parameters);
  17995. case _util.AnnotationType.TEXT:
  17996. return new TextAnnotationElement(parameters);
  17997. case _util.AnnotationType.WIDGET:
  17998. const fieldType = parameters.data.fieldType;
  17999. switch (fieldType) {
  18000. case "Tx":
  18001. return new TextWidgetAnnotationElement(parameters);
  18002. case "Btn":
  18003. if (parameters.data.radioButton) {
  18004. return new RadioButtonWidgetAnnotationElement(parameters);
  18005. } else if (parameters.data.checkBox) {
  18006. return new CheckboxWidgetAnnotationElement(parameters);
  18007. }
  18008. return new PushButtonWidgetAnnotationElement(parameters);
  18009. case "Ch":
  18010. return new ChoiceWidgetAnnotationElement(parameters);
  18011. case "Sig":
  18012. return new SignatureWidgetAnnotationElement(parameters);
  18013. }
  18014. return new WidgetAnnotationElement(parameters);
  18015. case _util.AnnotationType.POPUP:
  18016. return new PopupAnnotationElement(parameters);
  18017. case _util.AnnotationType.FREETEXT:
  18018. return new FreeTextAnnotationElement(parameters);
  18019. case _util.AnnotationType.LINE:
  18020. return new LineAnnotationElement(parameters);
  18021. case _util.AnnotationType.SQUARE:
  18022. return new SquareAnnotationElement(parameters);
  18023. case _util.AnnotationType.CIRCLE:
  18024. return new CircleAnnotationElement(parameters);
  18025. case _util.AnnotationType.POLYLINE:
  18026. return new PolylineAnnotationElement(parameters);
  18027. case _util.AnnotationType.CARET:
  18028. return new CaretAnnotationElement(parameters);
  18029. case _util.AnnotationType.INK:
  18030. return new InkAnnotationElement(parameters);
  18031. case _util.AnnotationType.POLYGON:
  18032. return new PolygonAnnotationElement(parameters);
  18033. case _util.AnnotationType.HIGHLIGHT:
  18034. return new HighlightAnnotationElement(parameters);
  18035. case _util.AnnotationType.UNDERLINE:
  18036. return new UnderlineAnnotationElement(parameters);
  18037. case _util.AnnotationType.SQUIGGLY:
  18038. return new SquigglyAnnotationElement(parameters);
  18039. case _util.AnnotationType.STRIKEOUT:
  18040. return new StrikeOutAnnotationElement(parameters);
  18041. case _util.AnnotationType.STAMP:
  18042. return new StampAnnotationElement(parameters);
  18043. case _util.AnnotationType.FILEATTACHMENT:
  18044. return new FileAttachmentAnnotationElement(parameters);
  18045. default:
  18046. return new AnnotationElement(parameters);
  18047. }
  18048. }
  18049. }
  18050. class AnnotationElement {
  18051. #hasBorder = false;
  18052. constructor(parameters) {
  18053. let {
  18054. isRenderable = false,
  18055. ignoreBorder = false,
  18056. createQuadrilaterals = false
  18057. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  18058. this.isRenderable = isRenderable;
  18059. this.data = parameters.data;
  18060. this.layer = parameters.layer;
  18061. this.linkService = parameters.linkService;
  18062. this.downloadManager = parameters.downloadManager;
  18063. this.imageResourcesPath = parameters.imageResourcesPath;
  18064. this.renderForms = parameters.renderForms;
  18065. this.svgFactory = parameters.svgFactory;
  18066. this.annotationStorage = parameters.annotationStorage;
  18067. this.enableScripting = parameters.enableScripting;
  18068. this.hasJSActions = parameters.hasJSActions;
  18069. this._fieldObjects = parameters.fieldObjects;
  18070. this.parent = parameters.parent;
  18071. if (isRenderable) {
  18072. this.container = this._createContainer(ignoreBorder);
  18073. }
  18074. if (createQuadrilaterals) {
  18075. this._createQuadrilaterals();
  18076. }
  18077. }
  18078. _createContainer(ignoreBorder) {
  18079. const {
  18080. data,
  18081. parent: {
  18082. page,
  18083. viewport
  18084. }
  18085. } = this;
  18086. const container = document.createElement("section");
  18087. container.setAttribute("data-annotation-id", data.id);
  18088. container.style.zIndex = this.parent.zIndex++;
  18089. if (this.data.popupRef) {
  18090. container.setAttribute("aria-haspopup", "dialog");
  18091. }
  18092. if (data.noRotate) {
  18093. container.classList.add("norotate");
  18094. }
  18095. const {
  18096. pageWidth,
  18097. pageHeight,
  18098. pageX,
  18099. pageY
  18100. } = viewport.rawDims;
  18101. if (!data.rect || this instanceof PopupAnnotationElement) {
  18102. const {
  18103. rotation
  18104. } = data;
  18105. if (!data.hasOwnCanvas && rotation !== 0) {
  18106. this.setRotation(rotation, container);
  18107. }
  18108. return container;
  18109. }
  18110. const {
  18111. width,
  18112. height
  18113. } = getRectDims(data.rect);
  18114. const 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]]);
  18115. if (!ignoreBorder && data.borderStyle.width > 0) {
  18116. container.style.borderWidth = `${data.borderStyle.width}px`;
  18117. const horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18118. const verticalRadius = data.borderStyle.verticalCornerRadius;
  18119. if (horizontalRadius > 0 || verticalRadius > 0) {
  18120. const radius = `calc(${horizontalRadius}px * var(--scale-factor)) / calc(${verticalRadius}px * var(--scale-factor))`;
  18121. container.style.borderRadius = radius;
  18122. } else if (this instanceof RadioButtonWidgetAnnotationElement) {
  18123. const radius = `calc(${width}px * var(--scale-factor)) / calc(${height}px * var(--scale-factor))`;
  18124. container.style.borderRadius = radius;
  18125. }
  18126. switch (data.borderStyle.style) {
  18127. case _util.AnnotationBorderStyleType.SOLID:
  18128. container.style.borderStyle = "solid";
  18129. break;
  18130. case _util.AnnotationBorderStyleType.DASHED:
  18131. container.style.borderStyle = "dashed";
  18132. break;
  18133. case _util.AnnotationBorderStyleType.BEVELED:
  18134. (0, _util.warn)("Unimplemented border style: beveled");
  18135. break;
  18136. case _util.AnnotationBorderStyleType.INSET:
  18137. (0, _util.warn)("Unimplemented border style: inset");
  18138. break;
  18139. case _util.AnnotationBorderStyleType.UNDERLINE:
  18140. container.style.borderBottomStyle = "solid";
  18141. break;
  18142. default:
  18143. break;
  18144. }
  18145. const borderColor = data.borderColor || null;
  18146. if (borderColor) {
  18147. this.#hasBorder = true;
  18148. container.style.borderColor = _util.Util.makeHexColor(borderColor[0] | 0, borderColor[1] | 0, borderColor[2] | 0);
  18149. } else {
  18150. container.style.borderWidth = 0;
  18151. }
  18152. }
  18153. container.style.left = `${100 * (rect[0] - pageX) / pageWidth}%`;
  18154. container.style.top = `${100 * (rect[1] - pageY) / pageHeight}%`;
  18155. const {
  18156. rotation
  18157. } = data;
  18158. if (data.hasOwnCanvas || rotation === 0) {
  18159. container.style.width = `${100 * width / pageWidth}%`;
  18160. container.style.height = `${100 * height / pageHeight}%`;
  18161. } else {
  18162. this.setRotation(rotation, container);
  18163. }
  18164. return container;
  18165. }
  18166. setRotation(angle) {
  18167. let container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.container;
  18168. if (!this.data.rect) {
  18169. return;
  18170. }
  18171. const {
  18172. pageWidth,
  18173. pageHeight
  18174. } = this.parent.viewport.rawDims;
  18175. const {
  18176. width,
  18177. height
  18178. } = getRectDims(this.data.rect);
  18179. let elementWidth, elementHeight;
  18180. if (angle % 180 === 0) {
  18181. elementWidth = 100 * width / pageWidth;
  18182. elementHeight = 100 * height / pageHeight;
  18183. } else {
  18184. elementWidth = 100 * height / pageWidth;
  18185. elementHeight = 100 * width / pageHeight;
  18186. }
  18187. container.style.width = `${elementWidth}%`;
  18188. container.style.height = `${elementHeight}%`;
  18189. container.setAttribute("data-main-rotation", (360 - angle) % 360);
  18190. }
  18191. get _commonActions() {
  18192. const setColor = (jsName, styleName, event) => {
  18193. const color = event.detail[jsName];
  18194. const colorType = color[0];
  18195. const colorArray = color.slice(1);
  18196. event.target.style[styleName] = _scripting_utils.ColorConverters[`${colorType}_HTML`](colorArray);
  18197. this.annotationStorage.setValue(this.data.id, {
  18198. [styleName]: _scripting_utils.ColorConverters[`${colorType}_rgb`](colorArray)
  18199. });
  18200. };
  18201. return (0, _util.shadow)(this, "_commonActions", {
  18202. display: event => {
  18203. const {
  18204. display
  18205. } = event.detail;
  18206. const hidden = display % 2 === 1;
  18207. this.container.style.visibility = hidden ? "hidden" : "visible";
  18208. this.annotationStorage.setValue(this.data.id, {
  18209. noView: hidden,
  18210. noPrint: display === 1 || display === 2
  18211. });
  18212. },
  18213. print: event => {
  18214. this.annotationStorage.setValue(this.data.id, {
  18215. noPrint: !event.detail.print
  18216. });
  18217. },
  18218. hidden: event => {
  18219. const {
  18220. hidden
  18221. } = event.detail;
  18222. this.container.style.visibility = hidden ? "hidden" : "visible";
  18223. this.annotationStorage.setValue(this.data.id, {
  18224. noPrint: hidden,
  18225. noView: hidden
  18226. });
  18227. },
  18228. focus: event => {
  18229. setTimeout(() => event.target.focus({
  18230. preventScroll: false
  18231. }), 0);
  18232. },
  18233. userName: event => {
  18234. event.target.title = event.detail.userName;
  18235. },
  18236. readonly: event => {
  18237. event.target.disabled = event.detail.readonly;
  18238. },
  18239. required: event => {
  18240. this._setRequired(event.target, event.detail.required);
  18241. },
  18242. bgColor: event => {
  18243. setColor("bgColor", "backgroundColor", event);
  18244. },
  18245. fillColor: event => {
  18246. setColor("fillColor", "backgroundColor", event);
  18247. },
  18248. fgColor: event => {
  18249. setColor("fgColor", "color", event);
  18250. },
  18251. textColor: event => {
  18252. setColor("textColor", "color", event);
  18253. },
  18254. borderColor: event => {
  18255. setColor("borderColor", "borderColor", event);
  18256. },
  18257. strokeColor: event => {
  18258. setColor("strokeColor", "borderColor", event);
  18259. },
  18260. rotation: event => {
  18261. const angle = event.detail.rotation;
  18262. this.setRotation(angle);
  18263. this.annotationStorage.setValue(this.data.id, {
  18264. rotation: angle
  18265. });
  18266. }
  18267. });
  18268. }
  18269. _dispatchEventFromSandbox(actions, jsEvent) {
  18270. const commonActions = this._commonActions;
  18271. for (const name of Object.keys(jsEvent.detail)) {
  18272. const action = actions[name] || commonActions[name];
  18273. action?.(jsEvent);
  18274. }
  18275. }
  18276. _setDefaultPropertiesFromJS(element) {
  18277. if (!this.enableScripting) {
  18278. return;
  18279. }
  18280. const storedData = this.annotationStorage.getRawValue(this.data.id);
  18281. if (!storedData) {
  18282. return;
  18283. }
  18284. const commonActions = this._commonActions;
  18285. for (const [actionName, detail] of Object.entries(storedData)) {
  18286. const action = commonActions[actionName];
  18287. if (action) {
  18288. const eventProxy = {
  18289. detail: {
  18290. [actionName]: detail
  18291. },
  18292. target: element
  18293. };
  18294. action(eventProxy);
  18295. delete storedData[actionName];
  18296. }
  18297. }
  18298. }
  18299. _createQuadrilaterals() {
  18300. if (!this.container) {
  18301. return;
  18302. }
  18303. const {
  18304. quadPoints
  18305. } = this.data;
  18306. if (!quadPoints) {
  18307. return;
  18308. }
  18309. const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect;
  18310. if (quadPoints.length === 1) {
  18311. const [, {
  18312. x: trX,
  18313. y: trY
  18314. }, {
  18315. x: blX,
  18316. y: blY
  18317. }] = quadPoints[0];
  18318. if (rectTrX === trX && rectTrY === trY && rectBlX === blX && rectBlY === blY) {
  18319. return;
  18320. }
  18321. }
  18322. const {
  18323. style
  18324. } = this.container;
  18325. let svgBuffer;
  18326. if (this.#hasBorder) {
  18327. const {
  18328. borderColor,
  18329. borderWidth
  18330. } = style;
  18331. style.borderWidth = 0;
  18332. svgBuffer = ["url('data:image/svg+xml;utf8,", `<svg xmlns="http://www.w3.org/2000/svg"`, ` preserveAspectRatio="none" viewBox="0 0 1 1">`, `<g fill="transparent" stroke="${borderColor}" stroke-width="${borderWidth}">`];
  18333. this.container.classList.add("hasBorder");
  18334. }
  18335. const width = rectTrX - rectBlX;
  18336. const height = rectTrY - rectBlY;
  18337. const {
  18338. svgFactory
  18339. } = this;
  18340. const svg = svgFactory.createElement("svg");
  18341. svg.classList.add("quadrilateralsContainer");
  18342. svg.setAttribute("width", 0);
  18343. svg.setAttribute("height", 0);
  18344. const defs = svgFactory.createElement("defs");
  18345. svg.append(defs);
  18346. const clipPath = svgFactory.createElement("clipPath");
  18347. const id = `clippath_${this.data.id}`;
  18348. clipPath.setAttribute("id", id);
  18349. clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
  18350. defs.append(clipPath);
  18351. for (const [, {
  18352. x: trX,
  18353. y: trY
  18354. }, {
  18355. x: blX,
  18356. y: blY
  18357. }] of quadPoints) {
  18358. const rect = svgFactory.createElement("rect");
  18359. const x = (blX - rectBlX) / width;
  18360. const y = (rectTrY - trY) / height;
  18361. const rectWidth = (trX - blX) / width;
  18362. const rectHeight = (trY - blY) / height;
  18363. rect.setAttribute("x", x);
  18364. rect.setAttribute("y", y);
  18365. rect.setAttribute("width", rectWidth);
  18366. rect.setAttribute("height", rectHeight);
  18367. clipPath.append(rect);
  18368. svgBuffer?.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${y}" width="${rectWidth}" height="${rectHeight}"/>`);
  18369. }
  18370. if (this.#hasBorder) {
  18371. svgBuffer.push(`</g></svg>')`);
  18372. style.backgroundImage = svgBuffer.join("");
  18373. }
  18374. this.container.append(svg);
  18375. this.container.style.clipPath = `url(#${id})`;
  18376. }
  18377. _createPopup() {
  18378. const {
  18379. container,
  18380. data
  18381. } = this;
  18382. container.setAttribute("aria-haspopup", "dialog");
  18383. const popup = new PopupAnnotationElement({
  18384. data: {
  18385. color: data.color,
  18386. titleObj: data.titleObj,
  18387. modificationDate: data.modificationDate,
  18388. contentsObj: data.contentsObj,
  18389. richText: data.richText,
  18390. parentRect: data.rect,
  18391. borderStyle: 0,
  18392. id: `popup_${data.id}`,
  18393. rotation: data.rotation
  18394. },
  18395. parent: this.parent,
  18396. elements: [this]
  18397. });
  18398. this.parent.div.append(popup.render());
  18399. }
  18400. render() {
  18401. (0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
  18402. }
  18403. _getElementsByName(name) {
  18404. let skipId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  18405. const fields = [];
  18406. if (this._fieldObjects) {
  18407. const fieldObj = this._fieldObjects[name];
  18408. if (fieldObj) {
  18409. for (const {
  18410. page,
  18411. id,
  18412. exportValues
  18413. } of fieldObj) {
  18414. if (page === -1) {
  18415. continue;
  18416. }
  18417. if (id === skipId) {
  18418. continue;
  18419. }
  18420. const exportValue = typeof exportValues === "string" ? exportValues : null;
  18421. const domElement = document.querySelector(`[data-element-id="${id}"]`);
  18422. if (domElement && !GetElementsByNameSet.has(domElement)) {
  18423. (0, _util.warn)(`_getElementsByName - element not allowed: ${id}`);
  18424. continue;
  18425. }
  18426. fields.push({
  18427. id,
  18428. exportValue,
  18429. domElement
  18430. });
  18431. }
  18432. }
  18433. return fields;
  18434. }
  18435. for (const domElement of document.getElementsByName(name)) {
  18436. const {
  18437. exportValue
  18438. } = domElement;
  18439. const id = domElement.getAttribute("data-element-id");
  18440. if (id === skipId) {
  18441. continue;
  18442. }
  18443. if (!GetElementsByNameSet.has(domElement)) {
  18444. continue;
  18445. }
  18446. fields.push({
  18447. id,
  18448. exportValue,
  18449. domElement
  18450. });
  18451. }
  18452. return fields;
  18453. }
  18454. show() {
  18455. if (this.container) {
  18456. this.container.hidden = false;
  18457. }
  18458. this.popup?.maybeShow();
  18459. }
  18460. hide() {
  18461. if (this.container) {
  18462. this.container.hidden = true;
  18463. }
  18464. this.popup?.forceHide();
  18465. }
  18466. getElementsToTriggerPopup() {
  18467. return this.container;
  18468. }
  18469. addHighlightArea() {
  18470. const triggers = this.getElementsToTriggerPopup();
  18471. if (Array.isArray(triggers)) {
  18472. for (const element of triggers) {
  18473. element.classList.add("highlightArea");
  18474. }
  18475. } else {
  18476. triggers.classList.add("highlightArea");
  18477. }
  18478. }
  18479. _editOnDoubleClick() {
  18480. const {
  18481. annotationEditorType: mode,
  18482. data: {
  18483. id: editId
  18484. }
  18485. } = this;
  18486. this.container.addEventListener("dblclick", () => {
  18487. this.linkService.eventBus?.dispatch("switchannotationeditormode", {
  18488. source: this,
  18489. mode,
  18490. editId
  18491. });
  18492. });
  18493. }
  18494. }
  18495. class LinkAnnotationElement extends AnnotationElement {
  18496. constructor(parameters) {
  18497. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  18498. super(parameters, {
  18499. isRenderable: true,
  18500. ignoreBorder: !!options?.ignoreBorder,
  18501. createQuadrilaterals: true
  18502. });
  18503. this.isTooltipOnly = parameters.data.isTooltipOnly;
  18504. }
  18505. render() {
  18506. const {
  18507. data,
  18508. linkService
  18509. } = this;
  18510. const link = document.createElement("a");
  18511. link.setAttribute("data-element-id", data.id);
  18512. let isBound = false;
  18513. if (data.url) {
  18514. linkService.addLinkAttributes(link, data.url, data.newWindow);
  18515. isBound = true;
  18516. } else if (data.action) {
  18517. this._bindNamedAction(link, data.action);
  18518. isBound = true;
  18519. } else if (data.attachment) {
  18520. this._bindAttachment(link, data.attachment);
  18521. isBound = true;
  18522. } else if (data.setOCGState) {
  18523. this.#bindSetOCGState(link, data.setOCGState);
  18524. isBound = true;
  18525. } else if (data.dest) {
  18526. this._bindLink(link, data.dest);
  18527. isBound = true;
  18528. } else {
  18529. if (data.actions && (data.actions.Action || data.actions["Mouse Up"] || data.actions["Mouse Down"]) && this.enableScripting && this.hasJSActions) {
  18530. this._bindJSAction(link, data);
  18531. isBound = true;
  18532. }
  18533. if (data.resetForm) {
  18534. this._bindResetFormAction(link, data.resetForm);
  18535. isBound = true;
  18536. } else if (this.isTooltipOnly && !isBound) {
  18537. this._bindLink(link, "");
  18538. isBound = true;
  18539. }
  18540. }
  18541. this.container.classList.add("linkAnnotation");
  18542. if (isBound) {
  18543. this.container.append(link);
  18544. }
  18545. return this.container;
  18546. }
  18547. #setInternalLink() {
  18548. this.container.setAttribute("data-internal-link", "");
  18549. }
  18550. _bindLink(link, destination) {
  18551. link.href = this.linkService.getDestinationHash(destination);
  18552. link.onclick = () => {
  18553. if (destination) {
  18554. this.linkService.goToDestination(destination);
  18555. }
  18556. return false;
  18557. };
  18558. if (destination || destination === "") {
  18559. this.#setInternalLink();
  18560. }
  18561. }
  18562. _bindNamedAction(link, action) {
  18563. link.href = this.linkService.getAnchorUrl("");
  18564. link.onclick = () => {
  18565. this.linkService.executeNamedAction(action);
  18566. return false;
  18567. };
  18568. this.#setInternalLink();
  18569. }
  18570. _bindAttachment(link, attachment) {
  18571. link.href = this.linkService.getAnchorUrl("");
  18572. link.onclick = () => {
  18573. this.downloadManager?.openOrDownloadData(this.container, attachment.content, attachment.filename);
  18574. return false;
  18575. };
  18576. this.#setInternalLink();
  18577. }
  18578. #bindSetOCGState(link, action) {
  18579. link.href = this.linkService.getAnchorUrl("");
  18580. link.onclick = () => {
  18581. this.linkService.executeSetOCGState(action);
  18582. return false;
  18583. };
  18584. this.#setInternalLink();
  18585. }
  18586. _bindJSAction(link, data) {
  18587. link.href = this.linkService.getAnchorUrl("");
  18588. const map = new Map([["Action", "onclick"], ["Mouse Up", "onmouseup"], ["Mouse Down", "onmousedown"]]);
  18589. for (const name of Object.keys(data.actions)) {
  18590. const jsName = map.get(name);
  18591. if (!jsName) {
  18592. continue;
  18593. }
  18594. link[jsName] = () => {
  18595. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  18596. source: this,
  18597. detail: {
  18598. id: data.id,
  18599. name
  18600. }
  18601. });
  18602. return false;
  18603. };
  18604. }
  18605. if (!link.onclick) {
  18606. link.onclick = () => false;
  18607. }
  18608. this.#setInternalLink();
  18609. }
  18610. _bindResetFormAction(link, resetForm) {
  18611. const otherClickAction = link.onclick;
  18612. if (!otherClickAction) {
  18613. link.href = this.linkService.getAnchorUrl("");
  18614. }
  18615. this.#setInternalLink();
  18616. if (!this._fieldObjects) {
  18617. (0, _util.warn)(`_bindResetFormAction - "resetForm" action not supported, ` + "ensure that the `fieldObjects` parameter is provided.");
  18618. if (!otherClickAction) {
  18619. link.onclick = () => false;
  18620. }
  18621. return;
  18622. }
  18623. link.onclick = () => {
  18624. otherClickAction?.();
  18625. const {
  18626. fields: resetFormFields,
  18627. refs: resetFormRefs,
  18628. include
  18629. } = resetForm;
  18630. const allFields = [];
  18631. if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {
  18632. const fieldIds = new Set(resetFormRefs);
  18633. for (const fieldName of resetFormFields) {
  18634. const fields = this._fieldObjects[fieldName] || [];
  18635. for (const {
  18636. id
  18637. } of fields) {
  18638. fieldIds.add(id);
  18639. }
  18640. }
  18641. for (const fields of Object.values(this._fieldObjects)) {
  18642. for (const field of fields) {
  18643. if (fieldIds.has(field.id) === include) {
  18644. allFields.push(field);
  18645. }
  18646. }
  18647. }
  18648. } else {
  18649. for (const fields of Object.values(this._fieldObjects)) {
  18650. allFields.push(...fields);
  18651. }
  18652. }
  18653. const storage = this.annotationStorage;
  18654. const allIds = [];
  18655. for (const field of allFields) {
  18656. const {
  18657. id
  18658. } = field;
  18659. allIds.push(id);
  18660. switch (field.type) {
  18661. case "text":
  18662. {
  18663. const value = field.defaultValue || "";
  18664. storage.setValue(id, {
  18665. value
  18666. });
  18667. break;
  18668. }
  18669. case "checkbox":
  18670. case "radiobutton":
  18671. {
  18672. const value = field.defaultValue === field.exportValues;
  18673. storage.setValue(id, {
  18674. value
  18675. });
  18676. break;
  18677. }
  18678. case "combobox":
  18679. case "listbox":
  18680. {
  18681. const value = field.defaultValue || "";
  18682. storage.setValue(id, {
  18683. value
  18684. });
  18685. break;
  18686. }
  18687. default:
  18688. continue;
  18689. }
  18690. const domElement = document.querySelector(`[data-element-id="${id}"]`);
  18691. if (!domElement) {
  18692. continue;
  18693. } else if (!GetElementsByNameSet.has(domElement)) {
  18694. (0, _util.warn)(`_bindResetFormAction - element not allowed: ${id}`);
  18695. continue;
  18696. }
  18697. domElement.dispatchEvent(new Event("resetform"));
  18698. }
  18699. if (this.enableScripting) {
  18700. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  18701. source: this,
  18702. detail: {
  18703. id: "app",
  18704. ids: allIds,
  18705. name: "ResetForm"
  18706. }
  18707. });
  18708. }
  18709. return false;
  18710. };
  18711. }
  18712. }
  18713. class TextAnnotationElement extends AnnotationElement {
  18714. constructor(parameters) {
  18715. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  18716. super(parameters, {
  18717. isRenderable
  18718. });
  18719. }
  18720. render() {
  18721. this.container.classList.add("textAnnotation");
  18722. const image = document.createElement("img");
  18723. image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
  18724. image.alt = "[{{type}} Annotation]";
  18725. image.dataset.l10nId = "text_annotation_type";
  18726. image.dataset.l10nArgs = JSON.stringify({
  18727. type: this.data.name
  18728. });
  18729. if (!this.data.popupRef) {
  18730. this._createPopup();
  18731. }
  18732. this.container.append(image);
  18733. return this.container;
  18734. }
  18735. }
  18736. class WidgetAnnotationElement extends AnnotationElement {
  18737. render() {
  18738. if (this.data.alternativeText) {
  18739. this.container.title = this.data.alternativeText;
  18740. }
  18741. return this.container;
  18742. }
  18743. showElementAndHideCanvas(element) {
  18744. if (this.data.hasOwnCanvas) {
  18745. if (element.previousSibling?.nodeName === "CANVAS") {
  18746. element.previousSibling.hidden = true;
  18747. }
  18748. element.hidden = false;
  18749. }
  18750. }
  18751. _getKeyModifier(event) {
  18752. const {
  18753. isWin,
  18754. isMac
  18755. } = _util.FeatureTest.platform;
  18756. return isWin && event.ctrlKey || isMac && event.metaKey;
  18757. }
  18758. _setEventListener(element, baseName, eventName, valueGetter) {
  18759. if (baseName.includes("mouse")) {
  18760. element.addEventListener(baseName, event => {
  18761. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  18762. source: this,
  18763. detail: {
  18764. id: this.data.id,
  18765. name: eventName,
  18766. value: valueGetter(event),
  18767. shift: event.shiftKey,
  18768. modifier: this._getKeyModifier(event)
  18769. }
  18770. });
  18771. });
  18772. } else {
  18773. element.addEventListener(baseName, event => {
  18774. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  18775. source: this,
  18776. detail: {
  18777. id: this.data.id,
  18778. name: eventName,
  18779. value: valueGetter(event)
  18780. }
  18781. });
  18782. });
  18783. }
  18784. }
  18785. _setEventListeners(element, names, getter) {
  18786. for (const [baseName, eventName] of names) {
  18787. if (eventName === "Action" || this.data.actions?.[eventName]) {
  18788. this._setEventListener(element, baseName, eventName, getter);
  18789. }
  18790. }
  18791. }
  18792. _setBackgroundColor(element) {
  18793. const color = this.data.backgroundColor || null;
  18794. element.style.backgroundColor = color === null ? "transparent" : _util.Util.makeHexColor(color[0], color[1], color[2]);
  18795. }
  18796. _setTextStyle(element) {
  18797. const TEXT_ALIGNMENT = ["left", "center", "right"];
  18798. const {
  18799. fontColor
  18800. } = this.data.defaultAppearanceData;
  18801. const fontSize = this.data.defaultAppearanceData.fontSize || DEFAULT_FONT_SIZE;
  18802. const style = element.style;
  18803. let computedFontSize;
  18804. const BORDER_SIZE = 2;
  18805. const roundToOneDecimal = x => Math.round(10 * x) / 10;
  18806. if (this.data.multiLine) {
  18807. const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
  18808. const numberOfLines = Math.round(height / (_util.LINE_FACTOR * fontSize)) || 1;
  18809. const lineHeight = height / numberOfLines;
  18810. computedFontSize = Math.min(fontSize, roundToOneDecimal(lineHeight / _util.LINE_FACTOR));
  18811. } else {
  18812. const height = Math.abs(this.data.rect[3] - this.data.rect[1] - BORDER_SIZE);
  18813. computedFontSize = Math.min(fontSize, roundToOneDecimal(height / _util.LINE_FACTOR));
  18814. }
  18815. style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
  18816. style.color = _util.Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);
  18817. if (this.data.textAlignment !== null) {
  18818. style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18819. }
  18820. }
  18821. _setRequired(element, isRequired) {
  18822. if (isRequired) {
  18823. element.setAttribute("required", true);
  18824. } else {
  18825. element.removeAttribute("required");
  18826. }
  18827. element.setAttribute("aria-required", isRequired);
  18828. }
  18829. }
  18830. class TextWidgetAnnotationElement extends WidgetAnnotationElement {
  18831. constructor(parameters) {
  18832. const isRenderable = parameters.renderForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18833. super(parameters, {
  18834. isRenderable
  18835. });
  18836. }
  18837. setPropertyOnSiblings(base, key, value, keyInStorage) {
  18838. const storage = this.annotationStorage;
  18839. for (const element of this._getElementsByName(base.name, base.id)) {
  18840. if (element.domElement) {
  18841. element.domElement[key] = value;
  18842. }
  18843. storage.setValue(element.id, {
  18844. [keyInStorage]: value
  18845. });
  18846. }
  18847. }
  18848. render() {
  18849. const storage = this.annotationStorage;
  18850. const id = this.data.id;
  18851. this.container.classList.add("textWidgetAnnotation");
  18852. let element = null;
  18853. if (this.renderForms) {
  18854. const storedData = storage.getValue(id, {
  18855. value: this.data.fieldValue
  18856. });
  18857. let textContent = storedData.value || "";
  18858. const maxLen = storage.getValue(id, {
  18859. charLimit: this.data.maxLen
  18860. }).charLimit;
  18861. if (maxLen && textContent.length > maxLen) {
  18862. textContent = textContent.slice(0, maxLen);
  18863. }
  18864. let fieldFormattedValues = storedData.formattedValue || this.data.textContent?.join("\n") || null;
  18865. if (fieldFormattedValues && this.data.comb) {
  18866. fieldFormattedValues = fieldFormattedValues.replaceAll(/\s+/g, "");
  18867. }
  18868. const elementData = {
  18869. userValue: textContent,
  18870. formattedValue: fieldFormattedValues,
  18871. lastCommittedValue: null,
  18872. commitKey: 1
  18873. };
  18874. if (this.data.multiLine) {
  18875. element = document.createElement("textarea");
  18876. element.textContent = fieldFormattedValues ?? textContent;
  18877. if (this.data.doNotScroll) {
  18878. element.style.overflowY = "hidden";
  18879. }
  18880. } else {
  18881. element = document.createElement("input");
  18882. element.type = "text";
  18883. element.setAttribute("value", fieldFormattedValues ?? textContent);
  18884. if (this.data.doNotScroll) {
  18885. element.style.overflowX = "hidden";
  18886. }
  18887. }
  18888. if (this.data.hasOwnCanvas) {
  18889. element.hidden = true;
  18890. }
  18891. GetElementsByNameSet.add(element);
  18892. element.setAttribute("data-element-id", id);
  18893. element.disabled = this.data.readOnly;
  18894. element.name = this.data.fieldName;
  18895. element.tabIndex = DEFAULT_TAB_INDEX;
  18896. this._setRequired(element, this.data.required);
  18897. if (maxLen) {
  18898. element.maxLength = maxLen;
  18899. }
  18900. element.addEventListener("input", event => {
  18901. storage.setValue(id, {
  18902. value: event.target.value
  18903. });
  18904. this.setPropertyOnSiblings(element, "value", event.target.value, "value");
  18905. elementData.formattedValue = null;
  18906. });
  18907. element.addEventListener("resetform", event => {
  18908. const defaultValue = this.data.defaultFieldValue ?? "";
  18909. element.value = elementData.userValue = defaultValue;
  18910. elementData.formattedValue = null;
  18911. });
  18912. let blurListener = event => {
  18913. const {
  18914. formattedValue
  18915. } = elementData;
  18916. if (formattedValue !== null && formattedValue !== undefined) {
  18917. event.target.value = formattedValue;
  18918. }
  18919. event.target.scrollLeft = 0;
  18920. };
  18921. if (this.enableScripting && this.hasJSActions) {
  18922. element.addEventListener("focus", event => {
  18923. const {
  18924. target
  18925. } = event;
  18926. if (elementData.userValue) {
  18927. target.value = elementData.userValue;
  18928. }
  18929. elementData.lastCommittedValue = target.value;
  18930. elementData.commitKey = 1;
  18931. });
  18932. element.addEventListener("updatefromsandbox", jsEvent => {
  18933. this.showElementAndHideCanvas(jsEvent.target);
  18934. const actions = {
  18935. value(event) {
  18936. elementData.userValue = event.detail.value ?? "";
  18937. storage.setValue(id, {
  18938. value: elementData.userValue.toString()
  18939. });
  18940. event.target.value = elementData.userValue;
  18941. },
  18942. formattedValue(event) {
  18943. const {
  18944. formattedValue
  18945. } = event.detail;
  18946. elementData.formattedValue = formattedValue;
  18947. if (formattedValue !== null && formattedValue !== undefined && event.target !== document.activeElement) {
  18948. event.target.value = formattedValue;
  18949. }
  18950. storage.setValue(id, {
  18951. formattedValue
  18952. });
  18953. },
  18954. selRange(event) {
  18955. event.target.setSelectionRange(...event.detail.selRange);
  18956. },
  18957. charLimit: event => {
  18958. const {
  18959. charLimit
  18960. } = event.detail;
  18961. const {
  18962. target
  18963. } = event;
  18964. if (charLimit === 0) {
  18965. target.removeAttribute("maxLength");
  18966. return;
  18967. }
  18968. target.setAttribute("maxLength", charLimit);
  18969. let value = elementData.userValue;
  18970. if (!value || value.length <= charLimit) {
  18971. return;
  18972. }
  18973. value = value.slice(0, charLimit);
  18974. target.value = elementData.userValue = value;
  18975. storage.setValue(id, {
  18976. value
  18977. });
  18978. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  18979. source: this,
  18980. detail: {
  18981. id,
  18982. name: "Keystroke",
  18983. value,
  18984. willCommit: true,
  18985. commitKey: 1,
  18986. selStart: target.selectionStart,
  18987. selEnd: target.selectionEnd
  18988. }
  18989. });
  18990. }
  18991. };
  18992. this._dispatchEventFromSandbox(actions, jsEvent);
  18993. });
  18994. element.addEventListener("keydown", event => {
  18995. elementData.commitKey = 1;
  18996. let commitKey = -1;
  18997. if (event.key === "Escape") {
  18998. commitKey = 0;
  18999. } else if (event.key === "Enter" && !this.data.multiLine) {
  19000. commitKey = 2;
  19001. } else if (event.key === "Tab") {
  19002. elementData.commitKey = 3;
  19003. }
  19004. if (commitKey === -1) {
  19005. return;
  19006. }
  19007. const {
  19008. value
  19009. } = event.target;
  19010. if (elementData.lastCommittedValue === value) {
  19011. return;
  19012. }
  19013. elementData.lastCommittedValue = value;
  19014. elementData.userValue = value;
  19015. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  19016. source: this,
  19017. detail: {
  19018. id,
  19019. name: "Keystroke",
  19020. value,
  19021. willCommit: true,
  19022. commitKey,
  19023. selStart: event.target.selectionStart,
  19024. selEnd: event.target.selectionEnd
  19025. }
  19026. });
  19027. });
  19028. const _blurListener = blurListener;
  19029. blurListener = null;
  19030. element.addEventListener("blur", event => {
  19031. if (!event.relatedTarget) {
  19032. return;
  19033. }
  19034. const {
  19035. value
  19036. } = event.target;
  19037. elementData.userValue = value;
  19038. if (elementData.lastCommittedValue !== value) {
  19039. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  19040. source: this,
  19041. detail: {
  19042. id,
  19043. name: "Keystroke",
  19044. value,
  19045. willCommit: true,
  19046. commitKey: elementData.commitKey,
  19047. selStart: event.target.selectionStart,
  19048. selEnd: event.target.selectionEnd
  19049. }
  19050. });
  19051. }
  19052. _blurListener(event);
  19053. });
  19054. if (this.data.actions?.Keystroke) {
  19055. element.addEventListener("beforeinput", event => {
  19056. elementData.lastCommittedValue = null;
  19057. const {
  19058. data,
  19059. target
  19060. } = event;
  19061. const {
  19062. value,
  19063. selectionStart,
  19064. selectionEnd
  19065. } = target;
  19066. let selStart = selectionStart,
  19067. selEnd = selectionEnd;
  19068. switch (event.inputType) {
  19069. case "deleteWordBackward":
  19070. {
  19071. const match = value.substring(0, selectionStart).match(/\w*[^\w]*$/);
  19072. if (match) {
  19073. selStart -= match[0].length;
  19074. }
  19075. break;
  19076. }
  19077. case "deleteWordForward":
  19078. {
  19079. const match = value.substring(selectionStart).match(/^[^\w]*\w*/);
  19080. if (match) {
  19081. selEnd += match[0].length;
  19082. }
  19083. break;
  19084. }
  19085. case "deleteContentBackward":
  19086. if (selectionStart === selectionEnd) {
  19087. selStart -= 1;
  19088. }
  19089. break;
  19090. case "deleteContentForward":
  19091. if (selectionStart === selectionEnd) {
  19092. selEnd += 1;
  19093. }
  19094. break;
  19095. }
  19096. event.preventDefault();
  19097. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  19098. source: this,
  19099. detail: {
  19100. id,
  19101. name: "Keystroke",
  19102. value,
  19103. change: data || "",
  19104. willCommit: false,
  19105. selStart,
  19106. selEnd
  19107. }
  19108. });
  19109. });
  19110. }
  19111. this._setEventListeners(element, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.value);
  19112. }
  19113. if (blurListener) {
  19114. element.addEventListener("blur", blurListener);
  19115. }
  19116. if (this.data.comb) {
  19117. const fieldWidth = this.data.rect[2] - this.data.rect[0];
  19118. const combWidth = fieldWidth / maxLen;
  19119. element.classList.add("comb");
  19120. element.style.letterSpacing = `calc(${combWidth}px * var(--scale-factor) - 1ch)`;
  19121. }
  19122. } else {
  19123. element = document.createElement("div");
  19124. element.textContent = this.data.fieldValue;
  19125. element.style.verticalAlign = "middle";
  19126. element.style.display = "table-cell";
  19127. }
  19128. this._setTextStyle(element);
  19129. this._setBackgroundColor(element);
  19130. this._setDefaultPropertiesFromJS(element);
  19131. this.container.append(element);
  19132. return this.container;
  19133. }
  19134. }
  19135. class SignatureWidgetAnnotationElement extends WidgetAnnotationElement {
  19136. constructor(parameters) {
  19137. super(parameters, {
  19138. isRenderable: !!parameters.data.hasOwnCanvas
  19139. });
  19140. }
  19141. }
  19142. class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
  19143. constructor(parameters) {
  19144. super(parameters, {
  19145. isRenderable: parameters.renderForms
  19146. });
  19147. }
  19148. render() {
  19149. const storage = this.annotationStorage;
  19150. const data = this.data;
  19151. const id = data.id;
  19152. let value = storage.getValue(id, {
  19153. value: data.exportValue === data.fieldValue
  19154. }).value;
  19155. if (typeof value === "string") {
  19156. value = value !== "Off";
  19157. storage.setValue(id, {
  19158. value
  19159. });
  19160. }
  19161. this.container.classList.add("buttonWidgetAnnotation", "checkBox");
  19162. const element = document.createElement("input");
  19163. GetElementsByNameSet.add(element);
  19164. element.setAttribute("data-element-id", id);
  19165. element.disabled = data.readOnly;
  19166. this._setRequired(element, this.data.required);
  19167. element.type = "checkbox";
  19168. element.name = data.fieldName;
  19169. if (value) {
  19170. element.setAttribute("checked", true);
  19171. }
  19172. element.setAttribute("exportValue", data.exportValue);
  19173. element.tabIndex = DEFAULT_TAB_INDEX;
  19174. element.addEventListener("change", event => {
  19175. const {
  19176. name,
  19177. checked
  19178. } = event.target;
  19179. for (const checkbox of this._getElementsByName(name, id)) {
  19180. const curChecked = checked && checkbox.exportValue === data.exportValue;
  19181. if (checkbox.domElement) {
  19182. checkbox.domElement.checked = curChecked;
  19183. }
  19184. storage.setValue(checkbox.id, {
  19185. value: curChecked
  19186. });
  19187. }
  19188. storage.setValue(id, {
  19189. value: checked
  19190. });
  19191. });
  19192. element.addEventListener("resetform", event => {
  19193. const defaultValue = data.defaultFieldValue || "Off";
  19194. event.target.checked = defaultValue === data.exportValue;
  19195. });
  19196. if (this.enableScripting && this.hasJSActions) {
  19197. element.addEventListener("updatefromsandbox", jsEvent => {
  19198. const actions = {
  19199. value(event) {
  19200. event.target.checked = event.detail.value !== "Off";
  19201. storage.setValue(id, {
  19202. value: event.target.checked
  19203. });
  19204. }
  19205. };
  19206. this._dispatchEventFromSandbox(actions, jsEvent);
  19207. });
  19208. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
  19209. }
  19210. this._setBackgroundColor(element);
  19211. this._setDefaultPropertiesFromJS(element);
  19212. this.container.append(element);
  19213. return this.container;
  19214. }
  19215. }
  19216. class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
  19217. constructor(parameters) {
  19218. super(parameters, {
  19219. isRenderable: parameters.renderForms
  19220. });
  19221. }
  19222. render() {
  19223. this.container.classList.add("buttonWidgetAnnotation", "radioButton");
  19224. const storage = this.annotationStorage;
  19225. const data = this.data;
  19226. const id = data.id;
  19227. let value = storage.getValue(id, {
  19228. value: data.fieldValue === data.buttonValue
  19229. }).value;
  19230. if (typeof value === "string") {
  19231. value = value !== data.buttonValue;
  19232. storage.setValue(id, {
  19233. value
  19234. });
  19235. }
  19236. const element = document.createElement("input");
  19237. GetElementsByNameSet.add(element);
  19238. element.setAttribute("data-element-id", id);
  19239. element.disabled = data.readOnly;
  19240. this._setRequired(element, this.data.required);
  19241. element.type = "radio";
  19242. element.name = data.fieldName;
  19243. if (value) {
  19244. element.setAttribute("checked", true);
  19245. }
  19246. element.tabIndex = DEFAULT_TAB_INDEX;
  19247. element.addEventListener("change", event => {
  19248. const {
  19249. name,
  19250. checked
  19251. } = event.target;
  19252. for (const radio of this._getElementsByName(name, id)) {
  19253. storage.setValue(radio.id, {
  19254. value: false
  19255. });
  19256. }
  19257. storage.setValue(id, {
  19258. value: checked
  19259. });
  19260. });
  19261. element.addEventListener("resetform", event => {
  19262. const defaultValue = data.defaultFieldValue;
  19263. event.target.checked = defaultValue !== null && defaultValue !== undefined && defaultValue === data.buttonValue;
  19264. });
  19265. if (this.enableScripting && this.hasJSActions) {
  19266. const pdfButtonValue = data.buttonValue;
  19267. element.addEventListener("updatefromsandbox", jsEvent => {
  19268. const actions = {
  19269. value: event => {
  19270. const checked = pdfButtonValue === event.detail.value;
  19271. for (const radio of this._getElementsByName(event.target.name)) {
  19272. const curChecked = checked && radio.id === id;
  19273. if (radio.domElement) {
  19274. radio.domElement.checked = curChecked;
  19275. }
  19276. storage.setValue(radio.id, {
  19277. value: curChecked
  19278. });
  19279. }
  19280. }
  19281. };
  19282. this._dispatchEventFromSandbox(actions, jsEvent);
  19283. });
  19284. this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
  19285. }
  19286. this._setBackgroundColor(element);
  19287. this._setDefaultPropertiesFromJS(element);
  19288. this.container.append(element);
  19289. return this.container;
  19290. }
  19291. }
  19292. class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
  19293. constructor(parameters) {
  19294. super(parameters, {
  19295. ignoreBorder: parameters.data.hasAppearance
  19296. });
  19297. }
  19298. render() {
  19299. const container = super.render();
  19300. container.classList.add("buttonWidgetAnnotation", "pushButton");
  19301. if (this.data.alternativeText) {
  19302. container.title = this.data.alternativeText;
  19303. }
  19304. const linkElement = container.lastChild;
  19305. if (this.enableScripting && this.hasJSActions && linkElement) {
  19306. this._setDefaultPropertiesFromJS(linkElement);
  19307. linkElement.addEventListener("updatefromsandbox", jsEvent => {
  19308. this._dispatchEventFromSandbox({}, jsEvent);
  19309. });
  19310. }
  19311. return container;
  19312. }
  19313. }
  19314. class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
  19315. constructor(parameters) {
  19316. super(parameters, {
  19317. isRenderable: parameters.renderForms
  19318. });
  19319. }
  19320. render() {
  19321. this.container.classList.add("choiceWidgetAnnotation");
  19322. const storage = this.annotationStorage;
  19323. const id = this.data.id;
  19324. const storedData = storage.getValue(id, {
  19325. value: this.data.fieldValue
  19326. });
  19327. const selectElement = document.createElement("select");
  19328. GetElementsByNameSet.add(selectElement);
  19329. selectElement.setAttribute("data-element-id", id);
  19330. selectElement.disabled = this.data.readOnly;
  19331. this._setRequired(selectElement, this.data.required);
  19332. selectElement.name = this.data.fieldName;
  19333. selectElement.tabIndex = DEFAULT_TAB_INDEX;
  19334. let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
  19335. if (!this.data.combo) {
  19336. selectElement.size = this.data.options.length;
  19337. if (this.data.multiSelect) {
  19338. selectElement.multiple = true;
  19339. }
  19340. }
  19341. selectElement.addEventListener("resetform", event => {
  19342. const defaultValue = this.data.defaultFieldValue;
  19343. for (const option of selectElement.options) {
  19344. option.selected = option.value === defaultValue;
  19345. }
  19346. });
  19347. for (const option of this.data.options) {
  19348. const optionElement = document.createElement("option");
  19349. optionElement.textContent = option.displayValue;
  19350. optionElement.value = option.exportValue;
  19351. if (storedData.value.includes(option.exportValue)) {
  19352. optionElement.setAttribute("selected", true);
  19353. addAnEmptyEntry = false;
  19354. }
  19355. selectElement.append(optionElement);
  19356. }
  19357. let removeEmptyEntry = null;
  19358. if (addAnEmptyEntry) {
  19359. const noneOptionElement = document.createElement("option");
  19360. noneOptionElement.value = " ";
  19361. noneOptionElement.setAttribute("hidden", true);
  19362. noneOptionElement.setAttribute("selected", true);
  19363. selectElement.prepend(noneOptionElement);
  19364. removeEmptyEntry = () => {
  19365. noneOptionElement.remove();
  19366. selectElement.removeEventListener("input", removeEmptyEntry);
  19367. removeEmptyEntry = null;
  19368. };
  19369. selectElement.addEventListener("input", removeEmptyEntry);
  19370. }
  19371. const getValue = isExport => {
  19372. const name = isExport ? "value" : "textContent";
  19373. const {
  19374. options,
  19375. multiple
  19376. } = selectElement;
  19377. if (!multiple) {
  19378. return options.selectedIndex === -1 ? null : options[options.selectedIndex][name];
  19379. }
  19380. return Array.prototype.filter.call(options, option => option.selected).map(option => option[name]);
  19381. };
  19382. let selectedValues = getValue(false);
  19383. const getItems = event => {
  19384. const options = event.target.options;
  19385. return Array.prototype.map.call(options, option => {
  19386. return {
  19387. displayValue: option.textContent,
  19388. exportValue: option.value
  19389. };
  19390. });
  19391. };
  19392. if (this.enableScripting && this.hasJSActions) {
  19393. selectElement.addEventListener("updatefromsandbox", jsEvent => {
  19394. const actions = {
  19395. value(event) {
  19396. removeEmptyEntry?.();
  19397. const value = event.detail.value;
  19398. const values = new Set(Array.isArray(value) ? value : [value]);
  19399. for (const option of selectElement.options) {
  19400. option.selected = values.has(option.value);
  19401. }
  19402. storage.setValue(id, {
  19403. value: getValue(true)
  19404. });
  19405. selectedValues = getValue(false);
  19406. },
  19407. multipleSelection(event) {
  19408. selectElement.multiple = true;
  19409. },
  19410. remove(event) {
  19411. const options = selectElement.options;
  19412. const index = event.detail.remove;
  19413. options[index].selected = false;
  19414. selectElement.remove(index);
  19415. if (options.length > 0) {
  19416. const i = Array.prototype.findIndex.call(options, option => option.selected);
  19417. if (i === -1) {
  19418. options[0].selected = true;
  19419. }
  19420. }
  19421. storage.setValue(id, {
  19422. value: getValue(true),
  19423. items: getItems(event)
  19424. });
  19425. selectedValues = getValue(false);
  19426. },
  19427. clear(event) {
  19428. while (selectElement.length !== 0) {
  19429. selectElement.remove(0);
  19430. }
  19431. storage.setValue(id, {
  19432. value: null,
  19433. items: []
  19434. });
  19435. selectedValues = getValue(false);
  19436. },
  19437. insert(event) {
  19438. const {
  19439. index,
  19440. displayValue,
  19441. exportValue
  19442. } = event.detail.insert;
  19443. const selectChild = selectElement.children[index];
  19444. const optionElement = document.createElement("option");
  19445. optionElement.textContent = displayValue;
  19446. optionElement.value = exportValue;
  19447. if (selectChild) {
  19448. selectChild.before(optionElement);
  19449. } else {
  19450. selectElement.append(optionElement);
  19451. }
  19452. storage.setValue(id, {
  19453. value: getValue(true),
  19454. items: getItems(event)
  19455. });
  19456. selectedValues = getValue(false);
  19457. },
  19458. items(event) {
  19459. const {
  19460. items
  19461. } = event.detail;
  19462. while (selectElement.length !== 0) {
  19463. selectElement.remove(0);
  19464. }
  19465. for (const item of items) {
  19466. const {
  19467. displayValue,
  19468. exportValue
  19469. } = item;
  19470. const optionElement = document.createElement("option");
  19471. optionElement.textContent = displayValue;
  19472. optionElement.value = exportValue;
  19473. selectElement.append(optionElement);
  19474. }
  19475. if (selectElement.options.length > 0) {
  19476. selectElement.options[0].selected = true;
  19477. }
  19478. storage.setValue(id, {
  19479. value: getValue(true),
  19480. items: getItems(event)
  19481. });
  19482. selectedValues = getValue(false);
  19483. },
  19484. indices(event) {
  19485. const indices = new Set(event.detail.indices);
  19486. for (const option of event.target.options) {
  19487. option.selected = indices.has(option.index);
  19488. }
  19489. storage.setValue(id, {
  19490. value: getValue(true)
  19491. });
  19492. selectedValues = getValue(false);
  19493. },
  19494. editable(event) {
  19495. event.target.disabled = !event.detail.editable;
  19496. }
  19497. };
  19498. this._dispatchEventFromSandbox(actions, jsEvent);
  19499. });
  19500. selectElement.addEventListener("input", event => {
  19501. const exportValue = getValue(true);
  19502. storage.setValue(id, {
  19503. value: exportValue
  19504. });
  19505. event.preventDefault();
  19506. this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
  19507. source: this,
  19508. detail: {
  19509. id,
  19510. name: "Keystroke",
  19511. value: selectedValues,
  19512. changeEx: exportValue,
  19513. willCommit: false,
  19514. commitKey: 1,
  19515. keyDown: false
  19516. }
  19517. });
  19518. });
  19519. this._setEventListeners(selectElement, [["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"], ["input", "Action"], ["input", "Validate"]], event => event.target.value);
  19520. } else {
  19521. selectElement.addEventListener("input", function (event) {
  19522. storage.setValue(id, {
  19523. value: getValue(true)
  19524. });
  19525. });
  19526. }
  19527. if (this.data.combo) {
  19528. this._setTextStyle(selectElement);
  19529. } else {}
  19530. this._setBackgroundColor(selectElement);
  19531. this._setDefaultPropertiesFromJS(selectElement);
  19532. this.container.append(selectElement);
  19533. return this.container;
  19534. }
  19535. }
  19536. class PopupAnnotationElement extends AnnotationElement {
  19537. constructor(parameters) {
  19538. const {
  19539. data,
  19540. elements
  19541. } = parameters;
  19542. const isRenderable = !!(data.titleObj?.str || data.contentsObj?.str || data.richText?.str);
  19543. super(parameters, {
  19544. isRenderable
  19545. });
  19546. this.elements = elements;
  19547. }
  19548. render() {
  19549. this.container.classList.add("popupAnnotation");
  19550. const popup = new PopupElement({
  19551. container: this.container,
  19552. color: this.data.color,
  19553. titleObj: this.data.titleObj,
  19554. modificationDate: this.data.modificationDate,
  19555. contentsObj: this.data.contentsObj,
  19556. richText: this.data.richText,
  19557. rect: this.data.rect,
  19558. parentRect: this.data.parentRect || null,
  19559. parent: this.parent,
  19560. elements: this.elements,
  19561. open: this.data.open
  19562. });
  19563. const elementIds = [];
  19564. for (const element of this.elements) {
  19565. element.popup = popup;
  19566. elementIds.push(element.data.id);
  19567. element.addHighlightArea();
  19568. }
  19569. this.container.setAttribute("aria-controls", elementIds.join(","));
  19570. return this.container;
  19571. }
  19572. }
  19573. class PopupElement {
  19574. #dateTimePromise = null;
  19575. #boundHide = this.#hide.bind(this);
  19576. #boundShow = this.#show.bind(this);
  19577. #boundToggle = this.#toggle.bind(this);
  19578. #color = null;
  19579. #container = null;
  19580. #contentsObj = null;
  19581. #elements = null;
  19582. #parent = null;
  19583. #parentRect = null;
  19584. #pinned = false;
  19585. #popup = null;
  19586. #rect = null;
  19587. #richText = null;
  19588. #titleObj = null;
  19589. #wasVisible = false;
  19590. constructor(_ref) {
  19591. let {
  19592. container,
  19593. color,
  19594. elements,
  19595. titleObj,
  19596. modificationDate,
  19597. contentsObj,
  19598. richText,
  19599. parent,
  19600. rect,
  19601. parentRect,
  19602. open
  19603. } = _ref;
  19604. this.#container = container;
  19605. this.#titleObj = titleObj;
  19606. this.#contentsObj = contentsObj;
  19607. this.#richText = richText;
  19608. this.#parent = parent;
  19609. this.#color = color;
  19610. this.#rect = rect;
  19611. this.#parentRect = parentRect;
  19612. this.#elements = elements;
  19613. const dateObject = _display_utils.PDFDateString.toDateObject(modificationDate);
  19614. if (dateObject) {
  19615. this.#dateTimePromise = parent.l10n.get("annotation_date_string", {
  19616. date: dateObject.toLocaleDateString(),
  19617. time: dateObject.toLocaleTimeString()
  19618. });
  19619. }
  19620. this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());
  19621. for (const element of this.trigger) {
  19622. element.addEventListener("click", this.#boundToggle);
  19623. element.addEventListener("mouseenter", this.#boundShow);
  19624. element.addEventListener("mouseleave", this.#boundHide);
  19625. }
  19626. this.#container.hidden = true;
  19627. if (open) {
  19628. this.#toggle();
  19629. }
  19630. }
  19631. render() {
  19632. if (this.#popup) {
  19633. return;
  19634. }
  19635. const {
  19636. page: {
  19637. view
  19638. },
  19639. viewport: {
  19640. rawDims: {
  19641. pageWidth,
  19642. pageHeight,
  19643. pageX,
  19644. pageY
  19645. }
  19646. }
  19647. } = this.#parent;
  19648. const popup = this.#popup = document.createElement("div");
  19649. popup.className = "popup";
  19650. if (this.#color) {
  19651. const baseColor = popup.style.outlineColor = _util.Util.makeHexColor(...this.#color);
  19652. if (CSS.supports("background-color", "color-mix(in srgb, red 30%, white)")) {
  19653. popup.style.backgroundColor = `color-mix(in srgb, ${baseColor} 30%, white)`;
  19654. } else {
  19655. const BACKGROUND_ENLIGHT = 0.7;
  19656. popup.style.backgroundColor = _util.Util.makeHexColor(...this.#color.map(c => Math.floor(BACKGROUND_ENLIGHT * (255 - c) + c)));
  19657. }
  19658. }
  19659. const header = document.createElement("span");
  19660. header.className = "header";
  19661. const title = document.createElement("h1");
  19662. header.append(title);
  19663. ({
  19664. dir: title.dir,
  19665. str: title.textContent
  19666. } = this.#titleObj);
  19667. popup.append(header);
  19668. if (this.#dateTimePromise) {
  19669. const modificationDate = document.createElement("span");
  19670. modificationDate.classList.add("popupDate");
  19671. this.#dateTimePromise.then(localized => {
  19672. modificationDate.textContent = localized;
  19673. });
  19674. header.append(modificationDate);
  19675. }
  19676. const contentsObj = this.#contentsObj;
  19677. const richText = this.#richText;
  19678. if (richText?.str && (!contentsObj?.str || contentsObj.str === richText.str)) {
  19679. _xfa_layer.XfaLayer.render({
  19680. xfaHtml: richText.html,
  19681. intent: "richText",
  19682. div: popup
  19683. });
  19684. popup.lastChild.classList.add("richText", "popupContent");
  19685. } else {
  19686. const contents = this._formatContents(contentsObj);
  19687. popup.append(contents);
  19688. }
  19689. let useParentRect = !!this.#parentRect;
  19690. let rect = useParentRect ? this.#parentRect : this.#rect;
  19691. for (const element of this.#elements) {
  19692. if (!rect || _util.Util.intersect(element.data.rect, rect) !== null) {
  19693. rect = element.data.rect;
  19694. useParentRect = true;
  19695. break;
  19696. }
  19697. }
  19698. const normalizedRect = _util.Util.normalizeRect([rect[0], view[3] - rect[1] + view[1], rect[2], view[3] - rect[3] + view[1]]);
  19699. const HORIZONTAL_SPACE_AFTER_ANNOTATION = 5;
  19700. const parentWidth = useParentRect ? rect[2] - rect[0] + HORIZONTAL_SPACE_AFTER_ANNOTATION : 0;
  19701. const popupLeft = normalizedRect[0] + parentWidth;
  19702. const popupTop = normalizedRect[1];
  19703. const {
  19704. style
  19705. } = this.#container;
  19706. style.left = `${100 * (popupLeft - pageX) / pageWidth}%`;
  19707. style.top = `${100 * (popupTop - pageY) / pageHeight}%`;
  19708. this.#container.append(popup);
  19709. }
  19710. _formatContents(_ref2) {
  19711. let {
  19712. str,
  19713. dir
  19714. } = _ref2;
  19715. const p = document.createElement("p");
  19716. p.classList.add("popupContent");
  19717. p.dir = dir;
  19718. const lines = str.split(/(?:\r\n?|\n)/);
  19719. for (let i = 0, ii = lines.length; i < ii; ++i) {
  19720. const line = lines[i];
  19721. p.append(document.createTextNode(line));
  19722. if (i < ii - 1) {
  19723. p.append(document.createElement("br"));
  19724. }
  19725. }
  19726. return p;
  19727. }
  19728. #toggle() {
  19729. this.#pinned = !this.#pinned;
  19730. if (this.#pinned) {
  19731. this.#show();
  19732. this.#container.addEventListener("click", this.#boundToggle);
  19733. } else {
  19734. this.#hide();
  19735. this.#container.removeEventListener("click", this.#boundToggle);
  19736. }
  19737. }
  19738. #show() {
  19739. if (!this.#popup) {
  19740. this.render();
  19741. }
  19742. if (!this.isVisible) {
  19743. this.#container.hidden = false;
  19744. this.#container.style.zIndex = parseInt(this.#container.style.zIndex) + 1000;
  19745. } else if (this.#pinned) {
  19746. this.#container.classList.add("focused");
  19747. }
  19748. }
  19749. #hide() {
  19750. this.#container.classList.remove("focused");
  19751. if (this.#pinned || !this.isVisible) {
  19752. return;
  19753. }
  19754. this.#container.hidden = true;
  19755. this.#container.style.zIndex = parseInt(this.#container.style.zIndex) - 1000;
  19756. }
  19757. forceHide() {
  19758. this.#wasVisible = this.isVisible;
  19759. if (!this.#wasVisible) {
  19760. return;
  19761. }
  19762. this.#container.hidden = true;
  19763. }
  19764. maybeShow() {
  19765. if (!this.#wasVisible) {
  19766. return;
  19767. }
  19768. this.#wasVisible = false;
  19769. this.#container.hidden = false;
  19770. }
  19771. get isVisible() {
  19772. return this.#container.hidden === false;
  19773. }
  19774. }
  19775. class FreeTextAnnotationElement extends AnnotationElement {
  19776. constructor(parameters) {
  19777. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19778. super(parameters, {
  19779. isRenderable,
  19780. ignoreBorder: true
  19781. });
  19782. this.textContent = parameters.data.textContent;
  19783. this.textPosition = parameters.data.textPosition;
  19784. this.annotationEditorType = _util.AnnotationEditorType.FREETEXT;
  19785. }
  19786. render() {
  19787. this.container.classList.add("freeTextAnnotation");
  19788. if (this.textContent) {
  19789. const content = document.createElement("div");
  19790. content.classList.add("annotationTextContent");
  19791. content.setAttribute("role", "comment");
  19792. for (const line of this.textContent) {
  19793. const lineSpan = document.createElement("span");
  19794. lineSpan.textContent = line;
  19795. content.append(lineSpan);
  19796. }
  19797. this.container.append(content);
  19798. }
  19799. if (!this.data.popupRef) {
  19800. this._createPopup();
  19801. }
  19802. this._editOnDoubleClick();
  19803. return this.container;
  19804. }
  19805. }
  19806. exports.FreeTextAnnotationElement = FreeTextAnnotationElement;
  19807. class LineAnnotationElement extends AnnotationElement {
  19808. #line = null;
  19809. constructor(parameters) {
  19810. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19811. super(parameters, {
  19812. isRenderable,
  19813. ignoreBorder: true
  19814. });
  19815. }
  19816. render() {
  19817. this.container.classList.add("lineAnnotation");
  19818. const data = this.data;
  19819. const {
  19820. width,
  19821. height
  19822. } = getRectDims(data.rect);
  19823. const svg = this.svgFactory.create(width, height, true);
  19824. const line = this.#line = this.svgFactory.createElement("svg:line");
  19825. line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
  19826. line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
  19827. line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
  19828. line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
  19829. line.setAttribute("stroke-width", data.borderStyle.width || 1);
  19830. line.setAttribute("stroke", "transparent");
  19831. line.setAttribute("fill", "transparent");
  19832. svg.append(line);
  19833. this.container.append(svg);
  19834. if (!data.popupRef) {
  19835. this._createPopup();
  19836. }
  19837. return this.container;
  19838. }
  19839. getElementsToTriggerPopup() {
  19840. return this.#line;
  19841. }
  19842. addHighlightArea() {
  19843. this.container.classList.add("highlightArea");
  19844. }
  19845. }
  19846. class SquareAnnotationElement extends AnnotationElement {
  19847. #square = null;
  19848. constructor(parameters) {
  19849. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19850. super(parameters, {
  19851. isRenderable,
  19852. ignoreBorder: true
  19853. });
  19854. }
  19855. render() {
  19856. this.container.classList.add("squareAnnotation");
  19857. const data = this.data;
  19858. const {
  19859. width,
  19860. height
  19861. } = getRectDims(data.rect);
  19862. const svg = this.svgFactory.create(width, height, true);
  19863. const borderWidth = data.borderStyle.width;
  19864. const square = this.#square = this.svgFactory.createElement("svg:rect");
  19865. square.setAttribute("x", borderWidth / 2);
  19866. square.setAttribute("y", borderWidth / 2);
  19867. square.setAttribute("width", width - borderWidth);
  19868. square.setAttribute("height", height - borderWidth);
  19869. square.setAttribute("stroke-width", borderWidth || 1);
  19870. square.setAttribute("stroke", "transparent");
  19871. square.setAttribute("fill", "transparent");
  19872. svg.append(square);
  19873. this.container.append(svg);
  19874. if (!data.popupRef) {
  19875. this._createPopup();
  19876. }
  19877. return this.container;
  19878. }
  19879. getElementsToTriggerPopup() {
  19880. return this.#square;
  19881. }
  19882. addHighlightArea() {
  19883. this.container.classList.add("highlightArea");
  19884. }
  19885. }
  19886. class CircleAnnotationElement extends AnnotationElement {
  19887. #circle = null;
  19888. constructor(parameters) {
  19889. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19890. super(parameters, {
  19891. isRenderable,
  19892. ignoreBorder: true
  19893. });
  19894. }
  19895. render() {
  19896. this.container.classList.add("circleAnnotation");
  19897. const data = this.data;
  19898. const {
  19899. width,
  19900. height
  19901. } = getRectDims(data.rect);
  19902. const svg = this.svgFactory.create(width, height, true);
  19903. const borderWidth = data.borderStyle.width;
  19904. const circle = this.#circle = this.svgFactory.createElement("svg:ellipse");
  19905. circle.setAttribute("cx", width / 2);
  19906. circle.setAttribute("cy", height / 2);
  19907. circle.setAttribute("rx", width / 2 - borderWidth / 2);
  19908. circle.setAttribute("ry", height / 2 - borderWidth / 2);
  19909. circle.setAttribute("stroke-width", borderWidth || 1);
  19910. circle.setAttribute("stroke", "transparent");
  19911. circle.setAttribute("fill", "transparent");
  19912. svg.append(circle);
  19913. this.container.append(svg);
  19914. if (!data.popupRef) {
  19915. this._createPopup();
  19916. }
  19917. return this.container;
  19918. }
  19919. getElementsToTriggerPopup() {
  19920. return this.#circle;
  19921. }
  19922. addHighlightArea() {
  19923. this.container.classList.add("highlightArea");
  19924. }
  19925. }
  19926. class PolylineAnnotationElement extends AnnotationElement {
  19927. #polyline = null;
  19928. constructor(parameters) {
  19929. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19930. super(parameters, {
  19931. isRenderable,
  19932. ignoreBorder: true
  19933. });
  19934. this.containerClassName = "polylineAnnotation";
  19935. this.svgElementName = "svg:polyline";
  19936. }
  19937. render() {
  19938. this.container.classList.add(this.containerClassName);
  19939. const data = this.data;
  19940. const {
  19941. width,
  19942. height
  19943. } = getRectDims(data.rect);
  19944. const svg = this.svgFactory.create(width, height, true);
  19945. let points = [];
  19946. for (const coordinate of data.vertices) {
  19947. const x = coordinate.x - data.rect[0];
  19948. const y = data.rect[3] - coordinate.y;
  19949. points.push(x + "," + y);
  19950. }
  19951. points = points.join(" ");
  19952. const polyline = this.#polyline = this.svgFactory.createElement(this.svgElementName);
  19953. polyline.setAttribute("points", points);
  19954. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  19955. polyline.setAttribute("stroke", "transparent");
  19956. polyline.setAttribute("fill", "transparent");
  19957. svg.append(polyline);
  19958. this.container.append(svg);
  19959. if (!data.popupRef) {
  19960. this._createPopup(polyline, data);
  19961. }
  19962. return this.container;
  19963. }
  19964. getElementsToTriggerPopup() {
  19965. return this.#polyline;
  19966. }
  19967. addHighlightArea() {
  19968. this.container.classList.add("highlightArea");
  19969. }
  19970. }
  19971. class PolygonAnnotationElement extends PolylineAnnotationElement {
  19972. constructor(parameters) {
  19973. super(parameters);
  19974. this.containerClassName = "polygonAnnotation";
  19975. this.svgElementName = "svg:polygon";
  19976. }
  19977. }
  19978. class CaretAnnotationElement extends AnnotationElement {
  19979. constructor(parameters) {
  19980. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19981. super(parameters, {
  19982. isRenderable,
  19983. ignoreBorder: true
  19984. });
  19985. }
  19986. render() {
  19987. this.container.classList.add("caretAnnotation");
  19988. if (!this.data.popupRef) {
  19989. this._createPopup();
  19990. }
  19991. return this.container;
  19992. }
  19993. }
  19994. class InkAnnotationElement extends AnnotationElement {
  19995. #polylines = [];
  19996. constructor(parameters) {
  19997. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  19998. super(parameters, {
  19999. isRenderable,
  20000. ignoreBorder: true
  20001. });
  20002. this.containerClassName = "inkAnnotation";
  20003. this.svgElementName = "svg:polyline";
  20004. this.annotationEditorType = _util.AnnotationEditorType.INK;
  20005. }
  20006. render() {
  20007. this.container.classList.add(this.containerClassName);
  20008. const data = this.data;
  20009. const {
  20010. width,
  20011. height
  20012. } = getRectDims(data.rect);
  20013. const svg = this.svgFactory.create(width, height, true);
  20014. for (const inkList of data.inkLists) {
  20015. let points = [];
  20016. for (const coordinate of inkList) {
  20017. const x = coordinate.x - data.rect[0];
  20018. const y = data.rect[3] - coordinate.y;
  20019. points.push(`${x},${y}`);
  20020. }
  20021. points = points.join(" ");
  20022. const polyline = this.svgFactory.createElement(this.svgElementName);
  20023. this.#polylines.push(polyline);
  20024. polyline.setAttribute("points", points);
  20025. polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
  20026. polyline.setAttribute("stroke", "transparent");
  20027. polyline.setAttribute("fill", "transparent");
  20028. if (!data.popupRef) {
  20029. this._createPopup(polyline, data);
  20030. }
  20031. svg.append(polyline);
  20032. }
  20033. this.container.append(svg);
  20034. return this.container;
  20035. }
  20036. getElementsToTriggerPopup() {
  20037. return this.#polylines;
  20038. }
  20039. addHighlightArea() {
  20040. this.container.classList.add("highlightArea");
  20041. }
  20042. }
  20043. exports.InkAnnotationElement = InkAnnotationElement;
  20044. class HighlightAnnotationElement extends AnnotationElement {
  20045. constructor(parameters) {
  20046. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  20047. super(parameters, {
  20048. isRenderable,
  20049. ignoreBorder: true,
  20050. createQuadrilaterals: true
  20051. });
  20052. }
  20053. render() {
  20054. if (!this.data.popupRef) {
  20055. this._createPopup();
  20056. }
  20057. this.container.classList.add("highlightAnnotation");
  20058. return this.container;
  20059. }
  20060. }
  20061. class UnderlineAnnotationElement extends AnnotationElement {
  20062. constructor(parameters) {
  20063. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  20064. super(parameters, {
  20065. isRenderable,
  20066. ignoreBorder: true,
  20067. createQuadrilaterals: true
  20068. });
  20069. }
  20070. render() {
  20071. if (!this.data.popupRef) {
  20072. this._createPopup();
  20073. }
  20074. this.container.classList.add("underlineAnnotation");
  20075. return this.container;
  20076. }
  20077. }
  20078. class SquigglyAnnotationElement extends AnnotationElement {
  20079. constructor(parameters) {
  20080. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  20081. super(parameters, {
  20082. isRenderable,
  20083. ignoreBorder: true,
  20084. createQuadrilaterals: true
  20085. });
  20086. }
  20087. render() {
  20088. if (!this.data.popupRef) {
  20089. this._createPopup();
  20090. }
  20091. this.container.classList.add("squigglyAnnotation");
  20092. return this.container;
  20093. }
  20094. }
  20095. class StrikeOutAnnotationElement extends AnnotationElement {
  20096. constructor(parameters) {
  20097. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  20098. super(parameters, {
  20099. isRenderable,
  20100. ignoreBorder: true,
  20101. createQuadrilaterals: true
  20102. });
  20103. }
  20104. render() {
  20105. if (!this.data.popupRef) {
  20106. this._createPopup();
  20107. }
  20108. this.container.classList.add("strikeoutAnnotation");
  20109. return this.container;
  20110. }
  20111. }
  20112. class StampAnnotationElement extends AnnotationElement {
  20113. constructor(parameters) {
  20114. const isRenderable = !!(parameters.data.popupRef || parameters.data.titleObj?.str || parameters.data.contentsObj?.str || parameters.data.richText?.str);
  20115. super(parameters, {
  20116. isRenderable,
  20117. ignoreBorder: true
  20118. });
  20119. }
  20120. render() {
  20121. this.container.classList.add("stampAnnotation");
  20122. if (!this.data.popupRef) {
  20123. this._createPopup();
  20124. }
  20125. return this.container;
  20126. }
  20127. }
  20128. exports.StampAnnotationElement = StampAnnotationElement;
  20129. class FileAttachmentAnnotationElement extends AnnotationElement {
  20130. #trigger = null;
  20131. constructor(parameters) {
  20132. super(parameters, {
  20133. isRenderable: true
  20134. });
  20135. const {
  20136. filename,
  20137. content
  20138. } = this.data.file;
  20139. this.filename = (0, _display_utils.getFilenameFromUrl)(filename, true);
  20140. this.content = content;
  20141. this.linkService.eventBus?.dispatch("fileattachmentannotation", {
  20142. source: this,
  20143. filename,
  20144. content
  20145. });
  20146. }
  20147. render() {
  20148. this.container.classList.add("fileAttachmentAnnotation");
  20149. const {
  20150. data
  20151. } = this;
  20152. let trigger;
  20153. if (data.hasAppearance || data.fillAlpha === 0) {
  20154. trigger = document.createElement("div");
  20155. } else {
  20156. trigger = document.createElement("img");
  20157. trigger.src = `${this.imageResourcesPath}annotation-${/paperclip/i.test(data.name) ? "paperclip" : "pushpin"}.svg`;
  20158. if (data.fillAlpha && data.fillAlpha < 1) {
  20159. trigger.style = `filter: opacity(${Math.round(data.fillAlpha * 100)}%);`;
  20160. }
  20161. }
  20162. trigger.classList.add("popupTriggerArea");
  20163. trigger.addEventListener("dblclick", this._download.bind(this));
  20164. this.#trigger = trigger;
  20165. if (!data.popupRef && (data.titleObj?.str || data.contentsObj?.str || data.richText)) {
  20166. this._createPopup();
  20167. }
  20168. this.container.append(trigger);
  20169. return this.container;
  20170. }
  20171. getElementsToTriggerPopup() {
  20172. return this.#trigger;
  20173. }
  20174. addHighlightArea() {
  20175. this.container.classList.add("highlightArea");
  20176. }
  20177. _download() {
  20178. this.downloadManager?.openOrDownloadData(this.container, this.content, this.filename);
  20179. }
  20180. }
  20181. class AnnotationLayer {
  20182. #accessibilityManager = null;
  20183. #annotationCanvasMap = null;
  20184. #editableAnnotations = new Map();
  20185. constructor(_ref3) {
  20186. let {
  20187. div,
  20188. accessibilityManager,
  20189. annotationCanvasMap,
  20190. l10n,
  20191. page,
  20192. viewport
  20193. } = _ref3;
  20194. this.div = div;
  20195. this.#accessibilityManager = accessibilityManager;
  20196. this.#annotationCanvasMap = annotationCanvasMap;
  20197. this.l10n = l10n;
  20198. this.page = page;
  20199. this.viewport = viewport;
  20200. this.zIndex = 0;
  20201. this.l10n ||= _displayL10n_utils.NullL10n;
  20202. }
  20203. #appendElement(element, id) {
  20204. const contentElement = element.firstChild || element;
  20205. contentElement.id = `${_display_utils.AnnotationPrefix}${id}`;
  20206. this.div.append(element);
  20207. this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false);
  20208. }
  20209. async render(params) {
  20210. const {
  20211. annotations
  20212. } = params;
  20213. const layer = this.div;
  20214. (0, _display_utils.setLayerDimensions)(layer, this.viewport);
  20215. const popupToElements = new Map();
  20216. const elementParams = {
  20217. data: null,
  20218. layer,
  20219. linkService: params.linkService,
  20220. downloadManager: params.downloadManager,
  20221. imageResourcesPath: params.imageResourcesPath || "",
  20222. renderForms: params.renderForms !== false,
  20223. svgFactory: new _display_utils.DOMSVGFactory(),
  20224. annotationStorage: params.annotationStorage || new _annotation_storage.AnnotationStorage(),
  20225. enableScripting: params.enableScripting === true,
  20226. hasJSActions: params.hasJSActions,
  20227. fieldObjects: params.fieldObjects,
  20228. parent: this,
  20229. elements: null
  20230. };
  20231. for (const data of annotations) {
  20232. if (data.noHTML) {
  20233. continue;
  20234. }
  20235. const isPopupAnnotation = data.annotationType === _util.AnnotationType.POPUP;
  20236. if (!isPopupAnnotation) {
  20237. const {
  20238. width,
  20239. height
  20240. } = getRectDims(data.rect);
  20241. if (width <= 0 || height <= 0) {
  20242. continue;
  20243. }
  20244. } else {
  20245. const elements = popupToElements.get(data.id);
  20246. if (!elements) {
  20247. continue;
  20248. }
  20249. elementParams.elements = elements;
  20250. }
  20251. elementParams.data = data;
  20252. const element = AnnotationElementFactory.create(elementParams);
  20253. if (!element.isRenderable) {
  20254. continue;
  20255. }
  20256. if (!isPopupAnnotation && data.popupRef) {
  20257. const elements = popupToElements.get(data.popupRef);
  20258. if (!elements) {
  20259. popupToElements.set(data.popupRef, [element]);
  20260. } else {
  20261. elements.push(element);
  20262. }
  20263. }
  20264. if (element.annotationEditorType > 0) {
  20265. this.#editableAnnotations.set(element.data.id, element);
  20266. }
  20267. const rendered = element.render();
  20268. if (data.hidden) {
  20269. rendered.style.visibility = "hidden";
  20270. }
  20271. this.#appendElement(rendered, data.id);
  20272. }
  20273. this.#setAnnotationCanvasMap();
  20274. await this.l10n.translate(layer);
  20275. }
  20276. update(_ref4) {
  20277. let {
  20278. viewport
  20279. } = _ref4;
  20280. const layer = this.div;
  20281. this.viewport = viewport;
  20282. (0, _display_utils.setLayerDimensions)(layer, {
  20283. rotation: viewport.rotation
  20284. });
  20285. this.#setAnnotationCanvasMap();
  20286. layer.hidden = false;
  20287. }
  20288. #setAnnotationCanvasMap() {
  20289. if (!this.#annotationCanvasMap) {
  20290. return;
  20291. }
  20292. const layer = this.div;
  20293. for (const [id, canvas] of this.#annotationCanvasMap) {
  20294. const element = layer.querySelector(`[data-annotation-id="${id}"]`);
  20295. if (!element) {
  20296. continue;
  20297. }
  20298. const {
  20299. firstChild
  20300. } = element;
  20301. if (!firstChild) {
  20302. element.append(canvas);
  20303. } else if (firstChild.nodeName === "CANVAS") {
  20304. firstChild.replaceWith(canvas);
  20305. } else {
  20306. firstChild.before(canvas);
  20307. }
  20308. }
  20309. this.#annotationCanvasMap.clear();
  20310. }
  20311. getEditableAnnotations() {
  20312. return Array.from(this.#editableAnnotations.values());
  20313. }
  20314. getEditableAnnotation(id) {
  20315. return this.#editableAnnotations.get(id);
  20316. }
  20317. }
  20318. exports.AnnotationLayer = AnnotationLayer;
  20319. /***/ }),
  20320. /* 199 */
  20321. /***/ ((__unused_webpack_module, exports) => {
  20322. Object.defineProperty(exports, "__esModule", ({
  20323. value: true
  20324. }));
  20325. exports.ColorConverters = void 0;
  20326. function makeColorComp(n) {
  20327. return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
  20328. }
  20329. function scaleAndClamp(x) {
  20330. return Math.max(0, Math.min(255, 255 * x));
  20331. }
  20332. class ColorConverters {
  20333. static CMYK_G(_ref) {
  20334. let [c, y, m, k] = _ref;
  20335. return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
  20336. }
  20337. static G_CMYK(_ref2) {
  20338. let [g] = _ref2;
  20339. return ["CMYK", 0, 0, 0, 1 - g];
  20340. }
  20341. static G_RGB(_ref3) {
  20342. let [g] = _ref3;
  20343. return ["RGB", g, g, g];
  20344. }
  20345. static G_rgb(_ref4) {
  20346. let [g] = _ref4;
  20347. g = scaleAndClamp(g);
  20348. return [g, g, g];
  20349. }
  20350. static G_HTML(_ref5) {
  20351. let [g] = _ref5;
  20352. const G = makeColorComp(g);
  20353. return `#${G}${G}${G}`;
  20354. }
  20355. static RGB_G(_ref6) {
  20356. let [r, g, b] = _ref6;
  20357. return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
  20358. }
  20359. static RGB_rgb(color) {
  20360. return color.map(scaleAndClamp);
  20361. }
  20362. static RGB_HTML(color) {
  20363. return `#${color.map(makeColorComp).join("")}`;
  20364. }
  20365. static T_HTML() {
  20366. return "#00000000";
  20367. }
  20368. static T_rgb() {
  20369. return [null];
  20370. }
  20371. static CMYK_RGB(_ref7) {
  20372. let [c, y, m, k] = _ref7;
  20373. return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
  20374. }
  20375. static CMYK_rgb(_ref8) {
  20376. let [c, y, m, k] = _ref8;
  20377. return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];
  20378. }
  20379. static CMYK_HTML(components) {
  20380. const rgb = this.CMYK_RGB(components).slice(1);
  20381. return this.RGB_HTML(rgb);
  20382. }
  20383. static RGB_CMYK(_ref9) {
  20384. let [r, g, b] = _ref9;
  20385. const c = 1 - r;
  20386. const m = 1 - g;
  20387. const y = 1 - b;
  20388. const k = Math.min(c, m, y);
  20389. return ["CMYK", c, m, y, k];
  20390. }
  20391. }
  20392. exports.ColorConverters = ColorConverters;
  20393. /***/ }),
  20394. /* 200 */
  20395. /***/ ((__unused_webpack_module, exports) => {
  20396. Object.defineProperty(exports, "__esModule", ({
  20397. value: true
  20398. }));
  20399. exports.NullL10n = void 0;
  20400. exports.getL10nFallback = getL10nFallback;
  20401. const DEFAULT_L10N_STRINGS = {
  20402. of_pages: "of {{pagesCount}}",
  20403. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  20404. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  20405. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  20406. document_properties_date_string: "{{date}}, {{time}}",
  20407. document_properties_page_size_unit_inches: "in",
  20408. document_properties_page_size_unit_millimeters: "mm",
  20409. document_properties_page_size_orientation_portrait: "portrait",
  20410. document_properties_page_size_orientation_landscape: "landscape",
  20411. document_properties_page_size_name_a3: "A3",
  20412. document_properties_page_size_name_a4: "A4",
  20413. document_properties_page_size_name_letter: "Letter",
  20414. document_properties_page_size_name_legal: "Legal",
  20415. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  20416. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  20417. document_properties_linearized_yes: "Yes",
  20418. document_properties_linearized_no: "No",
  20419. additional_layers: "Additional Layers",
  20420. page_landmark: "Page {{page}}",
  20421. thumb_page_title: "Page {{page}}",
  20422. thumb_page_canvas: "Thumbnail of Page {{page}}",
  20423. find_reached_top: "Reached top of document, continued from bottom",
  20424. find_reached_bottom: "Reached end of document, continued from top",
  20425. "find_match_count[one]": "{{current}} of {{total}} match",
  20426. "find_match_count[other]": "{{current}} of {{total}} matches",
  20427. "find_match_count_limit[one]": "More than {{limit}} match",
  20428. "find_match_count_limit[other]": "More than {{limit}} matches",
  20429. find_not_found: "Phrase not found",
  20430. page_scale_width: "Page Width",
  20431. page_scale_fit: "Page Fit",
  20432. page_scale_auto: "Automatic Zoom",
  20433. page_scale_actual: "Actual Size",
  20434. page_scale_percent: "{{scale}}%",
  20435. loading_error: "An error occurred while loading the PDF.",
  20436. invalid_file_error: "Invalid or corrupted PDF file.",
  20437. missing_file_error: "Missing PDF file.",
  20438. unexpected_response_error: "Unexpected server response.",
  20439. rendering_error: "An error occurred while rendering the page.",
  20440. annotation_date_string: "{{date}}, {{time}}",
  20441. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  20442. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  20443. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  20444. free_text2_default_content: "Start typing…",
  20445. editor_free_text2_aria_label: "Text Editor",
  20446. editor_ink2_aria_label: "Draw Editor",
  20447. editor_ink_canvas_aria_label: "User-created image"
  20448. };
  20449. {
  20450. DEFAULT_L10N_STRINGS.print_progress_percent = "{{progress}}%";
  20451. }
  20452. function getL10nFallback(key, args) {
  20453. switch (key) {
  20454. case "find_match_count":
  20455. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  20456. break;
  20457. case "find_match_count_limit":
  20458. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  20459. break;
  20460. }
  20461. return DEFAULT_L10N_STRINGS[key] || "";
  20462. }
  20463. function formatL10nValue(text, args) {
  20464. if (!args) {
  20465. return text;
  20466. }
  20467. return text.replaceAll(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  20468. return name in args ? args[name] : "{{" + name + "}}";
  20469. });
  20470. }
  20471. const NullL10n = {
  20472. async getLanguage() {
  20473. return "en-us";
  20474. },
  20475. async getDirection() {
  20476. return "ltr";
  20477. },
  20478. async get(key) {
  20479. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  20480. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args);
  20481. return formatL10nValue(fallback, args);
  20482. },
  20483. async translate(element) {}
  20484. };
  20485. exports.NullL10n = NullL10n;
  20486. /***/ }),
  20487. /* 201 */
  20488. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20489. Object.defineProperty(exports, "__esModule", ({
  20490. value: true
  20491. }));
  20492. exports.XfaLayer = void 0;
  20493. __w_pdfjs_require__(89);
  20494. var _xfa_text = __w_pdfjs_require__(194);
  20495. class XfaLayer {
  20496. static setupStorage(html, id, element, storage, intent) {
  20497. const storedData = storage.getValue(id, {
  20498. value: null
  20499. });
  20500. switch (element.name) {
  20501. case "textarea":
  20502. if (storedData.value !== null) {
  20503. html.textContent = storedData.value;
  20504. }
  20505. if (intent === "print") {
  20506. break;
  20507. }
  20508. html.addEventListener("input", event => {
  20509. storage.setValue(id, {
  20510. value: event.target.value
  20511. });
  20512. });
  20513. break;
  20514. case "input":
  20515. if (element.attributes.type === "radio" || element.attributes.type === "checkbox") {
  20516. if (storedData.value === element.attributes.xfaOn) {
  20517. html.setAttribute("checked", true);
  20518. } else if (storedData.value === element.attributes.xfaOff) {
  20519. html.removeAttribute("checked");
  20520. }
  20521. if (intent === "print") {
  20522. break;
  20523. }
  20524. html.addEventListener("change", event => {
  20525. storage.setValue(id, {
  20526. value: event.target.checked ? event.target.getAttribute("xfaOn") : event.target.getAttribute("xfaOff")
  20527. });
  20528. });
  20529. } else {
  20530. if (storedData.value !== null) {
  20531. html.setAttribute("value", storedData.value);
  20532. }
  20533. if (intent === "print") {
  20534. break;
  20535. }
  20536. html.addEventListener("input", event => {
  20537. storage.setValue(id, {
  20538. value: event.target.value
  20539. });
  20540. });
  20541. }
  20542. break;
  20543. case "select":
  20544. if (storedData.value !== null) {
  20545. html.setAttribute("value", storedData.value);
  20546. for (const option of element.children) {
  20547. if (option.attributes.value === storedData.value) {
  20548. option.attributes.selected = true;
  20549. } else if (option.attributes.hasOwnProperty("selected")) {
  20550. delete option.attributes.selected;
  20551. }
  20552. }
  20553. }
  20554. html.addEventListener("input", event => {
  20555. const options = event.target.options;
  20556. const value = options.selectedIndex === -1 ? "" : options[options.selectedIndex].value;
  20557. storage.setValue(id, {
  20558. value
  20559. });
  20560. });
  20561. break;
  20562. }
  20563. }
  20564. static setAttributes(_ref) {
  20565. let {
  20566. html,
  20567. element,
  20568. storage = null,
  20569. intent,
  20570. linkService
  20571. } = _ref;
  20572. const {
  20573. attributes
  20574. } = element;
  20575. const isHTMLAnchorElement = html instanceof HTMLAnchorElement;
  20576. if (attributes.type === "radio") {
  20577. attributes.name = `${attributes.name}-${intent}`;
  20578. }
  20579. for (const [key, value] of Object.entries(attributes)) {
  20580. if (value === null || value === undefined) {
  20581. continue;
  20582. }
  20583. switch (key) {
  20584. case "class":
  20585. if (value.length) {
  20586. html.setAttribute(key, value.join(" "));
  20587. }
  20588. break;
  20589. case "dataId":
  20590. break;
  20591. case "id":
  20592. html.setAttribute("data-element-id", value);
  20593. break;
  20594. case "style":
  20595. Object.assign(html.style, value);
  20596. break;
  20597. case "textContent":
  20598. html.textContent = value;
  20599. break;
  20600. default:
  20601. if (!isHTMLAnchorElement || key !== "href" && key !== "newWindow") {
  20602. html.setAttribute(key, value);
  20603. }
  20604. }
  20605. }
  20606. if (isHTMLAnchorElement) {
  20607. linkService.addLinkAttributes(html, attributes.href, attributes.newWindow);
  20608. }
  20609. if (storage && attributes.dataId) {
  20610. this.setupStorage(html, attributes.dataId, element, storage);
  20611. }
  20612. }
  20613. static render(parameters) {
  20614. const storage = parameters.annotationStorage;
  20615. const linkService = parameters.linkService;
  20616. const root = parameters.xfaHtml;
  20617. const intent = parameters.intent || "display";
  20618. const rootHtml = document.createElement(root.name);
  20619. if (root.attributes) {
  20620. this.setAttributes({
  20621. html: rootHtml,
  20622. element: root,
  20623. intent,
  20624. linkService
  20625. });
  20626. }
  20627. const stack = [[root, -1, rootHtml]];
  20628. const rootDiv = parameters.div;
  20629. rootDiv.append(rootHtml);
  20630. if (parameters.viewport) {
  20631. const transform = `matrix(${parameters.viewport.transform.join(",")})`;
  20632. rootDiv.style.transform = transform;
  20633. }
  20634. if (intent !== "richText") {
  20635. rootDiv.setAttribute("class", "xfaLayer xfaFont");
  20636. }
  20637. const textDivs = [];
  20638. while (stack.length > 0) {
  20639. const [parent, i, html] = stack.at(-1);
  20640. if (i + 1 === parent.children.length) {
  20641. stack.pop();
  20642. continue;
  20643. }
  20644. const child = parent.children[++stack.at(-1)[1]];
  20645. if (child === null) {
  20646. continue;
  20647. }
  20648. const {
  20649. name
  20650. } = child;
  20651. if (name === "#text") {
  20652. const node = document.createTextNode(child.value);
  20653. textDivs.push(node);
  20654. html.append(node);
  20655. continue;
  20656. }
  20657. const childHtml = child?.attributes?.xmlns ? document.createElementNS(child.attributes.xmlns, name) : document.createElement(name);
  20658. html.append(childHtml);
  20659. if (child.attributes) {
  20660. this.setAttributes({
  20661. html: childHtml,
  20662. element: child,
  20663. storage,
  20664. intent,
  20665. linkService
  20666. });
  20667. }
  20668. if (child.children && child.children.length > 0) {
  20669. stack.push([child, -1, childHtml]);
  20670. } else if (child.value) {
  20671. const node = document.createTextNode(child.value);
  20672. if (_xfa_text.XfaText.shouldBuildText(name)) {
  20673. textDivs.push(node);
  20674. }
  20675. childHtml.append(node);
  20676. }
  20677. }
  20678. for (const el of rootDiv.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea")) {
  20679. el.setAttribute("readOnly", true);
  20680. }
  20681. return {
  20682. textDivs
  20683. };
  20684. }
  20685. static update(parameters) {
  20686. const transform = `matrix(${parameters.viewport.transform.join(",")})`;
  20687. parameters.div.style.transform = transform;
  20688. parameters.div.hidden = false;
  20689. }
  20690. }
  20691. exports.XfaLayer = XfaLayer;
  20692. /***/ }),
  20693. /* 202 */
  20694. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  20695. Object.defineProperty(exports, "__esModule", ({
  20696. value: true
  20697. }));
  20698. exports.InkEditor = void 0;
  20699. __w_pdfjs_require__(89);
  20700. __w_pdfjs_require__(2);
  20701. var _util = __w_pdfjs_require__(1);
  20702. var _editor = __w_pdfjs_require__(164);
  20703. var _annotation_layer = __w_pdfjs_require__(198);
  20704. var _tools = __w_pdfjs_require__(165);
  20705. class InkEditor extends _editor.AnnotationEditor {
  20706. #baseHeight = 0;
  20707. #baseWidth = 0;
  20708. #boundCanvasContextMenu = this.canvasContextMenu.bind(this);
  20709. #boundCanvasPointermove = this.canvasPointermove.bind(this);
  20710. #boundCanvasPointerleave = this.canvasPointerleave.bind(this);
  20711. #boundCanvasPointerup = this.canvasPointerup.bind(this);
  20712. #boundCanvasPointerdown = this.canvasPointerdown.bind(this);
  20713. #currentPath2D = new Path2D();
  20714. #disableEditing = false;
  20715. #hasSomethingToDraw = false;
  20716. #isCanvasInitialized = false;
  20717. #observer = null;
  20718. #realWidth = 0;
  20719. #realHeight = 0;
  20720. #requestFrameCallback = null;
  20721. static _defaultColor = null;
  20722. static _defaultOpacity = 1;
  20723. static _defaultThickness = 1;
  20724. static _l10nPromise;
  20725. static _type = "ink";
  20726. constructor(params) {
  20727. super({
  20728. ...params,
  20729. name: "inkEditor"
  20730. });
  20731. this.color = params.color || null;
  20732. this.thickness = params.thickness || null;
  20733. this.opacity = params.opacity || null;
  20734. this.paths = [];
  20735. this.bezierPath2D = [];
  20736. this.allRawPaths = [];
  20737. this.currentPath = [];
  20738. this.scaleFactor = 1;
  20739. this.translationX = this.translationY = 0;
  20740. this.x = 0;
  20741. this.y = 0;
  20742. this._willKeepAspectRatio = true;
  20743. }
  20744. static initialize(l10n) {
  20745. this._l10nPromise = new Map(["editor_ink_canvas_aria_label", "editor_ink2_aria_label"].map(str => [str, l10n.get(str)]));
  20746. }
  20747. static updateDefaultParams(type, value) {
  20748. switch (type) {
  20749. case _util.AnnotationEditorParamsType.INK_THICKNESS:
  20750. InkEditor._defaultThickness = value;
  20751. break;
  20752. case _util.AnnotationEditorParamsType.INK_COLOR:
  20753. InkEditor._defaultColor = value;
  20754. break;
  20755. case _util.AnnotationEditorParamsType.INK_OPACITY:
  20756. InkEditor._defaultOpacity = value / 100;
  20757. break;
  20758. }
  20759. }
  20760. updateParams(type, value) {
  20761. switch (type) {
  20762. case _util.AnnotationEditorParamsType.INK_THICKNESS:
  20763. this.#updateThickness(value);
  20764. break;
  20765. case _util.AnnotationEditorParamsType.INK_COLOR:
  20766. this.#updateColor(value);
  20767. break;
  20768. case _util.AnnotationEditorParamsType.INK_OPACITY:
  20769. this.#updateOpacity(value);
  20770. break;
  20771. }
  20772. }
  20773. static get defaultPropertiesToUpdate() {
  20774. return [[_util.AnnotationEditorParamsType.INK_THICKNESS, InkEditor._defaultThickness], [_util.AnnotationEditorParamsType.INK_COLOR, InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor], [_util.AnnotationEditorParamsType.INK_OPACITY, Math.round(InkEditor._defaultOpacity * 100)]];
  20775. }
  20776. get propertiesToUpdate() {
  20777. return [[_util.AnnotationEditorParamsType.INK_THICKNESS, this.thickness || InkEditor._defaultThickness], [_util.AnnotationEditorParamsType.INK_COLOR, this.color || InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor], [_util.AnnotationEditorParamsType.INK_OPACITY, Math.round(100 * (this.opacity ?? InkEditor._defaultOpacity))]];
  20778. }
  20779. #updateThickness(thickness) {
  20780. const savedThickness = this.thickness;
  20781. this.addCommands({
  20782. cmd: () => {
  20783. this.thickness = thickness;
  20784. this.#fitToContent();
  20785. },
  20786. undo: () => {
  20787. this.thickness = savedThickness;
  20788. this.#fitToContent();
  20789. },
  20790. mustExec: true,
  20791. type: _util.AnnotationEditorParamsType.INK_THICKNESS,
  20792. overwriteIfSameType: true,
  20793. keepUndo: true
  20794. });
  20795. }
  20796. #updateColor(color) {
  20797. const savedColor = this.color;
  20798. this.addCommands({
  20799. cmd: () => {
  20800. this.color = color;
  20801. this.#redraw();
  20802. },
  20803. undo: () => {
  20804. this.color = savedColor;
  20805. this.#redraw();
  20806. },
  20807. mustExec: true,
  20808. type: _util.AnnotationEditorParamsType.INK_COLOR,
  20809. overwriteIfSameType: true,
  20810. keepUndo: true
  20811. });
  20812. }
  20813. #updateOpacity(opacity) {
  20814. opacity /= 100;
  20815. const savedOpacity = this.opacity;
  20816. this.addCommands({
  20817. cmd: () => {
  20818. this.opacity = opacity;
  20819. this.#redraw();
  20820. },
  20821. undo: () => {
  20822. this.opacity = savedOpacity;
  20823. this.#redraw();
  20824. },
  20825. mustExec: true,
  20826. type: _util.AnnotationEditorParamsType.INK_OPACITY,
  20827. overwriteIfSameType: true,
  20828. keepUndo: true
  20829. });
  20830. }
  20831. rebuild() {
  20832. if (!this.parent) {
  20833. return;
  20834. }
  20835. super.rebuild();
  20836. if (this.div === null) {
  20837. return;
  20838. }
  20839. if (!this.canvas) {
  20840. this.#createCanvas();
  20841. this.#createObserver();
  20842. }
  20843. if (!this.isAttachedToDOM) {
  20844. this.parent.add(this);
  20845. this.#setCanvasDims();
  20846. }
  20847. this.#fitToContent();
  20848. }
  20849. remove() {
  20850. if (this.canvas === null) {
  20851. return;
  20852. }
  20853. if (!this.isEmpty()) {
  20854. this.commit();
  20855. }
  20856. this.canvas.width = this.canvas.height = 0;
  20857. this.canvas.remove();
  20858. this.canvas = null;
  20859. this.#observer.disconnect();
  20860. this.#observer = null;
  20861. super.remove();
  20862. }
  20863. setParent(parent) {
  20864. if (!this.parent && parent) {
  20865. this._uiManager.removeShouldRescale(this);
  20866. } else if (this.parent && parent === null) {
  20867. this._uiManager.addShouldRescale(this);
  20868. }
  20869. super.setParent(parent);
  20870. }
  20871. onScaleChanging() {
  20872. const [parentWidth, parentHeight] = this.parentDimensions;
  20873. const width = this.width * parentWidth;
  20874. const height = this.height * parentHeight;
  20875. this.setDimensions(width, height);
  20876. }
  20877. enableEditMode() {
  20878. if (this.#disableEditing || this.canvas === null) {
  20879. return;
  20880. }
  20881. super.enableEditMode();
  20882. this._isDraggable = false;
  20883. this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
  20884. }
  20885. disableEditMode() {
  20886. if (!this.isInEditMode() || this.canvas === null) {
  20887. return;
  20888. }
  20889. super.disableEditMode();
  20890. this._isDraggable = !this.isEmpty();
  20891. this.div.classList.remove("editing");
  20892. this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
  20893. }
  20894. onceAdded() {
  20895. this._isDraggable = !this.isEmpty();
  20896. }
  20897. isEmpty() {
  20898. return this.paths.length === 0 || this.paths.length === 1 && this.paths[0].length === 0;
  20899. }
  20900. #getInitialBBox() {
  20901. const {
  20902. parentRotation,
  20903. parentDimensions: [width, height]
  20904. } = this;
  20905. switch (parentRotation) {
  20906. case 90:
  20907. return [0, height, height, width];
  20908. case 180:
  20909. return [width, height, width, height];
  20910. case 270:
  20911. return [width, 0, height, width];
  20912. default:
  20913. return [0, 0, width, height];
  20914. }
  20915. }
  20916. #setStroke() {
  20917. const {
  20918. ctx,
  20919. color,
  20920. opacity,
  20921. thickness,
  20922. parentScale,
  20923. scaleFactor
  20924. } = this;
  20925. ctx.lineWidth = thickness * parentScale / scaleFactor;
  20926. ctx.lineCap = "round";
  20927. ctx.lineJoin = "round";
  20928. ctx.miterLimit = 10;
  20929. ctx.strokeStyle = `${color}${(0, _tools.opacityToHex)(opacity)}`;
  20930. }
  20931. #startDrawing(x, y) {
  20932. this.canvas.addEventListener("contextmenu", this.#boundCanvasContextMenu);
  20933. this.canvas.addEventListener("pointerleave", this.#boundCanvasPointerleave);
  20934. this.canvas.addEventListener("pointermove", this.#boundCanvasPointermove);
  20935. this.canvas.addEventListener("pointerup", this.#boundCanvasPointerup);
  20936. this.canvas.removeEventListener("pointerdown", this.#boundCanvasPointerdown);
  20937. this.isEditing = true;
  20938. if (!this.#isCanvasInitialized) {
  20939. this.#isCanvasInitialized = true;
  20940. this.#setCanvasDims();
  20941. this.thickness ||= InkEditor._defaultThickness;
  20942. this.color ||= InkEditor._defaultColor || _editor.AnnotationEditor._defaultLineColor;
  20943. this.opacity ??= InkEditor._defaultOpacity;
  20944. }
  20945. this.currentPath.push([x, y]);
  20946. this.#hasSomethingToDraw = false;
  20947. this.#setStroke();
  20948. this.#requestFrameCallback = () => {
  20949. this.#drawPoints();
  20950. if (this.#requestFrameCallback) {
  20951. window.requestAnimationFrame(this.#requestFrameCallback);
  20952. }
  20953. };
  20954. window.requestAnimationFrame(this.#requestFrameCallback);
  20955. }
  20956. #draw(x, y) {
  20957. const [lastX, lastY] = this.currentPath.at(-1);
  20958. if (this.currentPath.length > 1 && x === lastX && y === lastY) {
  20959. return;
  20960. }
  20961. const currentPath = this.currentPath;
  20962. let path2D = this.#currentPath2D;
  20963. currentPath.push([x, y]);
  20964. this.#hasSomethingToDraw = true;
  20965. if (currentPath.length <= 2) {
  20966. path2D.moveTo(...currentPath[0]);
  20967. path2D.lineTo(x, y);
  20968. return;
  20969. }
  20970. if (currentPath.length === 3) {
  20971. this.#currentPath2D = path2D = new Path2D();
  20972. path2D.moveTo(...currentPath[0]);
  20973. }
  20974. this.#makeBezierCurve(path2D, ...currentPath.at(-3), ...currentPath.at(-2), x, y);
  20975. }
  20976. #endPath() {
  20977. if (this.currentPath.length === 0) {
  20978. return;
  20979. }
  20980. const lastPoint = this.currentPath.at(-1);
  20981. this.#currentPath2D.lineTo(...lastPoint);
  20982. }
  20983. #stopDrawing(x, y) {
  20984. this.#requestFrameCallback = null;
  20985. x = Math.min(Math.max(x, 0), this.canvas.width);
  20986. y = Math.min(Math.max(y, 0), this.canvas.height);
  20987. this.#draw(x, y);
  20988. this.#endPath();
  20989. let bezier;
  20990. if (this.currentPath.length !== 1) {
  20991. bezier = this.#generateBezierPoints();
  20992. } else {
  20993. const xy = [x, y];
  20994. bezier = [[xy, xy.slice(), xy.slice(), xy]];
  20995. }
  20996. const path2D = this.#currentPath2D;
  20997. const currentPath = this.currentPath;
  20998. this.currentPath = [];
  20999. this.#currentPath2D = new Path2D();
  21000. const cmd = () => {
  21001. this.allRawPaths.push(currentPath);
  21002. this.paths.push(bezier);
  21003. this.bezierPath2D.push(path2D);
  21004. this.rebuild();
  21005. };
  21006. const undo = () => {
  21007. this.allRawPaths.pop();
  21008. this.paths.pop();
  21009. this.bezierPath2D.pop();
  21010. if (this.paths.length === 0) {
  21011. this.remove();
  21012. } else {
  21013. if (!this.canvas) {
  21014. this.#createCanvas();
  21015. this.#createObserver();
  21016. }
  21017. this.#fitToContent();
  21018. }
  21019. };
  21020. this.addCommands({
  21021. cmd,
  21022. undo,
  21023. mustExec: true
  21024. });
  21025. }
  21026. #drawPoints() {
  21027. if (!this.#hasSomethingToDraw) {
  21028. return;
  21029. }
  21030. this.#hasSomethingToDraw = false;
  21031. const thickness = Math.ceil(this.thickness * this.parentScale);
  21032. const lastPoints = this.currentPath.slice(-3);
  21033. const x = lastPoints.map(xy => xy[0]);
  21034. const y = lastPoints.map(xy => xy[1]);
  21035. const xMin = Math.min(...x) - thickness;
  21036. const xMax = Math.max(...x) + thickness;
  21037. const yMin = Math.min(...y) - thickness;
  21038. const yMax = Math.max(...y) + thickness;
  21039. const {
  21040. ctx
  21041. } = this;
  21042. ctx.save();
  21043. ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
  21044. for (const path of this.bezierPath2D) {
  21045. ctx.stroke(path);
  21046. }
  21047. ctx.stroke(this.#currentPath2D);
  21048. ctx.restore();
  21049. }
  21050. #makeBezierCurve(path2D, x0, y0, x1, y1, x2, y2) {
  21051. const prevX = (x0 + x1) / 2;
  21052. const prevY = (y0 + y1) / 2;
  21053. const x3 = (x1 + x2) / 2;
  21054. const y3 = (y1 + y2) / 2;
  21055. path2D.bezierCurveTo(prevX + 2 * (x1 - prevX) / 3, prevY + 2 * (y1 - prevY) / 3, x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3, x3, y3);
  21056. }
  21057. #generateBezierPoints() {
  21058. const path = this.currentPath;
  21059. if (path.length <= 2) {
  21060. return [[path[0], path[0], path.at(-1), path.at(-1)]];
  21061. }
  21062. const bezierPoints = [];
  21063. let i;
  21064. let [x0, y0] = path[0];
  21065. for (i = 1; i < path.length - 2; i++) {
  21066. const [x1, y1] = path[i];
  21067. const [x2, y2] = path[i + 1];
  21068. const x3 = (x1 + x2) / 2;
  21069. const y3 = (y1 + y2) / 2;
  21070. const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
  21071. const control2 = [x3 + 2 * (x1 - x3) / 3, y3 + 2 * (y1 - y3) / 3];
  21072. bezierPoints.push([[x0, y0], control1, control2, [x3, y3]]);
  21073. [x0, y0] = [x3, y3];
  21074. }
  21075. const [x1, y1] = path[i];
  21076. const [x2, y2] = path[i + 1];
  21077. const control1 = [x0 + 2 * (x1 - x0) / 3, y0 + 2 * (y1 - y0) / 3];
  21078. const control2 = [x2 + 2 * (x1 - x2) / 3, y2 + 2 * (y1 - y2) / 3];
  21079. bezierPoints.push([[x0, y0], control1, control2, [x2, y2]]);
  21080. return bezierPoints;
  21081. }
  21082. #redraw() {
  21083. if (this.isEmpty()) {
  21084. this.#updateTransform();
  21085. return;
  21086. }
  21087. this.#setStroke();
  21088. const {
  21089. canvas,
  21090. ctx
  21091. } = this;
  21092. ctx.setTransform(1, 0, 0, 1, 0, 0);
  21093. ctx.clearRect(0, 0, canvas.width, canvas.height);
  21094. this.#updateTransform();
  21095. for (const path of this.bezierPath2D) {
  21096. ctx.stroke(path);
  21097. }
  21098. }
  21099. commit() {
  21100. if (this.#disableEditing) {
  21101. return;
  21102. }
  21103. super.commit();
  21104. this.isEditing = false;
  21105. this.disableEditMode();
  21106. this.setInForeground();
  21107. this.#disableEditing = true;
  21108. this.div.classList.add("disabled");
  21109. this.#fitToContent(true);
  21110. this.makeResizable();
  21111. this.parent.addInkEditorIfNeeded(true);
  21112. this.moveInDOM();
  21113. this.div.focus({
  21114. preventScroll: true
  21115. });
  21116. }
  21117. focusin(event) {
  21118. if (!this._focusEventsAllowed) {
  21119. return;
  21120. }
  21121. super.focusin(event);
  21122. this.enableEditMode();
  21123. }
  21124. canvasPointerdown(event) {
  21125. if (event.button !== 0 || !this.isInEditMode() || this.#disableEditing) {
  21126. return;
  21127. }
  21128. this.setInForeground();
  21129. event.preventDefault();
  21130. if (event.type !== "mouse") {
  21131. this.div.focus();
  21132. }
  21133. this.#startDrawing(event.offsetX, event.offsetY);
  21134. }
  21135. canvasContextMenu(event) {
  21136. event.preventDefault();
  21137. }
  21138. canvasPointermove(event) {
  21139. event.preventDefault();
  21140. this.#draw(event.offsetX, event.offsetY);
  21141. }
  21142. canvasPointerup(event) {
  21143. event.preventDefault();
  21144. this.#endDrawing(event);
  21145. }
  21146. canvasPointerleave(event) {
  21147. this.#endDrawing(event);
  21148. }
  21149. #endDrawing(event) {
  21150. this.canvas.removeEventListener("pointerleave", this.#boundCanvasPointerleave);
  21151. this.canvas.removeEventListener("pointermove", this.#boundCanvasPointermove);
  21152. this.canvas.removeEventListener("pointerup", this.#boundCanvasPointerup);
  21153. this.canvas.addEventListener("pointerdown", this.#boundCanvasPointerdown);
  21154. setTimeout(() => {
  21155. this.canvas.removeEventListener("contextmenu", this.#boundCanvasContextMenu);
  21156. }, 10);
  21157. this.#stopDrawing(event.offsetX, event.offsetY);
  21158. this.addToAnnotationStorage();
  21159. this.setInBackground();
  21160. }
  21161. #createCanvas() {
  21162. this.canvas = document.createElement("canvas");
  21163. this.canvas.width = this.canvas.height = 0;
  21164. this.canvas.className = "inkEditorCanvas";
  21165. InkEditor._l10nPromise.get("editor_ink_canvas_aria_label").then(msg => this.canvas?.setAttribute("aria-label", msg));
  21166. this.div.append(this.canvas);
  21167. this.ctx = this.canvas.getContext("2d");
  21168. }
  21169. #createObserver() {
  21170. this.#observer = new ResizeObserver(entries => {
  21171. const rect = entries[0].contentRect;
  21172. if (rect.width && rect.height) {
  21173. this.setDimensions(rect.width, rect.height);
  21174. }
  21175. });
  21176. this.#observer.observe(this.div);
  21177. }
  21178. get isResizable() {
  21179. return !this.isEmpty() && this.#disableEditing;
  21180. }
  21181. render() {
  21182. if (this.div) {
  21183. return this.div;
  21184. }
  21185. let baseX, baseY;
  21186. if (this.width) {
  21187. baseX = this.x;
  21188. baseY = this.y;
  21189. }
  21190. super.render();
  21191. InkEditor._l10nPromise.get("editor_ink2_aria_label").then(msg => this.div?.setAttribute("aria-label", msg));
  21192. const [x, y, w, h] = this.#getInitialBBox();
  21193. this.setAt(x, y, 0, 0);
  21194. this.setDims(w, h);
  21195. this.#createCanvas();
  21196. if (this.width) {
  21197. const [parentWidth, parentHeight] = this.parentDimensions;
  21198. this.setAspectRatio(this.width * parentWidth, this.height * parentHeight);
  21199. this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
  21200. this.#isCanvasInitialized = true;
  21201. this.#setCanvasDims();
  21202. this.setDims(this.width * parentWidth, this.height * parentHeight);
  21203. this.#redraw();
  21204. this.div.classList.add("disabled");
  21205. } else {
  21206. this.div.classList.add("editing");
  21207. this.enableEditMode();
  21208. }
  21209. this.#createObserver();
  21210. return this.div;
  21211. }
  21212. #setCanvasDims() {
  21213. if (!this.#isCanvasInitialized) {
  21214. return;
  21215. }
  21216. const [parentWidth, parentHeight] = this.parentDimensions;
  21217. this.canvas.width = Math.ceil(this.width * parentWidth);
  21218. this.canvas.height = Math.ceil(this.height * parentHeight);
  21219. this.#updateTransform();
  21220. }
  21221. setDimensions(width, height) {
  21222. const roundedWidth = Math.round(width);
  21223. const roundedHeight = Math.round(height);
  21224. if (this.#realWidth === roundedWidth && this.#realHeight === roundedHeight) {
  21225. return;
  21226. }
  21227. this.#realWidth = roundedWidth;
  21228. this.#realHeight = roundedHeight;
  21229. this.canvas.style.visibility = "hidden";
  21230. const [parentWidth, parentHeight] = this.parentDimensions;
  21231. this.width = width / parentWidth;
  21232. this.height = height / parentHeight;
  21233. this.fixAndSetPosition();
  21234. if (this.#disableEditing) {
  21235. this.#setScaleFactor(width, height);
  21236. }
  21237. this.#setCanvasDims();
  21238. this.#redraw();
  21239. this.canvas.style.visibility = "visible";
  21240. this.fixDims();
  21241. }
  21242. #setScaleFactor(width, height) {
  21243. const padding = this.#getPadding();
  21244. const scaleFactorW = (width - padding) / this.#baseWidth;
  21245. const scaleFactorH = (height - padding) / this.#baseHeight;
  21246. this.scaleFactor = Math.min(scaleFactorW, scaleFactorH);
  21247. }
  21248. #updateTransform() {
  21249. const padding = this.#getPadding() / 2;
  21250. this.ctx.setTransform(this.scaleFactor, 0, 0, this.scaleFactor, this.translationX * this.scaleFactor + padding, this.translationY * this.scaleFactor + padding);
  21251. }
  21252. static #buildPath2D(bezier) {
  21253. const path2D = new Path2D();
  21254. for (let i = 0, ii = bezier.length; i < ii; i++) {
  21255. const [first, control1, control2, second] = bezier[i];
  21256. if (i === 0) {
  21257. path2D.moveTo(...first);
  21258. }
  21259. path2D.bezierCurveTo(control1[0], control1[1], control2[0], control2[1], second[0], second[1]);
  21260. }
  21261. return path2D;
  21262. }
  21263. static #toPDFCoordinates(points, rect, rotation) {
  21264. const [blX, blY, trX, trY] = rect;
  21265. switch (rotation) {
  21266. case 0:
  21267. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21268. points[i] += blX;
  21269. points[i + 1] = trY - points[i + 1];
  21270. }
  21271. break;
  21272. case 90:
  21273. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21274. const x = points[i];
  21275. points[i] = points[i + 1] + blX;
  21276. points[i + 1] = x + blY;
  21277. }
  21278. break;
  21279. case 180:
  21280. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21281. points[i] = trX - points[i];
  21282. points[i + 1] += blY;
  21283. }
  21284. break;
  21285. case 270:
  21286. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21287. const x = points[i];
  21288. points[i] = trX - points[i + 1];
  21289. points[i + 1] = trY - x;
  21290. }
  21291. break;
  21292. default:
  21293. throw new Error("Invalid rotation");
  21294. }
  21295. return points;
  21296. }
  21297. static #fromPDFCoordinates(points, rect, rotation) {
  21298. const [blX, blY, trX, trY] = rect;
  21299. switch (rotation) {
  21300. case 0:
  21301. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21302. points[i] -= blX;
  21303. points[i + 1] = trY - points[i + 1];
  21304. }
  21305. break;
  21306. case 90:
  21307. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21308. const x = points[i];
  21309. points[i] = points[i + 1] - blY;
  21310. points[i + 1] = x - blX;
  21311. }
  21312. break;
  21313. case 180:
  21314. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21315. points[i] = trX - points[i];
  21316. points[i + 1] -= blY;
  21317. }
  21318. break;
  21319. case 270:
  21320. for (let i = 0, ii = points.length; i < ii; i += 2) {
  21321. const x = points[i];
  21322. points[i] = trY - points[i + 1];
  21323. points[i + 1] = trX - x;
  21324. }
  21325. break;
  21326. default:
  21327. throw new Error("Invalid rotation");
  21328. }
  21329. return points;
  21330. }
  21331. #serializePaths(s, tx, ty, rect) {
  21332. const paths = [];
  21333. const padding = this.thickness / 2;
  21334. const shiftX = s * tx + padding;
  21335. const shiftY = s * ty + padding;
  21336. for (const bezier of this.paths) {
  21337. const buffer = [];
  21338. const points = [];
  21339. for (let j = 0, jj = bezier.length; j < jj; j++) {
  21340. const [first, control1, control2, second] = bezier[j];
  21341. const p10 = s * first[0] + shiftX;
  21342. const p11 = s * first[1] + shiftY;
  21343. const p20 = s * control1[0] + shiftX;
  21344. const p21 = s * control1[1] + shiftY;
  21345. const p30 = s * control2[0] + shiftX;
  21346. const p31 = s * control2[1] + shiftY;
  21347. const p40 = s * second[0] + shiftX;
  21348. const p41 = s * second[1] + shiftY;
  21349. if (j === 0) {
  21350. buffer.push(p10, p11);
  21351. points.push(p10, p11);
  21352. }
  21353. buffer.push(p20, p21, p30, p31, p40, p41);
  21354. points.push(p20, p21);
  21355. if (j === jj - 1) {
  21356. points.push(p40, p41);
  21357. }
  21358. }
  21359. paths.push({
  21360. bezier: InkEditor.#toPDFCoordinates(buffer, rect, this.rotation),
  21361. points: InkEditor.#toPDFCoordinates(points, rect, this.rotation)
  21362. });
  21363. }
  21364. return paths;
  21365. }
  21366. #getBbox() {
  21367. let xMin = Infinity;
  21368. let xMax = -Infinity;
  21369. let yMin = Infinity;
  21370. let yMax = -Infinity;
  21371. for (const path of this.paths) {
  21372. for (const [first, control1, control2, second] of path) {
  21373. const bbox = _util.Util.bezierBoundingBox(...first, ...control1, ...control2, ...second);
  21374. xMin = Math.min(xMin, bbox[0]);
  21375. yMin = Math.min(yMin, bbox[1]);
  21376. xMax = Math.max(xMax, bbox[2]);
  21377. yMax = Math.max(yMax, bbox[3]);
  21378. }
  21379. }
  21380. return [xMin, yMin, xMax, yMax];
  21381. }
  21382. #getPadding() {
  21383. return this.#disableEditing ? Math.ceil(this.thickness * this.parentScale) : 0;
  21384. }
  21385. #fitToContent() {
  21386. let firstTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  21387. if (this.isEmpty()) {
  21388. return;
  21389. }
  21390. if (!this.#disableEditing) {
  21391. this.#redraw();
  21392. return;
  21393. }
  21394. const bbox = this.#getBbox();
  21395. const padding = this.#getPadding();
  21396. this.#baseWidth = Math.max(_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
  21397. this.#baseHeight = Math.max(_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
  21398. const width = Math.ceil(padding + this.#baseWidth * this.scaleFactor);
  21399. const height = Math.ceil(padding + this.#baseHeight * this.scaleFactor);
  21400. const [parentWidth, parentHeight] = this.parentDimensions;
  21401. this.width = width / parentWidth;
  21402. this.height = height / parentHeight;
  21403. this.setAspectRatio(width, height);
  21404. const prevTranslationX = this.translationX;
  21405. const prevTranslationY = this.translationY;
  21406. this.translationX = -bbox[0];
  21407. this.translationY = -bbox[1];
  21408. this.#setCanvasDims();
  21409. this.#redraw();
  21410. this.#realWidth = width;
  21411. this.#realHeight = height;
  21412. this.setDims(width, height);
  21413. const unscaledPadding = firstTime ? padding / this.scaleFactor / 2 : 0;
  21414. this.translate(prevTranslationX - this.translationX - unscaledPadding, prevTranslationY - this.translationY - unscaledPadding);
  21415. }
  21416. static deserialize(data, parent, uiManager) {
  21417. if (data instanceof _annotation_layer.InkAnnotationElement) {
  21418. return null;
  21419. }
  21420. const editor = super.deserialize(data, parent, uiManager);
  21421. editor.thickness = data.thickness;
  21422. editor.color = _util.Util.makeHexColor(...data.color);
  21423. editor.opacity = data.opacity;
  21424. const [pageWidth, pageHeight] = editor.pageDimensions;
  21425. const width = editor.width * pageWidth;
  21426. const height = editor.height * pageHeight;
  21427. const scaleFactor = editor.parentScale;
  21428. const padding = data.thickness / 2;
  21429. editor.#disableEditing = true;
  21430. editor.#realWidth = Math.round(width);
  21431. editor.#realHeight = Math.round(height);
  21432. const {
  21433. paths,
  21434. rect,
  21435. rotation
  21436. } = data;
  21437. for (let {
  21438. bezier
  21439. } of paths) {
  21440. bezier = InkEditor.#fromPDFCoordinates(bezier, rect, rotation);
  21441. const path = [];
  21442. editor.paths.push(path);
  21443. let p0 = scaleFactor * (bezier[0] - padding);
  21444. let p1 = scaleFactor * (bezier[1] - padding);
  21445. for (let i = 2, ii = bezier.length; i < ii; i += 6) {
  21446. const p10 = scaleFactor * (bezier[i] - padding);
  21447. const p11 = scaleFactor * (bezier[i + 1] - padding);
  21448. const p20 = scaleFactor * (bezier[i + 2] - padding);
  21449. const p21 = scaleFactor * (bezier[i + 3] - padding);
  21450. const p30 = scaleFactor * (bezier[i + 4] - padding);
  21451. const p31 = scaleFactor * (bezier[i + 5] - padding);
  21452. path.push([[p0, p1], [p10, p11], [p20, p21], [p30, p31]]);
  21453. p0 = p30;
  21454. p1 = p31;
  21455. }
  21456. const path2D = this.#buildPath2D(path);
  21457. editor.bezierPath2D.push(path2D);
  21458. }
  21459. const bbox = editor.#getBbox();
  21460. editor.#baseWidth = Math.max(_editor.AnnotationEditor.MIN_SIZE, bbox[2] - bbox[0]);
  21461. editor.#baseHeight = Math.max(_editor.AnnotationEditor.MIN_SIZE, bbox[3] - bbox[1]);
  21462. editor.#setScaleFactor(width, height);
  21463. return editor;
  21464. }
  21465. serialize() {
  21466. if (this.isEmpty()) {
  21467. return null;
  21468. }
  21469. const rect = this.getRect(0, 0);
  21470. const color = _editor.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);
  21471. return {
  21472. annotationType: _util.AnnotationEditorType.INK,
  21473. color,
  21474. thickness: this.thickness,
  21475. opacity: this.opacity,
  21476. paths: this.#serializePaths(this.scaleFactor / this.parentScale, this.translationX, this.translationY, rect),
  21477. pageIndex: this.pageIndex,
  21478. rect,
  21479. rotation: this.rotation
  21480. };
  21481. }
  21482. }
  21483. exports.InkEditor = InkEditor;
  21484. /***/ }),
  21485. /* 203 */
  21486. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  21487. Object.defineProperty(exports, "__esModule", ({
  21488. value: true
  21489. }));
  21490. exports.StampEditor = void 0;
  21491. __w_pdfjs_require__(149);
  21492. __w_pdfjs_require__(152);
  21493. var _util = __w_pdfjs_require__(1);
  21494. var _editor = __w_pdfjs_require__(164);
  21495. var _display_utils = __w_pdfjs_require__(168);
  21496. var _annotation_layer = __w_pdfjs_require__(198);
  21497. class StampEditor extends _editor.AnnotationEditor {
  21498. #bitmap = null;
  21499. #bitmapId = null;
  21500. #bitmapPromise = null;
  21501. #bitmapUrl = null;
  21502. #bitmapFile = null;
  21503. #canvas = null;
  21504. #observer = null;
  21505. #resizeTimeoutId = null;
  21506. #isSvg = false;
  21507. #hasBeenAddedInUndoStack = false;
  21508. static _type = "stamp";
  21509. constructor(params) {
  21510. super({
  21511. ...params,
  21512. name: "stampEditor"
  21513. });
  21514. this.#bitmapUrl = params.bitmapUrl;
  21515. this.#bitmapFile = params.bitmapFile;
  21516. }
  21517. static get supportedTypes() {
  21518. const types = ["apng", "avif", "bmp", "gif", "jpeg", "png", "svg+xml", "webp", "x-icon"];
  21519. return (0, _util.shadow)(this, "supportedTypes", types.map(type => `image/${type}`));
  21520. }
  21521. static get supportedTypesStr() {
  21522. return (0, _util.shadow)(this, "supportedTypesStr", this.supportedTypes.join(","));
  21523. }
  21524. static isHandlingMimeForPasting(mime) {
  21525. return this.supportedTypes.includes(mime);
  21526. }
  21527. static paste(item, parent) {
  21528. parent.pasteEditor(_util.AnnotationEditorType.STAMP, {
  21529. bitmapFile: item.getAsFile()
  21530. });
  21531. }
  21532. #getBitmapFetched(data) {
  21533. let fromId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  21534. if (!data) {
  21535. this.remove();
  21536. return;
  21537. }
  21538. this.#bitmap = data.bitmap;
  21539. if (!fromId) {
  21540. this.#bitmapId = data.id;
  21541. this.#isSvg = data.isSvg;
  21542. }
  21543. this.#createCanvas();
  21544. }
  21545. #getBitmapDone() {
  21546. this.#bitmapPromise = null;
  21547. this._uiManager.enableWaiting(false);
  21548. if (this.#canvas) {
  21549. this.div.focus();
  21550. }
  21551. }
  21552. #getBitmap() {
  21553. if (this.#bitmapId) {
  21554. this._uiManager.enableWaiting(true);
  21555. this._uiManager.imageManager.getFromId(this.#bitmapId).then(data => this.#getBitmapFetched(data, true)).finally(() => this.#getBitmapDone());
  21556. return;
  21557. }
  21558. if (this.#bitmapUrl) {
  21559. const url = this.#bitmapUrl;
  21560. this.#bitmapUrl = null;
  21561. this._uiManager.enableWaiting(true);
  21562. this.#bitmapPromise = this._uiManager.imageManager.getFromUrl(url).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
  21563. return;
  21564. }
  21565. if (this.#bitmapFile) {
  21566. const file = this.#bitmapFile;
  21567. this.#bitmapFile = null;
  21568. this._uiManager.enableWaiting(true);
  21569. this.#bitmapPromise = this._uiManager.imageManager.getFromFile(file).then(data => this.#getBitmapFetched(data)).finally(() => this.#getBitmapDone());
  21570. return;
  21571. }
  21572. const input = document.createElement("input");
  21573. input.type = "file";
  21574. input.accept = StampEditor.supportedTypesStr;
  21575. this.#bitmapPromise = new Promise(resolve => {
  21576. input.addEventListener("change", async () => {
  21577. if (!input.files || input.files.length === 0) {
  21578. this.remove();
  21579. } else {
  21580. this._uiManager.enableWaiting(true);
  21581. const data = await this._uiManager.imageManager.getFromFile(input.files[0]);
  21582. this.#getBitmapFetched(data);
  21583. }
  21584. resolve();
  21585. });
  21586. input.addEventListener("cancel", () => {
  21587. this.remove();
  21588. resolve();
  21589. });
  21590. }).finally(() => this.#getBitmapDone());
  21591. input.click();
  21592. }
  21593. remove() {
  21594. if (this.#bitmapId) {
  21595. this.#bitmap = null;
  21596. this._uiManager.imageManager.deleteId(this.#bitmapId);
  21597. this.#canvas?.remove();
  21598. this.#canvas = null;
  21599. this.#observer?.disconnect();
  21600. this.#observer = null;
  21601. }
  21602. super.remove();
  21603. }
  21604. rebuild() {
  21605. if (!this.parent) {
  21606. if (this.#bitmapId) {
  21607. this.#getBitmap();
  21608. }
  21609. return;
  21610. }
  21611. super.rebuild();
  21612. if (this.div === null) {
  21613. return;
  21614. }
  21615. if (this.#bitmapId) {
  21616. this.#getBitmap();
  21617. }
  21618. if (!this.isAttachedToDOM) {
  21619. this.parent.add(this);
  21620. }
  21621. }
  21622. onceAdded() {
  21623. this._isDraggable = true;
  21624. this.div.focus();
  21625. }
  21626. isEmpty() {
  21627. return !(this.#bitmapPromise || this.#bitmap || this.#bitmapUrl || this.#bitmapFile);
  21628. }
  21629. get isResizable() {
  21630. return true;
  21631. }
  21632. render() {
  21633. if (this.div) {
  21634. return this.div;
  21635. }
  21636. let baseX, baseY;
  21637. if (this.width) {
  21638. baseX = this.x;
  21639. baseY = this.y;
  21640. }
  21641. super.render();
  21642. this.div.hidden = true;
  21643. if (this.#bitmap) {
  21644. this.#createCanvas();
  21645. } else {
  21646. this.#getBitmap();
  21647. }
  21648. if (this.width) {
  21649. const [parentWidth, parentHeight] = this.parentDimensions;
  21650. this.setAt(baseX * parentWidth, baseY * parentHeight, this.width * parentWidth, this.height * parentHeight);
  21651. }
  21652. return this.div;
  21653. }
  21654. #createCanvas() {
  21655. const {
  21656. div
  21657. } = this;
  21658. let {
  21659. width,
  21660. height
  21661. } = this.#bitmap;
  21662. const [pageWidth, pageHeight] = this.pageDimensions;
  21663. const MAX_RATIO = 0.75;
  21664. if (this.width) {
  21665. width = this.width * pageWidth;
  21666. height = this.height * pageHeight;
  21667. } else if (width > MAX_RATIO * pageWidth || height > MAX_RATIO * pageHeight) {
  21668. const factor = Math.min(MAX_RATIO * pageWidth / width, MAX_RATIO * pageHeight / height);
  21669. width *= factor;
  21670. height *= factor;
  21671. }
  21672. const [parentWidth, parentHeight] = this.parentDimensions;
  21673. this.setDims(width * parentWidth / pageWidth, height * parentHeight / pageHeight);
  21674. this._uiManager.enableWaiting(false);
  21675. const canvas = this.#canvas = document.createElement("canvas");
  21676. div.append(canvas);
  21677. div.hidden = false;
  21678. this.#drawBitmap(width, height);
  21679. this.#createObserver();
  21680. if (!this.#hasBeenAddedInUndoStack) {
  21681. this.parent.addUndoableEditor(this);
  21682. this.#hasBeenAddedInUndoStack = true;
  21683. }
  21684. }
  21685. #setDimensions(width, height) {
  21686. const [parentWidth, parentHeight] = this.parentDimensions;
  21687. this.width = width / parentWidth;
  21688. this.height = height / parentHeight;
  21689. this.setDims(width, height);
  21690. if (this._initialOptions?.isCentered) {
  21691. this.center();
  21692. } else {
  21693. this.fixAndSetPosition();
  21694. }
  21695. this._initialOptions = null;
  21696. if (this.#resizeTimeoutId !== null) {
  21697. clearTimeout(this.#resizeTimeoutId);
  21698. }
  21699. const TIME_TO_WAIT = 200;
  21700. this.#resizeTimeoutId = setTimeout(() => {
  21701. this.#resizeTimeoutId = null;
  21702. this.#drawBitmap(width, height);
  21703. }, TIME_TO_WAIT);
  21704. }
  21705. #scaleBitmap(width, height) {
  21706. const {
  21707. width: bitmapWidth,
  21708. height: bitmapHeight
  21709. } = this.#bitmap;
  21710. let newWidth = bitmapWidth;
  21711. let newHeight = bitmapHeight;
  21712. let bitmap = this.#bitmap;
  21713. while (newWidth > 2 * width || newHeight > 2 * height) {
  21714. const prevWidth = newWidth;
  21715. const prevHeight = newHeight;
  21716. if (newWidth > 2 * width) {
  21717. newWidth = newWidth >= 16384 ? Math.floor(newWidth / 2) - 1 : Math.ceil(newWidth / 2);
  21718. }
  21719. if (newHeight > 2 * height) {
  21720. newHeight = newHeight >= 16384 ? Math.floor(newHeight / 2) - 1 : Math.ceil(newHeight / 2);
  21721. }
  21722. const offscreen = new OffscreenCanvas(newWidth, newHeight);
  21723. const ctx = offscreen.getContext("2d");
  21724. ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
  21725. bitmap = offscreen.transferToImageBitmap();
  21726. }
  21727. return bitmap;
  21728. }
  21729. #drawBitmap(width, height) {
  21730. width = Math.ceil(width);
  21731. height = Math.ceil(height);
  21732. const canvas = this.#canvas;
  21733. if (!canvas || canvas.width === width && canvas.height === height) {
  21734. return;
  21735. }
  21736. canvas.width = width;
  21737. canvas.height = height;
  21738. const bitmap = this.#isSvg ? this.#bitmap : this.#scaleBitmap(width, height);
  21739. const ctx = canvas.getContext("2d");
  21740. ctx.filter = this._uiManager.hcmFilter;
  21741. ctx.drawImage(bitmap, 0, 0, bitmap.width, bitmap.height, 0, 0, width, height);
  21742. }
  21743. #serializeBitmap(toUrl) {
  21744. if (toUrl) {
  21745. if (this.#isSvg) {
  21746. const url = this._uiManager.imageManager.getSvgUrl(this.#bitmapId);
  21747. if (url) {
  21748. return url;
  21749. }
  21750. }
  21751. const canvas = document.createElement("canvas");
  21752. ({
  21753. width: canvas.width,
  21754. height: canvas.height
  21755. } = this.#bitmap);
  21756. const ctx = canvas.getContext("2d");
  21757. ctx.drawImage(this.#bitmap, 0, 0);
  21758. return canvas.toDataURL();
  21759. }
  21760. if (this.#isSvg) {
  21761. const [pageWidth, pageHeight] = this.pageDimensions;
  21762. const width = Math.round(this.width * pageWidth * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
  21763. const height = Math.round(this.height * pageHeight * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS);
  21764. const offscreen = new OffscreenCanvas(width, height);
  21765. const ctx = offscreen.getContext("2d");
  21766. ctx.drawImage(this.#bitmap, 0, 0, this.#bitmap.width, this.#bitmap.height, 0, 0, width, height);
  21767. return offscreen.transferToImageBitmap();
  21768. }
  21769. return structuredClone(this.#bitmap);
  21770. }
  21771. #createObserver() {
  21772. this.#observer = new ResizeObserver(entries => {
  21773. const rect = entries[0].contentRect;
  21774. if (rect.width && rect.height) {
  21775. this.#setDimensions(rect.width, rect.height);
  21776. }
  21777. });
  21778. this.#observer.observe(this.div);
  21779. }
  21780. static deserialize(data, parent, uiManager) {
  21781. if (data instanceof _annotation_layer.StampAnnotationElement) {
  21782. return null;
  21783. }
  21784. const editor = super.deserialize(data, parent, uiManager);
  21785. const {
  21786. rect,
  21787. bitmapUrl,
  21788. bitmapId,
  21789. isSvg
  21790. } = data;
  21791. if (bitmapId && uiManager.imageManager.isValidId(bitmapId)) {
  21792. editor.#bitmapId = bitmapId;
  21793. } else {
  21794. editor.#bitmapUrl = bitmapUrl;
  21795. }
  21796. editor.#isSvg = isSvg;
  21797. const [parentWidth, parentHeight] = editor.pageDimensions;
  21798. editor.width = (rect[2] - rect[0]) / parentWidth;
  21799. editor.height = (rect[3] - rect[1]) / parentHeight;
  21800. return editor;
  21801. }
  21802. serialize() {
  21803. let isForCopying = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  21804. let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  21805. if (this.isEmpty()) {
  21806. return null;
  21807. }
  21808. const serialized = {
  21809. annotationType: _util.AnnotationEditorType.STAMP,
  21810. bitmapId: this.#bitmapId,
  21811. pageIndex: this.pageIndex,
  21812. rect: this.getRect(0, 0),
  21813. rotation: this.rotation,
  21814. isSvg: this.#isSvg
  21815. };
  21816. if (isForCopying) {
  21817. serialized.bitmapUrl = this.#serializeBitmap(true);
  21818. return serialized;
  21819. }
  21820. if (context === null) {
  21821. return serialized;
  21822. }
  21823. context.stamps ||= new Map();
  21824. const area = this.#isSvg ? (serialized.rect[2] - serialized.rect[0]) * (serialized.rect[3] - serialized.rect[1]) : null;
  21825. if (!context.stamps.has(this.#bitmapId)) {
  21826. context.stamps.set(this.#bitmapId, {
  21827. area,
  21828. serialized
  21829. });
  21830. serialized.bitmap = this.#serializeBitmap(false);
  21831. } else if (this.#isSvg) {
  21832. const prevData = context.stamps.get(this.#bitmapId);
  21833. if (area > prevData.area) {
  21834. prevData.area = area;
  21835. prevData.serialized.bitmap.close();
  21836. prevData.serialized.bitmap = this.#serializeBitmap(false);
  21837. }
  21838. }
  21839. return serialized;
  21840. }
  21841. }
  21842. exports.StampEditor = StampEditor;
  21843. /***/ })
  21844. /******/ ]);
  21845. /************************************************************************/
  21846. /******/ // The module cache
  21847. /******/ var __webpack_module_cache__ = {};
  21848. /******/
  21849. /******/ // The require function
  21850. /******/ function __w_pdfjs_require__(moduleId) {
  21851. /******/ // Check if module is in cache
  21852. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  21853. /******/ if (cachedModule !== undefined) {
  21854. /******/ return cachedModule.exports;
  21855. /******/ }
  21856. /******/ // Create a new module (and put it into the cache)
  21857. /******/ var module = __webpack_module_cache__[moduleId] = {
  21858. /******/ // no module.id needed
  21859. /******/ // no module.loaded needed
  21860. /******/ exports: {}
  21861. /******/ };
  21862. /******/
  21863. /******/ // Execute the module function
  21864. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  21865. /******/
  21866. /******/ // Return the exports of the module
  21867. /******/ return module.exports;
  21868. /******/ }
  21869. /******/
  21870. /************************************************************************/
  21871. var __webpack_exports__ = {};
  21872. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  21873. (() => {
  21874. var exports = __webpack_exports__;
  21875. Object.defineProperty(exports, "__esModule", ({
  21876. value: true
  21877. }));
  21878. Object.defineProperty(exports, "AbortException", ({
  21879. enumerable: true,
  21880. get: function () {
  21881. return _util.AbortException;
  21882. }
  21883. }));
  21884. Object.defineProperty(exports, "AnnotationEditorLayer", ({
  21885. enumerable: true,
  21886. get: function () {
  21887. return _annotation_editor_layer.AnnotationEditorLayer;
  21888. }
  21889. }));
  21890. Object.defineProperty(exports, "AnnotationEditorParamsType", ({
  21891. enumerable: true,
  21892. get: function () {
  21893. return _util.AnnotationEditorParamsType;
  21894. }
  21895. }));
  21896. Object.defineProperty(exports, "AnnotationEditorType", ({
  21897. enumerable: true,
  21898. get: function () {
  21899. return _util.AnnotationEditorType;
  21900. }
  21901. }));
  21902. Object.defineProperty(exports, "AnnotationEditorUIManager", ({
  21903. enumerable: true,
  21904. get: function () {
  21905. return _tools.AnnotationEditorUIManager;
  21906. }
  21907. }));
  21908. Object.defineProperty(exports, "AnnotationLayer", ({
  21909. enumerable: true,
  21910. get: function () {
  21911. return _annotation_layer.AnnotationLayer;
  21912. }
  21913. }));
  21914. Object.defineProperty(exports, "AnnotationMode", ({
  21915. enumerable: true,
  21916. get: function () {
  21917. return _util.AnnotationMode;
  21918. }
  21919. }));
  21920. Object.defineProperty(exports, "CMapCompressionType", ({
  21921. enumerable: true,
  21922. get: function () {
  21923. return _util.CMapCompressionType;
  21924. }
  21925. }));
  21926. Object.defineProperty(exports, "FeatureTest", ({
  21927. enumerable: true,
  21928. get: function () {
  21929. return _util.FeatureTest;
  21930. }
  21931. }));
  21932. Object.defineProperty(exports, "GlobalWorkerOptions", ({
  21933. enumerable: true,
  21934. get: function () {
  21935. return _worker_options.GlobalWorkerOptions;
  21936. }
  21937. }));
  21938. Object.defineProperty(exports, "ImageKind", ({
  21939. enumerable: true,
  21940. get: function () {
  21941. return _util.ImageKind;
  21942. }
  21943. }));
  21944. Object.defineProperty(exports, "InvalidPDFException", ({
  21945. enumerable: true,
  21946. get: function () {
  21947. return _util.InvalidPDFException;
  21948. }
  21949. }));
  21950. Object.defineProperty(exports, "MissingPDFException", ({
  21951. enumerable: true,
  21952. get: function () {
  21953. return _util.MissingPDFException;
  21954. }
  21955. }));
  21956. Object.defineProperty(exports, "OPS", ({
  21957. enumerable: true,
  21958. get: function () {
  21959. return _util.OPS;
  21960. }
  21961. }));
  21962. Object.defineProperty(exports, "PDFDataRangeTransport", ({
  21963. enumerable: true,
  21964. get: function () {
  21965. return _api.PDFDataRangeTransport;
  21966. }
  21967. }));
  21968. Object.defineProperty(exports, "PDFDateString", ({
  21969. enumerable: true,
  21970. get: function () {
  21971. return _display_utils.PDFDateString;
  21972. }
  21973. }));
  21974. Object.defineProperty(exports, "PDFWorker", ({
  21975. enumerable: true,
  21976. get: function () {
  21977. return _api.PDFWorker;
  21978. }
  21979. }));
  21980. Object.defineProperty(exports, "PasswordResponses", ({
  21981. enumerable: true,
  21982. get: function () {
  21983. return _util.PasswordResponses;
  21984. }
  21985. }));
  21986. Object.defineProperty(exports, "PermissionFlag", ({
  21987. enumerable: true,
  21988. get: function () {
  21989. return _util.PermissionFlag;
  21990. }
  21991. }));
  21992. Object.defineProperty(exports, "PixelsPerInch", ({
  21993. enumerable: true,
  21994. get: function () {
  21995. return _display_utils.PixelsPerInch;
  21996. }
  21997. }));
  21998. Object.defineProperty(exports, "PromiseCapability", ({
  21999. enumerable: true,
  22000. get: function () {
  22001. return _util.PromiseCapability;
  22002. }
  22003. }));
  22004. Object.defineProperty(exports, "RenderingCancelledException", ({
  22005. enumerable: true,
  22006. get: function () {
  22007. return _display_utils.RenderingCancelledException;
  22008. }
  22009. }));
  22010. Object.defineProperty(exports, "SVGGraphics", ({
  22011. enumerable: true,
  22012. get: function () {
  22013. return _api.SVGGraphics;
  22014. }
  22015. }));
  22016. Object.defineProperty(exports, "UnexpectedResponseException", ({
  22017. enumerable: true,
  22018. get: function () {
  22019. return _util.UnexpectedResponseException;
  22020. }
  22021. }));
  22022. Object.defineProperty(exports, "Util", ({
  22023. enumerable: true,
  22024. get: function () {
  22025. return _util.Util;
  22026. }
  22027. }));
  22028. Object.defineProperty(exports, "VerbosityLevel", ({
  22029. enumerable: true,
  22030. get: function () {
  22031. return _util.VerbosityLevel;
  22032. }
  22033. }));
  22034. Object.defineProperty(exports, "XfaLayer", ({
  22035. enumerable: true,
  22036. get: function () {
  22037. return _xfa_layer.XfaLayer;
  22038. }
  22039. }));
  22040. Object.defineProperty(exports, "build", ({
  22041. enumerable: true,
  22042. get: function () {
  22043. return _api.build;
  22044. }
  22045. }));
  22046. Object.defineProperty(exports, "createValidAbsoluteUrl", ({
  22047. enumerable: true,
  22048. get: function () {
  22049. return _util.createValidAbsoluteUrl;
  22050. }
  22051. }));
  22052. Object.defineProperty(exports, "getDocument", ({
  22053. enumerable: true,
  22054. get: function () {
  22055. return _api.getDocument;
  22056. }
  22057. }));
  22058. Object.defineProperty(exports, "getFilenameFromUrl", ({
  22059. enumerable: true,
  22060. get: function () {
  22061. return _display_utils.getFilenameFromUrl;
  22062. }
  22063. }));
  22064. Object.defineProperty(exports, "getPdfFilenameFromUrl", ({
  22065. enumerable: true,
  22066. get: function () {
  22067. return _display_utils.getPdfFilenameFromUrl;
  22068. }
  22069. }));
  22070. Object.defineProperty(exports, "getXfaPageViewport", ({
  22071. enumerable: true,
  22072. get: function () {
  22073. return _display_utils.getXfaPageViewport;
  22074. }
  22075. }));
  22076. Object.defineProperty(exports, "isDataScheme", ({
  22077. enumerable: true,
  22078. get: function () {
  22079. return _display_utils.isDataScheme;
  22080. }
  22081. }));
  22082. Object.defineProperty(exports, "isPdfFile", ({
  22083. enumerable: true,
  22084. get: function () {
  22085. return _display_utils.isPdfFile;
  22086. }
  22087. }));
  22088. Object.defineProperty(exports, "loadScript", ({
  22089. enumerable: true,
  22090. get: function () {
  22091. return _display_utils.loadScript;
  22092. }
  22093. }));
  22094. Object.defineProperty(exports, "normalizeUnicode", ({
  22095. enumerable: true,
  22096. get: function () {
  22097. return _util.normalizeUnicode;
  22098. }
  22099. }));
  22100. Object.defineProperty(exports, "renderTextLayer", ({
  22101. enumerable: true,
  22102. get: function () {
  22103. return _text_layer.renderTextLayer;
  22104. }
  22105. }));
  22106. Object.defineProperty(exports, "setLayerDimensions", ({
  22107. enumerable: true,
  22108. get: function () {
  22109. return _display_utils.setLayerDimensions;
  22110. }
  22111. }));
  22112. Object.defineProperty(exports, "shadow", ({
  22113. enumerable: true,
  22114. get: function () {
  22115. return _util.shadow;
  22116. }
  22117. }));
  22118. Object.defineProperty(exports, "updateTextLayer", ({
  22119. enumerable: true,
  22120. get: function () {
  22121. return _text_layer.updateTextLayer;
  22122. }
  22123. }));
  22124. Object.defineProperty(exports, "version", ({
  22125. enumerable: true,
  22126. get: function () {
  22127. return _api.version;
  22128. }
  22129. }));
  22130. var _util = __w_pdfjs_require__(1);
  22131. var _api = __w_pdfjs_require__(124);
  22132. var _display_utils = __w_pdfjs_require__(168);
  22133. var _text_layer = __w_pdfjs_require__(195);
  22134. var _annotation_editor_layer = __w_pdfjs_require__(196);
  22135. var _tools = __w_pdfjs_require__(165);
  22136. var _annotation_layer = __w_pdfjs_require__(198);
  22137. var _worker_options = __w_pdfjs_require__(176);
  22138. var _xfa_layer = __w_pdfjs_require__(201);
  22139. const pdfjsVersion = '3.10.111';
  22140. const pdfjsBuild = 'e142baecb';
  22141. })();
  22142. /******/ return __webpack_exports__;
  22143. /******/ })()
  22144. ;
  22145. });
  22146. //# sourceMappingURL=pdf.js.map