workerMain.js 654 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416
  1. /*!-----------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(5a1b4999493d49c857497ad481d73a737439f305)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------*/
  7. (function() {
  8. var __m = ["require","exports","vs/base/common/platform","vs/base/common/strings","vs/editor/common/core/position","vs/editor/common/core/range","vs/base/common/types","vs/base/common/event","vs/base/common/errors","vs/base/common/lifecycle","vs/base/common/stopwatch","vs/base/common/diff/diff","vs/base/common/uint","vs/base/common/uri","vs/editor/common/core/characterClassifier","vs/base/common/arrays","vs/base/common/diff/diffChange","vs/base/common/functional","vs/base/common/iterator","vs/base/common/keyCodes","vs/base/common/linkedList","vs/base/common/process","vs/base/common/path","vs/base/common/cancellation","vs/base/common/hash","vs/base/common/objects","vs/editor/common/controller/wordCharacterClassifier","vs/editor/common/core/selection","vs/editor/common/core/token","vs/editor/common/diff/diffComputer","vs/editor/common/model","vs/editor/common/model/textModelSearch","vs/editor/common/model/wordHelper","vs/editor/common/modes/linkComputer","vs/editor/common/modes/supports/inplaceReplaceSupport","vs/editor/common/modes/unicodeTextModelHighlighter","vs/editor/common/standalone/standaloneEnums","vs/editor/common/standalone/standaloneBase","vs/editor/common/viewModel/prefixSumComputer","vs/editor/common/model/mirrorTextModel","vs/base/common/worker/simpleWorker","vs/editor/common/services/editorSimpleWorker"];
  9. var __M = function(deps) {
  10. var result = [];
  11. for (var i = 0, len = deps.length; i < len; i++) {
  12. result[i] = __m[deps[i]];
  13. }
  14. return result;
  15. };
  16. /*---------------------------------------------------------------------------------------------
  17. * Copyright (c) Microsoft Corporation. All rights reserved.
  18. * Licensed under the MIT License. See License.txt in the project root for license information.
  19. *--------------------------------------------------------------------------------------------*/
  20. 'use strict';
  21. /*---------------------------------------------------------------------------------------------
  22. * Copyright (c) Microsoft Corporation. All rights reserved.
  23. * Licensed under the MIT License. See License.txt in the project root for license information.
  24. *--------------------------------------------------------------------------------------------*/
  25. /*---------------------------------------------------------------------------------------------
  26. *---------------------------------------------------------------------------------------------
  27. *---------------------------------------------------------------------------------------------
  28. *---------------------------------------------------------------------------------------------
  29. *---------------------------------------------------------------------------------------------
  30. * Please make sure to make edits in the .ts file at https://github.com/microsoft/vscode-loader/
  31. *---------------------------------------------------------------------------------------------
  32. *---------------------------------------------------------------------------------------------
  33. *---------------------------------------------------------------------------------------------
  34. *---------------------------------------------------------------------------------------------
  35. *--------------------------------------------------------------------------------------------*/
  36. var _amdLoaderGlobal = this;
  37. var _commonjsGlobal = typeof global === 'object' ? global : {};
  38. var AMDLoader;
  39. (function (AMDLoader) {
  40. AMDLoader.global = _amdLoaderGlobal;
  41. var Environment = /** @class */ (function () {
  42. function Environment() {
  43. this._detected = false;
  44. this._isWindows = false;
  45. this._isNode = false;
  46. this._isElectronRenderer = false;
  47. this._isWebWorker = false;
  48. this._isElectronNodeIntegrationWebWorker = false;
  49. }
  50. Object.defineProperty(Environment.prototype, "isWindows", {
  51. get: function () {
  52. this._detect();
  53. return this._isWindows;
  54. },
  55. enumerable: false,
  56. configurable: true
  57. });
  58. Object.defineProperty(Environment.prototype, "isNode", {
  59. get: function () {
  60. this._detect();
  61. return this._isNode;
  62. },
  63. enumerable: false,
  64. configurable: true
  65. });
  66. Object.defineProperty(Environment.prototype, "isElectronRenderer", {
  67. get: function () {
  68. this._detect();
  69. return this._isElectronRenderer;
  70. },
  71. enumerable: false,
  72. configurable: true
  73. });
  74. Object.defineProperty(Environment.prototype, "isWebWorker", {
  75. get: function () {
  76. this._detect();
  77. return this._isWebWorker;
  78. },
  79. enumerable: false,
  80. configurable: true
  81. });
  82. Object.defineProperty(Environment.prototype, "isElectronNodeIntegrationWebWorker", {
  83. get: function () {
  84. this._detect();
  85. return this._isElectronNodeIntegrationWebWorker;
  86. },
  87. enumerable: false,
  88. configurable: true
  89. });
  90. Environment.prototype._detect = function () {
  91. if (this._detected) {
  92. return;
  93. }
  94. this._detected = true;
  95. this._isWindows = Environment._isWindows();
  96. this._isNode = (typeof module !== 'undefined' && !!module.exports);
  97. this._isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
  98. this._isWebWorker = (typeof AMDLoader.global.importScripts === 'function');
  99. this._isElectronNodeIntegrationWebWorker = this._isWebWorker && (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'worker');
  100. };
  101. Environment._isWindows = function () {
  102. if (typeof navigator !== 'undefined') {
  103. if (navigator.userAgent && navigator.userAgent.indexOf('Windows') >= 0) {
  104. return true;
  105. }
  106. }
  107. if (typeof process !== 'undefined') {
  108. return (process.platform === 'win32');
  109. }
  110. return false;
  111. };
  112. return Environment;
  113. }());
  114. AMDLoader.Environment = Environment;
  115. })(AMDLoader || (AMDLoader = {}));
  116. /*---------------------------------------------------------------------------------------------
  117. * Copyright (c) Microsoft Corporation. All rights reserved.
  118. * Licensed under the MIT License. See License.txt in the project root for license information.
  119. *--------------------------------------------------------------------------------------------*/
  120. var AMDLoader;
  121. (function (AMDLoader) {
  122. var LoaderEvent = /** @class */ (function () {
  123. function LoaderEvent(type, detail, timestamp) {
  124. this.type = type;
  125. this.detail = detail;
  126. this.timestamp = timestamp;
  127. }
  128. return LoaderEvent;
  129. }());
  130. AMDLoader.LoaderEvent = LoaderEvent;
  131. var LoaderEventRecorder = /** @class */ (function () {
  132. function LoaderEventRecorder(loaderAvailableTimestamp) {
  133. this._events = [new LoaderEvent(1 /* LoaderAvailable */, '', loaderAvailableTimestamp)];
  134. }
  135. LoaderEventRecorder.prototype.record = function (type, detail) {
  136. this._events.push(new LoaderEvent(type, detail, AMDLoader.Utilities.getHighPerformanceTimestamp()));
  137. };
  138. LoaderEventRecorder.prototype.getEvents = function () {
  139. return this._events;
  140. };
  141. return LoaderEventRecorder;
  142. }());
  143. AMDLoader.LoaderEventRecorder = LoaderEventRecorder;
  144. var NullLoaderEventRecorder = /** @class */ (function () {
  145. function NullLoaderEventRecorder() {
  146. }
  147. NullLoaderEventRecorder.prototype.record = function (type, detail) {
  148. // Nothing to do
  149. };
  150. NullLoaderEventRecorder.prototype.getEvents = function () {
  151. return [];
  152. };
  153. NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();
  154. return NullLoaderEventRecorder;
  155. }());
  156. AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder;
  157. })(AMDLoader || (AMDLoader = {}));
  158. /*---------------------------------------------------------------------------------------------
  159. * Copyright (c) Microsoft Corporation. All rights reserved.
  160. * Licensed under the MIT License. See License.txt in the project root for license information.
  161. *--------------------------------------------------------------------------------------------*/
  162. var AMDLoader;
  163. (function (AMDLoader) {
  164. var Utilities = /** @class */ (function () {
  165. function Utilities() {
  166. }
  167. /**
  168. * This method does not take care of / vs \
  169. */
  170. Utilities.fileUriToFilePath = function (isWindows, uri) {
  171. uri = decodeURI(uri).replace(/%23/g, '#');
  172. if (isWindows) {
  173. if (/^file:\/\/\//.test(uri)) {
  174. // This is a URI without a hostname => return only the path segment
  175. return uri.substr(8);
  176. }
  177. if (/^file:\/\//.test(uri)) {
  178. return uri.substr(5);
  179. }
  180. }
  181. else {
  182. if (/^file:\/\//.test(uri)) {
  183. return uri.substr(7);
  184. }
  185. }
  186. // Not sure...
  187. return uri;
  188. };
  189. Utilities.startsWith = function (haystack, needle) {
  190. return haystack.length >= needle.length && haystack.substr(0, needle.length) === needle;
  191. };
  192. Utilities.endsWith = function (haystack, needle) {
  193. return haystack.length >= needle.length && haystack.substr(haystack.length - needle.length) === needle;
  194. };
  195. // only check for "?" before "#" to ensure that there is a real Query-String
  196. Utilities.containsQueryString = function (url) {
  197. return /^[^\#]*\?/gi.test(url);
  198. };
  199. /**
  200. * Does `url` start with http:// or https:// or file:// or / ?
  201. */
  202. Utilities.isAbsolutePath = function (url) {
  203. return /^((http:\/\/)|(https:\/\/)|(file:\/\/)|(\/))/.test(url);
  204. };
  205. Utilities.forEachProperty = function (obj, callback) {
  206. if (obj) {
  207. var key = void 0;
  208. for (key in obj) {
  209. if (obj.hasOwnProperty(key)) {
  210. callback(key, obj[key]);
  211. }
  212. }
  213. }
  214. };
  215. Utilities.isEmpty = function (obj) {
  216. var isEmpty = true;
  217. Utilities.forEachProperty(obj, function () {
  218. isEmpty = false;
  219. });
  220. return isEmpty;
  221. };
  222. Utilities.recursiveClone = function (obj) {
  223. if (!obj || typeof obj !== 'object' || obj instanceof RegExp) {
  224. return obj;
  225. }
  226. if (!Array.isArray(obj) && Object.getPrototypeOf(obj) !== Object.prototype) {
  227. // only clone "simple" objects
  228. return obj;
  229. }
  230. var result = Array.isArray(obj) ? [] : {};
  231. Utilities.forEachProperty(obj, function (key, value) {
  232. if (value && typeof value === 'object') {
  233. result[key] = Utilities.recursiveClone(value);
  234. }
  235. else {
  236. result[key] = value;
  237. }
  238. });
  239. return result;
  240. };
  241. Utilities.generateAnonymousModule = function () {
  242. return '===anonymous' + (Utilities.NEXT_ANONYMOUS_ID++) + '===';
  243. };
  244. Utilities.isAnonymousModule = function (id) {
  245. return Utilities.startsWith(id, '===anonymous');
  246. };
  247. Utilities.getHighPerformanceTimestamp = function () {
  248. if (!this.PERFORMANCE_NOW_PROBED) {
  249. this.PERFORMANCE_NOW_PROBED = true;
  250. this.HAS_PERFORMANCE_NOW = (AMDLoader.global.performance && typeof AMDLoader.global.performance.now === 'function');
  251. }
  252. return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now());
  253. };
  254. Utilities.NEXT_ANONYMOUS_ID = 1;
  255. Utilities.PERFORMANCE_NOW_PROBED = false;
  256. Utilities.HAS_PERFORMANCE_NOW = false;
  257. return Utilities;
  258. }());
  259. AMDLoader.Utilities = Utilities;
  260. })(AMDLoader || (AMDLoader = {}));
  261. /*---------------------------------------------------------------------------------------------
  262. * Copyright (c) Microsoft Corporation. All rights reserved.
  263. * Licensed under the MIT License. See License.txt in the project root for license information.
  264. *--------------------------------------------------------------------------------------------*/
  265. var AMDLoader;
  266. (function (AMDLoader) {
  267. function ensureError(err) {
  268. if (err instanceof Error) {
  269. return err;
  270. }
  271. var result = new Error(err.message || String(err) || 'Unknown Error');
  272. if (err.stack) {
  273. result.stack = err.stack;
  274. }
  275. return result;
  276. }
  277. AMDLoader.ensureError = ensureError;
  278. ;
  279. var ConfigurationOptionsUtil = /** @class */ (function () {
  280. function ConfigurationOptionsUtil() {
  281. }
  282. /**
  283. * Ensure configuration options make sense
  284. */
  285. ConfigurationOptionsUtil.validateConfigurationOptions = function (options) {
  286. function defaultOnError(err) {
  287. if (err.phase === 'loading') {
  288. console.error('Loading "' + err.moduleId + '" failed');
  289. console.error(err);
  290. console.error('Here are the modules that depend on it:');
  291. console.error(err.neededBy);
  292. return;
  293. }
  294. if (err.phase === 'factory') {
  295. console.error('The factory method of "' + err.moduleId + '" has thrown an exception');
  296. console.error(err);
  297. return;
  298. }
  299. }
  300. options = options || {};
  301. if (typeof options.baseUrl !== 'string') {
  302. options.baseUrl = '';
  303. }
  304. if (typeof options.isBuild !== 'boolean') {
  305. options.isBuild = false;
  306. }
  307. if (typeof options.paths !== 'object') {
  308. options.paths = {};
  309. }
  310. if (typeof options.config !== 'object') {
  311. options.config = {};
  312. }
  313. if (typeof options.catchError === 'undefined') {
  314. options.catchError = false;
  315. }
  316. if (typeof options.recordStats === 'undefined') {
  317. options.recordStats = false;
  318. }
  319. if (typeof options.urlArgs !== 'string') {
  320. options.urlArgs = '';
  321. }
  322. if (typeof options.onError !== 'function') {
  323. options.onError = defaultOnError;
  324. }
  325. if (!Array.isArray(options.ignoreDuplicateModules)) {
  326. options.ignoreDuplicateModules = [];
  327. }
  328. if (options.baseUrl.length > 0) {
  329. if (!AMDLoader.Utilities.endsWith(options.baseUrl, '/')) {
  330. options.baseUrl += '/';
  331. }
  332. }
  333. if (typeof options.cspNonce !== 'string') {
  334. options.cspNonce = '';
  335. }
  336. if (typeof options.preferScriptTags === 'undefined') {
  337. options.preferScriptTags = false;
  338. }
  339. if (!Array.isArray(options.nodeModules)) {
  340. options.nodeModules = [];
  341. }
  342. if (options.nodeCachedData && typeof options.nodeCachedData === 'object') {
  343. if (typeof options.nodeCachedData.seed !== 'string') {
  344. options.nodeCachedData.seed = 'seed';
  345. }
  346. if (typeof options.nodeCachedData.writeDelay !== 'number' || options.nodeCachedData.writeDelay < 0) {
  347. options.nodeCachedData.writeDelay = 1000 * 7;
  348. }
  349. if (!options.nodeCachedData.path || typeof options.nodeCachedData.path !== 'string') {
  350. var err = ensureError(new Error('INVALID cached data configuration, \'path\' MUST be set'));
  351. err.phase = 'configuration';
  352. options.onError(err);
  353. options.nodeCachedData = undefined;
  354. }
  355. }
  356. return options;
  357. };
  358. ConfigurationOptionsUtil.mergeConfigurationOptions = function (overwrite, base) {
  359. if (overwrite === void 0) { overwrite = null; }
  360. if (base === void 0) { base = null; }
  361. var result = AMDLoader.Utilities.recursiveClone(base || {});
  362. // Merge known properties and overwrite the unknown ones
  363. AMDLoader.Utilities.forEachProperty(overwrite, function (key, value) {
  364. if (key === 'ignoreDuplicateModules' && typeof result.ignoreDuplicateModules !== 'undefined') {
  365. result.ignoreDuplicateModules = result.ignoreDuplicateModules.concat(value);
  366. }
  367. else if (key === 'paths' && typeof result.paths !== 'undefined') {
  368. AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.paths[key2] = value2; });
  369. }
  370. else if (key === 'config' && typeof result.config !== 'undefined') {
  371. AMDLoader.Utilities.forEachProperty(value, function (key2, value2) { return result.config[key2] = value2; });
  372. }
  373. else {
  374. result[key] = AMDLoader.Utilities.recursiveClone(value);
  375. }
  376. });
  377. return ConfigurationOptionsUtil.validateConfigurationOptions(result);
  378. };
  379. return ConfigurationOptionsUtil;
  380. }());
  381. AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil;
  382. var Configuration = /** @class */ (function () {
  383. function Configuration(env, options) {
  384. this._env = env;
  385. this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);
  386. this._createIgnoreDuplicateModulesMap();
  387. this._createNodeModulesMap();
  388. this._createSortedPathsRules();
  389. if (this.options.baseUrl === '') {
  390. if (this.options.nodeRequire && this.options.nodeRequire.main && this.options.nodeRequire.main.filename && this._env.isNode) {
  391. var nodeMain = this.options.nodeRequire.main.filename;
  392. var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
  393. this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
  394. }
  395. if (this.options.nodeMain && this._env.isNode) {
  396. var nodeMain = this.options.nodeMain;
  397. var dirnameIndex = Math.max(nodeMain.lastIndexOf('/'), nodeMain.lastIndexOf('\\'));
  398. this.options.baseUrl = nodeMain.substring(0, dirnameIndex + 1);
  399. }
  400. }
  401. }
  402. Configuration.prototype._createIgnoreDuplicateModulesMap = function () {
  403. // Build a map out of the ignoreDuplicateModules array
  404. this.ignoreDuplicateModulesMap = {};
  405. for (var i = 0; i < this.options.ignoreDuplicateModules.length; i++) {
  406. this.ignoreDuplicateModulesMap[this.options.ignoreDuplicateModules[i]] = true;
  407. }
  408. };
  409. Configuration.prototype._createNodeModulesMap = function () {
  410. // Build a map out of nodeModules array
  411. this.nodeModulesMap = Object.create(null);
  412. for (var _i = 0, _a = this.options.nodeModules; _i < _a.length; _i++) {
  413. var nodeModule = _a[_i];
  414. this.nodeModulesMap[nodeModule] = true;
  415. }
  416. };
  417. Configuration.prototype._createSortedPathsRules = function () {
  418. var _this = this;
  419. // Create an array our of the paths rules, sorted descending by length to
  420. // result in a more specific -> less specific order
  421. this.sortedPathsRules = [];
  422. AMDLoader.Utilities.forEachProperty(this.options.paths, function (from, to) {
  423. if (!Array.isArray(to)) {
  424. _this.sortedPathsRules.push({
  425. from: from,
  426. to: [to]
  427. });
  428. }
  429. else {
  430. _this.sortedPathsRules.push({
  431. from: from,
  432. to: to
  433. });
  434. }
  435. });
  436. this.sortedPathsRules.sort(function (a, b) {
  437. return b.from.length - a.from.length;
  438. });
  439. };
  440. /**
  441. * Clone current configuration and overwrite options selectively.
  442. * @param options The selective options to overwrite with.
  443. * @result A new configuration
  444. */
  445. Configuration.prototype.cloneAndMerge = function (options) {
  446. return new Configuration(this._env, ConfigurationOptionsUtil.mergeConfigurationOptions(options, this.options));
  447. };
  448. /**
  449. * Get current options bag. Useful for passing it forward to plugins.
  450. */
  451. Configuration.prototype.getOptionsLiteral = function () {
  452. return this.options;
  453. };
  454. Configuration.prototype._applyPaths = function (moduleId) {
  455. var pathRule;
  456. for (var i = 0, len = this.sortedPathsRules.length; i < len; i++) {
  457. pathRule = this.sortedPathsRules[i];
  458. if (AMDLoader.Utilities.startsWith(moduleId, pathRule.from)) {
  459. var result = [];
  460. for (var j = 0, lenJ = pathRule.to.length; j < lenJ; j++) {
  461. result.push(pathRule.to[j] + moduleId.substr(pathRule.from.length));
  462. }
  463. return result;
  464. }
  465. }
  466. return [moduleId];
  467. };
  468. Configuration.prototype._addUrlArgsToUrl = function (url) {
  469. if (AMDLoader.Utilities.containsQueryString(url)) {
  470. return url + '&' + this.options.urlArgs;
  471. }
  472. else {
  473. return url + '?' + this.options.urlArgs;
  474. }
  475. };
  476. Configuration.prototype._addUrlArgsIfNecessaryToUrl = function (url) {
  477. if (this.options.urlArgs) {
  478. return this._addUrlArgsToUrl(url);
  479. }
  480. return url;
  481. };
  482. Configuration.prototype._addUrlArgsIfNecessaryToUrls = function (urls) {
  483. if (this.options.urlArgs) {
  484. for (var i = 0, len = urls.length; i < len; i++) {
  485. urls[i] = this._addUrlArgsToUrl(urls[i]);
  486. }
  487. }
  488. return urls;
  489. };
  490. /**
  491. * Transform a module id to a location. Appends .js to module ids
  492. */
  493. Configuration.prototype.moduleIdToPaths = function (moduleId) {
  494. if (this._env.isNode) {
  495. var isNodeModule = ((this.nodeModulesMap[moduleId] === true)
  496. || (this.options.amdModulesPattern instanceof RegExp && !this.options.amdModulesPattern.test(moduleId)));
  497. if (isNodeModule) {
  498. // This is a node module...
  499. if (this.isBuild()) {
  500. // ...and we are at build time, drop it
  501. return ['empty:'];
  502. }
  503. else {
  504. // ...and at runtime we create a `shortcut`-path
  505. return ['node|' + moduleId];
  506. }
  507. }
  508. }
  509. var result = moduleId;
  510. var results;
  511. if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.isAbsolutePath(result)) {
  512. results = this._applyPaths(result);
  513. for (var i = 0, len = results.length; i < len; i++) {
  514. if (this.isBuild() && results[i] === 'empty:') {
  515. continue;
  516. }
  517. if (!AMDLoader.Utilities.isAbsolutePath(results[i])) {
  518. results[i] = this.options.baseUrl + results[i];
  519. }
  520. if (!AMDLoader.Utilities.endsWith(results[i], '.js') && !AMDLoader.Utilities.containsQueryString(results[i])) {
  521. results[i] = results[i] + '.js';
  522. }
  523. }
  524. }
  525. else {
  526. if (!AMDLoader.Utilities.endsWith(result, '.js') && !AMDLoader.Utilities.containsQueryString(result)) {
  527. result = result + '.js';
  528. }
  529. results = [result];
  530. }
  531. return this._addUrlArgsIfNecessaryToUrls(results);
  532. };
  533. /**
  534. * Transform a module id or url to a location.
  535. */
  536. Configuration.prototype.requireToUrl = function (url) {
  537. var result = url;
  538. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  539. result = this._applyPaths(result)[0];
  540. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  541. result = this.options.baseUrl + result;
  542. }
  543. }
  544. return this._addUrlArgsIfNecessaryToUrl(result);
  545. };
  546. /**
  547. * Flag to indicate if current execution is as part of a build.
  548. */
  549. Configuration.prototype.isBuild = function () {
  550. return this.options.isBuild;
  551. };
  552. /**
  553. * Test if module `moduleId` is expected to be defined multiple times
  554. */
  555. Configuration.prototype.isDuplicateMessageIgnoredFor = function (moduleId) {
  556. return this.ignoreDuplicateModulesMap.hasOwnProperty(moduleId);
  557. };
  558. /**
  559. * Get the configuration settings for the provided module id
  560. */
  561. Configuration.prototype.getConfigForModule = function (moduleId) {
  562. if (this.options.config) {
  563. return this.options.config[moduleId];
  564. }
  565. };
  566. /**
  567. * Should errors be caught when executing module factories?
  568. */
  569. Configuration.prototype.shouldCatchError = function () {
  570. return this.options.catchError;
  571. };
  572. /**
  573. * Should statistics be recorded?
  574. */
  575. Configuration.prototype.shouldRecordStats = function () {
  576. return this.options.recordStats;
  577. };
  578. /**
  579. * Forward an error to the error handler.
  580. */
  581. Configuration.prototype.onError = function (err) {
  582. this.options.onError(err);
  583. };
  584. return Configuration;
  585. }());
  586. AMDLoader.Configuration = Configuration;
  587. })(AMDLoader || (AMDLoader = {}));
  588. /*---------------------------------------------------------------------------------------------
  589. * Copyright (c) Microsoft Corporation. All rights reserved.
  590. * Licensed under the MIT License. See License.txt in the project root for license information.
  591. *--------------------------------------------------------------------------------------------*/
  592. var AMDLoader;
  593. (function (AMDLoader) {
  594. /**
  595. * Load `scriptSrc` only once (avoid multiple <script> tags)
  596. */
  597. var OnlyOnceScriptLoader = /** @class */ (function () {
  598. function OnlyOnceScriptLoader(env) {
  599. this._env = env;
  600. this._scriptLoader = null;
  601. this._callbackMap = {};
  602. }
  603. OnlyOnceScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  604. var _this = this;
  605. if (!this._scriptLoader) {
  606. if (this._env.isWebWorker) {
  607. this._scriptLoader = new WorkerScriptLoader();
  608. }
  609. else if (this._env.isElectronRenderer) {
  610. var preferScriptTags = moduleManager.getConfig().getOptionsLiteral().preferScriptTags;
  611. if (preferScriptTags) {
  612. this._scriptLoader = new BrowserScriptLoader();
  613. }
  614. else {
  615. this._scriptLoader = new NodeScriptLoader(this._env);
  616. }
  617. }
  618. else if (this._env.isNode) {
  619. this._scriptLoader = new NodeScriptLoader(this._env);
  620. }
  621. else {
  622. this._scriptLoader = new BrowserScriptLoader();
  623. }
  624. }
  625. var scriptCallbacks = {
  626. callback: callback,
  627. errorback: errorback
  628. };
  629. if (this._callbackMap.hasOwnProperty(scriptSrc)) {
  630. this._callbackMap[scriptSrc].push(scriptCallbacks);
  631. return;
  632. }
  633. this._callbackMap[scriptSrc] = [scriptCallbacks];
  634. this._scriptLoader.load(moduleManager, scriptSrc, function () { return _this.triggerCallback(scriptSrc); }, function (err) { return _this.triggerErrorback(scriptSrc, err); });
  635. };
  636. OnlyOnceScriptLoader.prototype.triggerCallback = function (scriptSrc) {
  637. var scriptCallbacks = this._callbackMap[scriptSrc];
  638. delete this._callbackMap[scriptSrc];
  639. for (var i = 0; i < scriptCallbacks.length; i++) {
  640. scriptCallbacks[i].callback();
  641. }
  642. };
  643. OnlyOnceScriptLoader.prototype.triggerErrorback = function (scriptSrc, err) {
  644. var scriptCallbacks = this._callbackMap[scriptSrc];
  645. delete this._callbackMap[scriptSrc];
  646. for (var i = 0; i < scriptCallbacks.length; i++) {
  647. scriptCallbacks[i].errorback(err);
  648. }
  649. };
  650. return OnlyOnceScriptLoader;
  651. }());
  652. var BrowserScriptLoader = /** @class */ (function () {
  653. function BrowserScriptLoader() {
  654. }
  655. /**
  656. * Attach load / error listeners to a script element and remove them when either one has fired.
  657. * Implemented for browsers supporting HTML5 standard 'load' and 'error' events.
  658. */
  659. BrowserScriptLoader.prototype.attachListeners = function (script, callback, errorback) {
  660. var unbind = function () {
  661. script.removeEventListener('load', loadEventListener);
  662. script.removeEventListener('error', errorEventListener);
  663. };
  664. var loadEventListener = function (e) {
  665. unbind();
  666. callback();
  667. };
  668. var errorEventListener = function (e) {
  669. unbind();
  670. errorback(e);
  671. };
  672. script.addEventListener('load', loadEventListener);
  673. script.addEventListener('error', errorEventListener);
  674. };
  675. BrowserScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  676. if (/^node\|/.test(scriptSrc)) {
  677. var opts = moduleManager.getConfig().getOptionsLiteral();
  678. var nodeRequire = ensureRecordedNodeRequire(moduleManager.getRecorder(), (opts.nodeRequire || AMDLoader.global.nodeRequire));
  679. var pieces = scriptSrc.split('|');
  680. var moduleExports_1 = null;
  681. try {
  682. moduleExports_1 = nodeRequire(pieces[1]);
  683. }
  684. catch (err) {
  685. errorback(err);
  686. return;
  687. }
  688. moduleManager.enqueueDefineAnonymousModule([], function () { return moduleExports_1; });
  689. callback();
  690. }
  691. else {
  692. var script = document.createElement('script');
  693. script.setAttribute('async', 'async');
  694. script.setAttribute('type', 'text/javascript');
  695. this.attachListeners(script, callback, errorback);
  696. var trustedTypesPolicy = moduleManager.getConfig().getOptionsLiteral().trustedTypesPolicy;
  697. if (trustedTypesPolicy) {
  698. scriptSrc = trustedTypesPolicy.createScriptURL(scriptSrc);
  699. }
  700. script.setAttribute('src', scriptSrc);
  701. // Propagate CSP nonce to dynamically created script tag.
  702. var cspNonce = moduleManager.getConfig().getOptionsLiteral().cspNonce;
  703. if (cspNonce) {
  704. script.setAttribute('nonce', cspNonce);
  705. }
  706. document.getElementsByTagName('head')[0].appendChild(script);
  707. }
  708. };
  709. return BrowserScriptLoader;
  710. }());
  711. function canUseEval(moduleManager) {
  712. var trustedTypesPolicy = moduleManager.getConfig().getOptionsLiteral().trustedTypesPolicy;
  713. try {
  714. var func = (trustedTypesPolicy
  715. ? self.eval(trustedTypesPolicy.createScript('', 'true'))
  716. : new Function('true'));
  717. func.call(self);
  718. return true;
  719. }
  720. catch (err) {
  721. return false;
  722. }
  723. }
  724. var WorkerScriptLoader = /** @class */ (function () {
  725. function WorkerScriptLoader() {
  726. this._cachedCanUseEval = null;
  727. }
  728. WorkerScriptLoader.prototype._canUseEval = function (moduleManager) {
  729. if (this._cachedCanUseEval === null) {
  730. this._cachedCanUseEval = canUseEval(moduleManager);
  731. }
  732. return this._cachedCanUseEval;
  733. };
  734. WorkerScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  735. if (/^node\|/.test(scriptSrc)) {
  736. var opts = moduleManager.getConfig().getOptionsLiteral();
  737. var nodeRequire = ensureRecordedNodeRequire(moduleManager.getRecorder(), (opts.nodeRequire || AMDLoader.global.nodeRequire));
  738. var pieces = scriptSrc.split('|');
  739. var moduleExports_2 = null;
  740. try {
  741. moduleExports_2 = nodeRequire(pieces[1]);
  742. }
  743. catch (err) {
  744. errorback(err);
  745. return;
  746. }
  747. moduleManager.enqueueDefineAnonymousModule([], function () { return moduleExports_2; });
  748. callback();
  749. }
  750. else {
  751. var trustedTypesPolicy_1 = moduleManager.getConfig().getOptionsLiteral().trustedTypesPolicy;
  752. var isCrossOrigin = (/^((http:)|(https:)|(file:))/.test(scriptSrc) && scriptSrc.substring(0, self.origin.length) !== self.origin);
  753. if (!isCrossOrigin && this._canUseEval(moduleManager)) {
  754. // use `fetch` if possible because `importScripts`
  755. // is synchronous and can lead to deadlocks on Safari
  756. fetch(scriptSrc).then(function (response) {
  757. if (response.status !== 200) {
  758. throw new Error(response.statusText);
  759. }
  760. return response.text();
  761. }).then(function (text) {
  762. text = text + "\n//# sourceURL=" + scriptSrc;
  763. var func = (trustedTypesPolicy_1
  764. ? self.eval(trustedTypesPolicy_1.createScript('', text))
  765. : new Function(text));
  766. func.call(self);
  767. callback();
  768. }).then(undefined, errorback);
  769. return;
  770. }
  771. try {
  772. if (trustedTypesPolicy_1) {
  773. scriptSrc = trustedTypesPolicy_1.createScriptURL(scriptSrc);
  774. }
  775. importScripts(scriptSrc);
  776. callback();
  777. }
  778. catch (e) {
  779. errorback(e);
  780. }
  781. }
  782. };
  783. return WorkerScriptLoader;
  784. }());
  785. var NodeScriptLoader = /** @class */ (function () {
  786. function NodeScriptLoader(env) {
  787. this._env = env;
  788. this._didInitialize = false;
  789. this._didPatchNodeRequire = false;
  790. }
  791. NodeScriptLoader.prototype._init = function (nodeRequire) {
  792. if (this._didInitialize) {
  793. return;
  794. }
  795. this._didInitialize = true;
  796. // capture node modules
  797. this._fs = nodeRequire('fs');
  798. this._vm = nodeRequire('vm');
  799. this._path = nodeRequire('path');
  800. this._crypto = nodeRequire('crypto');
  801. };
  802. // patch require-function of nodejs such that we can manually create a script
  803. // from cached data. this is done by overriding the `Module._compile` function
  804. NodeScriptLoader.prototype._initNodeRequire = function (nodeRequire, moduleManager) {
  805. // It is important to check for `nodeCachedData` first and then set `_didPatchNodeRequire`.
  806. // That's because `nodeCachedData` is set _after_ calling this for the first time...
  807. var nodeCachedData = moduleManager.getConfig().getOptionsLiteral().nodeCachedData;
  808. if (!nodeCachedData) {
  809. return;
  810. }
  811. if (this._didPatchNodeRequire) {
  812. return;
  813. }
  814. this._didPatchNodeRequire = true;
  815. var that = this;
  816. var Module = nodeRequire('module');
  817. function makeRequireFunction(mod) {
  818. var Module = mod.constructor;
  819. var require = function require(path) {
  820. try {
  821. return mod.require(path);
  822. }
  823. finally {
  824. // nothing
  825. }
  826. };
  827. require.resolve = function resolve(request, options) {
  828. return Module._resolveFilename(request, mod, false, options);
  829. };
  830. require.resolve.paths = function paths(request) {
  831. return Module._resolveLookupPaths(request, mod);
  832. };
  833. require.main = process.mainModule;
  834. require.extensions = Module._extensions;
  835. require.cache = Module._cache;
  836. return require;
  837. }
  838. Module.prototype._compile = function (content, filename) {
  839. // remove shebang and create wrapper function
  840. var scriptSource = Module.wrap(content.replace(/^#!.*/, ''));
  841. // create script
  842. var recorder = moduleManager.getRecorder();
  843. var cachedDataPath = that._getCachedDataPath(nodeCachedData, filename);
  844. var options = { filename: filename };
  845. var hashData;
  846. try {
  847. var data = that._fs.readFileSync(cachedDataPath);
  848. hashData = data.slice(0, 16);
  849. options.cachedData = data.slice(16);
  850. recorder.record(60 /* CachedDataFound */, cachedDataPath);
  851. }
  852. catch (_e) {
  853. recorder.record(61 /* CachedDataMissed */, cachedDataPath);
  854. }
  855. var script = new that._vm.Script(scriptSource, options);
  856. var compileWrapper = script.runInThisContext(options);
  857. // run script
  858. var dirname = that._path.dirname(filename);
  859. var require = makeRequireFunction(this);
  860. var args = [this.exports, require, this, filename, dirname, process, _commonjsGlobal, Buffer];
  861. var result = compileWrapper.apply(this.exports, args);
  862. // cached data aftermath
  863. that._handleCachedData(script, scriptSource, cachedDataPath, !options.cachedData, moduleManager);
  864. that._verifyCachedData(script, scriptSource, cachedDataPath, hashData, moduleManager);
  865. return result;
  866. };
  867. };
  868. NodeScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
  869. var _this = this;
  870. var opts = moduleManager.getConfig().getOptionsLiteral();
  871. var nodeRequire = ensureRecordedNodeRequire(moduleManager.getRecorder(), (opts.nodeRequire || AMDLoader.global.nodeRequire));
  872. var nodeInstrumenter = (opts.nodeInstrumenter || function (c) { return c; });
  873. this._init(nodeRequire);
  874. this._initNodeRequire(nodeRequire, moduleManager);
  875. var recorder = moduleManager.getRecorder();
  876. if (/^node\|/.test(scriptSrc)) {
  877. var pieces = scriptSrc.split('|');
  878. var moduleExports_3 = null;
  879. try {
  880. moduleExports_3 = nodeRequire(pieces[1]);
  881. }
  882. catch (err) {
  883. errorback(err);
  884. return;
  885. }
  886. moduleManager.enqueueDefineAnonymousModule([], function () { return moduleExports_3; });
  887. callback();
  888. }
  889. else {
  890. scriptSrc = AMDLoader.Utilities.fileUriToFilePath(this._env.isWindows, scriptSrc);
  891. var normalizedScriptSrc_1 = this._path.normalize(scriptSrc);
  892. var vmScriptPathOrUri_1 = this._getElectronRendererScriptPathOrUri(normalizedScriptSrc_1);
  893. var wantsCachedData_1 = Boolean(opts.nodeCachedData);
  894. var cachedDataPath_1 = wantsCachedData_1 ? this._getCachedDataPath(opts.nodeCachedData, scriptSrc) : undefined;
  895. this._readSourceAndCachedData(normalizedScriptSrc_1, cachedDataPath_1, recorder, function (err, data, cachedData, hashData) {
  896. if (err) {
  897. errorback(err);
  898. return;
  899. }
  900. var scriptSource;
  901. if (data.charCodeAt(0) === NodeScriptLoader._BOM) {
  902. scriptSource = NodeScriptLoader._PREFIX + data.substring(1) + NodeScriptLoader._SUFFIX;
  903. }
  904. else {
  905. scriptSource = NodeScriptLoader._PREFIX + data + NodeScriptLoader._SUFFIX;
  906. }
  907. scriptSource = nodeInstrumenter(scriptSource, normalizedScriptSrc_1);
  908. var scriptOpts = { filename: vmScriptPathOrUri_1, cachedData: cachedData };
  909. var script = _this._createAndEvalScript(moduleManager, scriptSource, scriptOpts, callback, errorback);
  910. _this._handleCachedData(script, scriptSource, cachedDataPath_1, wantsCachedData_1 && !cachedData, moduleManager);
  911. _this._verifyCachedData(script, scriptSource, cachedDataPath_1, hashData, moduleManager);
  912. });
  913. }
  914. };
  915. NodeScriptLoader.prototype._createAndEvalScript = function (moduleManager, contents, options, callback, errorback) {
  916. var recorder = moduleManager.getRecorder();
  917. recorder.record(31 /* NodeBeginEvaluatingScript */, options.filename);
  918. var script = new this._vm.Script(contents, options);
  919. var ret = script.runInThisContext(options);
  920. var globalDefineFunc = moduleManager.getGlobalAMDDefineFunc();
  921. var receivedDefineCall = false;
  922. var localDefineFunc = function () {
  923. receivedDefineCall = true;
  924. return globalDefineFunc.apply(null, arguments);
  925. };
  926. localDefineFunc.amd = globalDefineFunc.amd;
  927. ret.call(AMDLoader.global, moduleManager.getGlobalAMDRequireFunc(), localDefineFunc, options.filename, this._path.dirname(options.filename));
  928. recorder.record(32 /* NodeEndEvaluatingScript */, options.filename);
  929. if (receivedDefineCall) {
  930. callback();
  931. }
  932. else {
  933. errorback(new Error("Didn't receive define call in " + options.filename + "!"));
  934. }
  935. return script;
  936. };
  937. NodeScriptLoader.prototype._getElectronRendererScriptPathOrUri = function (path) {
  938. if (!this._env.isElectronRenderer) {
  939. return path;
  940. }
  941. var driveLetterMatch = path.match(/^([a-z])\:(.*)/i);
  942. if (driveLetterMatch) {
  943. // windows
  944. return "file:///" + (driveLetterMatch[1].toUpperCase() + ':' + driveLetterMatch[2]).replace(/\\/g, '/');
  945. }
  946. else {
  947. // nix
  948. return "file://" + path;
  949. }
  950. };
  951. NodeScriptLoader.prototype._getCachedDataPath = function (config, filename) {
  952. var hash = this._crypto.createHash('md5').update(filename, 'utf8').update(config.seed, 'utf8').update(process.arch, '').digest('hex');
  953. var basename = this._path.basename(filename).replace(/\.js$/, '');
  954. return this._path.join(config.path, basename + "-" + hash + ".code");
  955. };
  956. NodeScriptLoader.prototype._handleCachedData = function (script, scriptSource, cachedDataPath, createCachedData, moduleManager) {
  957. var _this = this;
  958. if (script.cachedDataRejected) {
  959. // cached data got rejected -> delete and re-create
  960. this._fs.unlink(cachedDataPath, function (err) {
  961. moduleManager.getRecorder().record(62 /* CachedDataRejected */, cachedDataPath);
  962. _this._createAndWriteCachedData(script, scriptSource, cachedDataPath, moduleManager);
  963. if (err) {
  964. moduleManager.getConfig().onError(err);
  965. }
  966. });
  967. }
  968. else if (createCachedData) {
  969. // no cached data, but wanted
  970. this._createAndWriteCachedData(script, scriptSource, cachedDataPath, moduleManager);
  971. }
  972. };
  973. // Cached data format: | SOURCE_HASH | V8_CACHED_DATA |
  974. // -SOURCE_HASH is the md5 hash of the JS source (always 16 bytes)
  975. // -V8_CACHED_DATA is what v8 produces
  976. NodeScriptLoader.prototype._createAndWriteCachedData = function (script, scriptSource, cachedDataPath, moduleManager) {
  977. var _this = this;
  978. var timeout = Math.ceil(moduleManager.getConfig().getOptionsLiteral().nodeCachedData.writeDelay * (1 + Math.random()));
  979. var lastSize = -1;
  980. var iteration = 0;
  981. var hashData = undefined;
  982. var createLoop = function () {
  983. setTimeout(function () {
  984. if (!hashData) {
  985. hashData = _this._crypto.createHash('md5').update(scriptSource, 'utf8').digest();
  986. }
  987. var cachedData = script.createCachedData();
  988. if (cachedData.length === 0 || cachedData.length === lastSize || iteration >= 5) {
  989. // done
  990. return;
  991. }
  992. if (cachedData.length < lastSize) {
  993. // less data than before: skip, try again next round
  994. createLoop();
  995. return;
  996. }
  997. lastSize = cachedData.length;
  998. _this._fs.writeFile(cachedDataPath, Buffer.concat([hashData, cachedData]), function (err) {
  999. if (err) {
  1000. moduleManager.getConfig().onError(err);
  1001. }
  1002. moduleManager.getRecorder().record(63 /* CachedDataCreated */, cachedDataPath);
  1003. createLoop();
  1004. });
  1005. }, timeout * (Math.pow(4, iteration++)));
  1006. };
  1007. // with some delay (`timeout`) create cached data
  1008. // and repeat that (with backoff delay) until the
  1009. // data seems to be not changing anymore
  1010. createLoop();
  1011. };
  1012. NodeScriptLoader.prototype._readSourceAndCachedData = function (sourcePath, cachedDataPath, recorder, callback) {
  1013. if (!cachedDataPath) {
  1014. // no cached data case
  1015. this._fs.readFile(sourcePath, { encoding: 'utf8' }, callback);
  1016. }
  1017. else {
  1018. // cached data case: read both files in parallel
  1019. var source_1 = undefined;
  1020. var cachedData_1 = undefined;
  1021. var hashData_1 = undefined;
  1022. var steps_1 = 2;
  1023. var step_1 = function (err) {
  1024. if (err) {
  1025. callback(err);
  1026. }
  1027. else if (--steps_1 === 0) {
  1028. callback(undefined, source_1, cachedData_1, hashData_1);
  1029. }
  1030. };
  1031. this._fs.readFile(sourcePath, { encoding: 'utf8' }, function (err, data) {
  1032. source_1 = data;
  1033. step_1(err);
  1034. });
  1035. this._fs.readFile(cachedDataPath, function (err, data) {
  1036. if (!err && data && data.length > 0) {
  1037. hashData_1 = data.slice(0, 16);
  1038. cachedData_1 = data.slice(16);
  1039. recorder.record(60 /* CachedDataFound */, cachedDataPath);
  1040. }
  1041. else {
  1042. recorder.record(61 /* CachedDataMissed */, cachedDataPath);
  1043. }
  1044. step_1(); // ignored: cached data is optional
  1045. });
  1046. }
  1047. };
  1048. NodeScriptLoader.prototype._verifyCachedData = function (script, scriptSource, cachedDataPath, hashData, moduleManager) {
  1049. var _this = this;
  1050. if (!hashData) {
  1051. // nothing to do
  1052. return;
  1053. }
  1054. if (script.cachedDataRejected) {
  1055. // invalid anyways
  1056. return;
  1057. }
  1058. setTimeout(function () {
  1059. // check source hash - the contract is that file paths change when file content
  1060. // change (e.g use the commit or version id as cache path). this check is
  1061. // for violations of this contract.
  1062. var hashDataNow = _this._crypto.createHash('md5').update(scriptSource, 'utf8').digest();
  1063. if (!hashData.equals(hashDataNow)) {
  1064. moduleManager.getConfig().onError(new Error("FAILED TO VERIFY CACHED DATA, deleting stale '" + cachedDataPath + "' now, but a RESTART IS REQUIRED"));
  1065. _this._fs.unlink(cachedDataPath, function (err) {
  1066. if (err) {
  1067. moduleManager.getConfig().onError(err);
  1068. }
  1069. });
  1070. }
  1071. }, Math.ceil(5000 * (1 + Math.random())));
  1072. };
  1073. NodeScriptLoader._BOM = 0xFEFF;
  1074. NodeScriptLoader._PREFIX = '(function (require, define, __filename, __dirname) { ';
  1075. NodeScriptLoader._SUFFIX = '\n});';
  1076. return NodeScriptLoader;
  1077. }());
  1078. function ensureRecordedNodeRequire(recorder, _nodeRequire) {
  1079. if (_nodeRequire.__$__isRecorded) {
  1080. // it is already recorded
  1081. return _nodeRequire;
  1082. }
  1083. var nodeRequire = function nodeRequire(what) {
  1084. recorder.record(33 /* NodeBeginNativeRequire */, what);
  1085. try {
  1086. return _nodeRequire(what);
  1087. }
  1088. finally {
  1089. recorder.record(34 /* NodeEndNativeRequire */, what);
  1090. }
  1091. };
  1092. nodeRequire.__$__isRecorded = true;
  1093. return nodeRequire;
  1094. }
  1095. AMDLoader.ensureRecordedNodeRequire = ensureRecordedNodeRequire;
  1096. function createScriptLoader(env) {
  1097. return new OnlyOnceScriptLoader(env);
  1098. }
  1099. AMDLoader.createScriptLoader = createScriptLoader;
  1100. })(AMDLoader || (AMDLoader = {}));
  1101. /*---------------------------------------------------------------------------------------------
  1102. * Copyright (c) Microsoft Corporation. All rights reserved.
  1103. * Licensed under the MIT License. See License.txt in the project root for license information.
  1104. *--------------------------------------------------------------------------------------------*/
  1105. var AMDLoader;
  1106. (function (AMDLoader) {
  1107. // ------------------------------------------------------------------------
  1108. // ModuleIdResolver
  1109. var ModuleIdResolver = /** @class */ (function () {
  1110. function ModuleIdResolver(fromModuleId) {
  1111. var lastSlash = fromModuleId.lastIndexOf('/');
  1112. if (lastSlash !== -1) {
  1113. this.fromModulePath = fromModuleId.substr(0, lastSlash + 1);
  1114. }
  1115. else {
  1116. this.fromModulePath = '';
  1117. }
  1118. }
  1119. /**
  1120. * Normalize 'a/../name' to 'name', etc.
  1121. */
  1122. ModuleIdResolver._normalizeModuleId = function (moduleId) {
  1123. var r = moduleId, pattern;
  1124. // replace /./ => /
  1125. pattern = /\/\.\//;
  1126. while (pattern.test(r)) {
  1127. r = r.replace(pattern, '/');
  1128. }
  1129. // replace ^./ => nothing
  1130. r = r.replace(/^\.\//g, '');
  1131. // replace /aa/../ => / (BUT IGNORE /../../)
  1132. pattern = /\/(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//;
  1133. while (pattern.test(r)) {
  1134. r = r.replace(pattern, '/');
  1135. }
  1136. // replace ^aa/../ => nothing (BUT IGNORE ../../)
  1137. r = r.replace(/^(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//, '');
  1138. return r;
  1139. };
  1140. /**
  1141. * Resolve relative module ids
  1142. */
  1143. ModuleIdResolver.prototype.resolveModule = function (moduleId) {
  1144. var result = moduleId;
  1145. if (!AMDLoader.Utilities.isAbsolutePath(result)) {
  1146. if (AMDLoader.Utilities.startsWith(result, './') || AMDLoader.Utilities.startsWith(result, '../')) {
  1147. result = ModuleIdResolver._normalizeModuleId(this.fromModulePath + result);
  1148. }
  1149. }
  1150. return result;
  1151. };
  1152. ModuleIdResolver.ROOT = new ModuleIdResolver('');
  1153. return ModuleIdResolver;
  1154. }());
  1155. AMDLoader.ModuleIdResolver = ModuleIdResolver;
  1156. // ------------------------------------------------------------------------
  1157. // Module
  1158. var Module = /** @class */ (function () {
  1159. function Module(id, strId, dependencies, callback, errorback, moduleIdResolver) {
  1160. this.id = id;
  1161. this.strId = strId;
  1162. this.dependencies = dependencies;
  1163. this._callback = callback;
  1164. this._errorback = errorback;
  1165. this.moduleIdResolver = moduleIdResolver;
  1166. this.exports = {};
  1167. this.error = null;
  1168. this.exportsPassedIn = false;
  1169. this.unresolvedDependenciesCount = this.dependencies.length;
  1170. this._isComplete = false;
  1171. }
  1172. Module._safeInvokeFunction = function (callback, args) {
  1173. try {
  1174. return {
  1175. returnedValue: callback.apply(AMDLoader.global, args),
  1176. producedError: null
  1177. };
  1178. }
  1179. catch (e) {
  1180. return {
  1181. returnedValue: null,
  1182. producedError: e
  1183. };
  1184. }
  1185. };
  1186. Module._invokeFactory = function (config, strModuleId, callback, dependenciesValues) {
  1187. if (config.isBuild() && !AMDLoader.Utilities.isAnonymousModule(strModuleId)) {
  1188. return {
  1189. returnedValue: null,
  1190. producedError: null
  1191. };
  1192. }
  1193. if (config.shouldCatchError()) {
  1194. return this._safeInvokeFunction(callback, dependenciesValues);
  1195. }
  1196. return {
  1197. returnedValue: callback.apply(AMDLoader.global, dependenciesValues),
  1198. producedError: null
  1199. };
  1200. };
  1201. Module.prototype.complete = function (recorder, config, dependenciesValues) {
  1202. this._isComplete = true;
  1203. var producedError = null;
  1204. if (this._callback) {
  1205. if (typeof this._callback === 'function') {
  1206. recorder.record(21 /* BeginInvokeFactory */, this.strId);
  1207. var r = Module._invokeFactory(config, this.strId, this._callback, dependenciesValues);
  1208. producedError = r.producedError;
  1209. recorder.record(22 /* EndInvokeFactory */, this.strId);
  1210. if (!producedError && typeof r.returnedValue !== 'undefined' && (!this.exportsPassedIn || AMDLoader.Utilities.isEmpty(this.exports))) {
  1211. this.exports = r.returnedValue;
  1212. }
  1213. }
  1214. else {
  1215. this.exports = this._callback;
  1216. }
  1217. }
  1218. if (producedError) {
  1219. var err = AMDLoader.ensureError(producedError);
  1220. err.phase = 'factory';
  1221. err.moduleId = this.strId;
  1222. this.error = err;
  1223. config.onError(err);
  1224. }
  1225. this.dependencies = null;
  1226. this._callback = null;
  1227. this._errorback = null;
  1228. this.moduleIdResolver = null;
  1229. };
  1230. /**
  1231. * One of the direct dependencies or a transitive dependency has failed to load.
  1232. */
  1233. Module.prototype.onDependencyError = function (err) {
  1234. this._isComplete = true;
  1235. this.error = err;
  1236. if (this._errorback) {
  1237. this._errorback(err);
  1238. return true;
  1239. }
  1240. return false;
  1241. };
  1242. /**
  1243. * Is the current module complete?
  1244. */
  1245. Module.prototype.isComplete = function () {
  1246. return this._isComplete;
  1247. };
  1248. return Module;
  1249. }());
  1250. AMDLoader.Module = Module;
  1251. var ModuleIdProvider = /** @class */ (function () {
  1252. function ModuleIdProvider() {
  1253. this._nextId = 0;
  1254. this._strModuleIdToIntModuleId = new Map();
  1255. this._intModuleIdToStrModuleId = [];
  1256. // Ensure values 0, 1, 2 are assigned accordingly with ModuleId
  1257. this.getModuleId('exports');
  1258. this.getModuleId('module');
  1259. this.getModuleId('require');
  1260. }
  1261. ModuleIdProvider.prototype.getMaxModuleId = function () {
  1262. return this._nextId;
  1263. };
  1264. ModuleIdProvider.prototype.getModuleId = function (strModuleId) {
  1265. var id = this._strModuleIdToIntModuleId.get(strModuleId);
  1266. if (typeof id === 'undefined') {
  1267. id = this._nextId++;
  1268. this._strModuleIdToIntModuleId.set(strModuleId, id);
  1269. this._intModuleIdToStrModuleId[id] = strModuleId;
  1270. }
  1271. return id;
  1272. };
  1273. ModuleIdProvider.prototype.getStrModuleId = function (moduleId) {
  1274. return this._intModuleIdToStrModuleId[moduleId];
  1275. };
  1276. return ModuleIdProvider;
  1277. }());
  1278. var RegularDependency = /** @class */ (function () {
  1279. function RegularDependency(id) {
  1280. this.id = id;
  1281. }
  1282. RegularDependency.EXPORTS = new RegularDependency(0 /* EXPORTS */);
  1283. RegularDependency.MODULE = new RegularDependency(1 /* MODULE */);
  1284. RegularDependency.REQUIRE = new RegularDependency(2 /* REQUIRE */);
  1285. return RegularDependency;
  1286. }());
  1287. AMDLoader.RegularDependency = RegularDependency;
  1288. var PluginDependency = /** @class */ (function () {
  1289. function PluginDependency(id, pluginId, pluginParam) {
  1290. this.id = id;
  1291. this.pluginId = pluginId;
  1292. this.pluginParam = pluginParam;
  1293. }
  1294. return PluginDependency;
  1295. }());
  1296. AMDLoader.PluginDependency = PluginDependency;
  1297. var ModuleManager = /** @class */ (function () {
  1298. function ModuleManager(env, scriptLoader, defineFunc, requireFunc, loaderAvailableTimestamp) {
  1299. if (loaderAvailableTimestamp === void 0) { loaderAvailableTimestamp = 0; }
  1300. this._env = env;
  1301. this._scriptLoader = scriptLoader;
  1302. this._loaderAvailableTimestamp = loaderAvailableTimestamp;
  1303. this._defineFunc = defineFunc;
  1304. this._requireFunc = requireFunc;
  1305. this._moduleIdProvider = new ModuleIdProvider();
  1306. this._config = new AMDLoader.Configuration(this._env);
  1307. this._hasDependencyCycle = false;
  1308. this._modules2 = [];
  1309. this._knownModules2 = [];
  1310. this._inverseDependencies2 = [];
  1311. this._inversePluginDependencies2 = new Map();
  1312. this._currentAnonymousDefineCall = null;
  1313. this._recorder = null;
  1314. this._buildInfoPath = [];
  1315. this._buildInfoDefineStack = [];
  1316. this._buildInfoDependencies = [];
  1317. }
  1318. ModuleManager.prototype.reset = function () {
  1319. return new ModuleManager(this._env, this._scriptLoader, this._defineFunc, this._requireFunc, this._loaderAvailableTimestamp);
  1320. };
  1321. ModuleManager.prototype.getGlobalAMDDefineFunc = function () {
  1322. return this._defineFunc;
  1323. };
  1324. ModuleManager.prototype.getGlobalAMDRequireFunc = function () {
  1325. return this._requireFunc;
  1326. };
  1327. ModuleManager._findRelevantLocationInStack = function (needle, stack) {
  1328. var normalize = function (str) { return str.replace(/\\/g, '/'); };
  1329. var normalizedPath = normalize(needle);
  1330. var stackPieces = stack.split(/\n/);
  1331. for (var i = 0; i < stackPieces.length; i++) {
  1332. var m = stackPieces[i].match(/(.*):(\d+):(\d+)\)?$/);
  1333. if (m) {
  1334. var stackPath = m[1];
  1335. var stackLine = m[2];
  1336. var stackColumn = m[3];
  1337. var trimPathOffset = Math.max(stackPath.lastIndexOf(' ') + 1, stackPath.lastIndexOf('(') + 1);
  1338. stackPath = stackPath.substr(trimPathOffset);
  1339. stackPath = normalize(stackPath);
  1340. if (stackPath === normalizedPath) {
  1341. var r = {
  1342. line: parseInt(stackLine, 10),
  1343. col: parseInt(stackColumn, 10)
  1344. };
  1345. if (r.line === 1) {
  1346. r.col -= '(function (require, define, __filename, __dirname) { '.length;
  1347. }
  1348. return r;
  1349. }
  1350. }
  1351. }
  1352. throw new Error('Could not correlate define call site for needle ' + needle);
  1353. };
  1354. ModuleManager.prototype.getBuildInfo = function () {
  1355. if (!this._config.isBuild()) {
  1356. return null;
  1357. }
  1358. var result = [], resultLen = 0;
  1359. for (var i = 0, len = this._modules2.length; i < len; i++) {
  1360. var m = this._modules2[i];
  1361. if (!m) {
  1362. continue;
  1363. }
  1364. var location_1 = this._buildInfoPath[m.id] || null;
  1365. var defineStack = this._buildInfoDefineStack[m.id] || null;
  1366. var dependencies = this._buildInfoDependencies[m.id];
  1367. result[resultLen++] = {
  1368. id: m.strId,
  1369. path: location_1,
  1370. defineLocation: (location_1 && defineStack ? ModuleManager._findRelevantLocationInStack(location_1, defineStack) : null),
  1371. dependencies: dependencies,
  1372. shim: null,
  1373. exports: m.exports
  1374. };
  1375. }
  1376. return result;
  1377. };
  1378. ModuleManager.prototype.getRecorder = function () {
  1379. if (!this._recorder) {
  1380. if (this._config.shouldRecordStats()) {
  1381. this._recorder = new AMDLoader.LoaderEventRecorder(this._loaderAvailableTimestamp);
  1382. }
  1383. else {
  1384. this._recorder = AMDLoader.NullLoaderEventRecorder.INSTANCE;
  1385. }
  1386. }
  1387. return this._recorder;
  1388. };
  1389. ModuleManager.prototype.getLoaderEvents = function () {
  1390. return this.getRecorder().getEvents();
  1391. };
  1392. /**
  1393. * Defines an anonymous module (without an id). Its name will be resolved as we receive a callback from the scriptLoader.
  1394. * @param dependencies @see defineModule
  1395. * @param callback @see defineModule
  1396. */
  1397. ModuleManager.prototype.enqueueDefineAnonymousModule = function (dependencies, callback) {
  1398. if (this._currentAnonymousDefineCall !== null) {
  1399. throw new Error('Can only have one anonymous define call per script file');
  1400. }
  1401. var stack = null;
  1402. if (this._config.isBuild()) {
  1403. stack = new Error('StackLocation').stack || null;
  1404. }
  1405. this._currentAnonymousDefineCall = {
  1406. stack: stack,
  1407. dependencies: dependencies,
  1408. callback: callback
  1409. };
  1410. };
  1411. /**
  1412. * Creates a module and stores it in _modules. The manager will immediately begin resolving its dependencies.
  1413. * @param strModuleId An unique and absolute id of the module. This must not collide with another module's id
  1414. * @param dependencies An array with the dependencies of the module. Special keys are: "require", "exports" and "module"
  1415. * @param callback if callback is a function, it will be called with the resolved dependencies. if callback is an object, it will be considered as the exports of the module.
  1416. */
  1417. ModuleManager.prototype.defineModule = function (strModuleId, dependencies, callback, errorback, stack, moduleIdResolver) {
  1418. var _this = this;
  1419. if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(strModuleId); }
  1420. var moduleId = this._moduleIdProvider.getModuleId(strModuleId);
  1421. if (this._modules2[moduleId]) {
  1422. if (!this._config.isDuplicateMessageIgnoredFor(strModuleId)) {
  1423. console.warn('Duplicate definition of module \'' + strModuleId + '\'');
  1424. }
  1425. // Super important! Completely ignore duplicate module definition
  1426. return;
  1427. }
  1428. var m = new Module(moduleId, strModuleId, this._normalizeDependencies(dependencies, moduleIdResolver), callback, errorback, moduleIdResolver);
  1429. this._modules2[moduleId] = m;
  1430. if (this._config.isBuild()) {
  1431. this._buildInfoDefineStack[moduleId] = stack;
  1432. this._buildInfoDependencies[moduleId] = (m.dependencies || []).map(function (dep) { return _this._moduleIdProvider.getStrModuleId(dep.id); });
  1433. }
  1434. // Resolving of dependencies is immediate (not in a timeout). If there's a need to support a packer that concatenates in an
  1435. // unordered manner, in order to finish processing the file, execute the following method in a timeout
  1436. this._resolve(m);
  1437. };
  1438. ModuleManager.prototype._normalizeDependency = function (dependency, moduleIdResolver) {
  1439. if (dependency === 'exports') {
  1440. return RegularDependency.EXPORTS;
  1441. }
  1442. if (dependency === 'module') {
  1443. return RegularDependency.MODULE;
  1444. }
  1445. if (dependency === 'require') {
  1446. return RegularDependency.REQUIRE;
  1447. }
  1448. // Normalize dependency and then request it from the manager
  1449. var bangIndex = dependency.indexOf('!');
  1450. if (bangIndex >= 0) {
  1451. var strPluginId = moduleIdResolver.resolveModule(dependency.substr(0, bangIndex));
  1452. var pluginParam = moduleIdResolver.resolveModule(dependency.substr(bangIndex + 1));
  1453. var dependencyId = this._moduleIdProvider.getModuleId(strPluginId + '!' + pluginParam);
  1454. var pluginId = this._moduleIdProvider.getModuleId(strPluginId);
  1455. return new PluginDependency(dependencyId, pluginId, pluginParam);
  1456. }
  1457. return new RegularDependency(this._moduleIdProvider.getModuleId(moduleIdResolver.resolveModule(dependency)));
  1458. };
  1459. ModuleManager.prototype._normalizeDependencies = function (dependencies, moduleIdResolver) {
  1460. var result = [], resultLen = 0;
  1461. for (var i = 0, len = dependencies.length; i < len; i++) {
  1462. result[resultLen++] = this._normalizeDependency(dependencies[i], moduleIdResolver);
  1463. }
  1464. return result;
  1465. };
  1466. ModuleManager.prototype._relativeRequire = function (moduleIdResolver, dependencies, callback, errorback) {
  1467. if (typeof dependencies === 'string') {
  1468. return this.synchronousRequire(dependencies, moduleIdResolver);
  1469. }
  1470. this.defineModule(AMDLoader.Utilities.generateAnonymousModule(), dependencies, callback, errorback, null, moduleIdResolver);
  1471. };
  1472. /**
  1473. * Require synchronously a module by its absolute id. If the module is not loaded, an exception will be thrown.
  1474. * @param id The unique and absolute id of the required module
  1475. * @return The exports of module 'id'
  1476. */
  1477. ModuleManager.prototype.synchronousRequire = function (_strModuleId, moduleIdResolver) {
  1478. if (moduleIdResolver === void 0) { moduleIdResolver = new ModuleIdResolver(_strModuleId); }
  1479. var dependency = this._normalizeDependency(_strModuleId, moduleIdResolver);
  1480. var m = this._modules2[dependency.id];
  1481. if (!m) {
  1482. throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This is the first mention of this module!');
  1483. }
  1484. if (!m.isComplete()) {
  1485. throw new Error('Check dependency list! Synchronous require cannot resolve module \'' + _strModuleId + '\'. This module has not been resolved completely yet.');
  1486. }
  1487. if (m.error) {
  1488. throw m.error;
  1489. }
  1490. return m.exports;
  1491. };
  1492. ModuleManager.prototype.configure = function (params, shouldOverwrite) {
  1493. var oldShouldRecordStats = this._config.shouldRecordStats();
  1494. if (shouldOverwrite) {
  1495. this._config = new AMDLoader.Configuration(this._env, params);
  1496. }
  1497. else {
  1498. this._config = this._config.cloneAndMerge(params);
  1499. }
  1500. if (this._config.shouldRecordStats() && !oldShouldRecordStats) {
  1501. this._recorder = null;
  1502. }
  1503. };
  1504. ModuleManager.prototype.getConfig = function () {
  1505. return this._config;
  1506. };
  1507. /**
  1508. * Callback from the scriptLoader when a module has been loaded.
  1509. * This means its code is available and has been executed.
  1510. */
  1511. ModuleManager.prototype._onLoad = function (moduleId) {
  1512. if (this._currentAnonymousDefineCall !== null) {
  1513. var defineCall = this._currentAnonymousDefineCall;
  1514. this._currentAnonymousDefineCall = null;
  1515. // Hit an anonymous define call
  1516. this.defineModule(this._moduleIdProvider.getStrModuleId(moduleId), defineCall.dependencies, defineCall.callback, null, defineCall.stack);
  1517. }
  1518. };
  1519. ModuleManager.prototype._createLoadError = function (moduleId, _err) {
  1520. var _this = this;
  1521. var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
  1522. var neededBy = (this._inverseDependencies2[moduleId] || []).map(function (intModuleId) { return _this._moduleIdProvider.getStrModuleId(intModuleId); });
  1523. var err = AMDLoader.ensureError(_err);
  1524. err.phase = 'loading';
  1525. err.moduleId = strModuleId;
  1526. err.neededBy = neededBy;
  1527. return err;
  1528. };
  1529. /**
  1530. * Callback from the scriptLoader when a module hasn't been loaded.
  1531. * This means that the script was not found (e.g. 404) or there was an error in the script.
  1532. */
  1533. ModuleManager.prototype._onLoadError = function (moduleId, err) {
  1534. var error = this._createLoadError(moduleId, err);
  1535. if (!this._modules2[moduleId]) {
  1536. this._modules2[moduleId] = new Module(moduleId, this._moduleIdProvider.getStrModuleId(moduleId), [], function () { }, null, null);
  1537. }
  1538. // Find any 'local' error handlers, walk the entire chain of inverse dependencies if necessary.
  1539. var seenModuleId = [];
  1540. for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
  1541. seenModuleId[i] = false;
  1542. }
  1543. var someoneNotified = false;
  1544. var queue = [];
  1545. queue.push(moduleId);
  1546. seenModuleId[moduleId] = true;
  1547. while (queue.length > 0) {
  1548. var queueElement = queue.shift();
  1549. var m = this._modules2[queueElement];
  1550. if (m) {
  1551. someoneNotified = m.onDependencyError(error) || someoneNotified;
  1552. }
  1553. var inverseDeps = this._inverseDependencies2[queueElement];
  1554. if (inverseDeps) {
  1555. for (var i = 0, len = inverseDeps.length; i < len; i++) {
  1556. var inverseDep = inverseDeps[i];
  1557. if (!seenModuleId[inverseDep]) {
  1558. queue.push(inverseDep);
  1559. seenModuleId[inverseDep] = true;
  1560. }
  1561. }
  1562. }
  1563. }
  1564. if (!someoneNotified) {
  1565. this._config.onError(error);
  1566. }
  1567. };
  1568. /**
  1569. * Walks (recursively) the dependencies of 'from' in search of 'to'.
  1570. * Returns true if there is such a path or false otherwise.
  1571. * @param from Module id to start at
  1572. * @param to Module id to look for
  1573. */
  1574. ModuleManager.prototype._hasDependencyPath = function (fromId, toId) {
  1575. var from = this._modules2[fromId];
  1576. if (!from) {
  1577. return false;
  1578. }
  1579. var inQueue = [];
  1580. for (var i = 0, len = this._moduleIdProvider.getMaxModuleId(); i < len; i++) {
  1581. inQueue[i] = false;
  1582. }
  1583. var queue = [];
  1584. // Insert 'from' in queue
  1585. queue.push(from);
  1586. inQueue[fromId] = true;
  1587. while (queue.length > 0) {
  1588. // Pop first inserted element of queue
  1589. var element = queue.shift();
  1590. var dependencies = element.dependencies;
  1591. if (dependencies) {
  1592. // Walk the element's dependencies
  1593. for (var i = 0, len = dependencies.length; i < len; i++) {
  1594. var dependency = dependencies[i];
  1595. if (dependency.id === toId) {
  1596. // There is a path to 'to'
  1597. return true;
  1598. }
  1599. var dependencyModule = this._modules2[dependency.id];
  1600. if (dependencyModule && !inQueue[dependency.id]) {
  1601. // Insert 'dependency' in queue
  1602. inQueue[dependency.id] = true;
  1603. queue.push(dependencyModule);
  1604. }
  1605. }
  1606. }
  1607. }
  1608. // There is no path to 'to'
  1609. return false;
  1610. };
  1611. /**
  1612. * Walks (recursively) the dependencies of 'from' in search of 'to'.
  1613. * Returns cycle as array.
  1614. * @param from Module id to start at
  1615. * @param to Module id to look for
  1616. */
  1617. ModuleManager.prototype._findCyclePath = function (fromId, toId, depth) {
  1618. if (fromId === toId || depth === 50) {
  1619. return [fromId];
  1620. }
  1621. var from = this._modules2[fromId];
  1622. if (!from) {
  1623. return null;
  1624. }
  1625. // Walk the element's dependencies
  1626. var dependencies = from.dependencies;
  1627. if (dependencies) {
  1628. for (var i = 0, len = dependencies.length; i < len; i++) {
  1629. var path = this._findCyclePath(dependencies[i].id, toId, depth + 1);
  1630. if (path !== null) {
  1631. path.push(fromId);
  1632. return path;
  1633. }
  1634. }
  1635. }
  1636. return null;
  1637. };
  1638. /**
  1639. * Create the local 'require' that is passed into modules
  1640. */
  1641. ModuleManager.prototype._createRequire = function (moduleIdResolver) {
  1642. var _this = this;
  1643. var result = (function (dependencies, callback, errorback) {
  1644. return _this._relativeRequire(moduleIdResolver, dependencies, callback, errorback);
  1645. });
  1646. result.toUrl = function (id) {
  1647. return _this._config.requireToUrl(moduleIdResolver.resolveModule(id));
  1648. };
  1649. result.getStats = function () {
  1650. return _this.getLoaderEvents();
  1651. };
  1652. result.hasDependencyCycle = function () {
  1653. return _this._hasDependencyCycle;
  1654. };
  1655. result.config = function (params, shouldOverwrite) {
  1656. if (shouldOverwrite === void 0) { shouldOverwrite = false; }
  1657. _this.configure(params, shouldOverwrite);
  1658. };
  1659. result.__$__nodeRequire = AMDLoader.global.nodeRequire;
  1660. return result;
  1661. };
  1662. ModuleManager.prototype._loadModule = function (moduleId) {
  1663. var _this = this;
  1664. if (this._modules2[moduleId] || this._knownModules2[moduleId]) {
  1665. // known module
  1666. return;
  1667. }
  1668. this._knownModules2[moduleId] = true;
  1669. var strModuleId = this._moduleIdProvider.getStrModuleId(moduleId);
  1670. var paths = this._config.moduleIdToPaths(strModuleId);
  1671. var scopedPackageRegex = /^@[^\/]+\/[^\/]+$/; // matches @scope/package-name
  1672. if (this._env.isNode && (strModuleId.indexOf('/') === -1 || scopedPackageRegex.test(strModuleId))) {
  1673. paths.push('node|' + strModuleId);
  1674. }
  1675. var lastPathIndex = -1;
  1676. var loadNextPath = function (err) {
  1677. lastPathIndex++;
  1678. if (lastPathIndex >= paths.length) {
  1679. // No more paths to try
  1680. _this._onLoadError(moduleId, err);
  1681. }
  1682. else {
  1683. var currentPath_1 = paths[lastPathIndex];
  1684. var recorder_1 = _this.getRecorder();
  1685. if (_this._config.isBuild() && currentPath_1 === 'empty:') {
  1686. _this._buildInfoPath[moduleId] = currentPath_1;
  1687. _this.defineModule(_this._moduleIdProvider.getStrModuleId(moduleId), [], null, null, null);
  1688. _this._onLoad(moduleId);
  1689. return;
  1690. }
  1691. recorder_1.record(10 /* BeginLoadingScript */, currentPath_1);
  1692. _this._scriptLoader.load(_this, currentPath_1, function () {
  1693. if (_this._config.isBuild()) {
  1694. _this._buildInfoPath[moduleId] = currentPath_1;
  1695. }
  1696. recorder_1.record(11 /* EndLoadingScriptOK */, currentPath_1);
  1697. _this._onLoad(moduleId);
  1698. }, function (err) {
  1699. recorder_1.record(12 /* EndLoadingScriptError */, currentPath_1);
  1700. loadNextPath(err);
  1701. });
  1702. }
  1703. };
  1704. loadNextPath(null);
  1705. };
  1706. /**
  1707. * Resolve a plugin dependency with the plugin loaded & complete
  1708. * @param module The module that has this dependency
  1709. * @param pluginDependency The semi-normalized dependency that appears in the module. e.g. 'vs/css!./mycssfile'. Only the plugin part (before !) is normalized
  1710. * @param plugin The plugin (what the plugin exports)
  1711. */
  1712. ModuleManager.prototype._loadPluginDependency = function (plugin, pluginDependency) {
  1713. var _this = this;
  1714. if (this._modules2[pluginDependency.id] || this._knownModules2[pluginDependency.id]) {
  1715. // known module
  1716. return;
  1717. }
  1718. this._knownModules2[pluginDependency.id] = true;
  1719. // Delegate the loading of the resource to the plugin
  1720. var load = (function (value) {
  1721. _this.defineModule(_this._moduleIdProvider.getStrModuleId(pluginDependency.id), [], value, null, null);
  1722. });
  1723. load.error = function (err) {
  1724. _this._config.onError(_this._createLoadError(pluginDependency.id, err));
  1725. };
  1726. plugin.load(pluginDependency.pluginParam, this._createRequire(ModuleIdResolver.ROOT), load, this._config.getOptionsLiteral());
  1727. };
  1728. /**
  1729. * Examine the dependencies of module 'module' and resolve them as needed.
  1730. */
  1731. ModuleManager.prototype._resolve = function (module) {
  1732. var _this = this;
  1733. var dependencies = module.dependencies;
  1734. if (dependencies) {
  1735. for (var i = 0, len = dependencies.length; i < len; i++) {
  1736. var dependency = dependencies[i];
  1737. if (dependency === RegularDependency.EXPORTS) {
  1738. module.exportsPassedIn = true;
  1739. module.unresolvedDependenciesCount--;
  1740. continue;
  1741. }
  1742. if (dependency === RegularDependency.MODULE) {
  1743. module.unresolvedDependenciesCount--;
  1744. continue;
  1745. }
  1746. if (dependency === RegularDependency.REQUIRE) {
  1747. module.unresolvedDependenciesCount--;
  1748. continue;
  1749. }
  1750. var dependencyModule = this._modules2[dependency.id];
  1751. if (dependencyModule && dependencyModule.isComplete()) {
  1752. if (dependencyModule.error) {
  1753. module.onDependencyError(dependencyModule.error);
  1754. return;
  1755. }
  1756. module.unresolvedDependenciesCount--;
  1757. continue;
  1758. }
  1759. if (this._hasDependencyPath(dependency.id, module.id)) {
  1760. this._hasDependencyCycle = true;
  1761. console.warn('There is a dependency cycle between \'' + this._moduleIdProvider.getStrModuleId(dependency.id) + '\' and \'' + this._moduleIdProvider.getStrModuleId(module.id) + '\'. The cyclic path follows:');
  1762. var cyclePath = this._findCyclePath(dependency.id, module.id, 0) || [];
  1763. cyclePath.reverse();
  1764. cyclePath.push(dependency.id);
  1765. console.warn(cyclePath.map(function (id) { return _this._moduleIdProvider.getStrModuleId(id); }).join(' => \n'));
  1766. // Break the cycle
  1767. module.unresolvedDependenciesCount--;
  1768. continue;
  1769. }
  1770. // record inverse dependency
  1771. this._inverseDependencies2[dependency.id] = this._inverseDependencies2[dependency.id] || [];
  1772. this._inverseDependencies2[dependency.id].push(module.id);
  1773. if (dependency instanceof PluginDependency) {
  1774. var plugin = this._modules2[dependency.pluginId];
  1775. if (plugin && plugin.isComplete()) {
  1776. this._loadPluginDependency(plugin.exports, dependency);
  1777. continue;
  1778. }
  1779. // Record dependency for when the plugin gets loaded
  1780. var inversePluginDeps = this._inversePluginDependencies2.get(dependency.pluginId);
  1781. if (!inversePluginDeps) {
  1782. inversePluginDeps = [];
  1783. this._inversePluginDependencies2.set(dependency.pluginId, inversePluginDeps);
  1784. }
  1785. inversePluginDeps.push(dependency);
  1786. this._loadModule(dependency.pluginId);
  1787. continue;
  1788. }
  1789. this._loadModule(dependency.id);
  1790. }
  1791. }
  1792. if (module.unresolvedDependenciesCount === 0) {
  1793. this._onModuleComplete(module);
  1794. }
  1795. };
  1796. ModuleManager.prototype._onModuleComplete = function (module) {
  1797. var _this = this;
  1798. var recorder = this.getRecorder();
  1799. if (module.isComplete()) {
  1800. // already done
  1801. return;
  1802. }
  1803. var dependencies = module.dependencies;
  1804. var dependenciesValues = [];
  1805. if (dependencies) {
  1806. for (var i = 0, len = dependencies.length; i < len; i++) {
  1807. var dependency = dependencies[i];
  1808. if (dependency === RegularDependency.EXPORTS) {
  1809. dependenciesValues[i] = module.exports;
  1810. continue;
  1811. }
  1812. if (dependency === RegularDependency.MODULE) {
  1813. dependenciesValues[i] = {
  1814. id: module.strId,
  1815. config: function () {
  1816. return _this._config.getConfigForModule(module.strId);
  1817. }
  1818. };
  1819. continue;
  1820. }
  1821. if (dependency === RegularDependency.REQUIRE) {
  1822. dependenciesValues[i] = this._createRequire(module.moduleIdResolver);
  1823. continue;
  1824. }
  1825. var dependencyModule = this._modules2[dependency.id];
  1826. if (dependencyModule) {
  1827. dependenciesValues[i] = dependencyModule.exports;
  1828. continue;
  1829. }
  1830. dependenciesValues[i] = null;
  1831. }
  1832. }
  1833. module.complete(recorder, this._config, dependenciesValues);
  1834. // Fetch and clear inverse dependencies
  1835. var inverseDeps = this._inverseDependencies2[module.id];
  1836. this._inverseDependencies2[module.id] = null;
  1837. if (inverseDeps) {
  1838. // Resolve one inverse dependency at a time, always
  1839. // on the lookout for a completed module.
  1840. for (var i = 0, len = inverseDeps.length; i < len; i++) {
  1841. var inverseDependencyId = inverseDeps[i];
  1842. var inverseDependency = this._modules2[inverseDependencyId];
  1843. inverseDependency.unresolvedDependenciesCount--;
  1844. if (inverseDependency.unresolvedDependenciesCount === 0) {
  1845. this._onModuleComplete(inverseDependency);
  1846. }
  1847. }
  1848. }
  1849. var inversePluginDeps = this._inversePluginDependencies2.get(module.id);
  1850. if (inversePluginDeps) {
  1851. // This module is used as a plugin at least once
  1852. // Fetch and clear these inverse plugin dependencies
  1853. this._inversePluginDependencies2.delete(module.id);
  1854. // Resolve plugin dependencies one at a time
  1855. for (var i = 0, len = inversePluginDeps.length; i < len; i++) {
  1856. this._loadPluginDependency(module.exports, inversePluginDeps[i]);
  1857. }
  1858. }
  1859. };
  1860. return ModuleManager;
  1861. }());
  1862. AMDLoader.ModuleManager = ModuleManager;
  1863. })(AMDLoader || (AMDLoader = {}));
  1864. var define;
  1865. var AMDLoader;
  1866. (function (AMDLoader) {
  1867. var env = new AMDLoader.Environment();
  1868. var moduleManager = null;
  1869. var DefineFunc = function (id, dependencies, callback) {
  1870. if (typeof id !== 'string') {
  1871. callback = dependencies;
  1872. dependencies = id;
  1873. id = null;
  1874. }
  1875. if (typeof dependencies !== 'object' || !Array.isArray(dependencies)) {
  1876. callback = dependencies;
  1877. dependencies = null;
  1878. }
  1879. if (!dependencies) {
  1880. dependencies = ['require', 'exports', 'module'];
  1881. }
  1882. if (id) {
  1883. moduleManager.defineModule(id, dependencies, callback, null, null);
  1884. }
  1885. else {
  1886. moduleManager.enqueueDefineAnonymousModule(dependencies, callback);
  1887. }
  1888. };
  1889. DefineFunc.amd = {
  1890. jQuery: true
  1891. };
  1892. var _requireFunc_config = function (params, shouldOverwrite) {
  1893. if (shouldOverwrite === void 0) { shouldOverwrite = false; }
  1894. moduleManager.configure(params, shouldOverwrite);
  1895. };
  1896. var RequireFunc = function () {
  1897. if (arguments.length === 1) {
  1898. if ((arguments[0] instanceof Object) && !Array.isArray(arguments[0])) {
  1899. _requireFunc_config(arguments[0]);
  1900. return;
  1901. }
  1902. if (typeof arguments[0] === 'string') {
  1903. return moduleManager.synchronousRequire(arguments[0]);
  1904. }
  1905. }
  1906. if (arguments.length === 2 || arguments.length === 3) {
  1907. if (Array.isArray(arguments[0])) {
  1908. moduleManager.defineModule(AMDLoader.Utilities.generateAnonymousModule(), arguments[0], arguments[1], arguments[2], null);
  1909. return;
  1910. }
  1911. }
  1912. throw new Error('Unrecognized require call');
  1913. };
  1914. RequireFunc.config = _requireFunc_config;
  1915. RequireFunc.getConfig = function () {
  1916. return moduleManager.getConfig().getOptionsLiteral();
  1917. };
  1918. RequireFunc.reset = function () {
  1919. moduleManager = moduleManager.reset();
  1920. };
  1921. RequireFunc.getBuildInfo = function () {
  1922. return moduleManager.getBuildInfo();
  1923. };
  1924. RequireFunc.getStats = function () {
  1925. return moduleManager.getLoaderEvents();
  1926. };
  1927. RequireFunc.define = DefineFunc;
  1928. function init() {
  1929. if (typeof AMDLoader.global.require !== 'undefined' || typeof require !== 'undefined') {
  1930. var _nodeRequire = (AMDLoader.global.require || require);
  1931. if (typeof _nodeRequire === 'function' && typeof _nodeRequire.resolve === 'function') {
  1932. // re-expose node's require function
  1933. var nodeRequire = AMDLoader.ensureRecordedNodeRequire(moduleManager.getRecorder(), _nodeRequire);
  1934. AMDLoader.global.nodeRequire = nodeRequire;
  1935. RequireFunc.nodeRequire = nodeRequire;
  1936. RequireFunc.__$__nodeRequire = nodeRequire;
  1937. }
  1938. }
  1939. if (env.isNode && !env.isElectronRenderer && !env.isElectronNodeIntegrationWebWorker) {
  1940. module.exports = RequireFunc;
  1941. require = RequireFunc;
  1942. }
  1943. else {
  1944. if (!env.isElectronRenderer) {
  1945. AMDLoader.global.define = DefineFunc;
  1946. }
  1947. AMDLoader.global.require = RequireFunc;
  1948. }
  1949. }
  1950. AMDLoader.init = init;
  1951. if (typeof AMDLoader.global.define !== 'function' || !AMDLoader.global.define.amd) {
  1952. moduleManager = new AMDLoader.ModuleManager(env, AMDLoader.createScriptLoader(env), DefineFunc, RequireFunc, AMDLoader.Utilities.getHighPerformanceTimestamp());
  1953. // The global variable require can configure the loader
  1954. if (typeof AMDLoader.global.require !== 'undefined' && typeof AMDLoader.global.require !== 'function') {
  1955. RequireFunc.config(AMDLoader.global.require);
  1956. }
  1957. // This define is for the local closure defined in node in the case that the loader is concatenated
  1958. define = function () {
  1959. return DefineFunc.apply(null, arguments);
  1960. };
  1961. define.amd = DefineFunc.amd;
  1962. if (typeof doNotInitLoader === 'undefined') {
  1963. init();
  1964. }
  1965. }
  1966. })(AMDLoader || (AMDLoader = {}));
  1967. define(__m[15/*vs/base/common/arrays*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1968. "use strict";
  1969. Object.defineProperty(exports, "__esModule", { value: true });
  1970. exports.ArrayQueue = exports.splice = exports.insertInto = exports.asArray = exports.pushToEnd = exports.pushToStart = exports.arrayInsert = exports.range = exports.flatten = exports.firstOrDefault = exports.lastIndex = exports.findLast = exports.distinct = exports.isNonEmptyArray = exports.isFalsyOrEmpty = exports.coalesce = exports.groupBy = exports.quickSelect = exports.findFirstInSorted = exports.binarySearch = exports.equals = exports.tail2 = exports.tail = void 0;
  1971. /**
  1972. * Returns the last element of an array.
  1973. * @param array The array.
  1974. * @param n Which element from the end (default is zero).
  1975. */
  1976. function tail(array, n = 0) {
  1977. return array[array.length - (1 + n)];
  1978. }
  1979. exports.tail = tail;
  1980. function tail2(arr) {
  1981. if (arr.length === 0) {
  1982. throw new Error('Invalid tail call');
  1983. }
  1984. return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
  1985. }
  1986. exports.tail2 = tail2;
  1987. function equals(one, other, itemEquals = (a, b) => a === b) {
  1988. if (one === other) {
  1989. return true;
  1990. }
  1991. if (!one || !other) {
  1992. return false;
  1993. }
  1994. if (one.length !== other.length) {
  1995. return false;
  1996. }
  1997. for (let i = 0, len = one.length; i < len; i++) {
  1998. if (!itemEquals(one[i], other[i])) {
  1999. return false;
  2000. }
  2001. }
  2002. return true;
  2003. }
  2004. exports.equals = equals;
  2005. function binarySearch(array, key, comparator) {
  2006. let low = 0, high = array.length - 1;
  2007. while (low <= high) {
  2008. const mid = ((low + high) / 2) | 0;
  2009. const comp = comparator(array[mid], key);
  2010. if (comp < 0) {
  2011. low = mid + 1;
  2012. }
  2013. else if (comp > 0) {
  2014. high = mid - 1;
  2015. }
  2016. else {
  2017. return mid;
  2018. }
  2019. }
  2020. return -(low + 1);
  2021. }
  2022. exports.binarySearch = binarySearch;
  2023. /**
  2024. * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false
  2025. * are located before all elements where p(x) is true.
  2026. * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
  2027. */
  2028. function findFirstInSorted(array, p) {
  2029. let low = 0, high = array.length;
  2030. if (high === 0) {
  2031. return 0; // no children
  2032. }
  2033. while (low < high) {
  2034. const mid = Math.floor((low + high) / 2);
  2035. if (p(array[mid])) {
  2036. high = mid;
  2037. }
  2038. else {
  2039. low = mid + 1;
  2040. }
  2041. }
  2042. return low;
  2043. }
  2044. exports.findFirstInSorted = findFirstInSorted;
  2045. function quickSelect(nth, data, compare) {
  2046. nth = nth | 0;
  2047. if (nth >= data.length) {
  2048. throw new TypeError('invalid index');
  2049. }
  2050. let pivotValue = data[Math.floor(data.length * Math.random())];
  2051. let lower = [];
  2052. let higher = [];
  2053. let pivots = [];
  2054. for (let value of data) {
  2055. const val = compare(value, pivotValue);
  2056. if (val < 0) {
  2057. lower.push(value);
  2058. }
  2059. else if (val > 0) {
  2060. higher.push(value);
  2061. }
  2062. else {
  2063. pivots.push(value);
  2064. }
  2065. }
  2066. if (nth < lower.length) {
  2067. return quickSelect(nth, lower, compare);
  2068. }
  2069. else if (nth < lower.length + pivots.length) {
  2070. return pivots[0];
  2071. }
  2072. else {
  2073. return quickSelect(nth - (lower.length + pivots.length), higher, compare);
  2074. }
  2075. }
  2076. exports.quickSelect = quickSelect;
  2077. function groupBy(data, compare) {
  2078. const result = [];
  2079. let currentGroup = undefined;
  2080. for (const element of data.slice(0).sort(compare)) {
  2081. if (!currentGroup || compare(currentGroup[0], element) !== 0) {
  2082. currentGroup = [element];
  2083. result.push(currentGroup);
  2084. }
  2085. else {
  2086. currentGroup.push(element);
  2087. }
  2088. }
  2089. return result;
  2090. }
  2091. exports.groupBy = groupBy;
  2092. /**
  2093. * @returns New array with all falsy values removed. The original array IS NOT modified.
  2094. */
  2095. function coalesce(array) {
  2096. return array.filter(e => !!e);
  2097. }
  2098. exports.coalesce = coalesce;
  2099. /**
  2100. * @returns false if the provided object is an array and not empty.
  2101. */
  2102. function isFalsyOrEmpty(obj) {
  2103. return !Array.isArray(obj) || obj.length === 0;
  2104. }
  2105. exports.isFalsyOrEmpty = isFalsyOrEmpty;
  2106. function isNonEmptyArray(obj) {
  2107. return Array.isArray(obj) && obj.length > 0;
  2108. }
  2109. exports.isNonEmptyArray = isNonEmptyArray;
  2110. /**
  2111. * Removes duplicates from the given array. The optional keyFn allows to specify
  2112. * how elements are checked for equality by returning an alternate value for each.
  2113. */
  2114. function distinct(array, keyFn = value => value) {
  2115. const seen = new Set();
  2116. return array.filter(element => {
  2117. const key = keyFn(element);
  2118. if (seen.has(key)) {
  2119. return false;
  2120. }
  2121. seen.add(key);
  2122. return true;
  2123. });
  2124. }
  2125. exports.distinct = distinct;
  2126. function findLast(arr, predicate) {
  2127. const idx = lastIndex(arr, predicate);
  2128. if (idx === -1) {
  2129. return undefined;
  2130. }
  2131. return arr[idx];
  2132. }
  2133. exports.findLast = findLast;
  2134. function lastIndex(array, fn) {
  2135. for (let i = array.length - 1; i >= 0; i--) {
  2136. const element = array[i];
  2137. if (fn(element)) {
  2138. return i;
  2139. }
  2140. }
  2141. return -1;
  2142. }
  2143. exports.lastIndex = lastIndex;
  2144. function firstOrDefault(array, notFoundValue) {
  2145. return array.length > 0 ? array[0] : notFoundValue;
  2146. }
  2147. exports.firstOrDefault = firstOrDefault;
  2148. function flatten(arr) {
  2149. return [].concat(...arr);
  2150. }
  2151. exports.flatten = flatten;
  2152. function range(arg, to) {
  2153. let from = typeof to === 'number' ? arg : 0;
  2154. if (typeof to === 'number') {
  2155. from = arg;
  2156. }
  2157. else {
  2158. from = 0;
  2159. to = arg;
  2160. }
  2161. const result = [];
  2162. if (from <= to) {
  2163. for (let i = from; i < to; i++) {
  2164. result.push(i);
  2165. }
  2166. }
  2167. else {
  2168. for (let i = from; i > to; i--) {
  2169. result.push(i);
  2170. }
  2171. }
  2172. return result;
  2173. }
  2174. exports.range = range;
  2175. /**
  2176. * Insert `insertArr` inside `target` at `insertIndex`.
  2177. * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
  2178. */
  2179. function arrayInsert(target, insertIndex, insertArr) {
  2180. const before = target.slice(0, insertIndex);
  2181. const after = target.slice(insertIndex);
  2182. return before.concat(insertArr, after);
  2183. }
  2184. exports.arrayInsert = arrayInsert;
  2185. /**
  2186. * Pushes an element to the start of the array, if found.
  2187. */
  2188. function pushToStart(arr, value) {
  2189. const index = arr.indexOf(value);
  2190. if (index > -1) {
  2191. arr.splice(index, 1);
  2192. arr.unshift(value);
  2193. }
  2194. }
  2195. exports.pushToStart = pushToStart;
  2196. /**
  2197. * Pushes an element to the end of the array, if found.
  2198. */
  2199. function pushToEnd(arr, value) {
  2200. const index = arr.indexOf(value);
  2201. if (index > -1) {
  2202. arr.splice(index, 1);
  2203. arr.push(value);
  2204. }
  2205. }
  2206. exports.pushToEnd = pushToEnd;
  2207. function asArray(x) {
  2208. return Array.isArray(x) ? x : [x];
  2209. }
  2210. exports.asArray = asArray;
  2211. /**
  2212. * Insert the new items in the array.
  2213. * @param array The original array.
  2214. * @param start The zero-based location in the array from which to start inserting elements.
  2215. * @param newItems The items to be inserted
  2216. */
  2217. function insertInto(array, start, newItems) {
  2218. const startIdx = getActualStartIndex(array, start);
  2219. const originalLength = array.length;
  2220. const newItemsLength = newItems.length;
  2221. array.length = originalLength + newItemsLength;
  2222. // Move the items after the start index, start from the end so that we don't overwrite any value.
  2223. for (let i = originalLength - 1; i >= startIdx; i--) {
  2224. array[i + newItemsLength] = array[i];
  2225. }
  2226. for (let i = 0; i < newItemsLength; i++) {
  2227. array[i + startIdx] = newItems[i];
  2228. }
  2229. }
  2230. exports.insertInto = insertInto;
  2231. /**
  2232. * Removes elements from an array and inserts new elements in their place, returning the deleted elements. Alternative to the native Array.splice method, it
  2233. * can only support limited number of items due to the maximum call stack size limit.
  2234. * @param array The original array.
  2235. * @param start The zero-based location in the array from which to start removing elements.
  2236. * @param deleteCount The number of elements to remove.
  2237. * @returns An array containing the elements that were deleted.
  2238. */
  2239. function splice(array, start, deleteCount, newItems) {
  2240. const index = getActualStartIndex(array, start);
  2241. const result = array.splice(index, deleteCount);
  2242. insertInto(array, index, newItems);
  2243. return result;
  2244. }
  2245. exports.splice = splice;
  2246. /**
  2247. * Determine the actual start index (same logic as the native splice() or slice())
  2248. * If greater than the length of the array, start will be set to the length of the array. In this case, no element will be deleted but the method will behave as an adding function, adding as many element as item[n*] provided.
  2249. * If negative, it will begin that many elements from the end of the array. (In this case, the origin -1, meaning -n is the index of the nth last element, and is therefore equivalent to the index of array.length - n.) If array.length + start is less than 0, it will begin from index 0.
  2250. * @param array The target array.
  2251. * @param start The operation index.
  2252. */
  2253. function getActualStartIndex(array, start) {
  2254. return start < 0 ? Math.max(start + array.length, 0) : Math.min(start, array.length);
  2255. }
  2256. class ArrayQueue {
  2257. /**
  2258. * Constructs a queue that is backed by the given array. Runtime is O(1).
  2259. */
  2260. constructor(items) {
  2261. this.items = items;
  2262. this.firstIdx = 0;
  2263. this.lastIdx = this.items.length - 1;
  2264. }
  2265. /**
  2266. * Consumes elements from the beginning of the queue as long as the predicate returns true.
  2267. * If no elements were consumed, `null` is returned. Has a runtime of O(result.length).
  2268. */
  2269. takeWhile(predicate) {
  2270. // P(k) := k <= this.lastIdx && predicate(this.items[k])
  2271. // Find s := min { k | k >= this.firstIdx && !P(k) } and return this.data[this.firstIdx...s)
  2272. let startIdx = this.firstIdx;
  2273. while (startIdx < this.items.length && predicate(this.items[startIdx])) {
  2274. startIdx++;
  2275. }
  2276. const result = startIdx === this.firstIdx ? null : this.items.slice(this.firstIdx, startIdx);
  2277. this.firstIdx = startIdx;
  2278. return result;
  2279. }
  2280. /**
  2281. * Consumes elements from the end of the queue as long as the predicate returns true.
  2282. * If no elements were consumed, `null` is returned.
  2283. * The result has the same order as the underlying array!
  2284. */
  2285. takeFromEndWhile(predicate) {
  2286. // P(k) := this.firstIdx >= k && predicate(this.items[k])
  2287. // Find s := max { k | k <= this.lastIdx && !P(k) } and return this.data(s...this.lastIdx]
  2288. let endIdx = this.lastIdx;
  2289. while (endIdx >= 0 && predicate(this.items[endIdx])) {
  2290. endIdx--;
  2291. }
  2292. const result = endIdx === this.lastIdx ? null : this.items.slice(endIdx + 1, this.lastIdx + 1);
  2293. this.lastIdx = endIdx;
  2294. return result;
  2295. }
  2296. peek() {
  2297. return this.items[this.firstIdx];
  2298. }
  2299. dequeue() {
  2300. const result = this.items[this.firstIdx];
  2301. this.firstIdx++;
  2302. return result;
  2303. }
  2304. takeCount(count) {
  2305. const result = this.items.slice(this.firstIdx, this.firstIdx + count);
  2306. this.firstIdx += count;
  2307. return result;
  2308. }
  2309. }
  2310. exports.ArrayQueue = ArrayQueue;
  2311. });
  2312. /*---------------------------------------------------------------------------------------------
  2313. * Copyright (c) Microsoft Corporation. All rights reserved.
  2314. * Licensed under the MIT License. See License.txt in the project root for license information.
  2315. *--------------------------------------------------------------------------------------------*/
  2316. define(__m[16/*vs/base/common/diff/diffChange*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2317. "use strict";
  2318. Object.defineProperty(exports, "__esModule", { value: true });
  2319. exports.DiffChange = void 0;
  2320. /**
  2321. * Represents information about a specific difference between two sequences.
  2322. */
  2323. class DiffChange {
  2324. /**
  2325. * Constructs a new DiffChange with the given sequence information
  2326. * and content.
  2327. */
  2328. constructor(originalStart, originalLength, modifiedStart, modifiedLength) {
  2329. //Debug.Assert(originalLength > 0 || modifiedLength > 0, "originalLength and modifiedLength cannot both be <= 0");
  2330. this.originalStart = originalStart;
  2331. this.originalLength = originalLength;
  2332. this.modifiedStart = modifiedStart;
  2333. this.modifiedLength = modifiedLength;
  2334. }
  2335. /**
  2336. * The end point (exclusive) of the change in the original sequence.
  2337. */
  2338. getOriginalEnd() {
  2339. return this.originalStart + this.originalLength;
  2340. }
  2341. /**
  2342. * The end point (exclusive) of the change in the modified sequence.
  2343. */
  2344. getModifiedEnd() {
  2345. return this.modifiedStart + this.modifiedLength;
  2346. }
  2347. }
  2348. exports.DiffChange = DiffChange;
  2349. });
  2350. define(__m[8/*vs/base/common/errors*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2351. "use strict";
  2352. Object.defineProperty(exports, "__esModule", { value: true });
  2353. exports.NotSupportedError = exports.illegalState = exports.illegalArgument = exports.canceled = exports.isPromiseCanceledError = exports.transformErrorForSerialization = exports.onUnexpectedExternalError = exports.onUnexpectedError = exports.errorHandler = exports.ErrorHandler = void 0;
  2354. // Avoid circular dependency on EventEmitter by implementing a subset of the interface.
  2355. class ErrorHandler {
  2356. constructor() {
  2357. this.listeners = [];
  2358. this.unexpectedErrorHandler = function (e) {
  2359. setTimeout(() => {
  2360. if (e.stack) {
  2361. throw new Error(e.message + '\n\n' + e.stack);
  2362. }
  2363. throw e;
  2364. }, 0);
  2365. };
  2366. }
  2367. emit(e) {
  2368. this.listeners.forEach((listener) => {
  2369. listener(e);
  2370. });
  2371. }
  2372. onUnexpectedError(e) {
  2373. this.unexpectedErrorHandler(e);
  2374. this.emit(e);
  2375. }
  2376. // For external errors, we don't want the listeners to be called
  2377. onUnexpectedExternalError(e) {
  2378. this.unexpectedErrorHandler(e);
  2379. }
  2380. }
  2381. exports.ErrorHandler = ErrorHandler;
  2382. exports.errorHandler = new ErrorHandler();
  2383. function onUnexpectedError(e) {
  2384. // ignore errors from cancelled promises
  2385. if (!isPromiseCanceledError(e)) {
  2386. exports.errorHandler.onUnexpectedError(e);
  2387. }
  2388. return undefined;
  2389. }
  2390. exports.onUnexpectedError = onUnexpectedError;
  2391. function onUnexpectedExternalError(e) {
  2392. // ignore errors from cancelled promises
  2393. if (!isPromiseCanceledError(e)) {
  2394. exports.errorHandler.onUnexpectedExternalError(e);
  2395. }
  2396. return undefined;
  2397. }
  2398. exports.onUnexpectedExternalError = onUnexpectedExternalError;
  2399. function transformErrorForSerialization(error) {
  2400. if (error instanceof Error) {
  2401. let { name, message } = error;
  2402. const stack = error.stacktrace || error.stack;
  2403. return {
  2404. $isError: true,
  2405. name,
  2406. message,
  2407. stack
  2408. };
  2409. }
  2410. // return as is
  2411. return error;
  2412. }
  2413. exports.transformErrorForSerialization = transformErrorForSerialization;
  2414. const canceledName = 'Canceled';
  2415. /**
  2416. * Checks if the given error is a promise in canceled state
  2417. */
  2418. function isPromiseCanceledError(error) {
  2419. return error instanceof Error && error.name === canceledName && error.message === canceledName;
  2420. }
  2421. exports.isPromiseCanceledError = isPromiseCanceledError;
  2422. /**
  2423. * Returns an error that signals cancellation.
  2424. */
  2425. function canceled() {
  2426. const error = new Error(canceledName);
  2427. error.name = error.message;
  2428. return error;
  2429. }
  2430. exports.canceled = canceled;
  2431. function illegalArgument(name) {
  2432. if (name) {
  2433. return new Error(`Illegal argument: ${name}`);
  2434. }
  2435. else {
  2436. return new Error('Illegal argument');
  2437. }
  2438. }
  2439. exports.illegalArgument = illegalArgument;
  2440. function illegalState(name) {
  2441. if (name) {
  2442. return new Error(`Illegal state: ${name}`);
  2443. }
  2444. else {
  2445. return new Error('Illegal state');
  2446. }
  2447. }
  2448. exports.illegalState = illegalState;
  2449. class NotSupportedError extends Error {
  2450. constructor(message) {
  2451. super('NotSupported');
  2452. if (message) {
  2453. this.message = message;
  2454. }
  2455. }
  2456. }
  2457. exports.NotSupportedError = NotSupportedError;
  2458. });
  2459. /*---------------------------------------------------------------------------------------------
  2460. * Copyright (c) Microsoft Corporation. All rights reserved.
  2461. * Licensed under the MIT License. See License.txt in the project root for license information.
  2462. *--------------------------------------------------------------------------------------------*/
  2463. define(__m[17/*vs/base/common/functional*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2464. "use strict";
  2465. Object.defineProperty(exports, "__esModule", { value: true });
  2466. exports.once = void 0;
  2467. function once(fn) {
  2468. const _this = this;
  2469. let didCall = false;
  2470. let result;
  2471. return function () {
  2472. if (didCall) {
  2473. return result;
  2474. }
  2475. didCall = true;
  2476. result = fn.apply(_this, arguments);
  2477. return result;
  2478. };
  2479. }
  2480. exports.once = once;
  2481. });
  2482. /*---------------------------------------------------------------------------------------------
  2483. * Copyright (c) Microsoft Corporation. All rights reserved.
  2484. * Licensed under the MIT License. See License.txt in the project root for license information.
  2485. *--------------------------------------------------------------------------------------------*/
  2486. define(__m[18/*vs/base/common/iterator*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2487. "use strict";
  2488. Object.defineProperty(exports, "__esModule", { value: true });
  2489. exports.Iterable = void 0;
  2490. var Iterable;
  2491. (function (Iterable) {
  2492. function is(thing) {
  2493. return thing && typeof thing === 'object' && typeof thing[Symbol.iterator] === 'function';
  2494. }
  2495. Iterable.is = is;
  2496. const _empty = Object.freeze([]);
  2497. function empty() {
  2498. return _empty;
  2499. }
  2500. Iterable.empty = empty;
  2501. function* single(element) {
  2502. yield element;
  2503. }
  2504. Iterable.single = single;
  2505. function from(iterable) {
  2506. return iterable || _empty;
  2507. }
  2508. Iterable.from = from;
  2509. function isEmpty(iterable) {
  2510. return !iterable || iterable[Symbol.iterator]().next().done === true;
  2511. }
  2512. Iterable.isEmpty = isEmpty;
  2513. function first(iterable) {
  2514. return iterable[Symbol.iterator]().next().value;
  2515. }
  2516. Iterable.first = first;
  2517. function some(iterable, predicate) {
  2518. for (const element of iterable) {
  2519. if (predicate(element)) {
  2520. return true;
  2521. }
  2522. }
  2523. return false;
  2524. }
  2525. Iterable.some = some;
  2526. function find(iterable, predicate) {
  2527. for (const element of iterable) {
  2528. if (predicate(element)) {
  2529. return element;
  2530. }
  2531. }
  2532. return undefined;
  2533. }
  2534. Iterable.find = find;
  2535. function* filter(iterable, predicate) {
  2536. for (const element of iterable) {
  2537. if (predicate(element)) {
  2538. yield element;
  2539. }
  2540. }
  2541. }
  2542. Iterable.filter = filter;
  2543. function* map(iterable, fn) {
  2544. let index = 0;
  2545. for (const element of iterable) {
  2546. yield fn(element, index++);
  2547. }
  2548. }
  2549. Iterable.map = map;
  2550. function* concat(...iterables) {
  2551. for (const iterable of iterables) {
  2552. for (const element of iterable) {
  2553. yield element;
  2554. }
  2555. }
  2556. }
  2557. Iterable.concat = concat;
  2558. function* concatNested(iterables) {
  2559. for (const iterable of iterables) {
  2560. for (const element of iterable) {
  2561. yield element;
  2562. }
  2563. }
  2564. }
  2565. Iterable.concatNested = concatNested;
  2566. function reduce(iterable, reducer, initialValue) {
  2567. let value = initialValue;
  2568. for (const element of iterable) {
  2569. value = reducer(value, element);
  2570. }
  2571. return value;
  2572. }
  2573. Iterable.reduce = reduce;
  2574. /**
  2575. * Returns an iterable slice of the array, with the same semantics as `array.slice()`.
  2576. */
  2577. function* slice(arr, from, to = arr.length) {
  2578. if (from < 0) {
  2579. from += arr.length;
  2580. }
  2581. if (to < 0) {
  2582. to += arr.length;
  2583. }
  2584. else if (to > arr.length) {
  2585. to = arr.length;
  2586. }
  2587. for (; from < to; from++) {
  2588. yield arr[from];
  2589. }
  2590. }
  2591. Iterable.slice = slice;
  2592. /**
  2593. * Consumes `atMost` elements from iterable and returns the consumed elements,
  2594. * and an iterable for the rest of the elements.
  2595. */
  2596. function consume(iterable, atMost = Number.POSITIVE_INFINITY) {
  2597. const consumed = [];
  2598. if (atMost === 0) {
  2599. return [consumed, iterable];
  2600. }
  2601. const iterator = iterable[Symbol.iterator]();
  2602. for (let i = 0; i < atMost; i++) {
  2603. const next = iterator.next();
  2604. if (next.done) {
  2605. return [consumed, Iterable.empty()];
  2606. }
  2607. consumed.push(next.value);
  2608. }
  2609. return [consumed, { [Symbol.iterator]() { return iterator; } }];
  2610. }
  2611. Iterable.consume = consume;
  2612. /**
  2613. * Returns whether the iterables are the same length and all items are
  2614. * equal using the comparator function.
  2615. */
  2616. function equals(a, b, comparator = (at, bt) => at === bt) {
  2617. const ai = a[Symbol.iterator]();
  2618. const bi = b[Symbol.iterator]();
  2619. while (true) {
  2620. const an = ai.next();
  2621. const bn = bi.next();
  2622. if (an.done !== bn.done) {
  2623. return false;
  2624. }
  2625. else if (an.done) {
  2626. return true;
  2627. }
  2628. else if (!comparator(an.value, bn.value)) {
  2629. return false;
  2630. }
  2631. }
  2632. }
  2633. Iterable.equals = equals;
  2634. })(Iterable = exports.Iterable || (exports.Iterable = {}));
  2635. });
  2636. /*---------------------------------------------------------------------------------------------
  2637. * Copyright (c) Microsoft Corporation. All rights reserved.
  2638. * Licensed under the MIT License. See License.txt in the project root for license information.
  2639. *--------------------------------------------------------------------------------------------*/
  2640. define(__m[19/*vs/base/common/keyCodes*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2641. "use strict";
  2642. Object.defineProperty(exports, "__esModule", { value: true });
  2643. exports.KeyChord = exports.KeyCodeUtils = exports.IMMUTABLE_KEY_CODE_TO_CODE = exports.IMMUTABLE_CODE_TO_KEY_CODE = exports.NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE = exports.EVENT_KEY_CODE_MAP = void 0;
  2644. class KeyCodeStrMap {
  2645. constructor() {
  2646. this._keyCodeToStr = [];
  2647. this._strToKeyCode = Object.create(null);
  2648. }
  2649. define(keyCode, str) {
  2650. this._keyCodeToStr[keyCode] = str;
  2651. this._strToKeyCode[str.toLowerCase()] = keyCode;
  2652. }
  2653. keyCodeToStr(keyCode) {
  2654. return this._keyCodeToStr[keyCode];
  2655. }
  2656. strToKeyCode(str) {
  2657. return this._strToKeyCode[str.toLowerCase()] || 0 /* Unknown */;
  2658. }
  2659. }
  2660. const uiMap = new KeyCodeStrMap();
  2661. const userSettingsUSMap = new KeyCodeStrMap();
  2662. const userSettingsGeneralMap = new KeyCodeStrMap();
  2663. exports.EVENT_KEY_CODE_MAP = new Array(230);
  2664. exports.NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE = {};
  2665. const scanCodeIntToStr = [];
  2666. const scanCodeStrToInt = Object.create(null);
  2667. const scanCodeLowerCaseStrToInt = Object.create(null);
  2668. /**
  2669. * -1 if a ScanCode => KeyCode mapping depends on kb layout.
  2670. */
  2671. exports.IMMUTABLE_CODE_TO_KEY_CODE = [];
  2672. /**
  2673. * -1 if a KeyCode => ScanCode mapping depends on kb layout.
  2674. */
  2675. exports.IMMUTABLE_KEY_CODE_TO_CODE = [];
  2676. for (let i = 0; i <= 193 /* MAX_VALUE */; i++) {
  2677. exports.IMMUTABLE_CODE_TO_KEY_CODE[i] = -1 /* DependsOnKbLayout */;
  2678. }
  2679. for (let i = 0; i <= 126 /* MAX_VALUE */; i++) {
  2680. exports.IMMUTABLE_KEY_CODE_TO_CODE[i] = -1 /* DependsOnKbLayout */;
  2681. }
  2682. (function () {
  2683. // See https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  2684. // See https://github.com/microsoft/node-native-keymap/blob/master/deps/chromium/keyboard_codes_win.h
  2685. const empty = '';
  2686. const mappings = [
  2687. // keyCodeOrd, immutable, scanCode, scanCodeStr, keyCode, keyCodeStr, eventKeyCode, vkey, usUserSettingsLabel, generalUserSettingsLabel
  2688. [0, 1, 0 /* None */, 'None', 0 /* Unknown */, 'unknown', 0, 'VK_UNKNOWN', empty, empty],
  2689. [0, 1, 1 /* Hyper */, 'Hyper', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2690. [0, 1, 2 /* Super */, 'Super', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2691. [0, 1, 3 /* Fn */, 'Fn', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2692. [0, 1, 4 /* FnLock */, 'FnLock', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2693. [0, 1, 5 /* Suspend */, 'Suspend', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2694. [0, 1, 6 /* Resume */, 'Resume', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2695. [0, 1, 7 /* Turbo */, 'Turbo', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2696. [0, 1, 8 /* Sleep */, 'Sleep', 0 /* Unknown */, empty, 0, 'VK_SLEEP', empty, empty],
  2697. [0, 1, 9 /* WakeUp */, 'WakeUp', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2698. [31, 0, 10 /* KeyA */, 'KeyA', 31 /* KeyA */, 'A', 65, 'VK_A', empty, empty],
  2699. [32, 0, 11 /* KeyB */, 'KeyB', 32 /* KeyB */, 'B', 66, 'VK_B', empty, empty],
  2700. [33, 0, 12 /* KeyC */, 'KeyC', 33 /* KeyC */, 'C', 67, 'VK_C', empty, empty],
  2701. [34, 0, 13 /* KeyD */, 'KeyD', 34 /* KeyD */, 'D', 68, 'VK_D', empty, empty],
  2702. [35, 0, 14 /* KeyE */, 'KeyE', 35 /* KeyE */, 'E', 69, 'VK_E', empty, empty],
  2703. [36, 0, 15 /* KeyF */, 'KeyF', 36 /* KeyF */, 'F', 70, 'VK_F', empty, empty],
  2704. [37, 0, 16 /* KeyG */, 'KeyG', 37 /* KeyG */, 'G', 71, 'VK_G', empty, empty],
  2705. [38, 0, 17 /* KeyH */, 'KeyH', 38 /* KeyH */, 'H', 72, 'VK_H', empty, empty],
  2706. [39, 0, 18 /* KeyI */, 'KeyI', 39 /* KeyI */, 'I', 73, 'VK_I', empty, empty],
  2707. [40, 0, 19 /* KeyJ */, 'KeyJ', 40 /* KeyJ */, 'J', 74, 'VK_J', empty, empty],
  2708. [41, 0, 20 /* KeyK */, 'KeyK', 41 /* KeyK */, 'K', 75, 'VK_K', empty, empty],
  2709. [42, 0, 21 /* KeyL */, 'KeyL', 42 /* KeyL */, 'L', 76, 'VK_L', empty, empty],
  2710. [43, 0, 22 /* KeyM */, 'KeyM', 43 /* KeyM */, 'M', 77, 'VK_M', empty, empty],
  2711. [44, 0, 23 /* KeyN */, 'KeyN', 44 /* KeyN */, 'N', 78, 'VK_N', empty, empty],
  2712. [45, 0, 24 /* KeyO */, 'KeyO', 45 /* KeyO */, 'O', 79, 'VK_O', empty, empty],
  2713. [46, 0, 25 /* KeyP */, 'KeyP', 46 /* KeyP */, 'P', 80, 'VK_P', empty, empty],
  2714. [47, 0, 26 /* KeyQ */, 'KeyQ', 47 /* KeyQ */, 'Q', 81, 'VK_Q', empty, empty],
  2715. [48, 0, 27 /* KeyR */, 'KeyR', 48 /* KeyR */, 'R', 82, 'VK_R', empty, empty],
  2716. [49, 0, 28 /* KeyS */, 'KeyS', 49 /* KeyS */, 'S', 83, 'VK_S', empty, empty],
  2717. [50, 0, 29 /* KeyT */, 'KeyT', 50 /* KeyT */, 'T', 84, 'VK_T', empty, empty],
  2718. [51, 0, 30 /* KeyU */, 'KeyU', 51 /* KeyU */, 'U', 85, 'VK_U', empty, empty],
  2719. [52, 0, 31 /* KeyV */, 'KeyV', 52 /* KeyV */, 'V', 86, 'VK_V', empty, empty],
  2720. [53, 0, 32 /* KeyW */, 'KeyW', 53 /* KeyW */, 'W', 87, 'VK_W', empty, empty],
  2721. [54, 0, 33 /* KeyX */, 'KeyX', 54 /* KeyX */, 'X', 88, 'VK_X', empty, empty],
  2722. [55, 0, 34 /* KeyY */, 'KeyY', 55 /* KeyY */, 'Y', 89, 'VK_Y', empty, empty],
  2723. [56, 0, 35 /* KeyZ */, 'KeyZ', 56 /* KeyZ */, 'Z', 90, 'VK_Z', empty, empty],
  2724. [22, 0, 36 /* Digit1 */, 'Digit1', 22 /* Digit1 */, '1', 49, 'VK_1', empty, empty],
  2725. [23, 0, 37 /* Digit2 */, 'Digit2', 23 /* Digit2 */, '2', 50, 'VK_2', empty, empty],
  2726. [24, 0, 38 /* Digit3 */, 'Digit3', 24 /* Digit3 */, '3', 51, 'VK_3', empty, empty],
  2727. [25, 0, 39 /* Digit4 */, 'Digit4', 25 /* Digit4 */, '4', 52, 'VK_4', empty, empty],
  2728. [26, 0, 40 /* Digit5 */, 'Digit5', 26 /* Digit5 */, '5', 53, 'VK_5', empty, empty],
  2729. [27, 0, 41 /* Digit6 */, 'Digit6', 27 /* Digit6 */, '6', 54, 'VK_6', empty, empty],
  2730. [28, 0, 42 /* Digit7 */, 'Digit7', 28 /* Digit7 */, '7', 55, 'VK_7', empty, empty],
  2731. [29, 0, 43 /* Digit8 */, 'Digit8', 29 /* Digit8 */, '8', 56, 'VK_8', empty, empty],
  2732. [30, 0, 44 /* Digit9 */, 'Digit9', 30 /* Digit9 */, '9', 57, 'VK_9', empty, empty],
  2733. [21, 0, 45 /* Digit0 */, 'Digit0', 21 /* Digit0 */, '0', 48, 'VK_0', empty, empty],
  2734. [3, 1, 46 /* Enter */, 'Enter', 3 /* Enter */, 'Enter', 13, 'VK_RETURN', empty, empty],
  2735. [9, 1, 47 /* Escape */, 'Escape', 9 /* Escape */, 'Escape', 27, 'VK_ESCAPE', empty, empty],
  2736. [1, 1, 48 /* Backspace */, 'Backspace', 1 /* Backspace */, 'Backspace', 8, 'VK_BACK', empty, empty],
  2737. [2, 1, 49 /* Tab */, 'Tab', 2 /* Tab */, 'Tab', 9, 'VK_TAB', empty, empty],
  2738. [10, 1, 50 /* Space */, 'Space', 10 /* Space */, 'Space', 32, 'VK_SPACE', empty, empty],
  2739. [83, 0, 51 /* Minus */, 'Minus', 83 /* Minus */, '-', 189, 'VK_OEM_MINUS', '-', 'OEM_MINUS'],
  2740. [81, 0, 52 /* Equal */, 'Equal', 81 /* Equal */, '=', 187, 'VK_OEM_PLUS', '=', 'OEM_PLUS'],
  2741. [87, 0, 53 /* BracketLeft */, 'BracketLeft', 87 /* BracketLeft */, '[', 219, 'VK_OEM_4', '[', 'OEM_4'],
  2742. [89, 0, 54 /* BracketRight */, 'BracketRight', 89 /* BracketRight */, ']', 221, 'VK_OEM_6', ']', 'OEM_6'],
  2743. [88, 0, 55 /* Backslash */, 'Backslash', 88 /* Backslash */, '\\', 220, 'VK_OEM_5', '\\', 'OEM_5'],
  2744. [0, 0, 56 /* IntlHash */, 'IntlHash', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2745. [80, 0, 57 /* Semicolon */, 'Semicolon', 80 /* Semicolon */, ';', 186, 'VK_OEM_1', ';', 'OEM_1'],
  2746. [90, 0, 58 /* Quote */, 'Quote', 90 /* Quote */, '\'', 222, 'VK_OEM_7', '\'', 'OEM_7'],
  2747. [86, 0, 59 /* Backquote */, 'Backquote', 86 /* Backquote */, '`', 192, 'VK_OEM_3', '`', 'OEM_3'],
  2748. [82, 0, 60 /* Comma */, 'Comma', 82 /* Comma */, ',', 188, 'VK_OEM_COMMA', ',', 'OEM_COMMA'],
  2749. [84, 0, 61 /* Period */, 'Period', 84 /* Period */, '.', 190, 'VK_OEM_PERIOD', '.', 'OEM_PERIOD'],
  2750. [85, 0, 62 /* Slash */, 'Slash', 85 /* Slash */, '/', 191, 'VK_OEM_2', '/', 'OEM_2'],
  2751. [8, 1, 63 /* CapsLock */, 'CapsLock', 8 /* CapsLock */, 'CapsLock', 20, 'VK_CAPITAL', empty, empty],
  2752. [59, 1, 64 /* F1 */, 'F1', 59 /* F1 */, 'F1', 112, 'VK_F1', empty, empty],
  2753. [60, 1, 65 /* F2 */, 'F2', 60 /* F2 */, 'F2', 113, 'VK_F2', empty, empty],
  2754. [61, 1, 66 /* F3 */, 'F3', 61 /* F3 */, 'F3', 114, 'VK_F3', empty, empty],
  2755. [62, 1, 67 /* F4 */, 'F4', 62 /* F4 */, 'F4', 115, 'VK_F4', empty, empty],
  2756. [63, 1, 68 /* F5 */, 'F5', 63 /* F5 */, 'F5', 116, 'VK_F5', empty, empty],
  2757. [64, 1, 69 /* F6 */, 'F6', 64 /* F6 */, 'F6', 117, 'VK_F6', empty, empty],
  2758. [65, 1, 70 /* F7 */, 'F7', 65 /* F7 */, 'F7', 118, 'VK_F7', empty, empty],
  2759. [66, 1, 71 /* F8 */, 'F8', 66 /* F8 */, 'F8', 119, 'VK_F8', empty, empty],
  2760. [67, 1, 72 /* F9 */, 'F9', 67 /* F9 */, 'F9', 120, 'VK_F9', empty, empty],
  2761. [68, 1, 73 /* F10 */, 'F10', 68 /* F10 */, 'F10', 121, 'VK_F10', empty, empty],
  2762. [69, 1, 74 /* F11 */, 'F11', 69 /* F11 */, 'F11', 122, 'VK_F11', empty, empty],
  2763. [70, 1, 75 /* F12 */, 'F12', 70 /* F12 */, 'F12', 123, 'VK_F12', empty, empty],
  2764. [0, 1, 76 /* PrintScreen */, 'PrintScreen', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2765. [79, 1, 77 /* ScrollLock */, 'ScrollLock', 79 /* ScrollLock */, 'ScrollLock', 145, 'VK_SCROLL', empty, empty],
  2766. [7, 1, 78 /* Pause */, 'Pause', 7 /* PauseBreak */, 'PauseBreak', 19, 'VK_PAUSE', empty, empty],
  2767. [19, 1, 79 /* Insert */, 'Insert', 19 /* Insert */, 'Insert', 45, 'VK_INSERT', empty, empty],
  2768. [14, 1, 80 /* Home */, 'Home', 14 /* Home */, 'Home', 36, 'VK_HOME', empty, empty],
  2769. [11, 1, 81 /* PageUp */, 'PageUp', 11 /* PageUp */, 'PageUp', 33, 'VK_PRIOR', empty, empty],
  2770. [20, 1, 82 /* Delete */, 'Delete', 20 /* Delete */, 'Delete', 46, 'VK_DELETE', empty, empty],
  2771. [13, 1, 83 /* End */, 'End', 13 /* End */, 'End', 35, 'VK_END', empty, empty],
  2772. [12, 1, 84 /* PageDown */, 'PageDown', 12 /* PageDown */, 'PageDown', 34, 'VK_NEXT', empty, empty],
  2773. [17, 1, 85 /* ArrowRight */, 'ArrowRight', 17 /* RightArrow */, 'RightArrow', 39, 'VK_RIGHT', 'Right', empty],
  2774. [15, 1, 86 /* ArrowLeft */, 'ArrowLeft', 15 /* LeftArrow */, 'LeftArrow', 37, 'VK_LEFT', 'Left', empty],
  2775. [18, 1, 87 /* ArrowDown */, 'ArrowDown', 18 /* DownArrow */, 'DownArrow', 40, 'VK_DOWN', 'Down', empty],
  2776. [16, 1, 88 /* ArrowUp */, 'ArrowUp', 16 /* UpArrow */, 'UpArrow', 38, 'VK_UP', 'Up', empty],
  2777. [78, 1, 89 /* NumLock */, 'NumLock', 78 /* NumLock */, 'NumLock', 144, 'VK_NUMLOCK', empty, empty],
  2778. [108, 1, 90 /* NumpadDivide */, 'NumpadDivide', 108 /* NumpadDivide */, 'NumPad_Divide', 111, 'VK_DIVIDE', empty, empty],
  2779. [103, 1, 91 /* NumpadMultiply */, 'NumpadMultiply', 103 /* NumpadMultiply */, 'NumPad_Multiply', 106, 'VK_MULTIPLY', empty, empty],
  2780. [106, 1, 92 /* NumpadSubtract */, 'NumpadSubtract', 106 /* NumpadSubtract */, 'NumPad_Subtract', 109, 'VK_SUBTRACT', empty, empty],
  2781. [104, 1, 93 /* NumpadAdd */, 'NumpadAdd', 104 /* NumpadAdd */, 'NumPad_Add', 107, 'VK_ADD', empty, empty],
  2782. [3, 1, 94 /* NumpadEnter */, 'NumpadEnter', 3 /* Enter */, empty, 0, empty, empty, empty],
  2783. [94, 1, 95 /* Numpad1 */, 'Numpad1', 94 /* Numpad1 */, 'NumPad1', 97, 'VK_NUMPAD1', empty, empty],
  2784. [95, 1, 96 /* Numpad2 */, 'Numpad2', 95 /* Numpad2 */, 'NumPad2', 98, 'VK_NUMPAD2', empty, empty],
  2785. [96, 1, 97 /* Numpad3 */, 'Numpad3', 96 /* Numpad3 */, 'NumPad3', 99, 'VK_NUMPAD3', empty, empty],
  2786. [97, 1, 98 /* Numpad4 */, 'Numpad4', 97 /* Numpad4 */, 'NumPad4', 100, 'VK_NUMPAD4', empty, empty],
  2787. [98, 1, 99 /* Numpad5 */, 'Numpad5', 98 /* Numpad5 */, 'NumPad5', 101, 'VK_NUMPAD5', empty, empty],
  2788. [99, 1, 100 /* Numpad6 */, 'Numpad6', 99 /* Numpad6 */, 'NumPad6', 102, 'VK_NUMPAD6', empty, empty],
  2789. [100, 1, 101 /* Numpad7 */, 'Numpad7', 100 /* Numpad7 */, 'NumPad7', 103, 'VK_NUMPAD7', empty, empty],
  2790. [101, 1, 102 /* Numpad8 */, 'Numpad8', 101 /* Numpad8 */, 'NumPad8', 104, 'VK_NUMPAD8', empty, empty],
  2791. [102, 1, 103 /* Numpad9 */, 'Numpad9', 102 /* Numpad9 */, 'NumPad9', 105, 'VK_NUMPAD9', empty, empty],
  2792. [93, 1, 104 /* Numpad0 */, 'Numpad0', 93 /* Numpad0 */, 'NumPad0', 96, 'VK_NUMPAD0', empty, empty],
  2793. [107, 1, 105 /* NumpadDecimal */, 'NumpadDecimal', 107 /* NumpadDecimal */, 'NumPad_Decimal', 110, 'VK_DECIMAL', empty, empty],
  2794. [92, 0, 106 /* IntlBackslash */, 'IntlBackslash', 92 /* IntlBackslash */, 'OEM_102', 226, 'VK_OEM_102', empty, empty],
  2795. [58, 1, 107 /* ContextMenu */, 'ContextMenu', 58 /* ContextMenu */, 'ContextMenu', 93, empty, empty, empty],
  2796. [0, 1, 108 /* Power */, 'Power', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2797. [0, 1, 109 /* NumpadEqual */, 'NumpadEqual', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2798. [71, 1, 110 /* F13 */, 'F13', 71 /* F13 */, 'F13', 124, 'VK_F13', empty, empty],
  2799. [72, 1, 111 /* F14 */, 'F14', 72 /* F14 */, 'F14', 125, 'VK_F14', empty, empty],
  2800. [73, 1, 112 /* F15 */, 'F15', 73 /* F15 */, 'F15', 126, 'VK_F15', empty, empty],
  2801. [74, 1, 113 /* F16 */, 'F16', 74 /* F16 */, 'F16', 127, 'VK_F16', empty, empty],
  2802. [75, 1, 114 /* F17 */, 'F17', 75 /* F17 */, 'F17', 128, 'VK_F17', empty, empty],
  2803. [76, 1, 115 /* F18 */, 'F18', 76 /* F18 */, 'F18', 129, 'VK_F18', empty, empty],
  2804. [77, 1, 116 /* F19 */, 'F19', 77 /* F19 */, 'F19', 130, 'VK_F19', empty, empty],
  2805. [0, 1, 117 /* F20 */, 'F20', 0 /* Unknown */, empty, 0, 'VK_F20', empty, empty],
  2806. [0, 1, 118 /* F21 */, 'F21', 0 /* Unknown */, empty, 0, 'VK_F21', empty, empty],
  2807. [0, 1, 119 /* F22 */, 'F22', 0 /* Unknown */, empty, 0, 'VK_F22', empty, empty],
  2808. [0, 1, 120 /* F23 */, 'F23', 0 /* Unknown */, empty, 0, 'VK_F23', empty, empty],
  2809. [0, 1, 121 /* F24 */, 'F24', 0 /* Unknown */, empty, 0, 'VK_F24', empty, empty],
  2810. [0, 1, 122 /* Open */, 'Open', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2811. [0, 1, 123 /* Help */, 'Help', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2812. [0, 1, 124 /* Select */, 'Select', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2813. [0, 1, 125 /* Again */, 'Again', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2814. [0, 1, 126 /* Undo */, 'Undo', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2815. [0, 1, 127 /* Cut */, 'Cut', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2816. [0, 1, 128 /* Copy */, 'Copy', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2817. [0, 1, 129 /* Paste */, 'Paste', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2818. [0, 1, 130 /* Find */, 'Find', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2819. [0, 1, 131 /* AudioVolumeMute */, 'AudioVolumeMute', 112 /* AudioVolumeMute */, 'AudioVolumeMute', 173, 'VK_VOLUME_MUTE', empty, empty],
  2820. [0, 1, 132 /* AudioVolumeUp */, 'AudioVolumeUp', 113 /* AudioVolumeUp */, 'AudioVolumeUp', 175, 'VK_VOLUME_UP', empty, empty],
  2821. [0, 1, 133 /* AudioVolumeDown */, 'AudioVolumeDown', 114 /* AudioVolumeDown */, 'AudioVolumeDown', 174, 'VK_VOLUME_DOWN', empty, empty],
  2822. [105, 1, 134 /* NumpadComma */, 'NumpadComma', 105 /* NUMPAD_SEPARATOR */, 'NumPad_Separator', 108, 'VK_SEPARATOR', empty, empty],
  2823. [110, 0, 135 /* IntlRo */, 'IntlRo', 110 /* ABNT_C1 */, 'ABNT_C1', 193, 'VK_ABNT_C1', empty, empty],
  2824. [0, 1, 136 /* KanaMode */, 'KanaMode', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2825. [0, 0, 137 /* IntlYen */, 'IntlYen', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2826. [0, 1, 138 /* Convert */, 'Convert', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2827. [0, 1, 139 /* NonConvert */, 'NonConvert', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2828. [0, 1, 140 /* Lang1 */, 'Lang1', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2829. [0, 1, 141 /* Lang2 */, 'Lang2', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2830. [0, 1, 142 /* Lang3 */, 'Lang3', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2831. [0, 1, 143 /* Lang4 */, 'Lang4', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2832. [0, 1, 144 /* Lang5 */, 'Lang5', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2833. [0, 1, 145 /* Abort */, 'Abort', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2834. [0, 1, 146 /* Props */, 'Props', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2835. [0, 1, 147 /* NumpadParenLeft */, 'NumpadParenLeft', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2836. [0, 1, 148 /* NumpadParenRight */, 'NumpadParenRight', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2837. [0, 1, 149 /* NumpadBackspace */, 'NumpadBackspace', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2838. [0, 1, 150 /* NumpadMemoryStore */, 'NumpadMemoryStore', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2839. [0, 1, 151 /* NumpadMemoryRecall */, 'NumpadMemoryRecall', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2840. [0, 1, 152 /* NumpadMemoryClear */, 'NumpadMemoryClear', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2841. [0, 1, 153 /* NumpadMemoryAdd */, 'NumpadMemoryAdd', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2842. [0, 1, 154 /* NumpadMemorySubtract */, 'NumpadMemorySubtract', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2843. [0, 1, 155 /* NumpadClear */, 'NumpadClear', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2844. [0, 1, 156 /* NumpadClearEntry */, 'NumpadClearEntry', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2845. [5, 1, 0 /* None */, empty, 5 /* Ctrl */, 'Ctrl', 17, 'VK_CONTROL', empty, empty],
  2846. [4, 1, 0 /* None */, empty, 4 /* Shift */, 'Shift', 16, 'VK_SHIFT', empty, empty],
  2847. [6, 1, 0 /* None */, empty, 6 /* Alt */, 'Alt', 18, 'VK_MENU', empty, empty],
  2848. [57, 1, 0 /* None */, empty, 57 /* Meta */, 'Meta', 0, 'VK_COMMAND', empty, empty],
  2849. [5, 1, 157 /* ControlLeft */, 'ControlLeft', 5 /* Ctrl */, empty, 0, 'VK_LCONTROL', empty, empty],
  2850. [4, 1, 158 /* ShiftLeft */, 'ShiftLeft', 4 /* Shift */, empty, 0, 'VK_LSHIFT', empty, empty],
  2851. [6, 1, 159 /* AltLeft */, 'AltLeft', 6 /* Alt */, empty, 0, 'VK_LMENU', empty, empty],
  2852. [57, 1, 160 /* MetaLeft */, 'MetaLeft', 57 /* Meta */, empty, 0, 'VK_LWIN', empty, empty],
  2853. [5, 1, 161 /* ControlRight */, 'ControlRight', 5 /* Ctrl */, empty, 0, 'VK_RCONTROL', empty, empty],
  2854. [4, 1, 162 /* ShiftRight */, 'ShiftRight', 4 /* Shift */, empty, 0, 'VK_RSHIFT', empty, empty],
  2855. [6, 1, 163 /* AltRight */, 'AltRight', 6 /* Alt */, empty, 0, 'VK_RMENU', empty, empty],
  2856. [57, 1, 164 /* MetaRight */, 'MetaRight', 57 /* Meta */, empty, 0, 'VK_RWIN', empty, empty],
  2857. [0, 1, 165 /* BrightnessUp */, 'BrightnessUp', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2858. [0, 1, 166 /* BrightnessDown */, 'BrightnessDown', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2859. [0, 1, 167 /* MediaPlay */, 'MediaPlay', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2860. [0, 1, 168 /* MediaRecord */, 'MediaRecord', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2861. [0, 1, 169 /* MediaFastForward */, 'MediaFastForward', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2862. [0, 1, 170 /* MediaRewind */, 'MediaRewind', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2863. [114, 1, 171 /* MediaTrackNext */, 'MediaTrackNext', 119 /* MediaTrackNext */, 'MediaTrackNext', 176, 'VK_MEDIA_NEXT_TRACK', empty, empty],
  2864. [115, 1, 172 /* MediaTrackPrevious */, 'MediaTrackPrevious', 120 /* MediaTrackPrevious */, 'MediaTrackPrevious', 177, 'VK_MEDIA_PREV_TRACK', empty, empty],
  2865. [116, 1, 173 /* MediaStop */, 'MediaStop', 121 /* MediaStop */, 'MediaStop', 178, 'VK_MEDIA_STOP', empty, empty],
  2866. [0, 1, 174 /* Eject */, 'Eject', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2867. [117, 1, 175 /* MediaPlayPause */, 'MediaPlayPause', 122 /* MediaPlayPause */, 'MediaPlayPause', 179, 'VK_MEDIA_PLAY_PAUSE', empty, empty],
  2868. [0, 1, 176 /* MediaSelect */, 'MediaSelect', 123 /* LaunchMediaPlayer */, 'LaunchMediaPlayer', 181, 'VK_MEDIA_LAUNCH_MEDIA_SELECT', empty, empty],
  2869. [0, 1, 177 /* LaunchMail */, 'LaunchMail', 124 /* LaunchMail */, 'LaunchMail', 180, 'VK_MEDIA_LAUNCH_MAIL', empty, empty],
  2870. [0, 1, 178 /* LaunchApp2 */, 'LaunchApp2', 125 /* LaunchApp2 */, 'LaunchApp2', 183, 'VK_MEDIA_LAUNCH_APP2', empty, empty],
  2871. [0, 1, 179 /* LaunchApp1 */, 'LaunchApp1', 0 /* Unknown */, empty, 0, 'VK_MEDIA_LAUNCH_APP1', empty, empty],
  2872. [0, 1, 180 /* SelectTask */, 'SelectTask', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2873. [0, 1, 181 /* LaunchScreenSaver */, 'LaunchScreenSaver', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2874. [0, 1, 182 /* BrowserSearch */, 'BrowserSearch', 115 /* BrowserSearch */, 'BrowserSearch', 170, 'VK_BROWSER_SEARCH', empty, empty],
  2875. [0, 1, 183 /* BrowserHome */, 'BrowserHome', 116 /* BrowserHome */, 'BrowserHome', 172, 'VK_BROWSER_HOME', empty, empty],
  2876. [112, 1, 184 /* BrowserBack */, 'BrowserBack', 117 /* BrowserBack */, 'BrowserBack', 166, 'VK_BROWSER_BACK', empty, empty],
  2877. [113, 1, 185 /* BrowserForward */, 'BrowserForward', 118 /* BrowserForward */, 'BrowserForward', 167, 'VK_BROWSER_FORWARD', empty, empty],
  2878. [0, 1, 186 /* BrowserStop */, 'BrowserStop', 0 /* Unknown */, empty, 0, 'VK_BROWSER_STOP', empty, empty],
  2879. [0, 1, 187 /* BrowserRefresh */, 'BrowserRefresh', 0 /* Unknown */, empty, 0, 'VK_BROWSER_REFRESH', empty, empty],
  2880. [0, 1, 188 /* BrowserFavorites */, 'BrowserFavorites', 0 /* Unknown */, empty, 0, 'VK_BROWSER_FAVORITES', empty, empty],
  2881. [0, 1, 189 /* ZoomToggle */, 'ZoomToggle', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2882. [0, 1, 190 /* MailReply */, 'MailReply', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2883. [0, 1, 191 /* MailForward */, 'MailForward', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2884. [0, 1, 192 /* MailSend */, 'MailSend', 0 /* Unknown */, empty, 0, empty, empty, empty],
  2885. // See https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html
  2886. // If an Input Method Editor is processing key input and the event is keydown, return 229.
  2887. [109, 1, 0 /* None */, empty, 109 /* KEY_IN_COMPOSITION */, 'KeyInComposition', 229, empty, empty, empty],
  2888. [111, 1, 0 /* None */, empty, 111 /* ABNT_C2 */, 'ABNT_C2', 194, 'VK_ABNT_C2', empty, empty],
  2889. [91, 1, 0 /* None */, empty, 91 /* OEM_8 */, 'OEM_8', 223, 'VK_OEM_8', empty, empty],
  2890. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_CLEAR', empty, empty],
  2891. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_KANA', empty, empty],
  2892. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_HANGUL', empty, empty],
  2893. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_JUNJA', empty, empty],
  2894. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_FINAL', empty, empty],
  2895. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_HANJA', empty, empty],
  2896. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_KANJI', empty, empty],
  2897. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_CONVERT', empty, empty],
  2898. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_NONCONVERT', empty, empty],
  2899. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_ACCEPT', empty, empty],
  2900. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_MODECHANGE', empty, empty],
  2901. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_SELECT', empty, empty],
  2902. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_PRINT', empty, empty],
  2903. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_EXECUTE', empty, empty],
  2904. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_SNAPSHOT', empty, empty],
  2905. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_HELP', empty, empty],
  2906. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_APPS', empty, empty],
  2907. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_PROCESSKEY', empty, empty],
  2908. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_PACKET', empty, empty],
  2909. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_DBE_SBCSCHAR', empty, empty],
  2910. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_DBE_DBCSCHAR', empty, empty],
  2911. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_ATTN', empty, empty],
  2912. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_CRSEL', empty, empty],
  2913. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_EXSEL', empty, empty],
  2914. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_EREOF', empty, empty],
  2915. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_PLAY', empty, empty],
  2916. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_ZOOM', empty, empty],
  2917. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_NONAME', empty, empty],
  2918. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_PA1', empty, empty],
  2919. [0, 1, 0 /* None */, empty, 0 /* Unknown */, empty, 0, 'VK_OEM_CLEAR', empty, empty],
  2920. ];
  2921. let seenKeyCode = [];
  2922. let seenScanCode = [];
  2923. for (const mapping of mappings) {
  2924. const [_keyCodeOrd, immutable, scanCode, scanCodeStr, keyCode, keyCodeStr, eventKeyCode, vkey, usUserSettingsLabel, generalUserSettingsLabel] = mapping;
  2925. if (!seenScanCode[scanCode]) {
  2926. seenScanCode[scanCode] = true;
  2927. scanCodeIntToStr[scanCode] = scanCodeStr;
  2928. scanCodeStrToInt[scanCodeStr] = scanCode;
  2929. scanCodeLowerCaseStrToInt[scanCodeStr.toLowerCase()] = scanCode;
  2930. if (immutable) {
  2931. exports.IMMUTABLE_CODE_TO_KEY_CODE[scanCode] = keyCode;
  2932. if ((keyCode !== 0 /* Unknown */)
  2933. && (keyCode !== 3 /* Enter */)
  2934. && (keyCode !== 5 /* Ctrl */)
  2935. && (keyCode !== 4 /* Shift */)
  2936. && (keyCode !== 6 /* Alt */)
  2937. && (keyCode !== 57 /* Meta */)) {
  2938. exports.IMMUTABLE_KEY_CODE_TO_CODE[keyCode] = scanCode;
  2939. }
  2940. }
  2941. }
  2942. if (!seenKeyCode[keyCode]) {
  2943. seenKeyCode[keyCode] = true;
  2944. if (!keyCodeStr) {
  2945. throw new Error(`String representation missing for key code ${keyCode} around scan code ${scanCodeStr}`);
  2946. }
  2947. uiMap.define(keyCode, keyCodeStr);
  2948. userSettingsUSMap.define(keyCode, usUserSettingsLabel || keyCodeStr);
  2949. userSettingsGeneralMap.define(keyCode, generalUserSettingsLabel || usUserSettingsLabel || keyCodeStr);
  2950. }
  2951. if (eventKeyCode) {
  2952. exports.EVENT_KEY_CODE_MAP[eventKeyCode] = keyCode;
  2953. }
  2954. if (vkey) {
  2955. exports.NATIVE_WINDOWS_KEY_CODE_TO_KEY_CODE[vkey] = keyCode;
  2956. }
  2957. }
  2958. // Manually added due to the exclusion above (due to duplication with NumpadEnter)
  2959. exports.IMMUTABLE_KEY_CODE_TO_CODE[3 /* Enter */] = 46 /* Enter */;
  2960. })();
  2961. var KeyCodeUtils;
  2962. (function (KeyCodeUtils) {
  2963. function toString(keyCode) {
  2964. return uiMap.keyCodeToStr(keyCode);
  2965. }
  2966. KeyCodeUtils.toString = toString;
  2967. function fromString(key) {
  2968. return uiMap.strToKeyCode(key);
  2969. }
  2970. KeyCodeUtils.fromString = fromString;
  2971. function toUserSettingsUS(keyCode) {
  2972. return userSettingsUSMap.keyCodeToStr(keyCode);
  2973. }
  2974. KeyCodeUtils.toUserSettingsUS = toUserSettingsUS;
  2975. function toUserSettingsGeneral(keyCode) {
  2976. return userSettingsGeneralMap.keyCodeToStr(keyCode);
  2977. }
  2978. KeyCodeUtils.toUserSettingsGeneral = toUserSettingsGeneral;
  2979. function fromUserSettings(key) {
  2980. return userSettingsUSMap.strToKeyCode(key) || userSettingsGeneralMap.strToKeyCode(key);
  2981. }
  2982. KeyCodeUtils.fromUserSettings = fromUserSettings;
  2983. function toElectronAccelerator(keyCode) {
  2984. if (keyCode >= 93 /* Numpad0 */ && keyCode <= 108 /* NumpadDivide */) {
  2985. // [Electron Accelerators] Electron is able to parse numpad keys, but unfortunately it
  2986. // renders them just as regular keys in menus. For example, num0 is rendered as "0",
  2987. // numdiv is rendered as "/", numsub is rendered as "-".
  2988. //
  2989. // This can lead to incredible confusion, as it makes numpad based keybindings indistinguishable
  2990. // from keybindings based on regular keys.
  2991. //
  2992. // We therefore need to fall back to custom rendering for numpad keys.
  2993. return null;
  2994. }
  2995. switch (keyCode) {
  2996. case 16 /* UpArrow */:
  2997. return 'Up';
  2998. case 18 /* DownArrow */:
  2999. return 'Down';
  3000. case 15 /* LeftArrow */:
  3001. return 'Left';
  3002. case 17 /* RightArrow */:
  3003. return 'Right';
  3004. }
  3005. return uiMap.keyCodeToStr(keyCode);
  3006. }
  3007. KeyCodeUtils.toElectronAccelerator = toElectronAccelerator;
  3008. })(KeyCodeUtils = exports.KeyCodeUtils || (exports.KeyCodeUtils = {}));
  3009. function KeyChord(firstPart, secondPart) {
  3010. const chordPart = ((secondPart & 0x0000FFFF) << 16) >>> 0;
  3011. return (firstPart | chordPart) >>> 0;
  3012. }
  3013. exports.KeyChord = KeyChord;
  3014. });
  3015. /*---------------------------------------------------------------------------------------------
  3016. * Copyright (c) Microsoft Corporation. All rights reserved.
  3017. * Licensed under the MIT License. See License.txt in the project root for license information.
  3018. *--------------------------------------------------------------------------------------------*/
  3019. define(__m[9/*vs/base/common/lifecycle*/], __M([0/*require*/,1/*exports*/,17/*vs/base/common/functional*/,18/*vs/base/common/iterator*/]), function (require, exports, functional_1, iterator_1) {
  3020. "use strict";
  3021. Object.defineProperty(exports, "__esModule", { value: true });
  3022. exports.ImmortalReference = exports.MutableDisposable = exports.Disposable = exports.DisposableStore = exports.toDisposable = exports.combinedDisposable = exports.dispose = exports.isDisposable = exports.MultiDisposeError = exports.markAsSingleton = exports.setDisposableTracker = void 0;
  3023. /**
  3024. * Enables logging of potentially leaked disposables.
  3025. *
  3026. * A disposable is considered leaked if it is not disposed or not registered as the child of
  3027. * another disposable. This tracking is very simple an only works for classes that either
  3028. * extend Disposable or use a DisposableStore. This means there are a lot of false positives.
  3029. */
  3030. const TRACK_DISPOSABLES = false;
  3031. let disposableTracker = null;
  3032. function setDisposableTracker(tracker) {
  3033. disposableTracker = tracker;
  3034. }
  3035. exports.setDisposableTracker = setDisposableTracker;
  3036. if (TRACK_DISPOSABLES) {
  3037. const __is_disposable_tracked__ = '__is_disposable_tracked__';
  3038. setDisposableTracker(new class {
  3039. trackDisposable(x) {
  3040. const stack = new Error('Potentially leaked disposable').stack;
  3041. setTimeout(() => {
  3042. if (!x[__is_disposable_tracked__]) {
  3043. console.log(stack);
  3044. }
  3045. }, 3000);
  3046. }
  3047. setParent(child, parent) {
  3048. if (child && child !== Disposable.None) {
  3049. try {
  3050. child[__is_disposable_tracked__] = true;
  3051. }
  3052. catch (_a) {
  3053. // noop
  3054. }
  3055. }
  3056. }
  3057. markAsDisposed(disposable) {
  3058. if (disposable && disposable !== Disposable.None) {
  3059. try {
  3060. disposable[__is_disposable_tracked__] = true;
  3061. }
  3062. catch (_a) {
  3063. // noop
  3064. }
  3065. }
  3066. }
  3067. markAsSingleton(disposable) { }
  3068. });
  3069. }
  3070. function trackDisposable(x) {
  3071. disposableTracker === null || disposableTracker === void 0 ? void 0 : disposableTracker.trackDisposable(x);
  3072. return x;
  3073. }
  3074. function markAsDisposed(disposable) {
  3075. disposableTracker === null || disposableTracker === void 0 ? void 0 : disposableTracker.markAsDisposed(disposable);
  3076. }
  3077. function setParentOfDisposable(child, parent) {
  3078. disposableTracker === null || disposableTracker === void 0 ? void 0 : disposableTracker.setParent(child, parent);
  3079. }
  3080. function setParentOfDisposables(children, parent) {
  3081. if (!disposableTracker) {
  3082. return;
  3083. }
  3084. for (const child of children) {
  3085. disposableTracker.setParent(child, parent);
  3086. }
  3087. }
  3088. /**
  3089. * Indicates that the given object is a singleton which does not need to be disposed.
  3090. */
  3091. function markAsSingleton(singleton) {
  3092. disposableTracker === null || disposableTracker === void 0 ? void 0 : disposableTracker.markAsSingleton(singleton);
  3093. return singleton;
  3094. }
  3095. exports.markAsSingleton = markAsSingleton;
  3096. class MultiDisposeError extends Error {
  3097. constructor(errors) {
  3098. super(`Encountered errors while disposing of store. Errors: [${errors.join(', ')}]`);
  3099. this.errors = errors;
  3100. }
  3101. }
  3102. exports.MultiDisposeError = MultiDisposeError;
  3103. function isDisposable(thing) {
  3104. return typeof thing.dispose === 'function' && thing.dispose.length === 0;
  3105. }
  3106. exports.isDisposable = isDisposable;
  3107. function dispose(arg) {
  3108. if (iterator_1.Iterable.is(arg)) {
  3109. let errors = [];
  3110. for (const d of arg) {
  3111. if (d) {
  3112. try {
  3113. d.dispose();
  3114. }
  3115. catch (e) {
  3116. errors.push(e);
  3117. }
  3118. }
  3119. }
  3120. if (errors.length === 1) {
  3121. throw errors[0];
  3122. }
  3123. else if (errors.length > 1) {
  3124. throw new MultiDisposeError(errors);
  3125. }
  3126. return Array.isArray(arg) ? [] : arg;
  3127. }
  3128. else if (arg) {
  3129. arg.dispose();
  3130. return arg;
  3131. }
  3132. }
  3133. exports.dispose = dispose;
  3134. function combinedDisposable(...disposables) {
  3135. const parent = toDisposable(() => dispose(disposables));
  3136. setParentOfDisposables(disposables, parent);
  3137. return parent;
  3138. }
  3139. exports.combinedDisposable = combinedDisposable;
  3140. function toDisposable(fn) {
  3141. const self = trackDisposable({
  3142. dispose: (0, functional_1.once)(() => {
  3143. markAsDisposed(self);
  3144. fn();
  3145. })
  3146. });
  3147. return self;
  3148. }
  3149. exports.toDisposable = toDisposable;
  3150. class DisposableStore {
  3151. constructor() {
  3152. this._toDispose = new Set();
  3153. this._isDisposed = false;
  3154. trackDisposable(this);
  3155. }
  3156. /**
  3157. * Dispose of all registered disposables and mark this object as disposed.
  3158. *
  3159. * Any future disposables added to this object will be disposed of on `add`.
  3160. */
  3161. dispose() {
  3162. if (this._isDisposed) {
  3163. return;
  3164. }
  3165. markAsDisposed(this);
  3166. this._isDisposed = true;
  3167. this.clear();
  3168. }
  3169. /**
  3170. * Dispose of all registered disposables but do not mark this object as disposed.
  3171. */
  3172. clear() {
  3173. try {
  3174. dispose(this._toDispose.values());
  3175. }
  3176. finally {
  3177. this._toDispose.clear();
  3178. }
  3179. }
  3180. add(o) {
  3181. if (!o) {
  3182. return o;
  3183. }
  3184. if (o === this) {
  3185. throw new Error('Cannot register a disposable on itself!');
  3186. }
  3187. setParentOfDisposable(o, this);
  3188. if (this._isDisposed) {
  3189. if (!DisposableStore.DISABLE_DISPOSED_WARNING) {
  3190. console.warn(new Error('Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!').stack);
  3191. }
  3192. }
  3193. else {
  3194. this._toDispose.add(o);
  3195. }
  3196. return o;
  3197. }
  3198. }
  3199. exports.DisposableStore = DisposableStore;
  3200. DisposableStore.DISABLE_DISPOSED_WARNING = false;
  3201. class Disposable {
  3202. constructor() {
  3203. this._store = new DisposableStore();
  3204. trackDisposable(this);
  3205. setParentOfDisposable(this._store, this);
  3206. }
  3207. dispose() {
  3208. markAsDisposed(this);
  3209. this._store.dispose();
  3210. }
  3211. _register(o) {
  3212. if (o === this) {
  3213. throw new Error('Cannot register a disposable on itself!');
  3214. }
  3215. return this._store.add(o);
  3216. }
  3217. }
  3218. exports.Disposable = Disposable;
  3219. Disposable.None = Object.freeze({ dispose() { } });
  3220. /**
  3221. * Manages the lifecycle of a disposable value that may be changed.
  3222. *
  3223. * This ensures that when the disposable value is changed, the previously held disposable is disposed of. You can
  3224. * also register a `MutableDisposable` on a `Disposable` to ensure it is automatically cleaned up.
  3225. */
  3226. class MutableDisposable {
  3227. constructor() {
  3228. this._isDisposed = false;
  3229. trackDisposable(this);
  3230. }
  3231. get value() {
  3232. return this._isDisposed ? undefined : this._value;
  3233. }
  3234. set value(value) {
  3235. var _a;
  3236. if (this._isDisposed || value === this._value) {
  3237. return;
  3238. }
  3239. (_a = this._value) === null || _a === void 0 ? void 0 : _a.dispose();
  3240. if (value) {
  3241. setParentOfDisposable(value, this);
  3242. }
  3243. this._value = value;
  3244. }
  3245. clear() {
  3246. this.value = undefined;
  3247. }
  3248. dispose() {
  3249. var _a;
  3250. this._isDisposed = true;
  3251. markAsDisposed(this);
  3252. (_a = this._value) === null || _a === void 0 ? void 0 : _a.dispose();
  3253. this._value = undefined;
  3254. }
  3255. /**
  3256. * Clears the value, but does not dispose it.
  3257. * The old value is returned.
  3258. */
  3259. clearAndLeak() {
  3260. const oldValue = this._value;
  3261. this._value = undefined;
  3262. if (oldValue) {
  3263. setParentOfDisposable(oldValue, null);
  3264. }
  3265. return oldValue;
  3266. }
  3267. }
  3268. exports.MutableDisposable = MutableDisposable;
  3269. class ImmortalReference {
  3270. constructor(object) {
  3271. this.object = object;
  3272. }
  3273. dispose() { }
  3274. }
  3275. exports.ImmortalReference = ImmortalReference;
  3276. });
  3277. /*---------------------------------------------------------------------------------------------
  3278. * Copyright (c) Microsoft Corporation. All rights reserved.
  3279. * Licensed under the MIT License. See License.txt in the project root for license information.
  3280. *--------------------------------------------------------------------------------------------*/
  3281. define(__m[20/*vs/base/common/linkedList*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3282. "use strict";
  3283. Object.defineProperty(exports, "__esModule", { value: true });
  3284. exports.LinkedList = void 0;
  3285. class Node {
  3286. constructor(element) {
  3287. this.element = element;
  3288. this.next = Node.Undefined;
  3289. this.prev = Node.Undefined;
  3290. }
  3291. }
  3292. Node.Undefined = new Node(undefined);
  3293. class LinkedList {
  3294. constructor() {
  3295. this._first = Node.Undefined;
  3296. this._last = Node.Undefined;
  3297. this._size = 0;
  3298. }
  3299. get size() {
  3300. return this._size;
  3301. }
  3302. isEmpty() {
  3303. return this._first === Node.Undefined;
  3304. }
  3305. clear() {
  3306. let node = this._first;
  3307. while (node !== Node.Undefined) {
  3308. const next = node.next;
  3309. node.prev = Node.Undefined;
  3310. node.next = Node.Undefined;
  3311. node = next;
  3312. }
  3313. this._first = Node.Undefined;
  3314. this._last = Node.Undefined;
  3315. this._size = 0;
  3316. }
  3317. unshift(element) {
  3318. return this._insert(element, false);
  3319. }
  3320. push(element) {
  3321. return this._insert(element, true);
  3322. }
  3323. _insert(element, atTheEnd) {
  3324. const newNode = new Node(element);
  3325. if (this._first === Node.Undefined) {
  3326. this._first = newNode;
  3327. this._last = newNode;
  3328. }
  3329. else if (atTheEnd) {
  3330. // push
  3331. const oldLast = this._last;
  3332. this._last = newNode;
  3333. newNode.prev = oldLast;
  3334. oldLast.next = newNode;
  3335. }
  3336. else {
  3337. // unshift
  3338. const oldFirst = this._first;
  3339. this._first = newNode;
  3340. newNode.next = oldFirst;
  3341. oldFirst.prev = newNode;
  3342. }
  3343. this._size += 1;
  3344. let didRemove = false;
  3345. return () => {
  3346. if (!didRemove) {
  3347. didRemove = true;
  3348. this._remove(newNode);
  3349. }
  3350. };
  3351. }
  3352. shift() {
  3353. if (this._first === Node.Undefined) {
  3354. return undefined;
  3355. }
  3356. else {
  3357. const res = this._first.element;
  3358. this._remove(this._first);
  3359. return res;
  3360. }
  3361. }
  3362. pop() {
  3363. if (this._last === Node.Undefined) {
  3364. return undefined;
  3365. }
  3366. else {
  3367. const res = this._last.element;
  3368. this._remove(this._last);
  3369. return res;
  3370. }
  3371. }
  3372. _remove(node) {
  3373. if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
  3374. // middle
  3375. const anchor = node.prev;
  3376. anchor.next = node.next;
  3377. node.next.prev = anchor;
  3378. }
  3379. else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
  3380. // only node
  3381. this._first = Node.Undefined;
  3382. this._last = Node.Undefined;
  3383. }
  3384. else if (node.next === Node.Undefined) {
  3385. // last
  3386. this._last = this._last.prev;
  3387. this._last.next = Node.Undefined;
  3388. }
  3389. else if (node.prev === Node.Undefined) {
  3390. // first
  3391. this._first = this._first.next;
  3392. this._first.prev = Node.Undefined;
  3393. }
  3394. // done
  3395. this._size -= 1;
  3396. }
  3397. *[Symbol.iterator]() {
  3398. let node = this._first;
  3399. while (node !== Node.Undefined) {
  3400. yield node.element;
  3401. node = node.next;
  3402. }
  3403. }
  3404. }
  3405. exports.LinkedList = LinkedList;
  3406. });
  3407. /*---------------------------------------------------------------------------------------------
  3408. * Copyright (c) Microsoft Corporation. All rights reserved.
  3409. * Licensed under the MIT License. See License.txt in the project root for license information.
  3410. *--------------------------------------------------------------------------------------------*/
  3411. define(__m[2/*vs/base/common/platform*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3412. "use strict";
  3413. var _a;
  3414. Object.defineProperty(exports, "__esModule", { value: true });
  3415. exports.isLittleEndian = exports.OS = exports.setImmediate = exports.setTimeout0 = exports.locale = exports.language = exports.userAgent = exports.isIOS = exports.isWeb = exports.isNative = exports.isLinux = exports.isMacintosh = exports.isWindows = exports.globals = void 0;
  3416. const LANGUAGE_DEFAULT = 'en';
  3417. let _isWindows = false;
  3418. let _isMacintosh = false;
  3419. let _isLinux = false;
  3420. let _isLinuxSnap = false;
  3421. let _isNative = false;
  3422. let _isWeb = false;
  3423. let _isElectron = false;
  3424. let _isIOS = false;
  3425. let _locale = undefined;
  3426. let _language = LANGUAGE_DEFAULT;
  3427. let _translationsConfigFile = undefined;
  3428. let _userAgent = undefined;
  3429. exports.globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
  3430. let nodeProcess = undefined;
  3431. if (typeof exports.globals.vscode !== 'undefined' && typeof exports.globals.vscode.process !== 'undefined') {
  3432. // Native environment (sandboxed)
  3433. nodeProcess = exports.globals.vscode.process;
  3434. }
  3435. else if (typeof process !== 'undefined') {
  3436. // Native environment (non-sandboxed)
  3437. nodeProcess = process;
  3438. }
  3439. const isElectronProcess = typeof ((_a = nodeProcess === null || nodeProcess === void 0 ? void 0 : nodeProcess.versions) === null || _a === void 0 ? void 0 : _a.electron) === 'string';
  3440. const isElectronRenderer = isElectronProcess && (nodeProcess === null || nodeProcess === void 0 ? void 0 : nodeProcess.type) === 'renderer';
  3441. // Web environment
  3442. if (typeof navigator === 'object' && !isElectronRenderer) {
  3443. _userAgent = navigator.userAgent;
  3444. _isWindows = _userAgent.indexOf('Windows') >= 0;
  3445. _isMacintosh = _userAgent.indexOf('Macintosh') >= 0;
  3446. _isIOS = (_userAgent.indexOf('Macintosh') >= 0 || _userAgent.indexOf('iPad') >= 0 || _userAgent.indexOf('iPhone') >= 0) && !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
  3447. _isLinux = _userAgent.indexOf('Linux') >= 0;
  3448. _isWeb = true;
  3449. _locale = navigator.language;
  3450. _language = _locale;
  3451. }
  3452. // Native environment
  3453. else if (typeof nodeProcess === 'object') {
  3454. _isWindows = (nodeProcess.platform === 'win32');
  3455. _isMacintosh = (nodeProcess.platform === 'darwin');
  3456. _isLinux = (nodeProcess.platform === 'linux');
  3457. _isLinuxSnap = _isLinux && !!nodeProcess.env['SNAP'] && !!nodeProcess.env['SNAP_REVISION'];
  3458. _isElectron = isElectronProcess;
  3459. _locale = LANGUAGE_DEFAULT;
  3460. _language = LANGUAGE_DEFAULT;
  3461. const rawNlsConfig = nodeProcess.env['VSCODE_NLS_CONFIG'];
  3462. if (rawNlsConfig) {
  3463. try {
  3464. const nlsConfig = JSON.parse(rawNlsConfig);
  3465. const resolved = nlsConfig.availableLanguages['*'];
  3466. _locale = nlsConfig.locale;
  3467. // VSCode's default language is 'en'
  3468. _language = resolved ? resolved : LANGUAGE_DEFAULT;
  3469. _translationsConfigFile = nlsConfig._translationsConfigFile;
  3470. }
  3471. catch (e) {
  3472. }
  3473. }
  3474. _isNative = true;
  3475. }
  3476. // Unknown environment
  3477. else {
  3478. console.error('Unable to resolve platform.');
  3479. }
  3480. let _platform = 0 /* Web */;
  3481. if (_isMacintosh) {
  3482. _platform = 1 /* Mac */;
  3483. }
  3484. else if (_isWindows) {
  3485. _platform = 3 /* Windows */;
  3486. }
  3487. else if (_isLinux) {
  3488. _platform = 2 /* Linux */;
  3489. }
  3490. exports.isWindows = _isWindows;
  3491. exports.isMacintosh = _isMacintosh;
  3492. exports.isLinux = _isLinux;
  3493. exports.isNative = _isNative;
  3494. exports.isWeb = _isWeb;
  3495. exports.isIOS = _isIOS;
  3496. exports.userAgent = _userAgent;
  3497. /**
  3498. * The language used for the user interface. The format of
  3499. * the string is all lower case (e.g. zh-tw for Traditional
  3500. * Chinese)
  3501. */
  3502. exports.language = _language;
  3503. /**
  3504. * The OS locale or the locale specified by --locale. The format of
  3505. * the string is all lower case (e.g. zh-tw for Traditional
  3506. * Chinese). The UI is not necessarily shown in the provided locale.
  3507. */
  3508. exports.locale = _locale;
  3509. /**
  3510. * See https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#:~:text=than%204%2C%20then-,set%20timeout%20to%204,-.
  3511. *
  3512. * Works similarly to `setTimeout(0)` but doesn't suffer from the 4ms artificial delay
  3513. * that browsers set when the nesting level is > 5.
  3514. */
  3515. exports.setTimeout0 = (() => {
  3516. if (typeof exports.globals.postMessage === 'function' && !exports.globals.importScripts) {
  3517. let pending = [];
  3518. exports.globals.addEventListener('message', (e) => {
  3519. if (e.data && e.data.vscodeScheduleAsyncWork) {
  3520. for (let i = 0, len = pending.length; i < len; i++) {
  3521. const candidate = pending[i];
  3522. if (candidate.id === e.data.vscodeScheduleAsyncWork) {
  3523. pending.splice(i, 1);
  3524. candidate.callback();
  3525. return;
  3526. }
  3527. }
  3528. }
  3529. });
  3530. let lastId = 0;
  3531. return (callback) => {
  3532. const myId = ++lastId;
  3533. pending.push({
  3534. id: myId,
  3535. callback: callback
  3536. });
  3537. exports.globals.postMessage({ vscodeScheduleAsyncWork: myId }, '*');
  3538. };
  3539. }
  3540. return (callback) => setTimeout(callback);
  3541. })();
  3542. exports.setImmediate = (function defineSetImmediate() {
  3543. if (exports.globals.setImmediate) {
  3544. return exports.globals.setImmediate.bind(exports.globals);
  3545. }
  3546. if (typeof exports.globals.postMessage === 'function' && !exports.globals.importScripts) {
  3547. return exports.setTimeout0;
  3548. }
  3549. if (typeof (nodeProcess === null || nodeProcess === void 0 ? void 0 : nodeProcess.nextTick) === 'function') {
  3550. return nodeProcess.nextTick.bind(nodeProcess);
  3551. }
  3552. const _promise = Promise.resolve();
  3553. return (callback) => _promise.then(callback);
  3554. })();
  3555. exports.OS = (_isMacintosh || _isIOS ? 2 /* Macintosh */ : (_isWindows ? 1 /* Windows */ : 3 /* Linux */));
  3556. let _isLittleEndian = true;
  3557. let _isLittleEndianComputed = false;
  3558. function isLittleEndian() {
  3559. if (!_isLittleEndianComputed) {
  3560. _isLittleEndianComputed = true;
  3561. const test = new Uint8Array(2);
  3562. test[0] = 1;
  3563. test[1] = 2;
  3564. const view = new Uint16Array(test.buffer);
  3565. _isLittleEndian = (view[0] === (2 << 8) + 1);
  3566. }
  3567. return _isLittleEndian;
  3568. }
  3569. exports.isLittleEndian = isLittleEndian;
  3570. });
  3571. /*---------------------------------------------------------------------------------------------
  3572. * Copyright (c) Microsoft Corporation. All rights reserved.
  3573. * Licensed under the MIT License. See License.txt in the project root for license information.
  3574. *--------------------------------------------------------------------------------------------*/
  3575. define(__m[21/*vs/base/common/process*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  3576. "use strict";
  3577. Object.defineProperty(exports, "__esModule", { value: true });
  3578. exports.platform = exports.env = exports.cwd = void 0;
  3579. let safeProcess;
  3580. // Native sandbox environment
  3581. if (typeof platform_1.globals.vscode !== 'undefined' && typeof platform_1.globals.vscode.process !== 'undefined') {
  3582. const sandboxProcess = platform_1.globals.vscode.process;
  3583. safeProcess = {
  3584. get platform() { return sandboxProcess.platform; },
  3585. get arch() { return sandboxProcess.arch; },
  3586. get env() { return sandboxProcess.env; },
  3587. cwd() { return sandboxProcess.cwd(); }
  3588. };
  3589. }
  3590. // Native node.js environment
  3591. else if (typeof process !== 'undefined') {
  3592. safeProcess = {
  3593. get platform() { return process.platform; },
  3594. get arch() { return process.arch; },
  3595. get env() { return process.env; },
  3596. cwd() { return process.env['VSCODE_CWD'] || process.cwd(); }
  3597. };
  3598. }
  3599. // Web environment
  3600. else {
  3601. safeProcess = {
  3602. // Supported
  3603. get platform() { return platform_1.isWindows ? 'win32' : platform_1.isMacintosh ? 'darwin' : 'linux'; },
  3604. get arch() { return undefined; /* arch is undefined in web */ },
  3605. // Unsupported
  3606. get env() { return {}; },
  3607. cwd() { return '/'; }
  3608. };
  3609. }
  3610. /**
  3611. * Provides safe access to the `cwd` property in node.js, sandboxed or web
  3612. * environments.
  3613. *
  3614. * Note: in web, this property is hardcoded to be `/`.
  3615. */
  3616. exports.cwd = safeProcess.cwd;
  3617. /**
  3618. * Provides safe access to the `env` property in node.js, sandboxed or web
  3619. * environments.
  3620. *
  3621. * Note: in web, this property is hardcoded to be `{}`.
  3622. */
  3623. exports.env = safeProcess.env;
  3624. /**
  3625. * Provides safe access to the `platform` property in node.js, sandboxed or web
  3626. * environments.
  3627. */
  3628. exports.platform = safeProcess.platform;
  3629. });
  3630. /*---------------------------------------------------------------------------------------------
  3631. * Copyright (c) Microsoft Corporation. All rights reserved.
  3632. * Licensed under the MIT License. See License.txt in the project root for license information.
  3633. *--------------------------------------------------------------------------------------------*/
  3634. define(__m[22/*vs/base/common/path*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/process*/]), function (require, exports, process) {
  3635. "use strict";
  3636. Object.defineProperty(exports, "__esModule", { value: true });
  3637. exports.sep = exports.extname = exports.basename = exports.dirname = exports.relative = exports.resolve = exports.normalize = exports.posix = exports.win32 = void 0;
  3638. const CHAR_UPPERCASE_A = 65; /* A */
  3639. const CHAR_LOWERCASE_A = 97; /* a */
  3640. const CHAR_UPPERCASE_Z = 90; /* Z */
  3641. const CHAR_LOWERCASE_Z = 122; /* z */
  3642. const CHAR_DOT = 46; /* . */
  3643. const CHAR_FORWARD_SLASH = 47; /* / */
  3644. const CHAR_BACKWARD_SLASH = 92; /* \ */
  3645. const CHAR_COLON = 58; /* : */
  3646. const CHAR_QUESTION_MARK = 63; /* ? */
  3647. class ErrorInvalidArgType extends Error {
  3648. constructor(name, expected, actual) {
  3649. // determiner: 'must be' or 'must not be'
  3650. let determiner;
  3651. if (typeof expected === 'string' && expected.indexOf('not ') === 0) {
  3652. determiner = 'must not be';
  3653. expected = expected.replace(/^not /, '');
  3654. }
  3655. else {
  3656. determiner = 'must be';
  3657. }
  3658. const type = name.indexOf('.') !== -1 ? 'property' : 'argument';
  3659. let msg = `The "${name}" ${type} ${determiner} of type ${expected}`;
  3660. msg += `. Received type ${typeof actual}`;
  3661. super(msg);
  3662. this.code = 'ERR_INVALID_ARG_TYPE';
  3663. }
  3664. }
  3665. function validateString(value, name) {
  3666. if (typeof value !== 'string') {
  3667. throw new ErrorInvalidArgType(name, 'string', value);
  3668. }
  3669. }
  3670. function isPathSeparator(code) {
  3671. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  3672. }
  3673. function isPosixPathSeparator(code) {
  3674. return code === CHAR_FORWARD_SLASH;
  3675. }
  3676. function isWindowsDeviceRoot(code) {
  3677. return (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
  3678. (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z);
  3679. }
  3680. // Resolves . and .. elements in a path with directory names
  3681. function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
  3682. let res = '';
  3683. let lastSegmentLength = 0;
  3684. let lastSlash = -1;
  3685. let dots = 0;
  3686. let code = 0;
  3687. for (let i = 0; i <= path.length; ++i) {
  3688. if (i < path.length) {
  3689. code = path.charCodeAt(i);
  3690. }
  3691. else if (isPathSeparator(code)) {
  3692. break;
  3693. }
  3694. else {
  3695. code = CHAR_FORWARD_SLASH;
  3696. }
  3697. if (isPathSeparator(code)) {
  3698. if (lastSlash === i - 1 || dots === 1) {
  3699. // NOOP
  3700. }
  3701. else if (dots === 2) {
  3702. if (res.length < 2 || lastSegmentLength !== 2 ||
  3703. res.charCodeAt(res.length - 1) !== CHAR_DOT ||
  3704. res.charCodeAt(res.length - 2) !== CHAR_DOT) {
  3705. if (res.length > 2) {
  3706. const lastSlashIndex = res.lastIndexOf(separator);
  3707. if (lastSlashIndex === -1) {
  3708. res = '';
  3709. lastSegmentLength = 0;
  3710. }
  3711. else {
  3712. res = res.slice(0, lastSlashIndex);
  3713. lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
  3714. }
  3715. lastSlash = i;
  3716. dots = 0;
  3717. continue;
  3718. }
  3719. else if (res.length !== 0) {
  3720. res = '';
  3721. lastSegmentLength = 0;
  3722. lastSlash = i;
  3723. dots = 0;
  3724. continue;
  3725. }
  3726. }
  3727. if (allowAboveRoot) {
  3728. res += res.length > 0 ? `${separator}..` : '..';
  3729. lastSegmentLength = 2;
  3730. }
  3731. }
  3732. else {
  3733. if (res.length > 0) {
  3734. res += `${separator}${path.slice(lastSlash + 1, i)}`;
  3735. }
  3736. else {
  3737. res = path.slice(lastSlash + 1, i);
  3738. }
  3739. lastSegmentLength = i - lastSlash - 1;
  3740. }
  3741. lastSlash = i;
  3742. dots = 0;
  3743. }
  3744. else if (code === CHAR_DOT && dots !== -1) {
  3745. ++dots;
  3746. }
  3747. else {
  3748. dots = -1;
  3749. }
  3750. }
  3751. return res;
  3752. }
  3753. function _format(sep, pathObject) {
  3754. if (pathObject === null || typeof pathObject !== 'object') {
  3755. throw new ErrorInvalidArgType('pathObject', 'Object', pathObject);
  3756. }
  3757. const dir = pathObject.dir || pathObject.root;
  3758. const base = pathObject.base ||
  3759. `${pathObject.name || ''}${pathObject.ext || ''}`;
  3760. if (!dir) {
  3761. return base;
  3762. }
  3763. return dir === pathObject.root ? `${dir}${base}` : `${dir}${sep}${base}`;
  3764. }
  3765. exports.win32 = {
  3766. // path.resolve([from ...], to)
  3767. resolve(...pathSegments) {
  3768. let resolvedDevice = '';
  3769. let resolvedTail = '';
  3770. let resolvedAbsolute = false;
  3771. for (let i = pathSegments.length - 1; i >= -1; i--) {
  3772. let path;
  3773. if (i >= 0) {
  3774. path = pathSegments[i];
  3775. validateString(path, 'path');
  3776. // Skip empty entries
  3777. if (path.length === 0) {
  3778. continue;
  3779. }
  3780. }
  3781. else if (resolvedDevice.length === 0) {
  3782. path = process.cwd();
  3783. }
  3784. else {
  3785. // Windows has the concept of drive-specific current working
  3786. // directories. If we've resolved a drive letter but not yet an
  3787. // absolute path, get cwd for that drive, or the process cwd if
  3788. // the drive cwd is not available. We're sure the device is not
  3789. // a UNC path at this points, because UNC paths are always absolute.
  3790. path = process.env[`=${resolvedDevice}`] || process.cwd();
  3791. // Verify that a cwd was found and that it actually points
  3792. // to our drive. If not, default to the drive's root.
  3793. if (path === undefined ||
  3794. (path.slice(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() &&
  3795. path.charCodeAt(2) === CHAR_BACKWARD_SLASH)) {
  3796. path = `${resolvedDevice}\\`;
  3797. }
  3798. }
  3799. const len = path.length;
  3800. let rootEnd = 0;
  3801. let device = '';
  3802. let isAbsolute = false;
  3803. const code = path.charCodeAt(0);
  3804. // Try to match a root
  3805. if (len === 1) {
  3806. if (isPathSeparator(code)) {
  3807. // `path` contains just a path separator
  3808. rootEnd = 1;
  3809. isAbsolute = true;
  3810. }
  3811. }
  3812. else if (isPathSeparator(code)) {
  3813. // Possible UNC root
  3814. // If we started with a separator, we know we at least have an
  3815. // absolute path of some kind (UNC or otherwise)
  3816. isAbsolute = true;
  3817. if (isPathSeparator(path.charCodeAt(1))) {
  3818. // Matched double path separator at beginning
  3819. let j = 2;
  3820. let last = j;
  3821. // Match 1 or more non-path separators
  3822. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  3823. j++;
  3824. }
  3825. if (j < len && j !== last) {
  3826. const firstPart = path.slice(last, j);
  3827. // Matched!
  3828. last = j;
  3829. // Match 1 or more path separators
  3830. while (j < len && isPathSeparator(path.charCodeAt(j))) {
  3831. j++;
  3832. }
  3833. if (j < len && j !== last) {
  3834. // Matched!
  3835. last = j;
  3836. // Match 1 or more non-path separators
  3837. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  3838. j++;
  3839. }
  3840. if (j === len || j !== last) {
  3841. // We matched a UNC root
  3842. device = `\\\\${firstPart}\\${path.slice(last, j)}`;
  3843. rootEnd = j;
  3844. }
  3845. }
  3846. }
  3847. }
  3848. else {
  3849. rootEnd = 1;
  3850. }
  3851. }
  3852. else if (isWindowsDeviceRoot(code) &&
  3853. path.charCodeAt(1) === CHAR_COLON) {
  3854. // Possible device root
  3855. device = path.slice(0, 2);
  3856. rootEnd = 2;
  3857. if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
  3858. // Treat separator following drive name as an absolute path
  3859. // indicator
  3860. isAbsolute = true;
  3861. rootEnd = 3;
  3862. }
  3863. }
  3864. if (device.length > 0) {
  3865. if (resolvedDevice.length > 0) {
  3866. if (device.toLowerCase() !== resolvedDevice.toLowerCase()) {
  3867. // This path points to another device so it is not applicable
  3868. continue;
  3869. }
  3870. }
  3871. else {
  3872. resolvedDevice = device;
  3873. }
  3874. }
  3875. if (resolvedAbsolute) {
  3876. if (resolvedDevice.length > 0) {
  3877. break;
  3878. }
  3879. }
  3880. else {
  3881. resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
  3882. resolvedAbsolute = isAbsolute;
  3883. if (isAbsolute && resolvedDevice.length > 0) {
  3884. break;
  3885. }
  3886. }
  3887. }
  3888. // At this point the path should be resolved to a full absolute path,
  3889. // but handle relative paths to be safe (might happen when process.cwd()
  3890. // fails)
  3891. // Normalize the tail path
  3892. resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
  3893. return resolvedAbsolute ?
  3894. `${resolvedDevice}\\${resolvedTail}` :
  3895. `${resolvedDevice}${resolvedTail}` || '.';
  3896. },
  3897. normalize(path) {
  3898. validateString(path, 'path');
  3899. const len = path.length;
  3900. if (len === 0) {
  3901. return '.';
  3902. }
  3903. let rootEnd = 0;
  3904. let device;
  3905. let isAbsolute = false;
  3906. const code = path.charCodeAt(0);
  3907. // Try to match a root
  3908. if (len === 1) {
  3909. // `path` contains just a single char, exit early to avoid
  3910. // unnecessary work
  3911. return isPosixPathSeparator(code) ? '\\' : path;
  3912. }
  3913. if (isPathSeparator(code)) {
  3914. // Possible UNC root
  3915. // If we started with a separator, we know we at least have an absolute
  3916. // path of some kind (UNC or otherwise)
  3917. isAbsolute = true;
  3918. if (isPathSeparator(path.charCodeAt(1))) {
  3919. // Matched double path separator at beginning
  3920. let j = 2;
  3921. let last = j;
  3922. // Match 1 or more non-path separators
  3923. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  3924. j++;
  3925. }
  3926. if (j < len && j !== last) {
  3927. const firstPart = path.slice(last, j);
  3928. // Matched!
  3929. last = j;
  3930. // Match 1 or more path separators
  3931. while (j < len && isPathSeparator(path.charCodeAt(j))) {
  3932. j++;
  3933. }
  3934. if (j < len && j !== last) {
  3935. // Matched!
  3936. last = j;
  3937. // Match 1 or more non-path separators
  3938. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  3939. j++;
  3940. }
  3941. if (j === len) {
  3942. // We matched a UNC root only
  3943. // Return the normalized version of the UNC root since there
  3944. // is nothing left to process
  3945. return `\\\\${firstPart}\\${path.slice(last)}\\`;
  3946. }
  3947. if (j !== last) {
  3948. // We matched a UNC root with leftovers
  3949. device = `\\\\${firstPart}\\${path.slice(last, j)}`;
  3950. rootEnd = j;
  3951. }
  3952. }
  3953. }
  3954. }
  3955. else {
  3956. rootEnd = 1;
  3957. }
  3958. }
  3959. else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
  3960. // Possible device root
  3961. device = path.slice(0, 2);
  3962. rootEnd = 2;
  3963. if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
  3964. // Treat separator following drive name as an absolute path
  3965. // indicator
  3966. isAbsolute = true;
  3967. rootEnd = 3;
  3968. }
  3969. }
  3970. let tail = rootEnd < len ?
  3971. normalizeString(path.slice(rootEnd), !isAbsolute, '\\', isPathSeparator) :
  3972. '';
  3973. if (tail.length === 0 && !isAbsolute) {
  3974. tail = '.';
  3975. }
  3976. if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
  3977. tail += '\\';
  3978. }
  3979. if (device === undefined) {
  3980. return isAbsolute ? `\\${tail}` : tail;
  3981. }
  3982. return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
  3983. },
  3984. isAbsolute(path) {
  3985. validateString(path, 'path');
  3986. const len = path.length;
  3987. if (len === 0) {
  3988. return false;
  3989. }
  3990. const code = path.charCodeAt(0);
  3991. return isPathSeparator(code) ||
  3992. // Possible device root
  3993. (len > 2 &&
  3994. isWindowsDeviceRoot(code) &&
  3995. path.charCodeAt(1) === CHAR_COLON &&
  3996. isPathSeparator(path.charCodeAt(2)));
  3997. },
  3998. join(...paths) {
  3999. if (paths.length === 0) {
  4000. return '.';
  4001. }
  4002. let joined;
  4003. let firstPart;
  4004. for (let i = 0; i < paths.length; ++i) {
  4005. const arg = paths[i];
  4006. validateString(arg, 'path');
  4007. if (arg.length > 0) {
  4008. if (joined === undefined) {
  4009. joined = firstPart = arg;
  4010. }
  4011. else {
  4012. joined += `\\${arg}`;
  4013. }
  4014. }
  4015. }
  4016. if (joined === undefined) {
  4017. return '.';
  4018. }
  4019. // Make sure that the joined path doesn't start with two slashes, because
  4020. // normalize() will mistake it for a UNC path then.
  4021. //
  4022. // This step is skipped when it is very clear that the user actually
  4023. // intended to point at a UNC path. This is assumed when the first
  4024. // non-empty string arguments starts with exactly two slashes followed by
  4025. // at least one more non-slash character.
  4026. //
  4027. // Note that for normalize() to treat a path as a UNC path it needs to
  4028. // have at least 2 components, so we don't filter for that here.
  4029. // This means that the user can use join to construct UNC paths from
  4030. // a server name and a share name; for example:
  4031. // path.join('//server', 'share') -> '\\\\server\\share\\')
  4032. let needsReplace = true;
  4033. let slashCount = 0;
  4034. if (typeof firstPart === 'string' && isPathSeparator(firstPart.charCodeAt(0))) {
  4035. ++slashCount;
  4036. const firstLen = firstPart.length;
  4037. if (firstLen > 1 && isPathSeparator(firstPart.charCodeAt(1))) {
  4038. ++slashCount;
  4039. if (firstLen > 2) {
  4040. if (isPathSeparator(firstPart.charCodeAt(2))) {
  4041. ++slashCount;
  4042. }
  4043. else {
  4044. // We matched a UNC path in the first part
  4045. needsReplace = false;
  4046. }
  4047. }
  4048. }
  4049. }
  4050. if (needsReplace) {
  4051. // Find any more consecutive slashes we need to replace
  4052. while (slashCount < joined.length &&
  4053. isPathSeparator(joined.charCodeAt(slashCount))) {
  4054. slashCount++;
  4055. }
  4056. // Replace the slashes if needed
  4057. if (slashCount >= 2) {
  4058. joined = `\\${joined.slice(slashCount)}`;
  4059. }
  4060. }
  4061. return exports.win32.normalize(joined);
  4062. },
  4063. // It will solve the relative path from `from` to `to`, for instance:
  4064. // from = 'C:\\orandea\\test\\aaa'
  4065. // to = 'C:\\orandea\\impl\\bbb'
  4066. // The output of the function should be: '..\\..\\impl\\bbb'
  4067. relative(from, to) {
  4068. validateString(from, 'from');
  4069. validateString(to, 'to');
  4070. if (from === to) {
  4071. return '';
  4072. }
  4073. const fromOrig = exports.win32.resolve(from);
  4074. const toOrig = exports.win32.resolve(to);
  4075. if (fromOrig === toOrig) {
  4076. return '';
  4077. }
  4078. from = fromOrig.toLowerCase();
  4079. to = toOrig.toLowerCase();
  4080. if (from === to) {
  4081. return '';
  4082. }
  4083. // Trim any leading backslashes
  4084. let fromStart = 0;
  4085. while (fromStart < from.length &&
  4086. from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
  4087. fromStart++;
  4088. }
  4089. // Trim trailing backslashes (applicable to UNC paths only)
  4090. let fromEnd = from.length;
  4091. while (fromEnd - 1 > fromStart &&
  4092. from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
  4093. fromEnd--;
  4094. }
  4095. const fromLen = fromEnd - fromStart;
  4096. // Trim any leading backslashes
  4097. let toStart = 0;
  4098. while (toStart < to.length &&
  4099. to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
  4100. toStart++;
  4101. }
  4102. // Trim trailing backslashes (applicable to UNC paths only)
  4103. let toEnd = to.length;
  4104. while (toEnd - 1 > toStart &&
  4105. to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
  4106. toEnd--;
  4107. }
  4108. const toLen = toEnd - toStart;
  4109. // Compare paths to find the longest common path from root
  4110. const length = fromLen < toLen ? fromLen : toLen;
  4111. let lastCommonSep = -1;
  4112. let i = 0;
  4113. for (; i < length; i++) {
  4114. const fromCode = from.charCodeAt(fromStart + i);
  4115. if (fromCode !== to.charCodeAt(toStart + i)) {
  4116. break;
  4117. }
  4118. else if (fromCode === CHAR_BACKWARD_SLASH) {
  4119. lastCommonSep = i;
  4120. }
  4121. }
  4122. // We found a mismatch before the first common path separator was seen, so
  4123. // return the original `to`.
  4124. if (i !== length) {
  4125. if (lastCommonSep === -1) {
  4126. return toOrig;
  4127. }
  4128. }
  4129. else {
  4130. if (toLen > length) {
  4131. if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
  4132. // We get here if `from` is the exact base path for `to`.
  4133. // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
  4134. return toOrig.slice(toStart + i + 1);
  4135. }
  4136. if (i === 2) {
  4137. // We get here if `from` is the device root.
  4138. // For example: from='C:\\'; to='C:\\foo'
  4139. return toOrig.slice(toStart + i);
  4140. }
  4141. }
  4142. if (fromLen > length) {
  4143. if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
  4144. // We get here if `to` is the exact base path for `from`.
  4145. // For example: from='C:\\foo\\bar'; to='C:\\foo'
  4146. lastCommonSep = i;
  4147. }
  4148. else if (i === 2) {
  4149. // We get here if `to` is the device root.
  4150. // For example: from='C:\\foo\\bar'; to='C:\\'
  4151. lastCommonSep = 3;
  4152. }
  4153. }
  4154. if (lastCommonSep === -1) {
  4155. lastCommonSep = 0;
  4156. }
  4157. }
  4158. let out = '';
  4159. // Generate the relative path based on the path difference between `to` and
  4160. // `from`
  4161. for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
  4162. if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
  4163. out += out.length === 0 ? '..' : '\\..';
  4164. }
  4165. }
  4166. toStart += lastCommonSep;
  4167. // Lastly, append the rest of the destination (`to`) path that comes after
  4168. // the common path parts
  4169. if (out.length > 0) {
  4170. return `${out}${toOrig.slice(toStart, toEnd)}`;
  4171. }
  4172. if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
  4173. ++toStart;
  4174. }
  4175. return toOrig.slice(toStart, toEnd);
  4176. },
  4177. toNamespacedPath(path) {
  4178. // Note: this will *probably* throw somewhere.
  4179. if (typeof path !== 'string') {
  4180. return path;
  4181. }
  4182. if (path.length === 0) {
  4183. return '';
  4184. }
  4185. const resolvedPath = exports.win32.resolve(path);
  4186. if (resolvedPath.length <= 2) {
  4187. return path;
  4188. }
  4189. if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
  4190. // Possible UNC root
  4191. if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
  4192. const code = resolvedPath.charCodeAt(2);
  4193. if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
  4194. // Matched non-long UNC root, convert the path to a long UNC path
  4195. return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
  4196. }
  4197. }
  4198. }
  4199. else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) &&
  4200. resolvedPath.charCodeAt(1) === CHAR_COLON &&
  4201. resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
  4202. // Matched device root, convert the path to a long UNC path
  4203. return `\\\\?\\${resolvedPath}`;
  4204. }
  4205. return path;
  4206. },
  4207. dirname(path) {
  4208. validateString(path, 'path');
  4209. const len = path.length;
  4210. if (len === 0) {
  4211. return '.';
  4212. }
  4213. let rootEnd = -1;
  4214. let offset = 0;
  4215. const code = path.charCodeAt(0);
  4216. if (len === 1) {
  4217. // `path` contains just a path separator, exit early to avoid
  4218. // unnecessary work or a dot.
  4219. return isPathSeparator(code) ? path : '.';
  4220. }
  4221. // Try to match a root
  4222. if (isPathSeparator(code)) {
  4223. // Possible UNC root
  4224. rootEnd = offset = 1;
  4225. if (isPathSeparator(path.charCodeAt(1))) {
  4226. // Matched double path separator at beginning
  4227. let j = 2;
  4228. let last = j;
  4229. // Match 1 or more non-path separators
  4230. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  4231. j++;
  4232. }
  4233. if (j < len && j !== last) {
  4234. // Matched!
  4235. last = j;
  4236. // Match 1 or more path separators
  4237. while (j < len && isPathSeparator(path.charCodeAt(j))) {
  4238. j++;
  4239. }
  4240. if (j < len && j !== last) {
  4241. // Matched!
  4242. last = j;
  4243. // Match 1 or more non-path separators
  4244. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  4245. j++;
  4246. }
  4247. if (j === len) {
  4248. // We matched a UNC root only
  4249. return path;
  4250. }
  4251. if (j !== last) {
  4252. // We matched a UNC root with leftovers
  4253. // Offset by 1 to include the separator after the UNC root to
  4254. // treat it as a "normal root" on top of a (UNC) root
  4255. rootEnd = offset = j + 1;
  4256. }
  4257. }
  4258. }
  4259. }
  4260. // Possible device root
  4261. }
  4262. else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
  4263. rootEnd = len > 2 && isPathSeparator(path.charCodeAt(2)) ? 3 : 2;
  4264. offset = rootEnd;
  4265. }
  4266. let end = -1;
  4267. let matchedSlash = true;
  4268. for (let i = len - 1; i >= offset; --i) {
  4269. if (isPathSeparator(path.charCodeAt(i))) {
  4270. if (!matchedSlash) {
  4271. end = i;
  4272. break;
  4273. }
  4274. }
  4275. else {
  4276. // We saw the first non-path separator
  4277. matchedSlash = false;
  4278. }
  4279. }
  4280. if (end === -1) {
  4281. if (rootEnd === -1) {
  4282. return '.';
  4283. }
  4284. end = rootEnd;
  4285. }
  4286. return path.slice(0, end);
  4287. },
  4288. basename(path, ext) {
  4289. if (ext !== undefined) {
  4290. validateString(ext, 'ext');
  4291. }
  4292. validateString(path, 'path');
  4293. let start = 0;
  4294. let end = -1;
  4295. let matchedSlash = true;
  4296. let i;
  4297. // Check for a drive letter prefix so as not to mistake the following
  4298. // path separator as an extra separator at the end of the path that can be
  4299. // disregarded
  4300. if (path.length >= 2 &&
  4301. isWindowsDeviceRoot(path.charCodeAt(0)) &&
  4302. path.charCodeAt(1) === CHAR_COLON) {
  4303. start = 2;
  4304. }
  4305. if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
  4306. if (ext === path) {
  4307. return '';
  4308. }
  4309. let extIdx = ext.length - 1;
  4310. let firstNonSlashEnd = -1;
  4311. for (i = path.length - 1; i >= start; --i) {
  4312. const code = path.charCodeAt(i);
  4313. if (isPathSeparator(code)) {
  4314. // If we reached a path separator that was not part of a set of path
  4315. // separators at the end of the string, stop now
  4316. if (!matchedSlash) {
  4317. start = i + 1;
  4318. break;
  4319. }
  4320. }
  4321. else {
  4322. if (firstNonSlashEnd === -1) {
  4323. // We saw the first non-path separator, remember this index in case
  4324. // we need it if the extension ends up not matching
  4325. matchedSlash = false;
  4326. firstNonSlashEnd = i + 1;
  4327. }
  4328. if (extIdx >= 0) {
  4329. // Try to match the explicit extension
  4330. if (code === ext.charCodeAt(extIdx)) {
  4331. if (--extIdx === -1) {
  4332. // We matched the extension, so mark this as the end of our path
  4333. // component
  4334. end = i;
  4335. }
  4336. }
  4337. else {
  4338. // Extension does not match, so our result is the entire path
  4339. // component
  4340. extIdx = -1;
  4341. end = firstNonSlashEnd;
  4342. }
  4343. }
  4344. }
  4345. }
  4346. if (start === end) {
  4347. end = firstNonSlashEnd;
  4348. }
  4349. else if (end === -1) {
  4350. end = path.length;
  4351. }
  4352. return path.slice(start, end);
  4353. }
  4354. for (i = path.length - 1; i >= start; --i) {
  4355. if (isPathSeparator(path.charCodeAt(i))) {
  4356. // If we reached a path separator that was not part of a set of path
  4357. // separators at the end of the string, stop now
  4358. if (!matchedSlash) {
  4359. start = i + 1;
  4360. break;
  4361. }
  4362. }
  4363. else if (end === -1) {
  4364. // We saw the first non-path separator, mark this as the end of our
  4365. // path component
  4366. matchedSlash = false;
  4367. end = i + 1;
  4368. }
  4369. }
  4370. if (end === -1) {
  4371. return '';
  4372. }
  4373. return path.slice(start, end);
  4374. },
  4375. extname(path) {
  4376. validateString(path, 'path');
  4377. let start = 0;
  4378. let startDot = -1;
  4379. let startPart = 0;
  4380. let end = -1;
  4381. let matchedSlash = true;
  4382. // Track the state of characters (if any) we see before our first dot and
  4383. // after any path separator we find
  4384. let preDotState = 0;
  4385. // Check for a drive letter prefix so as not to mistake the following
  4386. // path separator as an extra separator at the end of the path that can be
  4387. // disregarded
  4388. if (path.length >= 2 &&
  4389. path.charCodeAt(1) === CHAR_COLON &&
  4390. isWindowsDeviceRoot(path.charCodeAt(0))) {
  4391. start = startPart = 2;
  4392. }
  4393. for (let i = path.length - 1; i >= start; --i) {
  4394. const code = path.charCodeAt(i);
  4395. if (isPathSeparator(code)) {
  4396. // If we reached a path separator that was not part of a set of path
  4397. // separators at the end of the string, stop now
  4398. if (!matchedSlash) {
  4399. startPart = i + 1;
  4400. break;
  4401. }
  4402. continue;
  4403. }
  4404. if (end === -1) {
  4405. // We saw the first non-path separator, mark this as the end of our
  4406. // extension
  4407. matchedSlash = false;
  4408. end = i + 1;
  4409. }
  4410. if (code === CHAR_DOT) {
  4411. // If this is our first dot, mark it as the start of our extension
  4412. if (startDot === -1) {
  4413. startDot = i;
  4414. }
  4415. else if (preDotState !== 1) {
  4416. preDotState = 1;
  4417. }
  4418. }
  4419. else if (startDot !== -1) {
  4420. // We saw a non-dot and non-path separator before our dot, so we should
  4421. // have a good chance at having a non-empty extension
  4422. preDotState = -1;
  4423. }
  4424. }
  4425. if (startDot === -1 ||
  4426. end === -1 ||
  4427. // We saw a non-dot character immediately before the dot
  4428. preDotState === 0 ||
  4429. // The (right-most) trimmed path component is exactly '..'
  4430. (preDotState === 1 &&
  4431. startDot === end - 1 &&
  4432. startDot === startPart + 1)) {
  4433. return '';
  4434. }
  4435. return path.slice(startDot, end);
  4436. },
  4437. format: _format.bind(null, '\\'),
  4438. parse(path) {
  4439. validateString(path, 'path');
  4440. const ret = { root: '', dir: '', base: '', ext: '', name: '' };
  4441. if (path.length === 0) {
  4442. return ret;
  4443. }
  4444. const len = path.length;
  4445. let rootEnd = 0;
  4446. let code = path.charCodeAt(0);
  4447. if (len === 1) {
  4448. if (isPathSeparator(code)) {
  4449. // `path` contains just a path separator, exit early to avoid
  4450. // unnecessary work
  4451. ret.root = ret.dir = path;
  4452. return ret;
  4453. }
  4454. ret.base = ret.name = path;
  4455. return ret;
  4456. }
  4457. // Try to match a root
  4458. if (isPathSeparator(code)) {
  4459. // Possible UNC root
  4460. rootEnd = 1;
  4461. if (isPathSeparator(path.charCodeAt(1))) {
  4462. // Matched double path separator at beginning
  4463. let j = 2;
  4464. let last = j;
  4465. // Match 1 or more non-path separators
  4466. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  4467. j++;
  4468. }
  4469. if (j < len && j !== last) {
  4470. // Matched!
  4471. last = j;
  4472. // Match 1 or more path separators
  4473. while (j < len && isPathSeparator(path.charCodeAt(j))) {
  4474. j++;
  4475. }
  4476. if (j < len && j !== last) {
  4477. // Matched!
  4478. last = j;
  4479. // Match 1 or more non-path separators
  4480. while (j < len && !isPathSeparator(path.charCodeAt(j))) {
  4481. j++;
  4482. }
  4483. if (j === len) {
  4484. // We matched a UNC root only
  4485. rootEnd = j;
  4486. }
  4487. else if (j !== last) {
  4488. // We matched a UNC root with leftovers
  4489. rootEnd = j + 1;
  4490. }
  4491. }
  4492. }
  4493. }
  4494. }
  4495. else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
  4496. // Possible device root
  4497. if (len <= 2) {
  4498. // `path` contains just a drive root, exit early to avoid
  4499. // unnecessary work
  4500. ret.root = ret.dir = path;
  4501. return ret;
  4502. }
  4503. rootEnd = 2;
  4504. if (isPathSeparator(path.charCodeAt(2))) {
  4505. if (len === 3) {
  4506. // `path` contains just a drive root, exit early to avoid
  4507. // unnecessary work
  4508. ret.root = ret.dir = path;
  4509. return ret;
  4510. }
  4511. rootEnd = 3;
  4512. }
  4513. }
  4514. if (rootEnd > 0) {
  4515. ret.root = path.slice(0, rootEnd);
  4516. }
  4517. let startDot = -1;
  4518. let startPart = rootEnd;
  4519. let end = -1;
  4520. let matchedSlash = true;
  4521. let i = path.length - 1;
  4522. // Track the state of characters (if any) we see before our first dot and
  4523. // after any path separator we find
  4524. let preDotState = 0;
  4525. // Get non-dir info
  4526. for (; i >= rootEnd; --i) {
  4527. code = path.charCodeAt(i);
  4528. if (isPathSeparator(code)) {
  4529. // If we reached a path separator that was not part of a set of path
  4530. // separators at the end of the string, stop now
  4531. if (!matchedSlash) {
  4532. startPart = i + 1;
  4533. break;
  4534. }
  4535. continue;
  4536. }
  4537. if (end === -1) {
  4538. // We saw the first non-path separator, mark this as the end of our
  4539. // extension
  4540. matchedSlash = false;
  4541. end = i + 1;
  4542. }
  4543. if (code === CHAR_DOT) {
  4544. // If this is our first dot, mark it as the start of our extension
  4545. if (startDot === -1) {
  4546. startDot = i;
  4547. }
  4548. else if (preDotState !== 1) {
  4549. preDotState = 1;
  4550. }
  4551. }
  4552. else if (startDot !== -1) {
  4553. // We saw a non-dot and non-path separator before our dot, so we should
  4554. // have a good chance at having a non-empty extension
  4555. preDotState = -1;
  4556. }
  4557. }
  4558. if (end !== -1) {
  4559. if (startDot === -1 ||
  4560. // We saw a non-dot character immediately before the dot
  4561. preDotState === 0 ||
  4562. // The (right-most) trimmed path component is exactly '..'
  4563. (preDotState === 1 &&
  4564. startDot === end - 1 &&
  4565. startDot === startPart + 1)) {
  4566. ret.base = ret.name = path.slice(startPart, end);
  4567. }
  4568. else {
  4569. ret.name = path.slice(startPart, startDot);
  4570. ret.base = path.slice(startPart, end);
  4571. ret.ext = path.slice(startDot, end);
  4572. }
  4573. }
  4574. // If the directory is the root, use the entire root as the `dir` including
  4575. // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
  4576. // trailing slash (`C:\abc\def` -> `C:\abc`).
  4577. if (startPart > 0 && startPart !== rootEnd) {
  4578. ret.dir = path.slice(0, startPart - 1);
  4579. }
  4580. else {
  4581. ret.dir = ret.root;
  4582. }
  4583. return ret;
  4584. },
  4585. sep: '\\',
  4586. delimiter: ';',
  4587. win32: null,
  4588. posix: null
  4589. };
  4590. exports.posix = {
  4591. // path.resolve([from ...], to)
  4592. resolve(...pathSegments) {
  4593. let resolvedPath = '';
  4594. let resolvedAbsolute = false;
  4595. for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  4596. const path = i >= 0 ? pathSegments[i] : process.cwd();
  4597. validateString(path, 'path');
  4598. // Skip empty entries
  4599. if (path.length === 0) {
  4600. continue;
  4601. }
  4602. resolvedPath = `${path}/${resolvedPath}`;
  4603. resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  4604. }
  4605. // At this point the path should be resolved to a full absolute path, but
  4606. // handle relative paths to be safe (might happen when process.cwd() fails)
  4607. // Normalize the path
  4608. resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
  4609. if (resolvedAbsolute) {
  4610. return `/${resolvedPath}`;
  4611. }
  4612. return resolvedPath.length > 0 ? resolvedPath : '.';
  4613. },
  4614. normalize(path) {
  4615. validateString(path, 'path');
  4616. if (path.length === 0) {
  4617. return '.';
  4618. }
  4619. const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  4620. const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
  4621. // Normalize the path
  4622. path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
  4623. if (path.length === 0) {
  4624. if (isAbsolute) {
  4625. return '/';
  4626. }
  4627. return trailingSeparator ? './' : '.';
  4628. }
  4629. if (trailingSeparator) {
  4630. path += '/';
  4631. }
  4632. return isAbsolute ? `/${path}` : path;
  4633. },
  4634. isAbsolute(path) {
  4635. validateString(path, 'path');
  4636. return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  4637. },
  4638. join(...paths) {
  4639. if (paths.length === 0) {
  4640. return '.';
  4641. }
  4642. let joined;
  4643. for (let i = 0; i < paths.length; ++i) {
  4644. const arg = paths[i];
  4645. validateString(arg, 'path');
  4646. if (arg.length > 0) {
  4647. if (joined === undefined) {
  4648. joined = arg;
  4649. }
  4650. else {
  4651. joined += `/${arg}`;
  4652. }
  4653. }
  4654. }
  4655. if (joined === undefined) {
  4656. return '.';
  4657. }
  4658. return exports.posix.normalize(joined);
  4659. },
  4660. relative(from, to) {
  4661. validateString(from, 'from');
  4662. validateString(to, 'to');
  4663. if (from === to) {
  4664. return '';
  4665. }
  4666. // Trim leading forward slashes.
  4667. from = exports.posix.resolve(from);
  4668. to = exports.posix.resolve(to);
  4669. if (from === to) {
  4670. return '';
  4671. }
  4672. const fromStart = 1;
  4673. const fromEnd = from.length;
  4674. const fromLen = fromEnd - fromStart;
  4675. const toStart = 1;
  4676. const toLen = to.length - toStart;
  4677. // Compare paths to find the longest common path from root
  4678. const length = (fromLen < toLen ? fromLen : toLen);
  4679. let lastCommonSep = -1;
  4680. let i = 0;
  4681. for (; i < length; i++) {
  4682. const fromCode = from.charCodeAt(fromStart + i);
  4683. if (fromCode !== to.charCodeAt(toStart + i)) {
  4684. break;
  4685. }
  4686. else if (fromCode === CHAR_FORWARD_SLASH) {
  4687. lastCommonSep = i;
  4688. }
  4689. }
  4690. if (i === length) {
  4691. if (toLen > length) {
  4692. if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
  4693. // We get here if `from` is the exact base path for `to`.
  4694. // For example: from='/foo/bar'; to='/foo/bar/baz'
  4695. return to.slice(toStart + i + 1);
  4696. }
  4697. if (i === 0) {
  4698. // We get here if `from` is the root
  4699. // For example: from='/'; to='/foo'
  4700. return to.slice(toStart + i);
  4701. }
  4702. }
  4703. else if (fromLen > length) {
  4704. if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
  4705. // We get here if `to` is the exact base path for `from`.
  4706. // For example: from='/foo/bar/baz'; to='/foo/bar'
  4707. lastCommonSep = i;
  4708. }
  4709. else if (i === 0) {
  4710. // We get here if `to` is the root.
  4711. // For example: from='/foo/bar'; to='/'
  4712. lastCommonSep = 0;
  4713. }
  4714. }
  4715. }
  4716. let out = '';
  4717. // Generate the relative path based on the path difference between `to`
  4718. // and `from`.
  4719. for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
  4720. if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  4721. out += out.length === 0 ? '..' : '/..';
  4722. }
  4723. }
  4724. // Lastly, append the rest of the destination (`to`) path that comes after
  4725. // the common path parts.
  4726. return `${out}${to.slice(toStart + lastCommonSep)}`;
  4727. },
  4728. toNamespacedPath(path) {
  4729. // Non-op on posix systems
  4730. return path;
  4731. },
  4732. dirname(path) {
  4733. validateString(path, 'path');
  4734. if (path.length === 0) {
  4735. return '.';
  4736. }
  4737. const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  4738. let end = -1;
  4739. let matchedSlash = true;
  4740. for (let i = path.length - 1; i >= 1; --i) {
  4741. if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  4742. if (!matchedSlash) {
  4743. end = i;
  4744. break;
  4745. }
  4746. }
  4747. else {
  4748. // We saw the first non-path separator
  4749. matchedSlash = false;
  4750. }
  4751. }
  4752. if (end === -1) {
  4753. return hasRoot ? '/' : '.';
  4754. }
  4755. if (hasRoot && end === 1) {
  4756. return '//';
  4757. }
  4758. return path.slice(0, end);
  4759. },
  4760. basename(path, ext) {
  4761. if (ext !== undefined) {
  4762. validateString(ext, 'ext');
  4763. }
  4764. validateString(path, 'path');
  4765. let start = 0;
  4766. let end = -1;
  4767. let matchedSlash = true;
  4768. let i;
  4769. if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
  4770. if (ext === path) {
  4771. return '';
  4772. }
  4773. let extIdx = ext.length - 1;
  4774. let firstNonSlashEnd = -1;
  4775. for (i = path.length - 1; i >= 0; --i) {
  4776. const code = path.charCodeAt(i);
  4777. if (code === CHAR_FORWARD_SLASH) {
  4778. // If we reached a path separator that was not part of a set of path
  4779. // separators at the end of the string, stop now
  4780. if (!matchedSlash) {
  4781. start = i + 1;
  4782. break;
  4783. }
  4784. }
  4785. else {
  4786. if (firstNonSlashEnd === -1) {
  4787. // We saw the first non-path separator, remember this index in case
  4788. // we need it if the extension ends up not matching
  4789. matchedSlash = false;
  4790. firstNonSlashEnd = i + 1;
  4791. }
  4792. if (extIdx >= 0) {
  4793. // Try to match the explicit extension
  4794. if (code === ext.charCodeAt(extIdx)) {
  4795. if (--extIdx === -1) {
  4796. // We matched the extension, so mark this as the end of our path
  4797. // component
  4798. end = i;
  4799. }
  4800. }
  4801. else {
  4802. // Extension does not match, so our result is the entire path
  4803. // component
  4804. extIdx = -1;
  4805. end = firstNonSlashEnd;
  4806. }
  4807. }
  4808. }
  4809. }
  4810. if (start === end) {
  4811. end = firstNonSlashEnd;
  4812. }
  4813. else if (end === -1) {
  4814. end = path.length;
  4815. }
  4816. return path.slice(start, end);
  4817. }
  4818. for (i = path.length - 1; i >= 0; --i) {
  4819. if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  4820. // If we reached a path separator that was not part of a set of path
  4821. // separators at the end of the string, stop now
  4822. if (!matchedSlash) {
  4823. start = i + 1;
  4824. break;
  4825. }
  4826. }
  4827. else if (end === -1) {
  4828. // We saw the first non-path separator, mark this as the end of our
  4829. // path component
  4830. matchedSlash = false;
  4831. end = i + 1;
  4832. }
  4833. }
  4834. if (end === -1) {
  4835. return '';
  4836. }
  4837. return path.slice(start, end);
  4838. },
  4839. extname(path) {
  4840. validateString(path, 'path');
  4841. let startDot = -1;
  4842. let startPart = 0;
  4843. let end = -1;
  4844. let matchedSlash = true;
  4845. // Track the state of characters (if any) we see before our first dot and
  4846. // after any path separator we find
  4847. let preDotState = 0;
  4848. for (let i = path.length - 1; i >= 0; --i) {
  4849. const code = path.charCodeAt(i);
  4850. if (code === CHAR_FORWARD_SLASH) {
  4851. // If we reached a path separator that was not part of a set of path
  4852. // separators at the end of the string, stop now
  4853. if (!matchedSlash) {
  4854. startPart = i + 1;
  4855. break;
  4856. }
  4857. continue;
  4858. }
  4859. if (end === -1) {
  4860. // We saw the first non-path separator, mark this as the end of our
  4861. // extension
  4862. matchedSlash = false;
  4863. end = i + 1;
  4864. }
  4865. if (code === CHAR_DOT) {
  4866. // If this is our first dot, mark it as the start of our extension
  4867. if (startDot === -1) {
  4868. startDot = i;
  4869. }
  4870. else if (preDotState !== 1) {
  4871. preDotState = 1;
  4872. }
  4873. }
  4874. else if (startDot !== -1) {
  4875. // We saw a non-dot and non-path separator before our dot, so we should
  4876. // have a good chance at having a non-empty extension
  4877. preDotState = -1;
  4878. }
  4879. }
  4880. if (startDot === -1 ||
  4881. end === -1 ||
  4882. // We saw a non-dot character immediately before the dot
  4883. preDotState === 0 ||
  4884. // The (right-most) trimmed path component is exactly '..'
  4885. (preDotState === 1 &&
  4886. startDot === end - 1 &&
  4887. startDot === startPart + 1)) {
  4888. return '';
  4889. }
  4890. return path.slice(startDot, end);
  4891. },
  4892. format: _format.bind(null, '/'),
  4893. parse(path) {
  4894. validateString(path, 'path');
  4895. const ret = { root: '', dir: '', base: '', ext: '', name: '' };
  4896. if (path.length === 0) {
  4897. return ret;
  4898. }
  4899. const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  4900. let start;
  4901. if (isAbsolute) {
  4902. ret.root = '/';
  4903. start = 1;
  4904. }
  4905. else {
  4906. start = 0;
  4907. }
  4908. let startDot = -1;
  4909. let startPart = 0;
  4910. let end = -1;
  4911. let matchedSlash = true;
  4912. let i = path.length - 1;
  4913. // Track the state of characters (if any) we see before our first dot and
  4914. // after any path separator we find
  4915. let preDotState = 0;
  4916. // Get non-dir info
  4917. for (; i >= start; --i) {
  4918. const code = path.charCodeAt(i);
  4919. if (code === CHAR_FORWARD_SLASH) {
  4920. // If we reached a path separator that was not part of a set of path
  4921. // separators at the end of the string, stop now
  4922. if (!matchedSlash) {
  4923. startPart = i + 1;
  4924. break;
  4925. }
  4926. continue;
  4927. }
  4928. if (end === -1) {
  4929. // We saw the first non-path separator, mark this as the end of our
  4930. // extension
  4931. matchedSlash = false;
  4932. end = i + 1;
  4933. }
  4934. if (code === CHAR_DOT) {
  4935. // If this is our first dot, mark it as the start of our extension
  4936. if (startDot === -1) {
  4937. startDot = i;
  4938. }
  4939. else if (preDotState !== 1) {
  4940. preDotState = 1;
  4941. }
  4942. }
  4943. else if (startDot !== -1) {
  4944. // We saw a non-dot and non-path separator before our dot, so we should
  4945. // have a good chance at having a non-empty extension
  4946. preDotState = -1;
  4947. }
  4948. }
  4949. if (end !== -1) {
  4950. const start = startPart === 0 && isAbsolute ? 1 : startPart;
  4951. if (startDot === -1 ||
  4952. // We saw a non-dot character immediately before the dot
  4953. preDotState === 0 ||
  4954. // The (right-most) trimmed path component is exactly '..'
  4955. (preDotState === 1 &&
  4956. startDot === end - 1 &&
  4957. startDot === startPart + 1)) {
  4958. ret.base = ret.name = path.slice(start, end);
  4959. }
  4960. else {
  4961. ret.name = path.slice(start, startDot);
  4962. ret.base = path.slice(start, end);
  4963. ret.ext = path.slice(startDot, end);
  4964. }
  4965. }
  4966. if (startPart > 0) {
  4967. ret.dir = path.slice(0, startPart - 1);
  4968. }
  4969. else if (isAbsolute) {
  4970. ret.dir = '/';
  4971. }
  4972. return ret;
  4973. },
  4974. sep: '/',
  4975. delimiter: ':',
  4976. win32: null,
  4977. posix: null
  4978. };
  4979. exports.posix.win32 = exports.win32.win32 = exports.win32;
  4980. exports.posix.posix = exports.win32.posix = exports.posix;
  4981. exports.normalize = (process.platform === 'win32' ? exports.win32.normalize : exports.posix.normalize);
  4982. exports.resolve = (process.platform === 'win32' ? exports.win32.resolve : exports.posix.resolve);
  4983. exports.relative = (process.platform === 'win32' ? exports.win32.relative : exports.posix.relative);
  4984. exports.dirname = (process.platform === 'win32' ? exports.win32.dirname : exports.posix.dirname);
  4985. exports.basename = (process.platform === 'win32' ? exports.win32.basename : exports.posix.basename);
  4986. exports.extname = (process.platform === 'win32' ? exports.win32.extname : exports.posix.extname);
  4987. exports.sep = (process.platform === 'win32' ? exports.win32.sep : exports.posix.sep);
  4988. });
  4989. /*---------------------------------------------------------------------------------------------
  4990. * Copyright (c) Microsoft Corporation. All rights reserved.
  4991. * Licensed under the MIT License. See License.txt in the project root for license information.
  4992. *--------------------------------------------------------------------------------------------*/
  4993. define(__m[10/*vs/base/common/stopwatch*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  4994. "use strict";
  4995. Object.defineProperty(exports, "__esModule", { value: true });
  4996. exports.StopWatch = void 0;
  4997. const hasPerformanceNow = (platform_1.globals.performance && typeof platform_1.globals.performance.now === 'function');
  4998. class StopWatch {
  4999. constructor(highResolution) {
  5000. this._highResolution = hasPerformanceNow && highResolution;
  5001. this._startTime = this._now();
  5002. this._stopTime = -1;
  5003. }
  5004. static create(highResolution = true) {
  5005. return new StopWatch(highResolution);
  5006. }
  5007. stop() {
  5008. this._stopTime = this._now();
  5009. }
  5010. elapsed() {
  5011. if (this._stopTime !== -1) {
  5012. return this._stopTime - this._startTime;
  5013. }
  5014. return this._now() - this._startTime;
  5015. }
  5016. _now() {
  5017. return this._highResolution ? platform_1.globals.performance.now() : Date.now();
  5018. }
  5019. }
  5020. exports.StopWatch = StopWatch;
  5021. });
  5022. define(__m[7/*vs/base/common/event*/], __M([0/*require*/,1/*exports*/,8/*vs/base/common/errors*/,9/*vs/base/common/lifecycle*/,20/*vs/base/common/linkedList*/,10/*vs/base/common/stopwatch*/]), function (require, exports, errors_1, lifecycle_1, linkedList_1, stopwatch_1) {
  5023. "use strict";
  5024. Object.defineProperty(exports, "__esModule", { value: true });
  5025. exports.Relay = exports.EventBufferer = exports.DebounceEmitter = exports.PauseableEmitter = exports.Emitter = exports.Event = void 0;
  5026. var Event;
  5027. (function (Event) {
  5028. Event.None = () => lifecycle_1.Disposable.None;
  5029. /**
  5030. * Given an event, returns another event which only fires once.
  5031. */
  5032. function once(event) {
  5033. return (listener, thisArgs = null, disposables) => {
  5034. // we need this, in case the event fires during the listener call
  5035. let didFire = false;
  5036. let result;
  5037. result = event(e => {
  5038. if (didFire) {
  5039. return;
  5040. }
  5041. else if (result) {
  5042. result.dispose();
  5043. }
  5044. else {
  5045. didFire = true;
  5046. }
  5047. return listener.call(thisArgs, e);
  5048. }, null, disposables);
  5049. if (didFire) {
  5050. result.dispose();
  5051. }
  5052. return result;
  5053. };
  5054. }
  5055. Event.once = once;
  5056. /**
  5057. * @deprecated DO NOT use, this leaks memory
  5058. */
  5059. function map(event, map) {
  5060. return snapshot((listener, thisArgs = null, disposables) => event(i => listener.call(thisArgs, map(i)), null, disposables));
  5061. }
  5062. Event.map = map;
  5063. /**
  5064. * @deprecated DO NOT use, this leaks memory
  5065. */
  5066. function forEach(event, each) {
  5067. return snapshot((listener, thisArgs = null, disposables) => event(i => { each(i); listener.call(thisArgs, i); }, null, disposables));
  5068. }
  5069. Event.forEach = forEach;
  5070. function filter(event, filter) {
  5071. return snapshot((listener, thisArgs = null, disposables) => event(e => filter(e) && listener.call(thisArgs, e), null, disposables));
  5072. }
  5073. Event.filter = filter;
  5074. /**
  5075. * Given an event, returns the same event but typed as `Event<void>`.
  5076. */
  5077. function signal(event) {
  5078. return event;
  5079. }
  5080. Event.signal = signal;
  5081. function any(...events) {
  5082. return (listener, thisArgs = null, disposables) => (0, lifecycle_1.combinedDisposable)(...events.map(event => event(e => listener.call(thisArgs, e), null, disposables)));
  5083. }
  5084. Event.any = any;
  5085. /**
  5086. * @deprecated DO NOT use, this leaks memory
  5087. */
  5088. function reduce(event, merge, initial) {
  5089. let output = initial;
  5090. return map(event, e => {
  5091. output = merge(output, e);
  5092. return output;
  5093. });
  5094. }
  5095. Event.reduce = reduce;
  5096. /**
  5097. * @deprecated DO NOT use, this leaks memory
  5098. */
  5099. function snapshot(event) {
  5100. let listener;
  5101. const emitter = new Emitter({
  5102. onFirstListenerAdd() {
  5103. listener = event(emitter.fire, emitter);
  5104. },
  5105. onLastListenerRemove() {
  5106. listener.dispose();
  5107. }
  5108. });
  5109. return emitter.event;
  5110. }
  5111. /**
  5112. * @deprecated DO NOT use, this leaks memory
  5113. */
  5114. function debounce(event, merge, delay = 100, leading = false, leakWarningThreshold) {
  5115. let subscription;
  5116. let output = undefined;
  5117. let handle = undefined;
  5118. let numDebouncedCalls = 0;
  5119. const emitter = new Emitter({
  5120. leakWarningThreshold,
  5121. onFirstListenerAdd() {
  5122. subscription = event(cur => {
  5123. numDebouncedCalls++;
  5124. output = merge(output, cur);
  5125. if (leading && !handle) {
  5126. emitter.fire(output);
  5127. output = undefined;
  5128. }
  5129. clearTimeout(handle);
  5130. handle = setTimeout(() => {
  5131. const _output = output;
  5132. output = undefined;
  5133. handle = undefined;
  5134. if (!leading || numDebouncedCalls > 1) {
  5135. emitter.fire(_output);
  5136. }
  5137. numDebouncedCalls = 0;
  5138. }, delay);
  5139. });
  5140. },
  5141. onLastListenerRemove() {
  5142. subscription.dispose();
  5143. }
  5144. });
  5145. return emitter.event;
  5146. }
  5147. Event.debounce = debounce;
  5148. /**
  5149. * @deprecated DO NOT use, this leaks memory
  5150. */
  5151. function latch(event, equals = (a, b) => a === b) {
  5152. let firstCall = true;
  5153. let cache;
  5154. return filter(event, value => {
  5155. const shouldEmit = firstCall || !equals(value, cache);
  5156. firstCall = false;
  5157. cache = value;
  5158. return shouldEmit;
  5159. });
  5160. }
  5161. Event.latch = latch;
  5162. /**
  5163. * @deprecated DO NOT use, this leaks memory
  5164. */
  5165. function split(event, isT) {
  5166. return [
  5167. Event.filter(event, isT),
  5168. Event.filter(event, e => !isT(e)),
  5169. ];
  5170. }
  5171. Event.split = split;
  5172. /**
  5173. * @deprecated DO NOT use, this leaks memory
  5174. */
  5175. function buffer(event, flushAfterTimeout = false, _buffer = []) {
  5176. let buffer = _buffer.slice();
  5177. let listener = event(e => {
  5178. if (buffer) {
  5179. buffer.push(e);
  5180. }
  5181. else {
  5182. emitter.fire(e);
  5183. }
  5184. });
  5185. const flush = () => {
  5186. if (buffer) {
  5187. buffer.forEach(e => emitter.fire(e));
  5188. }
  5189. buffer = null;
  5190. };
  5191. const emitter = new Emitter({
  5192. onFirstListenerAdd() {
  5193. if (!listener) {
  5194. listener = event(e => emitter.fire(e));
  5195. }
  5196. },
  5197. onFirstListenerDidAdd() {
  5198. if (buffer) {
  5199. if (flushAfterTimeout) {
  5200. setTimeout(flush);
  5201. }
  5202. else {
  5203. flush();
  5204. }
  5205. }
  5206. },
  5207. onLastListenerRemove() {
  5208. if (listener) {
  5209. listener.dispose();
  5210. }
  5211. listener = null;
  5212. }
  5213. });
  5214. return emitter.event;
  5215. }
  5216. Event.buffer = buffer;
  5217. class ChainableEvent {
  5218. constructor(event) {
  5219. this.event = event;
  5220. }
  5221. map(fn) {
  5222. return new ChainableEvent(map(this.event, fn));
  5223. }
  5224. forEach(fn) {
  5225. return new ChainableEvent(forEach(this.event, fn));
  5226. }
  5227. filter(fn) {
  5228. return new ChainableEvent(filter(this.event, fn));
  5229. }
  5230. reduce(merge, initial) {
  5231. return new ChainableEvent(reduce(this.event, merge, initial));
  5232. }
  5233. latch() {
  5234. return new ChainableEvent(latch(this.event));
  5235. }
  5236. debounce(merge, delay = 100, leading = false, leakWarningThreshold) {
  5237. return new ChainableEvent(debounce(this.event, merge, delay, leading, leakWarningThreshold));
  5238. }
  5239. on(listener, thisArgs, disposables) {
  5240. return this.event(listener, thisArgs, disposables);
  5241. }
  5242. once(listener, thisArgs, disposables) {
  5243. return once(this.event)(listener, thisArgs, disposables);
  5244. }
  5245. }
  5246. /**
  5247. * @deprecated DO NOT use, this leaks memory
  5248. */
  5249. function chain(event) {
  5250. return new ChainableEvent(event);
  5251. }
  5252. Event.chain = chain;
  5253. function fromNodeEventEmitter(emitter, eventName, map = id => id) {
  5254. const fn = (...args) => result.fire(map(...args));
  5255. const onFirstListenerAdd = () => emitter.on(eventName, fn);
  5256. const onLastListenerRemove = () => emitter.removeListener(eventName, fn);
  5257. const result = new Emitter({ onFirstListenerAdd, onLastListenerRemove });
  5258. return result.event;
  5259. }
  5260. Event.fromNodeEventEmitter = fromNodeEventEmitter;
  5261. function fromDOMEventEmitter(emitter, eventName, map = id => id) {
  5262. const fn = (...args) => result.fire(map(...args));
  5263. const onFirstListenerAdd = () => emitter.addEventListener(eventName, fn);
  5264. const onLastListenerRemove = () => emitter.removeEventListener(eventName, fn);
  5265. const result = new Emitter({ onFirstListenerAdd, onLastListenerRemove });
  5266. return result.event;
  5267. }
  5268. Event.fromDOMEventEmitter = fromDOMEventEmitter;
  5269. function toPromise(event) {
  5270. return new Promise(resolve => once(event)(resolve));
  5271. }
  5272. Event.toPromise = toPromise;
  5273. })(Event = exports.Event || (exports.Event = {}));
  5274. class EventProfiling {
  5275. constructor(name) {
  5276. this._listenerCount = 0;
  5277. this._invocationCount = 0;
  5278. this._elapsedOverall = 0;
  5279. this._name = `${name}_${EventProfiling._idPool++}`;
  5280. }
  5281. start(listenerCount) {
  5282. this._stopWatch = new stopwatch_1.StopWatch(true);
  5283. this._listenerCount = listenerCount;
  5284. }
  5285. stop() {
  5286. if (this._stopWatch) {
  5287. const elapsed = this._stopWatch.elapsed();
  5288. this._elapsedOverall += elapsed;
  5289. this._invocationCount += 1;
  5290. console.info(`did FIRE ${this._name}: elapsed_ms: ${elapsed.toFixed(5)}, listener: ${this._listenerCount} (elapsed_overall: ${this._elapsedOverall.toFixed(2)}, invocations: ${this._invocationCount})`);
  5291. this._stopWatch = undefined;
  5292. }
  5293. }
  5294. }
  5295. EventProfiling._idPool = 0;
  5296. let _globalLeakWarningThreshold = -1;
  5297. class LeakageMonitor {
  5298. constructor(customThreshold, name = Math.random().toString(18).slice(2, 5)) {
  5299. this.customThreshold = customThreshold;
  5300. this.name = name;
  5301. this._warnCountdown = 0;
  5302. }
  5303. dispose() {
  5304. if (this._stacks) {
  5305. this._stacks.clear();
  5306. }
  5307. }
  5308. check(listenerCount) {
  5309. let threshold = _globalLeakWarningThreshold;
  5310. if (typeof this.customThreshold === 'number') {
  5311. threshold = this.customThreshold;
  5312. }
  5313. if (threshold <= 0 || listenerCount < threshold) {
  5314. return undefined;
  5315. }
  5316. if (!this._stacks) {
  5317. this._stacks = new Map();
  5318. }
  5319. const stack = new Error().stack.split('\n').slice(3).join('\n');
  5320. const count = (this._stacks.get(stack) || 0);
  5321. this._stacks.set(stack, count + 1);
  5322. this._warnCountdown -= 1;
  5323. if (this._warnCountdown <= 0) {
  5324. // only warn on first exceed and then every time the limit
  5325. // is exceeded by 50% again
  5326. this._warnCountdown = threshold * 0.5;
  5327. // find most frequent listener and print warning
  5328. let topStack;
  5329. let topCount = 0;
  5330. for (const [stack, count] of this._stacks) {
  5331. if (!topStack || topCount < count) {
  5332. topStack = stack;
  5333. topCount = count;
  5334. }
  5335. }
  5336. console.warn(`[${this.name}] potential listener LEAK detected, having ${listenerCount} listeners already. MOST frequent listener (${topCount}):`);
  5337. console.warn(topStack);
  5338. }
  5339. return () => {
  5340. const count = (this._stacks.get(stack) || 0);
  5341. this._stacks.set(stack, count - 1);
  5342. };
  5343. }
  5344. }
  5345. /**
  5346. * The Emitter can be used to expose an Event to the public
  5347. * to fire it from the insides.
  5348. * Sample:
  5349. class Document {
  5350. private readonly _onDidChange = new Emitter<(value:string)=>any>();
  5351. public onDidChange = this._onDidChange.event;
  5352. // getter-style
  5353. // get onDidChange(): Event<(value:string)=>any> {
  5354. // return this._onDidChange.event;
  5355. // }
  5356. private _doIt() {
  5357. //...
  5358. this._onDidChange.fire(value);
  5359. }
  5360. }
  5361. */
  5362. class Emitter {
  5363. constructor(options) {
  5364. var _a;
  5365. this._disposed = false;
  5366. this._options = options;
  5367. this._leakageMon = _globalLeakWarningThreshold > 0 ? new LeakageMonitor(this._options && this._options.leakWarningThreshold) : undefined;
  5368. this._perfMon = ((_a = this._options) === null || _a === void 0 ? void 0 : _a._profName) ? new EventProfiling(this._options._profName) : undefined;
  5369. }
  5370. /**
  5371. * For the public to allow to subscribe
  5372. * to events from this Emitter
  5373. */
  5374. get event() {
  5375. if (!this._event) {
  5376. this._event = (listener, thisArgs, disposables) => {
  5377. var _a;
  5378. if (!this._listeners) {
  5379. this._listeners = new linkedList_1.LinkedList();
  5380. }
  5381. const firstListener = this._listeners.isEmpty();
  5382. if (firstListener && this._options && this._options.onFirstListenerAdd) {
  5383. this._options.onFirstListenerAdd(this);
  5384. }
  5385. const remove = this._listeners.push(!thisArgs ? listener : [listener, thisArgs]);
  5386. if (firstListener && this._options && this._options.onFirstListenerDidAdd) {
  5387. this._options.onFirstListenerDidAdd(this);
  5388. }
  5389. if (this._options && this._options.onListenerDidAdd) {
  5390. this._options.onListenerDidAdd(this, listener, thisArgs);
  5391. }
  5392. // check and record this emitter for potential leakage
  5393. const removeMonitor = (_a = this._leakageMon) === null || _a === void 0 ? void 0 : _a.check(this._listeners.size);
  5394. const result = (0, lifecycle_1.toDisposable)(() => {
  5395. if (removeMonitor) {
  5396. removeMonitor();
  5397. }
  5398. if (!this._disposed) {
  5399. remove();
  5400. if (this._options && this._options.onLastListenerRemove) {
  5401. const hasListeners = (this._listeners && !this._listeners.isEmpty());
  5402. if (!hasListeners) {
  5403. this._options.onLastListenerRemove(this);
  5404. }
  5405. }
  5406. }
  5407. });
  5408. if (disposables instanceof lifecycle_1.DisposableStore) {
  5409. disposables.add(result);
  5410. }
  5411. else if (Array.isArray(disposables)) {
  5412. disposables.push(result);
  5413. }
  5414. return result;
  5415. };
  5416. }
  5417. return this._event;
  5418. }
  5419. /**
  5420. * To be kept private to fire an event to
  5421. * subscribers
  5422. */
  5423. fire(event) {
  5424. var _a, _b;
  5425. if (this._listeners) {
  5426. // put all [listener,event]-pairs into delivery queue
  5427. // then emit all event. an inner/nested event might be
  5428. // the driver of this
  5429. if (!this._deliveryQueue) {
  5430. this._deliveryQueue = new linkedList_1.LinkedList();
  5431. }
  5432. for (let listener of this._listeners) {
  5433. this._deliveryQueue.push([listener, event]);
  5434. }
  5435. // start/stop performance insight collection
  5436. (_a = this._perfMon) === null || _a === void 0 ? void 0 : _a.start(this._deliveryQueue.size);
  5437. while (this._deliveryQueue.size > 0) {
  5438. const [listener, event] = this._deliveryQueue.shift();
  5439. try {
  5440. if (typeof listener === 'function') {
  5441. listener.call(undefined, event);
  5442. }
  5443. else {
  5444. listener[0].call(listener[1], event);
  5445. }
  5446. }
  5447. catch (e) {
  5448. (0, errors_1.onUnexpectedError)(e);
  5449. }
  5450. }
  5451. (_b = this._perfMon) === null || _b === void 0 ? void 0 : _b.stop();
  5452. }
  5453. }
  5454. dispose() {
  5455. var _a, _b, _c, _d, _e;
  5456. if (!this._disposed) {
  5457. this._disposed = true;
  5458. (_a = this._listeners) === null || _a === void 0 ? void 0 : _a.clear();
  5459. (_b = this._deliveryQueue) === null || _b === void 0 ? void 0 : _b.clear();
  5460. (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.onLastListenerRemove) === null || _d === void 0 ? void 0 : _d.call(_c);
  5461. (_e = this._leakageMon) === null || _e === void 0 ? void 0 : _e.dispose();
  5462. }
  5463. }
  5464. }
  5465. exports.Emitter = Emitter;
  5466. class PauseableEmitter extends Emitter {
  5467. constructor(options) {
  5468. super(options);
  5469. this._isPaused = 0;
  5470. this._eventQueue = new linkedList_1.LinkedList();
  5471. this._mergeFn = options === null || options === void 0 ? void 0 : options.merge;
  5472. }
  5473. pause() {
  5474. this._isPaused++;
  5475. }
  5476. resume() {
  5477. if (this._isPaused !== 0 && --this._isPaused === 0) {
  5478. if (this._mergeFn) {
  5479. // use the merge function to create a single composite
  5480. // event. make a copy in case firing pauses this emitter
  5481. const events = Array.from(this._eventQueue);
  5482. this._eventQueue.clear();
  5483. super.fire(this._mergeFn(events));
  5484. }
  5485. else {
  5486. // no merging, fire each event individually and test
  5487. // that this emitter isn't paused halfway through
  5488. while (!this._isPaused && this._eventQueue.size !== 0) {
  5489. super.fire(this._eventQueue.shift());
  5490. }
  5491. }
  5492. }
  5493. }
  5494. fire(event) {
  5495. if (this._listeners) {
  5496. if (this._isPaused !== 0) {
  5497. this._eventQueue.push(event);
  5498. }
  5499. else {
  5500. super.fire(event);
  5501. }
  5502. }
  5503. }
  5504. }
  5505. exports.PauseableEmitter = PauseableEmitter;
  5506. class DebounceEmitter extends PauseableEmitter {
  5507. constructor(options) {
  5508. var _a;
  5509. super(options);
  5510. this._delay = (_a = options.delay) !== null && _a !== void 0 ? _a : 100;
  5511. }
  5512. fire(event) {
  5513. if (!this._handle) {
  5514. this.pause();
  5515. this._handle = setTimeout(() => {
  5516. this._handle = undefined;
  5517. this.resume();
  5518. }, this._delay);
  5519. }
  5520. super.fire(event);
  5521. }
  5522. }
  5523. exports.DebounceEmitter = DebounceEmitter;
  5524. /**
  5525. * The EventBufferer is useful in situations in which you want
  5526. * to delay firing your events during some code.
  5527. * You can wrap that code and be sure that the event will not
  5528. * be fired during that wrap.
  5529. *
  5530. * ```
  5531. * const emitter: Emitter;
  5532. * const delayer = new EventDelayer();
  5533. * const delayedEvent = delayer.wrapEvent(emitter.event);
  5534. *
  5535. * delayedEvent(console.log);
  5536. *
  5537. * delayer.bufferEvents(() => {
  5538. * emitter.fire(); // event will not be fired yet
  5539. * });
  5540. *
  5541. * // event will only be fired at this point
  5542. * ```
  5543. */
  5544. class EventBufferer {
  5545. constructor() {
  5546. this.buffers = [];
  5547. }
  5548. wrapEvent(event) {
  5549. return (listener, thisArgs, disposables) => {
  5550. return event(i => {
  5551. const buffer = this.buffers[this.buffers.length - 1];
  5552. if (buffer) {
  5553. buffer.push(() => listener.call(thisArgs, i));
  5554. }
  5555. else {
  5556. listener.call(thisArgs, i);
  5557. }
  5558. }, undefined, disposables);
  5559. };
  5560. }
  5561. bufferEvents(fn) {
  5562. const buffer = [];
  5563. this.buffers.push(buffer);
  5564. const r = fn();
  5565. this.buffers.pop();
  5566. buffer.forEach(flush => flush());
  5567. return r;
  5568. }
  5569. }
  5570. exports.EventBufferer = EventBufferer;
  5571. /**
  5572. * A Relay is an event forwarder which functions as a replugabble event pipe.
  5573. * Once created, you can connect an input event to it and it will simply forward
  5574. * events from that input event through its own `event` property. The `input`
  5575. * can be changed at any point in time.
  5576. */
  5577. class Relay {
  5578. constructor() {
  5579. this.listening = false;
  5580. this.inputEvent = Event.None;
  5581. this.inputEventListener = lifecycle_1.Disposable.None;
  5582. this.emitter = new Emitter({
  5583. onFirstListenerDidAdd: () => {
  5584. this.listening = true;
  5585. this.inputEventListener = this.inputEvent(this.emitter.fire, this.emitter);
  5586. },
  5587. onLastListenerRemove: () => {
  5588. this.listening = false;
  5589. this.inputEventListener.dispose();
  5590. }
  5591. });
  5592. this.event = this.emitter.event;
  5593. }
  5594. set input(event) {
  5595. this.inputEvent = event;
  5596. if (this.listening) {
  5597. this.inputEventListener.dispose();
  5598. this.inputEventListener = event(this.emitter.fire, this.emitter);
  5599. }
  5600. }
  5601. dispose() {
  5602. this.inputEventListener.dispose();
  5603. this.emitter.dispose();
  5604. }
  5605. }
  5606. exports.Relay = Relay;
  5607. });
  5608. /*---------------------------------------------------------------------------------------------
  5609. * Copyright (c) Microsoft Corporation. All rights reserved.
  5610. * Licensed under the MIT License. See License.txt in the project root for license information.
  5611. *--------------------------------------------------------------------------------------------*/
  5612. define(__m[23/*vs/base/common/cancellation*/], __M([0/*require*/,1/*exports*/,7/*vs/base/common/event*/]), function (require, exports, event_1) {
  5613. "use strict";
  5614. Object.defineProperty(exports, "__esModule", { value: true });
  5615. exports.CancellationTokenSource = exports.CancellationToken = void 0;
  5616. const shortcutEvent = Object.freeze(function (callback, context) {
  5617. const handle = setTimeout(callback.bind(context), 0);
  5618. return { dispose() { clearTimeout(handle); } };
  5619. });
  5620. var CancellationToken;
  5621. (function (CancellationToken) {
  5622. function isCancellationToken(thing) {
  5623. if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {
  5624. return true;
  5625. }
  5626. if (thing instanceof MutableToken) {
  5627. return true;
  5628. }
  5629. if (!thing || typeof thing !== 'object') {
  5630. return false;
  5631. }
  5632. return typeof thing.isCancellationRequested === 'boolean'
  5633. && typeof thing.onCancellationRequested === 'function';
  5634. }
  5635. CancellationToken.isCancellationToken = isCancellationToken;
  5636. CancellationToken.None = Object.freeze({
  5637. isCancellationRequested: false,
  5638. onCancellationRequested: event_1.Event.None
  5639. });
  5640. CancellationToken.Cancelled = Object.freeze({
  5641. isCancellationRequested: true,
  5642. onCancellationRequested: shortcutEvent
  5643. });
  5644. })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
  5645. class MutableToken {
  5646. constructor() {
  5647. this._isCancelled = false;
  5648. this._emitter = null;
  5649. }
  5650. cancel() {
  5651. if (!this._isCancelled) {
  5652. this._isCancelled = true;
  5653. if (this._emitter) {
  5654. this._emitter.fire(undefined);
  5655. this.dispose();
  5656. }
  5657. }
  5658. }
  5659. get isCancellationRequested() {
  5660. return this._isCancelled;
  5661. }
  5662. get onCancellationRequested() {
  5663. if (this._isCancelled) {
  5664. return shortcutEvent;
  5665. }
  5666. if (!this._emitter) {
  5667. this._emitter = new event_1.Emitter();
  5668. }
  5669. return this._emitter.event;
  5670. }
  5671. dispose() {
  5672. if (this._emitter) {
  5673. this._emitter.dispose();
  5674. this._emitter = null;
  5675. }
  5676. }
  5677. }
  5678. class CancellationTokenSource {
  5679. constructor(parent) {
  5680. this._token = undefined;
  5681. this._parentListener = undefined;
  5682. this._parentListener = parent && parent.onCancellationRequested(this.cancel, this);
  5683. }
  5684. get token() {
  5685. if (!this._token) {
  5686. // be lazy and create the token only when
  5687. // actually needed
  5688. this._token = new MutableToken();
  5689. }
  5690. return this._token;
  5691. }
  5692. cancel() {
  5693. if (!this._token) {
  5694. // save an object by returning the default
  5695. // cancelled token when cancellation happens
  5696. // before someone asks for the token
  5697. this._token = CancellationToken.Cancelled;
  5698. }
  5699. else if (this._token instanceof MutableToken) {
  5700. // actually cancel
  5701. this._token.cancel();
  5702. }
  5703. }
  5704. dispose(cancel = false) {
  5705. if (cancel) {
  5706. this.cancel();
  5707. }
  5708. if (this._parentListener) {
  5709. this._parentListener.dispose();
  5710. }
  5711. if (!this._token) {
  5712. // ensure to initialize with an empty token if we had none
  5713. this._token = CancellationToken.None;
  5714. }
  5715. else if (this._token instanceof MutableToken) {
  5716. // actually dispose
  5717. this._token.dispose();
  5718. }
  5719. }
  5720. }
  5721. exports.CancellationTokenSource = CancellationTokenSource;
  5722. });
  5723. /*---------------------------------------------------------------------------------------------
  5724. * Copyright (c) Microsoft Corporation. All rights reserved.
  5725. * Licensed under the MIT License. See License.txt in the project root for license information.
  5726. *--------------------------------------------------------------------------------------------*/
  5727. define(__m[3/*vs/base/common/strings*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/platform*/]), function (require, exports, platform) {
  5728. "use strict";
  5729. Object.defineProperty(exports, "__esModule", { value: true });
  5730. exports.InvisibleCharacters = exports.AmbiguousCharacters = exports.noBreakWhitespace = exports.getLeftDeleteOffset = exports.breakBetweenGraphemeBreakType = exports.getGraphemeBreakType = exports.singleLetterHash = exports.containsUppercaseCharacter = exports.startsWithUTF8BOM = exports.UTF8_BOM_CHARACTER = exports.isEmojiImprecise = exports.isFullWidthCharacter = exports.containsFullWidthCharacter = exports.containsUnusualLineTerminators = exports.UNUSUAL_LINE_TERMINATORS = exports.isBasicASCII = exports.containsEmoji = exports.containsRTL = exports.prevCharLength = exports.nextCharLength = exports.getNextCodePoint = exports.computeCodePoint = exports.isLowSurrogate = exports.isHighSurrogate = exports.commonSuffixLength = exports.commonPrefixLength = exports.startsWithIgnoreCase = exports.equalsIgnoreCase = exports.isUpperAsciiLetter = exports.isLowerAsciiLetter = exports.compareSubstringIgnoreCase = exports.compareIgnoreCase = exports.compareSubstring = exports.compare = exports.lastNonWhitespaceIndex = exports.getLeadingWhitespace = exports.firstNonWhitespaceIndex = exports.splitLines = exports.regExpFlags = exports.regExpLeadsToEndlessLoop = exports.createRegExp = exports.stripWildcards = exports.convertSimple2RegExpPattern = exports.rtrim = exports.ltrim = exports.trim = exports.escapeRegExpCharacters = exports.escape = exports.format = exports.isFalsyOrWhitespace = void 0;
  5731. function isFalsyOrWhitespace(str) {
  5732. if (!str || typeof str !== 'string') {
  5733. return true;
  5734. }
  5735. return str.trim().length === 0;
  5736. }
  5737. exports.isFalsyOrWhitespace = isFalsyOrWhitespace;
  5738. const _formatRegexp = /{(\d+)}/g;
  5739. /**
  5740. * Helper to produce a string with a variable number of arguments. Insert variable segments
  5741. * into the string using the {n} notation where N is the index of the argument following the string.
  5742. * @param value string to which formatting is applied
  5743. * @param args replacements for {n}-entries
  5744. */
  5745. function format(value, ...args) {
  5746. if (args.length === 0) {
  5747. return value;
  5748. }
  5749. return value.replace(_formatRegexp, function (match, group) {
  5750. const idx = parseInt(group, 10);
  5751. return isNaN(idx) || idx < 0 || idx >= args.length ?
  5752. match :
  5753. args[idx];
  5754. });
  5755. }
  5756. exports.format = format;
  5757. /**
  5758. * Converts HTML characters inside the string to use entities instead. Makes the string safe from
  5759. * being used e.g. in HTMLElement.innerHTML.
  5760. */
  5761. function escape(html) {
  5762. return html.replace(/[<>&]/g, function (match) {
  5763. switch (match) {
  5764. case '<': return '&lt;';
  5765. case '>': return '&gt;';
  5766. case '&': return '&amp;';
  5767. default: return match;
  5768. }
  5769. });
  5770. }
  5771. exports.escape = escape;
  5772. /**
  5773. * Escapes regular expression characters in a given string
  5774. */
  5775. function escapeRegExpCharacters(value) {
  5776. return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
  5777. }
  5778. exports.escapeRegExpCharacters = escapeRegExpCharacters;
  5779. /**
  5780. * Removes all occurrences of needle from the beginning and end of haystack.
  5781. * @param haystack string to trim
  5782. * @param needle the thing to trim (default is a blank)
  5783. */
  5784. function trim(haystack, needle = ' ') {
  5785. const trimmed = ltrim(haystack, needle);
  5786. return rtrim(trimmed, needle);
  5787. }
  5788. exports.trim = trim;
  5789. /**
  5790. * Removes all occurrences of needle from the beginning of haystack.
  5791. * @param haystack string to trim
  5792. * @param needle the thing to trim
  5793. */
  5794. function ltrim(haystack, needle) {
  5795. if (!haystack || !needle) {
  5796. return haystack;
  5797. }
  5798. const needleLen = needle.length;
  5799. if (needleLen === 0 || haystack.length === 0) {
  5800. return haystack;
  5801. }
  5802. let offset = 0;
  5803. while (haystack.indexOf(needle, offset) === offset) {
  5804. offset = offset + needleLen;
  5805. }
  5806. return haystack.substring(offset);
  5807. }
  5808. exports.ltrim = ltrim;
  5809. /**
  5810. * Removes all occurrences of needle from the end of haystack.
  5811. * @param haystack string to trim
  5812. * @param needle the thing to trim
  5813. */
  5814. function rtrim(haystack, needle) {
  5815. if (!haystack || !needle) {
  5816. return haystack;
  5817. }
  5818. const needleLen = needle.length, haystackLen = haystack.length;
  5819. if (needleLen === 0 || haystackLen === 0) {
  5820. return haystack;
  5821. }
  5822. let offset = haystackLen, idx = -1;
  5823. while (true) {
  5824. idx = haystack.lastIndexOf(needle, offset - 1);
  5825. if (idx === -1 || idx + needleLen !== offset) {
  5826. break;
  5827. }
  5828. if (idx === 0) {
  5829. return '';
  5830. }
  5831. offset = idx;
  5832. }
  5833. return haystack.substring(0, offset);
  5834. }
  5835. exports.rtrim = rtrim;
  5836. function convertSimple2RegExpPattern(pattern) {
  5837. return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
  5838. }
  5839. exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
  5840. function stripWildcards(pattern) {
  5841. return pattern.replace(/\*/g, '');
  5842. }
  5843. exports.stripWildcards = stripWildcards;
  5844. function createRegExp(searchString, isRegex, options = {}) {
  5845. if (!searchString) {
  5846. throw new Error('Cannot create regex from empty string');
  5847. }
  5848. if (!isRegex) {
  5849. searchString = escapeRegExpCharacters(searchString);
  5850. }
  5851. if (options.wholeWord) {
  5852. if (!/\B/.test(searchString.charAt(0))) {
  5853. searchString = '\\b' + searchString;
  5854. }
  5855. if (!/\B/.test(searchString.charAt(searchString.length - 1))) {
  5856. searchString = searchString + '\\b';
  5857. }
  5858. }
  5859. let modifiers = '';
  5860. if (options.global) {
  5861. modifiers += 'g';
  5862. }
  5863. if (!options.matchCase) {
  5864. modifiers += 'i';
  5865. }
  5866. if (options.multiline) {
  5867. modifiers += 'm';
  5868. }
  5869. if (options.unicode) {
  5870. modifiers += 'u';
  5871. }
  5872. return new RegExp(searchString, modifiers);
  5873. }
  5874. exports.createRegExp = createRegExp;
  5875. function regExpLeadsToEndlessLoop(regexp) {
  5876. // Exit early if it's one of these special cases which are meant to match
  5877. // against an empty string
  5878. if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\s*$') {
  5879. return false;
  5880. }
  5881. // We check against an empty string. If the regular expression doesn't advance
  5882. // (e.g. ends in an endless loop) it will match an empty string.
  5883. const match = regexp.exec('');
  5884. return !!(match && regexp.lastIndex === 0);
  5885. }
  5886. exports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;
  5887. function regExpFlags(regexp) {
  5888. return (regexp.global ? 'g' : '')
  5889. + (regexp.ignoreCase ? 'i' : '')
  5890. + (regexp.multiline ? 'm' : '')
  5891. + (regexp /* standalone editor compilation */.unicode ? 'u' : '');
  5892. }
  5893. exports.regExpFlags = regExpFlags;
  5894. function splitLines(str) {
  5895. return str.split(/\r\n|\r|\n/);
  5896. }
  5897. exports.splitLines = splitLines;
  5898. /**
  5899. * Returns first index of the string that is not whitespace.
  5900. * If string is empty or contains only whitespaces, returns -1
  5901. */
  5902. function firstNonWhitespaceIndex(str) {
  5903. for (let i = 0, len = str.length; i < len; i++) {
  5904. const chCode = str.charCodeAt(i);
  5905. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5906. return i;
  5907. }
  5908. }
  5909. return -1;
  5910. }
  5911. exports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;
  5912. /**
  5913. * Returns the leading whitespace of the string.
  5914. * If the string contains only whitespaces, returns entire string
  5915. */
  5916. function getLeadingWhitespace(str, start = 0, end = str.length) {
  5917. for (let i = start; i < end; i++) {
  5918. const chCode = str.charCodeAt(i);
  5919. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5920. return str.substring(start, i);
  5921. }
  5922. }
  5923. return str.substring(start, end);
  5924. }
  5925. exports.getLeadingWhitespace = getLeadingWhitespace;
  5926. /**
  5927. * Returns last index of the string that is not whitespace.
  5928. * If string is empty or contains only whitespaces, returns -1
  5929. */
  5930. function lastNonWhitespaceIndex(str, startIndex = str.length - 1) {
  5931. for (let i = startIndex; i >= 0; i--) {
  5932. const chCode = str.charCodeAt(i);
  5933. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  5934. return i;
  5935. }
  5936. }
  5937. return -1;
  5938. }
  5939. exports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;
  5940. function compare(a, b) {
  5941. if (a < b) {
  5942. return -1;
  5943. }
  5944. else if (a > b) {
  5945. return 1;
  5946. }
  5947. else {
  5948. return 0;
  5949. }
  5950. }
  5951. exports.compare = compare;
  5952. function compareSubstring(a, b, aStart = 0, aEnd = a.length, bStart = 0, bEnd = b.length) {
  5953. for (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {
  5954. let codeA = a.charCodeAt(aStart);
  5955. let codeB = b.charCodeAt(bStart);
  5956. if (codeA < codeB) {
  5957. return -1;
  5958. }
  5959. else if (codeA > codeB) {
  5960. return 1;
  5961. }
  5962. }
  5963. const aLen = aEnd - aStart;
  5964. const bLen = bEnd - bStart;
  5965. if (aLen < bLen) {
  5966. return -1;
  5967. }
  5968. else if (aLen > bLen) {
  5969. return 1;
  5970. }
  5971. return 0;
  5972. }
  5973. exports.compareSubstring = compareSubstring;
  5974. function compareIgnoreCase(a, b) {
  5975. return compareSubstringIgnoreCase(a, b, 0, a.length, 0, b.length);
  5976. }
  5977. exports.compareIgnoreCase = compareIgnoreCase;
  5978. function compareSubstringIgnoreCase(a, b, aStart = 0, aEnd = a.length, bStart = 0, bEnd = b.length) {
  5979. for (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {
  5980. let codeA = a.charCodeAt(aStart);
  5981. let codeB = b.charCodeAt(bStart);
  5982. if (codeA === codeB) {
  5983. // equal
  5984. continue;
  5985. }
  5986. if (codeA >= 128 || codeB >= 128) {
  5987. // not ASCII letters -> fallback to lower-casing strings
  5988. return compareSubstring(a.toLowerCase(), b.toLowerCase(), aStart, aEnd, bStart, bEnd);
  5989. }
  5990. // mapper lower-case ascii letter onto upper-case varinats
  5991. // [97-122] (lower ascii) --> [65-90] (upper ascii)
  5992. if (isLowerAsciiLetter(codeA)) {
  5993. codeA -= 32;
  5994. }
  5995. if (isLowerAsciiLetter(codeB)) {
  5996. codeB -= 32;
  5997. }
  5998. // compare both code points
  5999. const diff = codeA - codeB;
  6000. if (diff === 0) {
  6001. continue;
  6002. }
  6003. return diff;
  6004. }
  6005. const aLen = aEnd - aStart;
  6006. const bLen = bEnd - bStart;
  6007. if (aLen < bLen) {
  6008. return -1;
  6009. }
  6010. else if (aLen > bLen) {
  6011. return 1;
  6012. }
  6013. return 0;
  6014. }
  6015. exports.compareSubstringIgnoreCase = compareSubstringIgnoreCase;
  6016. function isLowerAsciiLetter(code) {
  6017. return code >= 97 /* a */ && code <= 122 /* z */;
  6018. }
  6019. exports.isLowerAsciiLetter = isLowerAsciiLetter;
  6020. function isUpperAsciiLetter(code) {
  6021. return code >= 65 /* A */ && code <= 90 /* Z */;
  6022. }
  6023. exports.isUpperAsciiLetter = isUpperAsciiLetter;
  6024. function equalsIgnoreCase(a, b) {
  6025. return a.length === b.length && compareSubstringIgnoreCase(a, b) === 0;
  6026. }
  6027. exports.equalsIgnoreCase = equalsIgnoreCase;
  6028. function startsWithIgnoreCase(str, candidate) {
  6029. const candidateLength = candidate.length;
  6030. if (candidate.length > str.length) {
  6031. return false;
  6032. }
  6033. return compareSubstringIgnoreCase(str, candidate, 0, candidateLength) === 0;
  6034. }
  6035. exports.startsWithIgnoreCase = startsWithIgnoreCase;
  6036. /**
  6037. * @returns the length of the common prefix of the two strings.
  6038. */
  6039. function commonPrefixLength(a, b) {
  6040. let i, len = Math.min(a.length, b.length);
  6041. for (i = 0; i < len; i++) {
  6042. if (a.charCodeAt(i) !== b.charCodeAt(i)) {
  6043. return i;
  6044. }
  6045. }
  6046. return len;
  6047. }
  6048. exports.commonPrefixLength = commonPrefixLength;
  6049. /**
  6050. * @returns the length of the common suffix of the two strings.
  6051. */
  6052. function commonSuffixLength(a, b) {
  6053. let i, len = Math.min(a.length, b.length);
  6054. const aLastIndex = a.length - 1;
  6055. const bLastIndex = b.length - 1;
  6056. for (i = 0; i < len; i++) {
  6057. if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {
  6058. return i;
  6059. }
  6060. }
  6061. return len;
  6062. }
  6063. exports.commonSuffixLength = commonSuffixLength;
  6064. /**
  6065. * See http://en.wikipedia.org/wiki/Surrogate_pair
  6066. */
  6067. function isHighSurrogate(charCode) {
  6068. return (0xD800 <= charCode && charCode <= 0xDBFF);
  6069. }
  6070. exports.isHighSurrogate = isHighSurrogate;
  6071. /**
  6072. * See http://en.wikipedia.org/wiki/Surrogate_pair
  6073. */
  6074. function isLowSurrogate(charCode) {
  6075. return (0xDC00 <= charCode && charCode <= 0xDFFF);
  6076. }
  6077. exports.isLowSurrogate = isLowSurrogate;
  6078. /**
  6079. * See http://en.wikipedia.org/wiki/Surrogate_pair
  6080. */
  6081. function computeCodePoint(highSurrogate, lowSurrogate) {
  6082. return ((highSurrogate - 0xD800) << 10) + (lowSurrogate - 0xDC00) + 0x10000;
  6083. }
  6084. exports.computeCodePoint = computeCodePoint;
  6085. /**
  6086. * get the code point that begins at offset `offset`
  6087. */
  6088. function getNextCodePoint(str, len, offset) {
  6089. const charCode = str.charCodeAt(offset);
  6090. if (isHighSurrogate(charCode) && offset + 1 < len) {
  6091. const nextCharCode = str.charCodeAt(offset + 1);
  6092. if (isLowSurrogate(nextCharCode)) {
  6093. return computeCodePoint(charCode, nextCharCode);
  6094. }
  6095. }
  6096. return charCode;
  6097. }
  6098. exports.getNextCodePoint = getNextCodePoint;
  6099. /**
  6100. * get the code point that ends right before offset `offset`
  6101. */
  6102. function getPrevCodePoint(str, offset) {
  6103. const charCode = str.charCodeAt(offset - 1);
  6104. if (isLowSurrogate(charCode) && offset > 1) {
  6105. const prevCharCode = str.charCodeAt(offset - 2);
  6106. if (isHighSurrogate(prevCharCode)) {
  6107. return computeCodePoint(prevCharCode, charCode);
  6108. }
  6109. }
  6110. return charCode;
  6111. }
  6112. function nextCharLength(str, offset) {
  6113. const graphemeBreakTree = GraphemeBreakTree.getInstance();
  6114. const initialOffset = offset;
  6115. const len = str.length;
  6116. const initialCodePoint = getNextCodePoint(str, len, offset);
  6117. offset += (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  6118. let graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  6119. while (offset < len) {
  6120. const nextCodePoint = getNextCodePoint(str, len, offset);
  6121. const nextGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(nextCodePoint);
  6122. if (breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
  6123. break;
  6124. }
  6125. offset += (nextCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  6126. graphemeBreakType = nextGraphemeBreakType;
  6127. }
  6128. return (offset - initialOffset);
  6129. }
  6130. exports.nextCharLength = nextCharLength;
  6131. function prevCharLength(str, offset) {
  6132. const graphemeBreakTree = GraphemeBreakTree.getInstance();
  6133. const initialOffset = offset;
  6134. const initialCodePoint = getPrevCodePoint(str, offset);
  6135. offset -= (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  6136. let graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  6137. while (offset > 0) {
  6138. const prevCodePoint = getPrevCodePoint(str, offset);
  6139. const prevGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(prevCodePoint);
  6140. if (breakBetweenGraphemeBreakType(prevGraphemeBreakType, graphemeBreakType)) {
  6141. break;
  6142. }
  6143. offset -= (prevCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  6144. graphemeBreakType = prevGraphemeBreakType;
  6145. }
  6146. return (initialOffset - offset);
  6147. }
  6148. exports.prevCharLength = prevCharLength;
  6149. /**
  6150. * Generated using https://github.com/alexdima/unicode-utils/blob/main/rtl-test.js
  6151. */
  6152. const CONTAINS_RTL = /(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA\u07FE-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u088E\u08A0-\u08C9\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDC7\uFDF0-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE35\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDD23\uDE80-\uDEA9\uDEAD-\uDF45\uDF51-\uDF81\uDF86-\uDFF6]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD4B-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;
  6153. /**
  6154. * Returns true if `str` contains any Unicode character that is classified as "R" or "AL".
  6155. */
  6156. function containsRTL(str) {
  6157. return CONTAINS_RTL.test(str);
  6158. }
  6159. exports.containsRTL = containsRTL;
  6160. /**
  6161. * Generated using https://github.com/alexdima/unicode-utils/blob/main/emoji-test.js
  6162. */
  6163. const CONTAINS_EMOJI = /(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFC\uDFE0-\uDFF0]|\uD83E[\uDD00-\uDDFF\uDE70-\uDEF6])/;
  6164. function containsEmoji(str) {
  6165. return CONTAINS_EMOJI.test(str);
  6166. }
  6167. exports.containsEmoji = containsEmoji;
  6168. const IS_BASIC_ASCII = /^[\t\n\r\x20-\x7E]*$/;
  6169. /**
  6170. * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \n, \r, \t
  6171. */
  6172. function isBasicASCII(str) {
  6173. return IS_BASIC_ASCII.test(str);
  6174. }
  6175. exports.isBasicASCII = isBasicASCII;
  6176. exports.UNUSUAL_LINE_TERMINATORS = /[\u2028\u2029]/; // LINE SEPARATOR (LS) or PARAGRAPH SEPARATOR (PS)
  6177. /**
  6178. * Returns true if `str` contains unusual line terminators, like LS or PS
  6179. */
  6180. function containsUnusualLineTerminators(str) {
  6181. return exports.UNUSUAL_LINE_TERMINATORS.test(str);
  6182. }
  6183. exports.containsUnusualLineTerminators = containsUnusualLineTerminators;
  6184. function containsFullWidthCharacter(str) {
  6185. for (let i = 0, len = str.length; i < len; i++) {
  6186. if (isFullWidthCharacter(str.charCodeAt(i))) {
  6187. return true;
  6188. }
  6189. }
  6190. return false;
  6191. }
  6192. exports.containsFullWidthCharacter = containsFullWidthCharacter;
  6193. function isFullWidthCharacter(charCode) {
  6194. // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns
  6195. // http://jrgraphix.net/research/unicode_blocks.php
  6196. // 2E80 - 2EFF CJK Radicals Supplement
  6197. // 2F00 - 2FDF Kangxi Radicals
  6198. // 2FF0 - 2FFF Ideographic Description Characters
  6199. // 3000 - 303F CJK Symbols and Punctuation
  6200. // 3040 - 309F Hiragana
  6201. // 30A0 - 30FF Katakana
  6202. // 3100 - 312F Bopomofo
  6203. // 3130 - 318F Hangul Compatibility Jamo
  6204. // 3190 - 319F Kanbun
  6205. // 31A0 - 31BF Bopomofo Extended
  6206. // 31F0 - 31FF Katakana Phonetic Extensions
  6207. // 3200 - 32FF Enclosed CJK Letters and Months
  6208. // 3300 - 33FF CJK Compatibility
  6209. // 3400 - 4DBF CJK Unified Ideographs Extension A
  6210. // 4DC0 - 4DFF Yijing Hexagram Symbols
  6211. // 4E00 - 9FFF CJK Unified Ideographs
  6212. // A000 - A48F Yi Syllables
  6213. // A490 - A4CF Yi Radicals
  6214. // AC00 - D7AF Hangul Syllables
  6215. // [IGNORE] D800 - DB7F High Surrogates
  6216. // [IGNORE] DB80 - DBFF High Private Use Surrogates
  6217. // [IGNORE] DC00 - DFFF Low Surrogates
  6218. // [IGNORE] E000 - F8FF Private Use Area
  6219. // F900 - FAFF CJK Compatibility Ideographs
  6220. // [IGNORE] FB00 - FB4F Alphabetic Presentation Forms
  6221. // [IGNORE] FB50 - FDFF Arabic Presentation Forms-A
  6222. // [IGNORE] FE00 - FE0F Variation Selectors
  6223. // [IGNORE] FE20 - FE2F Combining Half Marks
  6224. // [IGNORE] FE30 - FE4F CJK Compatibility Forms
  6225. // [IGNORE] FE50 - FE6F Small Form Variants
  6226. // [IGNORE] FE70 - FEFF Arabic Presentation Forms-B
  6227. // FF00 - FFEF Halfwidth and Fullwidth Forms
  6228. // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]
  6229. // of which FF01 - FF5E fullwidth ASCII of 21 to 7E
  6230. // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
  6231. // [IGNORE] FFF0 - FFFF Specials
  6232. return ((charCode >= 0x2E80 && charCode <= 0xD7AF)
  6233. || (charCode >= 0xF900 && charCode <= 0xFAFF)
  6234. || (charCode >= 0xFF01 && charCode <= 0xFF5E));
  6235. }
  6236. exports.isFullWidthCharacter = isFullWidthCharacter;
  6237. /**
  6238. * A fast function (therefore imprecise) to check if code points are emojis.
  6239. * Generated using https://github.com/alexdima/unicode-utils/blob/main/emoji-test.js
  6240. */
  6241. function isEmojiImprecise(x) {
  6242. return ((x >= 0x1F1E6 && x <= 0x1F1FF) || (x === 8986) || (x === 8987) || (x === 9200)
  6243. || (x === 9203) || (x >= 9728 && x <= 10175) || (x === 11088) || (x === 11093)
  6244. || (x >= 127744 && x <= 128591) || (x >= 128640 && x <= 128764)
  6245. || (x >= 128992 && x <= 129008) || (x >= 129280 && x <= 129535)
  6246. || (x >= 129648 && x <= 129782));
  6247. }
  6248. exports.isEmojiImprecise = isEmojiImprecise;
  6249. // -- UTF-8 BOM
  6250. exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
  6251. function startsWithUTF8BOM(str) {
  6252. return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
  6253. }
  6254. exports.startsWithUTF8BOM = startsWithUTF8BOM;
  6255. function containsUppercaseCharacter(target, ignoreEscapedChars = false) {
  6256. if (!target) {
  6257. return false;
  6258. }
  6259. if (ignoreEscapedChars) {
  6260. target = target.replace(/\\./g, '');
  6261. }
  6262. return target.toLowerCase() !== target;
  6263. }
  6264. exports.containsUppercaseCharacter = containsUppercaseCharacter;
  6265. /**
  6266. * Produces 'a'-'z', followed by 'A'-'Z'... followed by 'a'-'z', etc.
  6267. */
  6268. function singleLetterHash(n) {
  6269. const LETTERS_CNT = (90 /* Z */ - 65 /* A */ + 1);
  6270. n = n % (2 * LETTERS_CNT);
  6271. if (n < LETTERS_CNT) {
  6272. return String.fromCharCode(97 /* a */ + n);
  6273. }
  6274. return String.fromCharCode(65 /* A */ + n - LETTERS_CNT);
  6275. }
  6276. exports.singleLetterHash = singleLetterHash;
  6277. //#region Unicode Grapheme Break
  6278. function getGraphemeBreakType(codePoint) {
  6279. const graphemeBreakTree = GraphemeBreakTree.getInstance();
  6280. return graphemeBreakTree.getGraphemeBreakType(codePoint);
  6281. }
  6282. exports.getGraphemeBreakType = getGraphemeBreakType;
  6283. function breakBetweenGraphemeBreakType(breakTypeA, breakTypeB) {
  6284. // http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
  6285. // !!! Let's make the common case a bit faster
  6286. if (breakTypeA === 0 /* Other */) {
  6287. // see https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakTest-13.0.0d10.html#table
  6288. return (breakTypeB !== 5 /* Extend */ && breakTypeB !== 7 /* SpacingMark */);
  6289. }
  6290. // Do not break between a CR and LF. Otherwise, break before and after controls.
  6291. // GB3 CR × LF
  6292. // GB4 (Control | CR | LF) ÷
  6293. // GB5 ÷ (Control | CR | LF)
  6294. if (breakTypeA === 2 /* CR */) {
  6295. if (breakTypeB === 3 /* LF */) {
  6296. return false; // GB3
  6297. }
  6298. }
  6299. if (breakTypeA === 4 /* Control */ || breakTypeA === 2 /* CR */ || breakTypeA === 3 /* LF */) {
  6300. return true; // GB4
  6301. }
  6302. if (breakTypeB === 4 /* Control */ || breakTypeB === 2 /* CR */ || breakTypeB === 3 /* LF */) {
  6303. return true; // GB5
  6304. }
  6305. // Do not break Hangul syllable sequences.
  6306. // GB6 L × (L | V | LV | LVT)
  6307. // GB7 (LV | V) × (V | T)
  6308. // GB8 (LVT | T) × T
  6309. if (breakTypeA === 8 /* L */) {
  6310. if (breakTypeB === 8 /* L */ || breakTypeB === 9 /* V */ || breakTypeB === 11 /* LV */ || breakTypeB === 12 /* LVT */) {
  6311. return false; // GB6
  6312. }
  6313. }
  6314. if (breakTypeA === 11 /* LV */ || breakTypeA === 9 /* V */) {
  6315. if (breakTypeB === 9 /* V */ || breakTypeB === 10 /* T */) {
  6316. return false; // GB7
  6317. }
  6318. }
  6319. if (breakTypeA === 12 /* LVT */ || breakTypeA === 10 /* T */) {
  6320. if (breakTypeB === 10 /* T */) {
  6321. return false; // GB8
  6322. }
  6323. }
  6324. // Do not break before extending characters or ZWJ.
  6325. // GB9 × (Extend | ZWJ)
  6326. if (breakTypeB === 5 /* Extend */ || breakTypeB === 13 /* ZWJ */) {
  6327. return false; // GB9
  6328. }
  6329. // The GB9a and GB9b rules only apply to extended grapheme clusters:
  6330. // Do not break before SpacingMarks, or after Prepend characters.
  6331. // GB9a × SpacingMark
  6332. // GB9b Prepend ×
  6333. if (breakTypeB === 7 /* SpacingMark */) {
  6334. return false; // GB9a
  6335. }
  6336. if (breakTypeA === 1 /* Prepend */) {
  6337. return false; // GB9b
  6338. }
  6339. // Do not break within emoji modifier sequences or emoji zwj sequences.
  6340. // GB11 \p{Extended_Pictographic} Extend* ZWJ × \p{Extended_Pictographic}
  6341. if (breakTypeA === 13 /* ZWJ */ && breakTypeB === 14 /* Extended_Pictographic */) {
  6342. // Note: we are not implementing the rule entirely here to avoid introducing states
  6343. return false; // GB11
  6344. }
  6345. // GB12 sot (RI RI)* RI × RI
  6346. // GB13 [^RI] (RI RI)* RI × RI
  6347. if (breakTypeA === 6 /* Regional_Indicator */ && breakTypeB === 6 /* Regional_Indicator */) {
  6348. // Note: we are not implementing the rule entirely here to avoid introducing states
  6349. return false; // GB12 & GB13
  6350. }
  6351. // GB999 Any ÷ Any
  6352. return true;
  6353. }
  6354. exports.breakBetweenGraphemeBreakType = breakBetweenGraphemeBreakType;
  6355. class GraphemeBreakTree {
  6356. constructor() {
  6357. this._data = getGraphemeBreakRawData();
  6358. }
  6359. static getInstance() {
  6360. if (!GraphemeBreakTree._INSTANCE) {
  6361. GraphemeBreakTree._INSTANCE = new GraphemeBreakTree();
  6362. }
  6363. return GraphemeBreakTree._INSTANCE;
  6364. }
  6365. getGraphemeBreakType(codePoint) {
  6366. // !!! Let's make 7bit ASCII a bit faster: 0..31
  6367. if (codePoint < 32) {
  6368. if (codePoint === 10 /* LineFeed */) {
  6369. return 3 /* LF */;
  6370. }
  6371. if (codePoint === 13 /* CarriageReturn */) {
  6372. return 2 /* CR */;
  6373. }
  6374. return 4 /* Control */;
  6375. }
  6376. // !!! Let's make 7bit ASCII a bit faster: 32..126
  6377. if (codePoint < 127) {
  6378. return 0 /* Other */;
  6379. }
  6380. const data = this._data;
  6381. const nodeCount = data.length / 3;
  6382. let nodeIndex = 1;
  6383. while (nodeIndex <= nodeCount) {
  6384. if (codePoint < data[3 * nodeIndex]) {
  6385. // go left
  6386. nodeIndex = 2 * nodeIndex;
  6387. }
  6388. else if (codePoint > data[3 * nodeIndex + 1]) {
  6389. // go right
  6390. nodeIndex = 2 * nodeIndex + 1;
  6391. }
  6392. else {
  6393. // hit
  6394. return data[3 * nodeIndex + 2];
  6395. }
  6396. }
  6397. return 0 /* Other */;
  6398. }
  6399. }
  6400. GraphemeBreakTree._INSTANCE = null;
  6401. function getGraphemeBreakRawData() {
  6402. // generated using https://github.com/alexdima/unicode-utils/blob/main/grapheme-break.js
  6403. return JSON.parse('[0,0,0,51229,51255,12,44061,44087,12,127462,127487,6,7083,7085,5,47645,47671,12,54813,54839,12,128678,128678,14,3270,3270,5,9919,9923,14,45853,45879,12,49437,49463,12,53021,53047,12,71216,71218,7,128398,128399,14,129360,129374,14,2519,2519,5,4448,4519,9,9742,9742,14,12336,12336,14,44957,44983,12,46749,46775,12,48541,48567,12,50333,50359,12,52125,52151,12,53917,53943,12,69888,69890,5,73018,73018,5,127990,127990,14,128558,128559,14,128759,128760,14,129653,129655,14,2027,2035,5,2891,2892,7,3761,3761,5,6683,6683,5,8293,8293,4,9825,9826,14,9999,9999,14,43452,43453,5,44509,44535,12,45405,45431,12,46301,46327,12,47197,47223,12,48093,48119,12,48989,49015,12,49885,49911,12,50781,50807,12,51677,51703,12,52573,52599,12,53469,53495,12,54365,54391,12,65279,65279,4,70471,70472,7,72145,72147,7,119173,119179,5,127799,127818,14,128240,128244,14,128512,128512,14,128652,128652,14,128721,128722,14,129292,129292,14,129445,129450,14,129734,129743,14,1476,1477,5,2366,2368,7,2750,2752,7,3076,3076,5,3415,3415,5,4141,4144,5,6109,6109,5,6964,6964,5,7394,7400,5,9197,9198,14,9770,9770,14,9877,9877,14,9968,9969,14,10084,10084,14,43052,43052,5,43713,43713,5,44285,44311,12,44733,44759,12,45181,45207,12,45629,45655,12,46077,46103,12,46525,46551,12,46973,46999,12,47421,47447,12,47869,47895,12,48317,48343,12,48765,48791,12,49213,49239,12,49661,49687,12,50109,50135,12,50557,50583,12,51005,51031,12,51453,51479,12,51901,51927,12,52349,52375,12,52797,52823,12,53245,53271,12,53693,53719,12,54141,54167,12,54589,54615,12,55037,55063,12,69506,69509,5,70191,70193,5,70841,70841,7,71463,71467,5,72330,72342,5,94031,94031,5,123628,123631,5,127763,127765,14,127941,127941,14,128043,128062,14,128302,128317,14,128465,128467,14,128539,128539,14,128640,128640,14,128662,128662,14,128703,128703,14,128745,128745,14,129004,129007,14,129329,129330,14,129402,129402,14,129483,129483,14,129686,129704,14,130048,131069,14,173,173,4,1757,1757,1,2200,2207,5,2434,2435,7,2631,2632,5,2817,2817,5,3008,3008,5,3201,3201,5,3387,3388,5,3542,3542,5,3902,3903,7,4190,4192,5,6002,6003,5,6439,6440,5,6765,6770,7,7019,7027,5,7154,7155,7,8205,8205,13,8505,8505,14,9654,9654,14,9757,9757,14,9792,9792,14,9852,9853,14,9890,9894,14,9937,9937,14,9981,9981,14,10035,10036,14,11035,11036,14,42654,42655,5,43346,43347,7,43587,43587,5,44006,44007,7,44173,44199,12,44397,44423,12,44621,44647,12,44845,44871,12,45069,45095,12,45293,45319,12,45517,45543,12,45741,45767,12,45965,45991,12,46189,46215,12,46413,46439,12,46637,46663,12,46861,46887,12,47085,47111,12,47309,47335,12,47533,47559,12,47757,47783,12,47981,48007,12,48205,48231,12,48429,48455,12,48653,48679,12,48877,48903,12,49101,49127,12,49325,49351,12,49549,49575,12,49773,49799,12,49997,50023,12,50221,50247,12,50445,50471,12,50669,50695,12,50893,50919,12,51117,51143,12,51341,51367,12,51565,51591,12,51789,51815,12,52013,52039,12,52237,52263,12,52461,52487,12,52685,52711,12,52909,52935,12,53133,53159,12,53357,53383,12,53581,53607,12,53805,53831,12,54029,54055,12,54253,54279,12,54477,54503,12,54701,54727,12,54925,54951,12,55149,55175,12,68101,68102,5,69762,69762,7,70067,70069,7,70371,70378,5,70720,70721,7,71087,71087,5,71341,71341,5,71995,71996,5,72249,72249,7,72850,72871,5,73109,73109,5,118576,118598,5,121505,121519,5,127245,127247,14,127568,127569,14,127777,127777,14,127872,127891,14,127956,127967,14,128015,128016,14,128110,128172,14,128259,128259,14,128367,128368,14,128424,128424,14,128488,128488,14,128530,128532,14,128550,128551,14,128566,128566,14,128647,128647,14,128656,128656,14,128667,128673,14,128691,128693,14,128715,128715,14,128728,128732,14,128752,128752,14,128765,128767,14,129096,129103,14,129311,129311,14,129344,129349,14,129394,129394,14,129413,129425,14,129466,129471,14,129511,129535,14,129664,129666,14,129719,129722,14,129760,129767,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2307,2307,7,2382,2383,7,2497,2500,5,2563,2563,7,2677,2677,5,2763,2764,7,2879,2879,5,2914,2915,5,3021,3021,5,3142,3144,5,3263,3263,5,3285,3286,5,3398,3400,7,3530,3530,5,3633,3633,5,3864,3865,5,3974,3975,5,4155,4156,7,4229,4230,5,5909,5909,7,6078,6085,7,6277,6278,5,6451,6456,7,6744,6750,5,6846,6846,5,6972,6972,5,7074,7077,5,7146,7148,7,7222,7223,5,7416,7417,5,8234,8238,4,8417,8417,5,9000,9000,14,9203,9203,14,9730,9731,14,9748,9749,14,9762,9763,14,9776,9783,14,9800,9811,14,9831,9831,14,9872,9873,14,9882,9882,14,9900,9903,14,9929,9933,14,9941,9960,14,9974,9974,14,9989,9989,14,10006,10006,14,10062,10062,14,10160,10160,14,11647,11647,5,12953,12953,14,43019,43019,5,43232,43249,5,43443,43443,5,43567,43568,7,43696,43696,5,43765,43765,7,44013,44013,5,44117,44143,12,44229,44255,12,44341,44367,12,44453,44479,12,44565,44591,12,44677,44703,12,44789,44815,12,44901,44927,12,45013,45039,12,45125,45151,12,45237,45263,12,45349,45375,12,45461,45487,12,45573,45599,12,45685,45711,12,45797,45823,12,45909,45935,12,46021,46047,12,46133,46159,12,46245,46271,12,46357,46383,12,46469,46495,12,46581,46607,12,46693,46719,12,46805,46831,12,46917,46943,12,47029,47055,12,47141,47167,12,47253,47279,12,47365,47391,12,47477,47503,12,47589,47615,12,47701,47727,12,47813,47839,12,47925,47951,12,48037,48063,12,48149,48175,12,48261,48287,12,48373,48399,12,48485,48511,12,48597,48623,12,48709,48735,12,48821,48847,12,48933,48959,12,49045,49071,12,49157,49183,12,49269,49295,12,49381,49407,12,49493,49519,12,49605,49631,12,49717,49743,12,49829,49855,12,49941,49967,12,50053,50079,12,50165,50191,12,50277,50303,12,50389,50415,12,50501,50527,12,50613,50639,12,50725,50751,12,50837,50863,12,50949,50975,12,51061,51087,12,51173,51199,12,51285,51311,12,51397,51423,12,51509,51535,12,51621,51647,12,51733,51759,12,51845,51871,12,51957,51983,12,52069,52095,12,52181,52207,12,52293,52319,12,52405,52431,12,52517,52543,12,52629,52655,12,52741,52767,12,52853,52879,12,52965,52991,12,53077,53103,12,53189,53215,12,53301,53327,12,53413,53439,12,53525,53551,12,53637,53663,12,53749,53775,12,53861,53887,12,53973,53999,12,54085,54111,12,54197,54223,12,54309,54335,12,54421,54447,12,54533,54559,12,54645,54671,12,54757,54783,12,54869,54895,12,54981,55007,12,55093,55119,12,55243,55291,10,66045,66045,5,68325,68326,5,69688,69702,5,69817,69818,5,69957,69958,7,70089,70092,5,70198,70199,5,70462,70462,5,70502,70508,5,70750,70750,5,70846,70846,7,71100,71101,5,71230,71230,7,71351,71351,5,71737,71738,5,72000,72000,7,72160,72160,5,72273,72278,5,72752,72758,5,72882,72883,5,73031,73031,5,73461,73462,7,94192,94193,7,119149,119149,7,121403,121452,5,122915,122916,5,126980,126980,14,127358,127359,14,127535,127535,14,127759,127759,14,127771,127771,14,127792,127793,14,127825,127867,14,127897,127899,14,127945,127945,14,127985,127986,14,128000,128007,14,128021,128021,14,128066,128100,14,128184,128235,14,128249,128252,14,128266,128276,14,128335,128335,14,128379,128390,14,128407,128419,14,128444,128444,14,128481,128481,14,128499,128499,14,128526,128526,14,128536,128536,14,128543,128543,14,128556,128556,14,128564,128564,14,128577,128580,14,128643,128645,14,128649,128649,14,128654,128654,14,128660,128660,14,128664,128664,14,128675,128675,14,128686,128689,14,128695,128696,14,128705,128709,14,128717,128719,14,128725,128725,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129009,129023,14,129160,129167,14,129296,129304,14,129320,129327,14,129340,129342,14,129356,129356,14,129388,129392,14,129399,129400,14,129404,129407,14,129432,129442,14,129454,129455,14,129473,129474,14,129485,129487,14,129648,129651,14,129659,129660,14,129671,129679,14,129709,129711,14,129728,129730,14,129751,129753,14,129776,129782,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2274,2274,1,2363,2363,7,2377,2380,7,2402,2403,5,2494,2494,5,2507,2508,7,2558,2558,5,2622,2624,7,2641,2641,5,2691,2691,7,2759,2760,5,2786,2787,5,2876,2876,5,2881,2884,5,2901,2902,5,3006,3006,5,3014,3016,7,3072,3072,5,3134,3136,5,3157,3158,5,3260,3260,5,3266,3266,5,3274,3275,7,3328,3329,5,3391,3392,7,3405,3405,5,3457,3457,5,3536,3537,7,3551,3551,5,3636,3642,5,3764,3772,5,3895,3895,5,3967,3967,7,3993,4028,5,4146,4151,5,4182,4183,7,4226,4226,5,4253,4253,5,4957,4959,5,5940,5940,7,6070,6070,7,6087,6088,7,6158,6158,4,6432,6434,5,6448,6449,7,6679,6680,5,6742,6742,5,6754,6754,5,6783,6783,5,6912,6915,5,6966,6970,5,6978,6978,5,7042,7042,7,7080,7081,5,7143,7143,7,7150,7150,7,7212,7219,5,7380,7392,5,7412,7412,5,8203,8203,4,8232,8232,4,8265,8265,14,8400,8412,5,8421,8432,5,8617,8618,14,9167,9167,14,9200,9200,14,9410,9410,14,9723,9726,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9774,14,9786,9786,14,9794,9794,14,9823,9823,14,9828,9828,14,9833,9850,14,9855,9855,14,9875,9875,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9935,9935,14,9939,9939,14,9962,9962,14,9972,9972,14,9978,9978,14,9986,9986,14,9997,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10133,10135,14,10548,10549,14,11093,11093,14,12330,12333,5,12441,12442,5,42608,42610,5,43010,43010,5,43045,43046,5,43188,43203,7,43302,43309,5,43392,43394,5,43446,43449,5,43493,43493,5,43571,43572,7,43597,43597,7,43703,43704,5,43756,43757,5,44003,44004,7,44009,44010,7,44033,44059,12,44089,44115,12,44145,44171,12,44201,44227,12,44257,44283,12,44313,44339,12,44369,44395,12,44425,44451,12,44481,44507,12,44537,44563,12,44593,44619,12,44649,44675,12,44705,44731,12,44761,44787,12,44817,44843,12,44873,44899,12,44929,44955,12,44985,45011,12,45041,45067,12,45097,45123,12,45153,45179,12,45209,45235,12,45265,45291,12,45321,45347,12,45377,45403,12,45433,45459,12,45489,45515,12,45545,45571,12,45601,45627,12,45657,45683,12,45713,45739,12,45769,45795,12,45825,45851,12,45881,45907,12,45937,45963,12,45993,46019,12,46049,46075,12,46105,46131,12,46161,46187,12,46217,46243,12,46273,46299,12,46329,46355,12,46385,46411,12,46441,46467,12,46497,46523,12,46553,46579,12,46609,46635,12,46665,46691,12,46721,46747,12,46777,46803,12,46833,46859,12,46889,46915,12,46945,46971,12,47001,47027,12,47057,47083,12,47113,47139,12,47169,47195,12,47225,47251,12,47281,47307,12,47337,47363,12,47393,47419,12,47449,47475,12,47505,47531,12,47561,47587,12,47617,47643,12,47673,47699,12,47729,47755,12,47785,47811,12,47841,47867,12,47897,47923,12,47953,47979,12,48009,48035,12,48065,48091,12,48121,48147,12,48177,48203,12,48233,48259,12,48289,48315,12,48345,48371,12,48401,48427,12,48457,48483,12,48513,48539,12,48569,48595,12,48625,48651,12,48681,48707,12,48737,48763,12,48793,48819,12,48849,48875,12,48905,48931,12,48961,48987,12,49017,49043,12,49073,49099,12,49129,49155,12,49185,49211,12,49241,49267,12,49297,49323,12,49353,49379,12,49409,49435,12,49465,49491,12,49521,49547,12,49577,49603,12,49633,49659,12,49689,49715,12,49745,49771,12,49801,49827,12,49857,49883,12,49913,49939,12,49969,49995,12,50025,50051,12,50081,50107,12,50137,50163,12,50193,50219,12,50249,50275,12,50305,50331,12,50361,50387,12,50417,50443,12,50473,50499,12,50529,50555,12,50585,50611,12,50641,50667,12,50697,50723,12,50753,50779,12,50809,50835,12,50865,50891,12,50921,50947,12,50977,51003,12,51033,51059,12,51089,51115,12,51145,51171,12,51201,51227,12,51257,51283,12,51313,51339,12,51369,51395,12,51425,51451,12,51481,51507,12,51537,51563,12,51593,51619,12,51649,51675,12,51705,51731,12,51761,51787,12,51817,51843,12,51873,51899,12,51929,51955,12,51985,52011,12,52041,52067,12,52097,52123,12,52153,52179,12,52209,52235,12,52265,52291,12,52321,52347,12,52377,52403,12,52433,52459,12,52489,52515,12,52545,52571,12,52601,52627,12,52657,52683,12,52713,52739,12,52769,52795,12,52825,52851,12,52881,52907,12,52937,52963,12,52993,53019,12,53049,53075,12,53105,53131,12,53161,53187,12,53217,53243,12,53273,53299,12,53329,53355,12,53385,53411,12,53441,53467,12,53497,53523,12,53553,53579,12,53609,53635,12,53665,53691,12,53721,53747,12,53777,53803,12,53833,53859,12,53889,53915,12,53945,53971,12,54001,54027,12,54057,54083,12,54113,54139,12,54169,54195,12,54225,54251,12,54281,54307,12,54337,54363,12,54393,54419,12,54449,54475,12,54505,54531,12,54561,54587,12,54617,54643,12,54673,54699,12,54729,54755,12,54785,54811,12,54841,54867,12,54897,54923,12,54953,54979,12,55009,55035,12,55065,55091,12,55121,55147,12,55177,55203,12,65024,65039,5,65520,65528,4,66422,66426,5,68152,68154,5,69291,69292,5,69633,69633,5,69747,69748,5,69811,69814,5,69826,69826,5,69932,69932,7,70016,70017,5,70079,70080,7,70095,70095,5,70196,70196,5,70367,70367,5,70402,70403,7,70464,70464,5,70487,70487,5,70709,70711,7,70725,70725,7,70833,70834,7,70843,70844,7,70849,70849,7,71090,71093,5,71103,71104,5,71227,71228,7,71339,71339,5,71344,71349,5,71458,71461,5,71727,71735,5,71985,71989,7,71998,71998,5,72002,72002,7,72154,72155,5,72193,72202,5,72251,72254,5,72281,72283,5,72344,72345,5,72766,72766,7,72874,72880,5,72885,72886,5,73023,73029,5,73104,73105,5,73111,73111,5,92912,92916,5,94095,94098,5,113824,113827,4,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,125252,125258,5,127183,127183,14,127340,127343,14,127377,127386,14,127491,127503,14,127548,127551,14,127744,127756,14,127761,127761,14,127769,127769,14,127773,127774,14,127780,127788,14,127796,127797,14,127820,127823,14,127869,127869,14,127894,127895,14,127902,127903,14,127943,127943,14,127947,127950,14,127972,127972,14,127988,127988,14,127992,127994,14,128009,128011,14,128019,128019,14,128023,128041,14,128064,128064,14,128102,128107,14,128174,128181,14,128238,128238,14,128246,128247,14,128254,128254,14,128264,128264,14,128278,128299,14,128329,128330,14,128348,128359,14,128371,128377,14,128392,128393,14,128401,128404,14,128421,128421,14,128433,128434,14,128450,128452,14,128476,128478,14,128483,128483,14,128495,128495,14,128506,128506,14,128519,128520,14,128528,128528,14,128534,128534,14,128538,128538,14,128540,128542,14,128544,128549,14,128552,128555,14,128557,128557,14,128560,128563,14,128565,128565,14,128567,128576,14,128581,128591,14,128641,128642,14,128646,128646,14,128648,128648,14,128650,128651,14,128653,128653,14,128655,128655,14,128657,128659,14,128661,128661,14,128663,128663,14,128665,128666,14,128674,128674,14,128676,128677,14,128679,128685,14,128690,128690,14,128694,128694,14,128697,128702,14,128704,128704,14,128710,128714,14,128716,128716,14,128720,128720,14,128723,128724,14,128726,128727,14,128733,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129008,129008,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129661,129663,14,129667,129670,14,129680,129685,14,129705,129708,14,129712,129718,14,129723,129727,14,129731,129733,14,129744,129750,14,129754,129759,14,129768,129775,14,129783,129791,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2192,2193,1,2250,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3132,3132,5,3137,3140,7,3146,3149,5,3170,3171,5,3202,3203,7,3262,3262,7,3264,3265,7,3267,3268,7,3271,3272,7,3276,3277,5,3298,3299,5,3330,3331,7,3390,3390,5,3393,3396,5,3402,3404,7,3406,3406,1,3426,3427,5,3458,3459,7,3535,3535,5,3538,3540,5,3544,3550,7,3570,3571,7,3635,3635,7,3655,3662,5,3763,3763,7,3784,3789,5,3893,3893,5,3897,3897,5,3953,3966,5,3968,3972,5,3981,3991,5,4038,4038,5,4145,4145,7,4153,4154,5,4157,4158,5,4184,4185,5,4209,4212,5,4228,4228,7,4237,4237,5,4352,4447,8,4520,4607,10,5906,5908,5,5938,5939,5,5970,5971,5,6068,6069,5,6071,6077,5,6086,6086,5,6089,6099,5,6155,6157,5,6159,6159,5,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6862,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7679,5,8204,8204,5,8206,8207,4,8233,8233,4,8252,8252,14,8288,8292,4,8294,8303,4,8413,8416,5,8418,8420,5,8482,8482,14,8596,8601,14,8986,8987,14,9096,9096,14,9193,9196,14,9199,9199,14,9201,9202,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9729,14,9732,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9775,9775,14,9784,9785,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9874,14,9876,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9934,14,9936,9936,14,9938,9938,14,9940,9940,14,9961,9961,14,9963,9967,14,9970,9971,14,9973,9973,14,9975,9977,14,9979,9980,14,9982,9985,14,9987,9988,14,9992,9996,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10083,14,10085,10087,14,10145,10145,14,10175,10175,14,11013,11015,14,11088,11088,14,11503,11505,5,11744,11775,5,12334,12335,5,12349,12349,14,12951,12951,14,42607,42607,5,42612,42621,5,42736,42737,5,43014,43014,5,43043,43044,7,43047,43047,7,43136,43137,7,43204,43205,5,43263,43263,5,43335,43345,5,43360,43388,8,43395,43395,7,43444,43445,7,43450,43451,7,43454,43456,7,43561,43566,5,43569,43570,5,43573,43574,5,43596,43596,5,43644,43644,5,43698,43700,5,43710,43711,5,43755,43755,7,43758,43759,7,43766,43766,5,44005,44005,5,44008,44008,5,44012,44012,7,44032,44032,11,44060,44060,11,44088,44088,11,44116,44116,11,44144,44144,11,44172,44172,11,44200,44200,11,44228,44228,11,44256,44256,11,44284,44284,11,44312,44312,11,44340,44340,11,44368,44368,11,44396,44396,11,44424,44424,11,44452,44452,11,44480,44480,11,44508,44508,11,44536,44536,11,44564,44564,11,44592,44592,11,44620,44620,11,44648,44648,11,44676,44676,11,44704,44704,11,44732,44732,11,44760,44760,11,44788,44788,11,44816,44816,11,44844,44844,11,44872,44872,11,44900,44900,11,44928,44928,11,44956,44956,11,44984,44984,11,45012,45012,11,45040,45040,11,45068,45068,11,45096,45096,11,45124,45124,11,45152,45152,11,45180,45180,11,45208,45208,11,45236,45236,11,45264,45264,11,45292,45292,11,45320,45320,11,45348,45348,11,45376,45376,11,45404,45404,11,45432,45432,11,45460,45460,11,45488,45488,11,45516,45516,11,45544,45544,11,45572,45572,11,45600,45600,11,45628,45628,11,45656,45656,11,45684,45684,11,45712,45712,11,45740,45740,11,45768,45768,11,45796,45796,11,45824,45824,11,45852,45852,11,45880,45880,11,45908,45908,11,45936,45936,11,45964,45964,11,45992,45992,11,46020,46020,11,46048,46048,11,46076,46076,11,46104,46104,11,46132,46132,11,46160,46160,11,46188,46188,11,46216,46216,11,46244,46244,11,46272,46272,11,46300,46300,11,46328,46328,11,46356,46356,11,46384,46384,11,46412,46412,11,46440,46440,11,46468,46468,11,46496,46496,11,46524,46524,11,46552,46552,11,46580,46580,11,46608,46608,11,46636,46636,11,46664,46664,11,46692,46692,11,46720,46720,11,46748,46748,11,46776,46776,11,46804,46804,11,46832,46832,11,46860,46860,11,46888,46888,11,46916,46916,11,46944,46944,11,46972,46972,11,47000,47000,11,47028,47028,11,47056,47056,11,47084,47084,11,47112,47112,11,47140,47140,11,47168,47168,11,47196,47196,11,47224,47224,11,47252,47252,11,47280,47280,11,47308,47308,11,47336,47336,11,47364,47364,11,47392,47392,11,47420,47420,11,47448,47448,11,47476,47476,11,47504,47504,11,47532,47532,11,47560,47560,11,47588,47588,11,47616,47616,11,47644,47644,11,47672,47672,11,47700,47700,11,47728,47728,11,47756,47756,11,47784,47784,11,47812,47812,11,47840,47840,11,47868,47868,11,47896,47896,11,47924,47924,11,47952,47952,11,47980,47980,11,48008,48008,11,48036,48036,11,48064,48064,11,48092,48092,11,48120,48120,11,48148,48148,11,48176,48176,11,48204,48204,11,48232,48232,11,48260,48260,11,48288,48288,11,48316,48316,11,48344,48344,11,48372,48372,11,48400,48400,11,48428,48428,11,48456,48456,11,48484,48484,11,48512,48512,11,48540,48540,11,48568,48568,11,48596,48596,11,48624,48624,11,48652,48652,11,48680,48680,11,48708,48708,11,48736,48736,11,48764,48764,11,48792,48792,11,48820,48820,11,48848,48848,11,48876,48876,11,48904,48904,11,48932,48932,11,48960,48960,11,48988,48988,11,49016,49016,11,49044,49044,11,49072,49072,11,49100,49100,11,49128,49128,11,49156,49156,11,49184,49184,11,49212,49212,11,49240,49240,11,49268,49268,11,49296,49296,11,49324,49324,11,49352,49352,11,49380,49380,11,49408,49408,11,49436,49436,11,49464,49464,11,49492,49492,11,49520,49520,11,49548,49548,11,49576,49576,11,49604,49604,11,49632,49632,11,49660,49660,11,49688,49688,11,49716,49716,11,49744,49744,11,49772,49772,11,49800,49800,11,49828,49828,11,49856,49856,11,49884,49884,11,49912,49912,11,49940,49940,11,49968,49968,11,49996,49996,11,50024,50024,11,50052,50052,11,50080,50080,11,50108,50108,11,50136,50136,11,50164,50164,11,50192,50192,11,50220,50220,11,50248,50248,11,50276,50276,11,50304,50304,11,50332,50332,11,50360,50360,11,50388,50388,11,50416,50416,11,50444,50444,11,50472,50472,11,50500,50500,11,50528,50528,11,50556,50556,11,50584,50584,11,50612,50612,11,50640,50640,11,50668,50668,11,50696,50696,11,50724,50724,11,50752,50752,11,50780,50780,11,50808,50808,11,50836,50836,11,50864,50864,11,50892,50892,11,50920,50920,11,50948,50948,11,50976,50976,11,51004,51004,11,51032,51032,11,51060,51060,11,51088,51088,11,51116,51116,11,51144,51144,11,51172,51172,11,51200,51200,11,51228,51228,11,51256,51256,11,51284,51284,11,51312,51312,11,51340,51340,11,51368,51368,11,51396,51396,11,51424,51424,11,51452,51452,11,51480,51480,11,51508,51508,11,51536,51536,11,51564,51564,11,51592,51592,11,51620,51620,11,51648,51648,11,51676,51676,11,51704,51704,11,51732,51732,11,51760,51760,11,51788,51788,11,51816,51816,11,51844,51844,11,51872,51872,11,51900,51900,11,51928,51928,11,51956,51956,11,51984,51984,11,52012,52012,11,52040,52040,11,52068,52068,11,52096,52096,11,52124,52124,11,52152,52152,11,52180,52180,11,52208,52208,11,52236,52236,11,52264,52264,11,52292,52292,11,52320,52320,11,52348,52348,11,52376,52376,11,52404,52404,11,52432,52432,11,52460,52460,11,52488,52488,11,52516,52516,11,52544,52544,11,52572,52572,11,52600,52600,11,52628,52628,11,52656,52656,11,52684,52684,11,52712,52712,11,52740,52740,11,52768,52768,11,52796,52796,11,52824,52824,11,52852,52852,11,52880,52880,11,52908,52908,11,52936,52936,11,52964,52964,11,52992,52992,11,53020,53020,11,53048,53048,11,53076,53076,11,53104,53104,11,53132,53132,11,53160,53160,11,53188,53188,11,53216,53216,11,53244,53244,11,53272,53272,11,53300,53300,11,53328,53328,11,53356,53356,11,53384,53384,11,53412,53412,11,53440,53440,11,53468,53468,11,53496,53496,11,53524,53524,11,53552,53552,11,53580,53580,11,53608,53608,11,53636,53636,11,53664,53664,11,53692,53692,11,53720,53720,11,53748,53748,11,53776,53776,11,53804,53804,11,53832,53832,11,53860,53860,11,53888,53888,11,53916,53916,11,53944,53944,11,53972,53972,11,54000,54000,11,54028,54028,11,54056,54056,11,54084,54084,11,54112,54112,11,54140,54140,11,54168,54168,11,54196,54196,11,54224,54224,11,54252,54252,11,54280,54280,11,54308,54308,11,54336,54336,11,54364,54364,11,54392,54392,11,54420,54420,11,54448,54448,11,54476,54476,11,54504,54504,11,54532,54532,11,54560,54560,11,54588,54588,11,54616,54616,11,54644,54644,11,54672,54672,11,54700,54700,11,54728,54728,11,54756,54756,11,54784,54784,11,54812,54812,11,54840,54840,11,54868,54868,11,54896,54896,11,54924,54924,11,54952,54952,11,54980,54980,11,55008,55008,11,55036,55036,11,55064,55064,11,55092,55092,11,55120,55120,11,55148,55148,11,55176,55176,11,55216,55238,9,64286,64286,5,65056,65071,5,65438,65439,5,65529,65531,4,66272,66272,5,68097,68099,5,68108,68111,5,68159,68159,5,68900,68903,5,69446,69456,5,69632,69632,7,69634,69634,7,69744,69744,5,69759,69761,5,69808,69810,7,69815,69816,7,69821,69821,1,69837,69837,1,69927,69931,5,69933,69940,5,70003,70003,5,70018,70018,7,70070,70078,5,70082,70083,1,70094,70094,7,70188,70190,7,70194,70195,7,70197,70197,7,70206,70206,5,70368,70370,7,70400,70401,5,70459,70460,5,70463,70463,7,70465,70468,7,70475,70477,7,70498,70499,7,70512,70516,5,70712,70719,5,70722,70724,5,70726,70726,5,70832,70832,5,70835,70840,5,70842,70842,5,70845,70845,5,70847,70848,5,70850,70851,5,71088,71089,7,71096,71099,7,71102,71102,7,71132,71133,5,71219,71226,5,71229,71229,5,71231,71232,5,71340,71340,7,71342,71343,7,71350,71350,7,71453,71455,5,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,118528,118573,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123566,123566,5,125136,125142,5,126976,126979,14,126981,127182,14,127184,127231,14,127279,127279,14,127344,127345,14,127374,127374,14,127405,127461,14,127489,127490,14,127514,127514,14,127538,127546,14,127561,127567,14,127570,127743,14,127757,127758,14,127760,127760,14,127762,127762,14,127766,127768,14,127770,127770,14,127772,127772,14,127775,127776,14,127778,127779,14,127789,127791,14,127794,127795,14,127798,127798,14,127819,127819,14,127824,127824,14,127868,127868,14,127870,127871,14,127892,127893,14,127896,127896,14,127900,127901,14,127904,127940,14,127942,127942,14,127944,127944,14,127946,127946,14,127951,127955,14,127968,127971,14,127973,127984,14,127987,127987,14,127989,127989,14,127991,127991,14,127995,127999,5,128008,128008,14,128012,128014,14,128017,128018,14,128020,128020,14,128022,128022,14,128042,128042,14,128063,128063,14,128065,128065,14,128101,128101,14,128108,128109,14,128173,128173,14,128182,128183,14,128236,128237,14,128239,128239,14,128245,128245,14,128248,128248,14,128253,128253,14,128255,128258,14,128260,128263,14,128265,128265,14,128277,128277,14,128300,128301,14,128326,128328,14,128331,128334,14,128336,128347,14,128360,128366,14,128369,128370,14,128378,128378,14,128391,128391,14,128394,128397,14,128400,128400,14,128405,128406,14,128420,128420,14,128422,128423,14,128425,128432,14,128435,128443,14,128445,128449,14,128453,128464,14,128468,128475,14,128479,128480,14,128482,128482,14,128484,128487,14,128489,128494,14,128496,128498,14,128500,128505,14,128507,128511,14,128513,128518,14,128521,128525,14,128527,128527,14,128529,128529,14,128533,128533,14,128535,128535,14,128537,128537,14]');
  6404. }
  6405. //#endregion
  6406. /**
  6407. * Computes the offset after performing a left delete on the given string,
  6408. * while considering unicode grapheme/emoji rules.
  6409. */
  6410. function getLeftDeleteOffset(offset, str) {
  6411. if (offset === 0) {
  6412. return 0;
  6413. }
  6414. // Try to delete emoji part.
  6415. const emojiOffset = getOffsetBeforeLastEmojiComponent(offset, str);
  6416. if (emojiOffset !== undefined) {
  6417. return emojiOffset;
  6418. }
  6419. // Otherwise, just skip a single code point.
  6420. const codePoint = getPrevCodePoint(str, offset);
  6421. offset -= getUTF16Length(codePoint);
  6422. return offset;
  6423. }
  6424. exports.getLeftDeleteOffset = getLeftDeleteOffset;
  6425. function getOffsetBeforeLastEmojiComponent(offset, str) {
  6426. // See https://www.unicode.org/reports/tr51/tr51-14.html#EBNF_and_Regex for the
  6427. // structure of emojis.
  6428. let codePoint = getPrevCodePoint(str, offset);
  6429. offset -= getUTF16Length(codePoint);
  6430. // Skip modifiers
  6431. while ((isEmojiModifier(codePoint) || codePoint === 65039 /* emojiVariantSelector */ || codePoint === 8419 /* enclosingKeyCap */)) {
  6432. if (offset === 0) {
  6433. // Cannot skip modifier, no preceding emoji base.
  6434. return undefined;
  6435. }
  6436. codePoint = getPrevCodePoint(str, offset);
  6437. offset -= getUTF16Length(codePoint);
  6438. }
  6439. // Expect base emoji
  6440. if (!isEmojiImprecise(codePoint)) {
  6441. // Unexpected code point, not a valid emoji.
  6442. return undefined;
  6443. }
  6444. if (offset >= 0) {
  6445. // Skip optional ZWJ code points that combine multiple emojis.
  6446. // In theory, we should check if that ZWJ actually combines multiple emojis
  6447. // to prevent deleting ZWJs in situations we didn't account for.
  6448. const optionalZwjCodePoint = getPrevCodePoint(str, offset);
  6449. if (optionalZwjCodePoint === 8205 /* zwj */) {
  6450. offset -= getUTF16Length(optionalZwjCodePoint);
  6451. }
  6452. }
  6453. return offset;
  6454. }
  6455. function getUTF16Length(codePoint) {
  6456. return codePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;
  6457. }
  6458. function isEmojiModifier(codePoint) {
  6459. return 0x1F3FB <= codePoint && codePoint <= 0x1F3FF;
  6460. }
  6461. exports.noBreakWhitespace = '\xa0';
  6462. class AmbiguousCharacters {
  6463. static getData() {
  6464. // Stored as key1, value1, key2, value2, ...
  6465. return JSON.parse('{\"_common\":[8232,32,8233,32,5760,32,8192,32,8193,32,8194,32,8195,32,8196,32,8197,32,8198,32,8200,32,8201,32,8202,32,8287,32,8199,32,8239,32,2042,95,65101,95,65102,95,65103,95,8208,45,8209,45,8210,45,65112,45,1748,45,8259,45,727,45,8722,45,10134,45,11450,45,1549,44,1643,44,8218,44,184,44,42233,44,894,59,2307,58,2691,58,1417,58,1795,58,1796,58,5868,58,65072,58,6147,58,6153,58,8282,58,1475,58,760,58,42889,58,8758,58,720,58,42237,58,451,33,11601,33,660,63,577,63,2429,63,5038,63,42731,63,119149,46,8228,46,1793,46,1794,46,42510,46,68176,46,1632,46,1776,46,42232,46,1373,96,65287,96,8219,96,8242,96,1370,96,1523,96,8175,96,65344,96,900,96,8189,96,8125,96,8127,96,8190,96,697,96,884,96,712,96,714,96,715,96,756,96,699,96,701,96,700,96,702,96,42892,96,1497,96,2036,96,2037,96,5194,96,5836,96,94033,96,94034,96,65339,40,10088,40,10098,40,12308,40,64830,40,65341,41,10089,41,10099,41,12309,41,64831,41,10100,123,119060,123,10101,125,8270,42,1645,42,8727,42,66335,42,5941,47,8257,47,8725,47,8260,47,9585,47,10187,47,10744,47,119354,47,12755,47,12339,47,11462,47,20031,47,12035,47,65340,92,65128,92,8726,92,10189,92,10741,92,10745,92,119311,92,119355,92,12756,92,20022,92,12034,92,42872,38,708,94,710,94,5869,43,10133,43,66203,43,8249,60,10094,60,706,60,119350,60,5176,60,5810,60,5120,61,11840,61,12448,61,42239,61,8250,62,10095,62,707,62,119351,62,5171,62,94015,62,8275,126,732,126,8128,126,8764,126,120784,50,120794,50,120804,50,120814,50,120824,50,130034,50,42842,50,423,50,1000,50,42564,50,5311,50,42735,50,119302,51,120785,51,120795,51,120805,51,120815,51,120825,51,130035,51,42923,51,540,51,439,51,42858,51,11468,51,1248,51,94011,51,71882,51,120786,52,120796,52,120806,52,120816,52,120826,52,130036,52,5070,52,71855,52,120787,53,120797,53,120807,53,120817,53,120827,53,130037,53,444,53,71867,53,120788,54,120798,54,120808,54,120818,54,120828,54,130038,54,11474,54,5102,54,71893,54,119314,55,120789,55,120799,55,120809,55,120819,55,120829,55,130039,55,66770,55,71878,55,2819,56,2538,56,2666,56,125131,56,120790,56,120800,56,120810,56,120820,56,120830,56,130040,56,547,56,546,56,66330,56,2663,57,2920,57,2541,57,3437,57,120791,57,120801,57,120811,57,120821,57,120831,57,130041,57,42862,57,11466,57,71884,57,71852,57,71894,57,9082,97,65345,97,119834,97,119886,97,119938,97,119990,97,120042,97,120094,97,120146,97,120198,97,120250,97,120302,97,120354,97,120406,97,120458,97,593,97,945,97,120514,97,120572,97,120630,97,120688,97,120746,97,65313,65,119808,65,119860,65,119912,65,119964,65,120016,65,120068,65,120120,65,120172,65,120224,65,120276,65,120328,65,120380,65,120432,65,913,65,120488,65,120546,65,120604,65,120662,65,120720,65,5034,65,5573,65,42222,65,94016,65,66208,65,119835,98,119887,98,119939,98,119991,98,120043,98,120095,98,120147,98,120199,98,120251,98,120303,98,120355,98,120407,98,120459,98,388,98,5071,98,5234,98,5551,98,65314,66,8492,66,119809,66,119861,66,119913,66,120017,66,120069,66,120121,66,120173,66,120225,66,120277,66,120329,66,120381,66,120433,66,42932,66,914,66,120489,66,120547,66,120605,66,120663,66,120721,66,5108,66,5623,66,42192,66,66178,66,66209,66,66305,66,65347,99,8573,99,119836,99,119888,99,119940,99,119992,99,120044,99,120096,99,120148,99,120200,99,120252,99,120304,99,120356,99,120408,99,120460,99,7428,99,1010,99,11429,99,43951,99,66621,99,128844,67,71922,67,71913,67,65315,67,8557,67,8450,67,8493,67,119810,67,119862,67,119914,67,119966,67,120018,67,120174,67,120226,67,120278,67,120330,67,120382,67,120434,67,1017,67,11428,67,5087,67,42202,67,66210,67,66306,67,66581,67,66844,67,8574,100,8518,100,119837,100,119889,100,119941,100,119993,100,120045,100,120097,100,120149,100,120201,100,120253,100,120305,100,120357,100,120409,100,120461,100,1281,100,5095,100,5231,100,42194,100,8558,68,8517,68,119811,68,119863,68,119915,68,119967,68,120019,68,120071,68,120123,68,120175,68,120227,68,120279,68,120331,68,120383,68,120435,68,5024,68,5598,68,5610,68,42195,68,8494,101,65349,101,8495,101,8519,101,119838,101,119890,101,119942,101,120046,101,120098,101,120150,101,120202,101,120254,101,120306,101,120358,101,120410,101,120462,101,43826,101,1213,101,8959,69,65317,69,8496,69,119812,69,119864,69,119916,69,120020,69,120072,69,120124,69,120176,69,120228,69,120280,69,120332,69,120384,69,120436,69,917,69,120492,69,120550,69,120608,69,120666,69,120724,69,11577,69,5036,69,42224,69,71846,69,71854,69,66182,69,119839,102,119891,102,119943,102,119995,102,120047,102,120099,102,120151,102,120203,102,120255,102,120307,102,120359,102,120411,102,120463,102,43829,102,42905,102,383,102,7837,102,1412,102,119315,70,8497,70,119813,70,119865,70,119917,70,120021,70,120073,70,120125,70,120177,70,120229,70,120281,70,120333,70,120385,70,120437,70,42904,70,988,70,120778,70,5556,70,42205,70,71874,70,71842,70,66183,70,66213,70,66853,70,65351,103,8458,103,119840,103,119892,103,119944,103,120048,103,120100,103,120152,103,120204,103,120256,103,120308,103,120360,103,120412,103,120464,103,609,103,7555,103,397,103,1409,103,119814,71,119866,71,119918,71,119970,71,120022,71,120074,71,120126,71,120178,71,120230,71,120282,71,120334,71,120386,71,120438,71,1292,71,5056,71,5107,71,42198,71,65352,104,8462,104,119841,104,119945,104,119997,104,120049,104,120101,104,120153,104,120205,104,120257,104,120309,104,120361,104,120413,104,120465,104,1211,104,1392,104,5058,104,65320,72,8459,72,8460,72,8461,72,119815,72,119867,72,119919,72,120023,72,120179,72,120231,72,120283,72,120335,72,120387,72,120439,72,919,72,120494,72,120552,72,120610,72,120668,72,120726,72,11406,72,5051,72,5500,72,42215,72,66255,72,731,105,9075,105,65353,105,8560,105,8505,105,8520,105,119842,105,119894,105,119946,105,119998,105,120050,105,120102,105,120154,105,120206,105,120258,105,120310,105,120362,105,120414,105,120466,105,120484,105,618,105,617,105,953,105,8126,105,890,105,120522,105,120580,105,120638,105,120696,105,120754,105,1110,105,42567,105,1231,105,43893,105,5029,105,71875,105,65354,106,8521,106,119843,106,119895,106,119947,106,119999,106,120051,106,120103,106,120155,106,120207,106,120259,106,120311,106,120363,106,120415,106,120467,106,1011,106,1112,106,65322,74,119817,74,119869,74,119921,74,119973,74,120025,74,120077,74,120129,74,120181,74,120233,74,120285,74,120337,74,120389,74,120441,74,42930,74,895,74,1032,74,5035,74,5261,74,42201,74,119844,107,119896,107,119948,107,120000,107,120052,107,120104,107,120156,107,120208,107,120260,107,120312,107,120364,107,120416,107,120468,107,8490,75,65323,75,119818,75,119870,75,119922,75,119974,75,120026,75,120078,75,120130,75,120182,75,120234,75,120286,75,120338,75,120390,75,120442,75,922,75,120497,75,120555,75,120613,75,120671,75,120729,75,11412,75,5094,75,5845,75,42199,75,66840,75,1472,124,8739,124,9213,124,65512,124,1633,124,1777,124,66336,124,125127,124,120783,124,120793,124,120803,124,120813,124,120823,124,130033,124,65321,124,8544,124,8464,124,8465,124,119816,124,119868,124,119920,124,120024,124,120128,124,120180,124,120232,124,120284,124,120336,124,120388,124,120440,124,406,124,65356,124,8572,124,8467,124,119845,124,119897,124,119949,124,120001,124,120053,124,120105,124,120157,124,120209,124,120261,124,120313,124,120365,124,120417,124,120469,124,448,124,120496,124,120554,124,120612,124,120670,124,120728,124,11410,124,1030,124,1216,124,1493,124,1503,124,1575,124,126464,124,126592,124,65166,124,65165,124,1994,124,11599,124,5825,124,42226,124,93992,124,66186,124,66313,124,119338,76,8556,76,8466,76,119819,76,119871,76,119923,76,120027,76,120079,76,120131,76,120183,76,120235,76,120287,76,120339,76,120391,76,120443,76,11472,76,5086,76,5290,76,42209,76,93974,76,71843,76,71858,76,66587,76,66854,76,65325,77,8559,77,8499,77,119820,77,119872,77,119924,77,120028,77,120080,77,120132,77,120184,77,120236,77,120288,77,120340,77,120392,77,120444,77,924,77,120499,77,120557,77,120615,77,120673,77,120731,77,1018,77,11416,77,5047,77,5616,77,5846,77,42207,77,66224,77,66321,77,119847,110,119899,110,119951,110,120003,110,120055,110,120107,110,120159,110,120211,110,120263,110,120315,110,120367,110,120419,110,120471,110,1400,110,1404,110,65326,78,8469,78,119821,78,119873,78,119925,78,119977,78,120029,78,120081,78,120185,78,120237,78,120289,78,120341,78,120393,78,120445,78,925,78,120500,78,120558,78,120616,78,120674,78,120732,78,11418,78,42208,78,66835,78,3074,111,3202,111,3330,111,3458,111,2406,111,2662,111,2790,111,3046,111,3174,111,3302,111,3430,111,3664,111,3792,111,4160,111,1637,111,1781,111,65359,111,8500,111,119848,111,119900,111,119952,111,120056,111,120108,111,120160,111,120212,111,120264,111,120316,111,120368,111,120420,111,120472,111,7439,111,7441,111,43837,111,959,111,120528,111,120586,111,120644,111,120702,111,120760,111,963,111,120532,111,120590,111,120648,111,120706,111,120764,111,11423,111,4351,111,1413,111,1505,111,1607,111,126500,111,126564,111,126596,111,65259,111,65260,111,65258,111,65257,111,1726,111,64428,111,64429,111,64427,111,64426,111,1729,111,64424,111,64425,111,64423,111,64422,111,1749,111,3360,111,4125,111,66794,111,71880,111,71895,111,66604,111,1984,79,2534,79,2918,79,12295,79,70864,79,71904,79,120782,79,120792,79,120802,79,120812,79,120822,79,130032,79,65327,79,119822,79,119874,79,119926,79,119978,79,120030,79,120082,79,120134,79,120186,79,120238,79,120290,79,120342,79,120394,79,120446,79,927,79,120502,79,120560,79,120618,79,120676,79,120734,79,11422,79,1365,79,11604,79,4816,79,2848,79,66754,79,42227,79,71861,79,66194,79,66219,79,66564,79,66838,79,9076,112,65360,112,119849,112,119901,112,119953,112,120005,112,120057,112,120109,112,120161,112,120213,112,120265,112,120317,112,120369,112,120421,112,120473,112,961,112,120530,112,120544,112,120588,112,120602,112,120646,112,120660,112,120704,112,120718,112,120762,112,120776,112,11427,112,65328,80,8473,80,119823,80,119875,80,119927,80,119979,80,120031,80,120083,80,120187,80,120239,80,120291,80,120343,80,120395,80,120447,80,929,80,120504,80,120562,80,120620,80,120678,80,120736,80,11426,80,5090,80,5229,80,42193,80,66197,80,119850,113,119902,113,119954,113,120006,113,120058,113,120110,113,120162,113,120214,113,120266,113,120318,113,120370,113,120422,113,120474,113,1307,113,1379,113,1382,113,8474,81,119824,81,119876,81,119928,81,119980,81,120032,81,120084,81,120188,81,120240,81,120292,81,120344,81,120396,81,120448,81,11605,81,119851,114,119903,114,119955,114,120007,114,120059,114,120111,114,120163,114,120215,114,120267,114,120319,114,120371,114,120423,114,120475,114,43847,114,43848,114,7462,114,11397,114,43905,114,119318,82,8475,82,8476,82,8477,82,119825,82,119877,82,119929,82,120033,82,120189,82,120241,82,120293,82,120345,82,120397,82,120449,82,422,82,5025,82,5074,82,66740,82,5511,82,42211,82,94005,82,65363,115,119852,115,119904,115,119956,115,120008,115,120060,115,120112,115,120164,115,120216,115,120268,115,120320,115,120372,115,120424,115,120476,115,42801,115,445,115,1109,115,43946,115,71873,115,66632,115,65331,83,119826,83,119878,83,119930,83,119982,83,120034,83,120086,83,120138,83,120190,83,120242,83,120294,83,120346,83,120398,83,120450,83,1029,83,1359,83,5077,83,5082,83,42210,83,94010,83,66198,83,66592,83,119853,116,119905,116,119957,116,120009,116,120061,116,120113,116,120165,116,120217,116,120269,116,120321,116,120373,116,120425,116,120477,116,8868,84,10201,84,128872,84,65332,84,119827,84,119879,84,119931,84,119983,84,120035,84,120087,84,120139,84,120191,84,120243,84,120295,84,120347,84,120399,84,120451,84,932,84,120507,84,120565,84,120623,84,120681,84,120739,84,11430,84,5026,84,42196,84,93962,84,71868,84,66199,84,66225,84,66325,84,119854,117,119906,117,119958,117,120010,117,120062,117,120114,117,120166,117,120218,117,120270,117,120322,117,120374,117,120426,117,120478,117,42911,117,7452,117,43854,117,43858,117,651,117,965,117,120534,117,120592,117,120650,117,120708,117,120766,117,1405,117,66806,117,71896,117,8746,85,8899,85,119828,85,119880,85,119932,85,119984,85,120036,85,120088,85,120140,85,120192,85,120244,85,120296,85,120348,85,120400,85,120452,85,1357,85,4608,85,66766,85,5196,85,42228,85,94018,85,71864,85,8744,118,8897,118,65366,118,8564,118,119855,118,119907,118,119959,118,120011,118,120063,118,120115,118,120167,118,120219,118,120271,118,120323,118,120375,118,120427,118,120479,118,7456,118,957,118,120526,118,120584,118,120642,118,120700,118,120758,118,1141,118,1496,118,71430,118,43945,118,71872,118,119309,86,1639,86,1783,86,8548,86,119829,86,119881,86,119933,86,119985,86,120037,86,120089,86,120141,86,120193,86,120245,86,120297,86,120349,86,120401,86,120453,86,1140,86,11576,86,5081,86,5167,86,42719,86,42214,86,93960,86,71840,86,66845,86,623,119,119856,119,119908,119,119960,119,120012,119,120064,119,120116,119,120168,119,120220,119,120272,119,120324,119,120376,119,120428,119,120480,119,7457,119,1121,119,1309,119,1377,119,71434,119,71438,119,71439,119,43907,119,71919,87,71910,87,119830,87,119882,87,119934,87,119986,87,120038,87,120090,87,120142,87,120194,87,120246,87,120298,87,120350,87,120402,87,120454,87,1308,87,5043,87,5076,87,42218,87,5742,120,10539,120,10540,120,10799,120,65368,120,8569,120,119857,120,119909,120,119961,120,120013,120,120065,120,120117,120,120169,120,120221,120,120273,120,120325,120,120377,120,120429,120,120481,120,5441,120,5501,120,5741,88,9587,88,66338,88,71916,88,65336,88,8553,88,119831,88,119883,88,119935,88,119987,88,120039,88,120091,88,120143,88,120195,88,120247,88,120299,88,120351,88,120403,88,120455,88,42931,88,935,88,120510,88,120568,88,120626,88,120684,88,120742,88,11436,88,11613,88,5815,88,42219,88,66192,88,66228,88,66327,88,66855,88,611,121,7564,121,65369,121,119858,121,119910,121,119962,121,120014,121,120066,121,120118,121,120170,121,120222,121,120274,121,120326,121,120378,121,120430,121,120482,121,655,121,7935,121,43866,121,947,121,8509,121,120516,121,120574,121,120632,121,120690,121,120748,121,1199,121,4327,121,71900,121,65337,89,119832,89,119884,89,119936,89,119988,89,120040,89,120092,89,120144,89,120196,89,120248,89,120300,89,120352,89,120404,89,120456,89,933,89,978,89,120508,89,120566,89,120624,89,120682,89,120740,89,11432,89,1198,89,5033,89,5053,89,42220,89,94019,89,71844,89,66226,89,119859,122,119911,122,119963,122,120015,122,120067,122,120119,122,120171,122,120223,122,120275,122,120327,122,120379,122,120431,122,120483,122,7458,122,43923,122,71876,122,66293,90,71909,90,65338,90,8484,90,8488,90,119833,90,119885,90,119937,90,119989,90,120041,90,120197,90,120249,90,120301,90,120353,90,120405,90,120457,90,918,90,120493,90,120551,90,120609,90,120667,90,120725,90,5059,90,42204,90,71849,90],\"_default\":[160,32,8211,45,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"cs\":[65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89],\"de\":[65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,1093,120,1061,88,1091,121,1059,89],\"es\":[8211,45,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"fr\":[65306,58,65281,33,8216,96,8245,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"it\":[160,32,8211,45,65306,58,65281,33,8216,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"ja\":[8211,45,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"ko\":[8211,45,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"pl\":[65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"pt-BR\":[65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"qps-ploc\":[160,32,8211,45,65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"ru\":[65306,58,65281,33,8216,96,8217,96,8245,96,180,96,12494,47,305,105,921,124,1009,112,215,120],\"tr\":[160,32,8211,45,65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"zh-hans\":[65306,58,65281,33,8245,96,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89],\"zh-hant\":[8211,45,180,96,12494,47,1047,51,1073,54,1072,97,1040,65,1068,98,1042,66,1089,99,1057,67,1077,101,1045,69,1053,72,305,105,1050,75,921,124,1052,77,1086,111,1054,79,1009,112,1088,112,1056,80,1075,114,1058,84,215,120,1093,120,1061,88,1091,121,1059,89]}');
  6466. }
  6467. static getConfusablesForCurrentLocale() {
  6468. if (!AmbiguousCharacters.map) {
  6469. const data = AmbiguousCharacters.getData();
  6470. let locale = platform.locale;
  6471. if (!locale || !(locale in data)) {
  6472. locale = platform.language;
  6473. }
  6474. if (!locale || !(locale in data)) {
  6475. locale = '_default';
  6476. }
  6477. function arrayToMap(arr) {
  6478. const result = new Map();
  6479. for (let i = 0; i < arr.length; i += 2) {
  6480. result.set(arr[i], arr[i + 1]);
  6481. }
  6482. return result;
  6483. }
  6484. const set = arrayToMap(data['_common']);
  6485. const additionalConfusables = arrayToMap(data[locale]);
  6486. for (const [codePoint, originalCodePoint] of additionalConfusables) {
  6487. set.set(codePoint, originalCodePoint);
  6488. }
  6489. AmbiguousCharacters.map = set;
  6490. }
  6491. return AmbiguousCharacters.map;
  6492. }
  6493. static isAmbiguous(codePoint) {
  6494. return AmbiguousCharacters.getConfusablesForCurrentLocale().has(codePoint);
  6495. }
  6496. /**
  6497. * Returns the non basic ASCII code point that the given code point can be confused,
  6498. * or undefined if such code point does note exist.
  6499. */
  6500. static getPrimaryConfusable(codePoint) {
  6501. return AmbiguousCharacters.getConfusablesForCurrentLocale().get(codePoint);
  6502. }
  6503. static getPrimaryConfusableCodePoints() {
  6504. return new Set(AmbiguousCharacters.getConfusablesForCurrentLocale().keys());
  6505. }
  6506. }
  6507. exports.AmbiguousCharacters = AmbiguousCharacters;
  6508. class InvisibleCharacters {
  6509. static getRawData() {
  6510. return JSON.parse('[9,10,11,12,13,32,127,160,173,847,1564,4447,4448,6068,6069,6155,6156,6157,6158,7355,7356,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8234,8235,8236,8237,8238,8239,8287,8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,10240,12288,12644,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65279,65440,65520,65521,65522,65523,65524,65525,65526,65527,65528,65532,78844,119155,119156,119157,119158,119159,119160,119161,119162,917504,917505,917506,917507,917508,917509,917510,917511,917512,917513,917514,917515,917516,917517,917518,917519,917520,917521,917522,917523,917524,917525,917526,917527,917528,917529,917530,917531,917532,917533,917534,917535,917536,917537,917538,917539,917540,917541,917542,917543,917544,917545,917546,917547,917548,917549,917550,917551,917552,917553,917554,917555,917556,917557,917558,917559,917560,917561,917562,917563,917564,917565,917566,917567,917568,917569,917570,917571,917572,917573,917574,917575,917576,917577,917578,917579,917580,917581,917582,917583,917584,917585,917586,917587,917588,917589,917590,917591,917592,917593,917594,917595,917596,917597,917598,917599,917600,917601,917602,917603,917604,917605,917606,917607,917608,917609,917610,917611,917612,917613,917614,917615,917616,917617,917618,917619,917620,917621,917622,917623,917624,917625,917626,917627,917628,917629,917630,917631,917760,917761,917762,917763,917764,917765,917766,917767,917768,917769,917770,917771,917772,917773,917774,917775,917776,917777,917778,917779,917780,917781,917782,917783,917784,917785,917786,917787,917788,917789,917790,917791,917792,917793,917794,917795,917796,917797,917798,917799,917800,917801,917802,917803,917804,917805,917806,917807,917808,917809,917810,917811,917812,917813,917814,917815,917816,917817,917818,917819,917820,917821,917822,917823,917824,917825,917826,917827,917828,917829,917830,917831,917832,917833,917834,917835,917836,917837,917838,917839,917840,917841,917842,917843,917844,917845,917846,917847,917848,917849,917850,917851,917852,917853,917854,917855,917856,917857,917858,917859,917860,917861,917862,917863,917864,917865,917866,917867,917868,917869,917870,917871,917872,917873,917874,917875,917876,917877,917878,917879,917880,917881,917882,917883,917884,917885,917886,917887,917888,917889,917890,917891,917892,917893,917894,917895,917896,917897,917898,917899,917900,917901,917902,917903,917904,917905,917906,917907,917908,917909,917910,917911,917912,917913,917914,917915,917916,917917,917918,917919,917920,917921,917922,917923,917924,917925,917926,917927,917928,917929,917930,917931,917932,917933,917934,917935,917936,917937,917938,917939,917940,917941,917942,917943,917944,917945,917946,917947,917948,917949,917950,917951,917952,917953,917954,917955,917956,917957,917958,917959,917960,917961,917962,917963,917964,917965,917966,917967,917968,917969,917970,917971,917972,917973,917974,917975,917976,917977,917978,917979,917980,917981,917982,917983,917984,917985,917986,917987,917988,917989,917990,917991,917992,917993,917994,917995,917996,917997,917998,917999]');
  6511. }
  6512. static getData() {
  6513. if (!this._data) {
  6514. this._data = new Set(InvisibleCharacters.getRawData());
  6515. }
  6516. return this._data;
  6517. }
  6518. static isInvisibleCharacter(codePoint) {
  6519. return InvisibleCharacters.getData().has(codePoint);
  6520. }
  6521. static get codePoints() {
  6522. return InvisibleCharacters.getData();
  6523. }
  6524. }
  6525. exports.InvisibleCharacters = InvisibleCharacters;
  6526. InvisibleCharacters._data = undefined;
  6527. });
  6528. /*---------------------------------------------------------------------------------------------
  6529. * Copyright (c) Microsoft Corporation. All rights reserved.
  6530. * Licensed under the MIT License. See License.txt in the project root for license information.
  6531. *--------------------------------------------------------------------------------------------*/
  6532. define(__m[24/*vs/base/common/hash*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/strings*/]), function (require, exports, strings) {
  6533. "use strict";
  6534. Object.defineProperty(exports, "__esModule", { value: true });
  6535. exports.StringSHA1 = exports.toHexString = exports.stringHash = exports.numberHash = exports.doHash = exports.hash = void 0;
  6536. /**
  6537. * Return a hash value for an object.
  6538. */
  6539. function hash(obj) {
  6540. return doHash(obj, 0);
  6541. }
  6542. exports.hash = hash;
  6543. function doHash(obj, hashVal) {
  6544. switch (typeof obj) {
  6545. case 'object':
  6546. if (obj === null) {
  6547. return numberHash(349, hashVal);
  6548. }
  6549. else if (Array.isArray(obj)) {
  6550. return arrayHash(obj, hashVal);
  6551. }
  6552. return objectHash(obj, hashVal);
  6553. case 'string':
  6554. return stringHash(obj, hashVal);
  6555. case 'boolean':
  6556. return booleanHash(obj, hashVal);
  6557. case 'number':
  6558. return numberHash(obj, hashVal);
  6559. case 'undefined':
  6560. return numberHash(937, hashVal);
  6561. default:
  6562. return numberHash(617, hashVal);
  6563. }
  6564. }
  6565. exports.doHash = doHash;
  6566. function numberHash(val, initialHashVal) {
  6567. return (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32
  6568. }
  6569. exports.numberHash = numberHash;
  6570. function booleanHash(b, initialHashVal) {
  6571. return numberHash(b ? 433 : 863, initialHashVal);
  6572. }
  6573. function stringHash(s, hashVal) {
  6574. hashVal = numberHash(149417, hashVal);
  6575. for (let i = 0, length = s.length; i < length; i++) {
  6576. hashVal = numberHash(s.charCodeAt(i), hashVal);
  6577. }
  6578. return hashVal;
  6579. }
  6580. exports.stringHash = stringHash;
  6581. function arrayHash(arr, initialHashVal) {
  6582. initialHashVal = numberHash(104579, initialHashVal);
  6583. return arr.reduce((hashVal, item) => doHash(item, hashVal), initialHashVal);
  6584. }
  6585. function objectHash(obj, initialHashVal) {
  6586. initialHashVal = numberHash(181387, initialHashVal);
  6587. return Object.keys(obj).sort().reduce((hashVal, key) => {
  6588. hashVal = stringHash(key, hashVal);
  6589. return doHash(obj[key], hashVal);
  6590. }, initialHashVal);
  6591. }
  6592. function leftRotate(value, bits, totalBits = 32) {
  6593. // delta + bits = totalBits
  6594. const delta = totalBits - bits;
  6595. // All ones, expect `delta` zeros aligned to the right
  6596. const mask = ~((1 << delta) - 1);
  6597. // Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)
  6598. return ((value << bits) | ((mask & value) >>> delta)) >>> 0;
  6599. }
  6600. function fill(dest, index = 0, count = dest.byteLength, value = 0) {
  6601. for (let i = 0; i < count; i++) {
  6602. dest[index + i] = value;
  6603. }
  6604. }
  6605. function leftPad(value, length, char = '0') {
  6606. while (value.length < length) {
  6607. value = char + value;
  6608. }
  6609. return value;
  6610. }
  6611. function toHexString(bufferOrValue, bitsize = 32) {
  6612. if (bufferOrValue instanceof ArrayBuffer) {
  6613. return Array.from(new Uint8Array(bufferOrValue)).map(b => b.toString(16).padStart(2, '0')).join('');
  6614. }
  6615. return leftPad((bufferOrValue >>> 0).toString(16), bitsize / 4);
  6616. }
  6617. exports.toHexString = toHexString;
  6618. /**
  6619. * A SHA1 implementation that works with strings and does not allocate.
  6620. */
  6621. class StringSHA1 {
  6622. constructor() {
  6623. this._h0 = 0x67452301;
  6624. this._h1 = 0xEFCDAB89;
  6625. this._h2 = 0x98BADCFE;
  6626. this._h3 = 0x10325476;
  6627. this._h4 = 0xC3D2E1F0;
  6628. this._buff = new Uint8Array(64 /* BLOCK_SIZE */ + 3 /* to fit any utf-8 */);
  6629. this._buffDV = new DataView(this._buff.buffer);
  6630. this._buffLen = 0;
  6631. this._totalLen = 0;
  6632. this._leftoverHighSurrogate = 0;
  6633. this._finished = false;
  6634. }
  6635. update(str) {
  6636. const strLen = str.length;
  6637. if (strLen === 0) {
  6638. return;
  6639. }
  6640. const buff = this._buff;
  6641. let buffLen = this._buffLen;
  6642. let leftoverHighSurrogate = this._leftoverHighSurrogate;
  6643. let charCode;
  6644. let offset;
  6645. if (leftoverHighSurrogate !== 0) {
  6646. charCode = leftoverHighSurrogate;
  6647. offset = -1;
  6648. leftoverHighSurrogate = 0;
  6649. }
  6650. else {
  6651. charCode = str.charCodeAt(0);
  6652. offset = 0;
  6653. }
  6654. while (true) {
  6655. let codePoint = charCode;
  6656. if (strings.isHighSurrogate(charCode)) {
  6657. if (offset + 1 < strLen) {
  6658. const nextCharCode = str.charCodeAt(offset + 1);
  6659. if (strings.isLowSurrogate(nextCharCode)) {
  6660. offset++;
  6661. codePoint = strings.computeCodePoint(charCode, nextCharCode);
  6662. }
  6663. else {
  6664. // illegal => unicode replacement character
  6665. codePoint = 65533 /* UNICODE_REPLACEMENT */;
  6666. }
  6667. }
  6668. else {
  6669. // last character is a surrogate pair
  6670. leftoverHighSurrogate = charCode;
  6671. break;
  6672. }
  6673. }
  6674. else if (strings.isLowSurrogate(charCode)) {
  6675. // illegal => unicode replacement character
  6676. codePoint = 65533 /* UNICODE_REPLACEMENT */;
  6677. }
  6678. buffLen = this._push(buff, buffLen, codePoint);
  6679. offset++;
  6680. if (offset < strLen) {
  6681. charCode = str.charCodeAt(offset);
  6682. }
  6683. else {
  6684. break;
  6685. }
  6686. }
  6687. this._buffLen = buffLen;
  6688. this._leftoverHighSurrogate = leftoverHighSurrogate;
  6689. }
  6690. _push(buff, buffLen, codePoint) {
  6691. if (codePoint < 0x0080) {
  6692. buff[buffLen++] = codePoint;
  6693. }
  6694. else if (codePoint < 0x0800) {
  6695. buff[buffLen++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);
  6696. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
  6697. }
  6698. else if (codePoint < 0x10000) {
  6699. buff[buffLen++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);
  6700. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);
  6701. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
  6702. }
  6703. else {
  6704. buff[buffLen++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);
  6705. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);
  6706. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);
  6707. buff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
  6708. }
  6709. if (buffLen >= 64 /* BLOCK_SIZE */) {
  6710. this._step();
  6711. buffLen -= 64 /* BLOCK_SIZE */;
  6712. this._totalLen += 64 /* BLOCK_SIZE */;
  6713. // take last 3 in case of UTF8 overflow
  6714. buff[0] = buff[64 /* BLOCK_SIZE */ + 0];
  6715. buff[1] = buff[64 /* BLOCK_SIZE */ + 1];
  6716. buff[2] = buff[64 /* BLOCK_SIZE */ + 2];
  6717. }
  6718. return buffLen;
  6719. }
  6720. digest() {
  6721. if (!this._finished) {
  6722. this._finished = true;
  6723. if (this._leftoverHighSurrogate) {
  6724. // illegal => unicode replacement character
  6725. this._leftoverHighSurrogate = 0;
  6726. this._buffLen = this._push(this._buff, this._buffLen, 65533 /* UNICODE_REPLACEMENT */);
  6727. }
  6728. this._totalLen += this._buffLen;
  6729. this._wrapUp();
  6730. }
  6731. return toHexString(this._h0) + toHexString(this._h1) + toHexString(this._h2) + toHexString(this._h3) + toHexString(this._h4);
  6732. }
  6733. _wrapUp() {
  6734. this._buff[this._buffLen++] = 0x80;
  6735. fill(this._buff, this._buffLen);
  6736. if (this._buffLen > 56) {
  6737. this._step();
  6738. fill(this._buff);
  6739. }
  6740. // this will fit because the mantissa can cover up to 52 bits
  6741. const ml = 8 * this._totalLen;
  6742. this._buffDV.setUint32(56, Math.floor(ml / 4294967296), false);
  6743. this._buffDV.setUint32(60, ml % 4294967296, false);
  6744. this._step();
  6745. }
  6746. _step() {
  6747. const bigBlock32 = StringSHA1._bigBlock32;
  6748. const data = this._buffDV;
  6749. for (let j = 0; j < 64 /* 16*4 */; j += 4) {
  6750. bigBlock32.setUint32(j, data.getUint32(j, false), false);
  6751. }
  6752. for (let j = 64; j < 320 /* 80*4 */; j += 4) {
  6753. bigBlock32.setUint32(j, leftRotate((bigBlock32.getUint32(j - 12, false) ^ bigBlock32.getUint32(j - 32, false) ^ bigBlock32.getUint32(j - 56, false) ^ bigBlock32.getUint32(j - 64, false)), 1), false);
  6754. }
  6755. let a = this._h0;
  6756. let b = this._h1;
  6757. let c = this._h2;
  6758. let d = this._h3;
  6759. let e = this._h4;
  6760. let f, k;
  6761. let temp;
  6762. for (let j = 0; j < 80; j++) {
  6763. if (j < 20) {
  6764. f = (b & c) | ((~b) & d);
  6765. k = 0x5A827999;
  6766. }
  6767. else if (j < 40) {
  6768. f = b ^ c ^ d;
  6769. k = 0x6ED9EBA1;
  6770. }
  6771. else if (j < 60) {
  6772. f = (b & c) | (b & d) | (c & d);
  6773. k = 0x8F1BBCDC;
  6774. }
  6775. else {
  6776. f = b ^ c ^ d;
  6777. k = 0xCA62C1D6;
  6778. }
  6779. temp = (leftRotate(a, 5) + f + e + k + bigBlock32.getUint32(j * 4, false)) & 0xffffffff;
  6780. e = d;
  6781. d = c;
  6782. c = leftRotate(b, 30);
  6783. b = a;
  6784. a = temp;
  6785. }
  6786. this._h0 = (this._h0 + a) & 0xffffffff;
  6787. this._h1 = (this._h1 + b) & 0xffffffff;
  6788. this._h2 = (this._h2 + c) & 0xffffffff;
  6789. this._h3 = (this._h3 + d) & 0xffffffff;
  6790. this._h4 = (this._h4 + e) & 0xffffffff;
  6791. }
  6792. }
  6793. exports.StringSHA1 = StringSHA1;
  6794. StringSHA1._bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320
  6795. });
  6796. /*---------------------------------------------------------------------------------------------
  6797. * Copyright (c) Microsoft Corporation. All rights reserved.
  6798. * Licensed under the MIT License. See License.txt in the project root for license information.
  6799. *--------------------------------------------------------------------------------------------*/
  6800. define(__m[11/*vs/base/common/diff/diff*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/diff/diffChange*/,24/*vs/base/common/hash*/]), function (require, exports, diffChange_1, hash_1) {
  6801. "use strict";
  6802. Object.defineProperty(exports, "__esModule", { value: true });
  6803. exports.LcsDiff = exports.MyArray = exports.Debug = exports.stringDiff = exports.StringDiffSequence = void 0;
  6804. class StringDiffSequence {
  6805. constructor(source) {
  6806. this.source = source;
  6807. }
  6808. getElements() {
  6809. const source = this.source;
  6810. const characters = new Int32Array(source.length);
  6811. for (let i = 0, len = source.length; i < len; i++) {
  6812. characters[i] = source.charCodeAt(i);
  6813. }
  6814. return characters;
  6815. }
  6816. }
  6817. exports.StringDiffSequence = StringDiffSequence;
  6818. function stringDiff(original, modified, pretty) {
  6819. return new LcsDiff(new StringDiffSequence(original), new StringDiffSequence(modified)).ComputeDiff(pretty).changes;
  6820. }
  6821. exports.stringDiff = stringDiff;
  6822. //
  6823. // The code below has been ported from a C# implementation in VS
  6824. //
  6825. class Debug {
  6826. static Assert(condition, message) {
  6827. if (!condition) {
  6828. throw new Error(message);
  6829. }
  6830. }
  6831. }
  6832. exports.Debug = Debug;
  6833. class MyArray {
  6834. /**
  6835. * Copies a range of elements from an Array starting at the specified source index and pastes
  6836. * them to another Array starting at the specified destination index. The length and the indexes
  6837. * are specified as 64-bit integers.
  6838. * sourceArray:
  6839. * The Array that contains the data to copy.
  6840. * sourceIndex:
  6841. * A 64-bit integer that represents the index in the sourceArray at which copying begins.
  6842. * destinationArray:
  6843. * The Array that receives the data.
  6844. * destinationIndex:
  6845. * A 64-bit integer that represents the index in the destinationArray at which storing begins.
  6846. * length:
  6847. * A 64-bit integer that represents the number of elements to copy.
  6848. */
  6849. static Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  6850. for (let i = 0; i < length; i++) {
  6851. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  6852. }
  6853. }
  6854. static Copy2(sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  6855. for (let i = 0; i < length; i++) {
  6856. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  6857. }
  6858. }
  6859. }
  6860. exports.MyArray = MyArray;
  6861. /**
  6862. * A utility class which helps to create the set of DiffChanges from
  6863. * a difference operation. This class accepts original DiffElements and
  6864. * modified DiffElements that are involved in a particular change. The
  6865. * MarkNextChange() method can be called to mark the separation between
  6866. * distinct changes. At the end, the Changes property can be called to retrieve
  6867. * the constructed changes.
  6868. */
  6869. class DiffChangeHelper {
  6870. /**
  6871. * Constructs a new DiffChangeHelper for the given DiffSequences.
  6872. */
  6873. constructor() {
  6874. this.m_changes = [];
  6875. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  6876. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  6877. this.m_originalCount = 0;
  6878. this.m_modifiedCount = 0;
  6879. }
  6880. /**
  6881. * Marks the beginning of the next change in the set of differences.
  6882. */
  6883. MarkNextChange() {
  6884. // Only add to the list if there is something to add
  6885. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  6886. // Add the new change to our list
  6887. this.m_changes.push(new diffChange_1.DiffChange(this.m_originalStart, this.m_originalCount, this.m_modifiedStart, this.m_modifiedCount));
  6888. }
  6889. // Reset for the next change
  6890. this.m_originalCount = 0;
  6891. this.m_modifiedCount = 0;
  6892. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  6893. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  6894. }
  6895. /**
  6896. * Adds the original element at the given position to the elements
  6897. * affected by the current change. The modified index gives context
  6898. * to the change position with respect to the original sequence.
  6899. * @param originalIndex The index of the original element to add.
  6900. * @param modifiedIndex The index of the modified element that provides corresponding position in the modified sequence.
  6901. */
  6902. AddOriginalElement(originalIndex, modifiedIndex) {
  6903. // The 'true' start index is the smallest of the ones we've seen
  6904. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  6905. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  6906. this.m_originalCount++;
  6907. }
  6908. /**
  6909. * Adds the modified element at the given position to the elements
  6910. * affected by the current change. The original index gives context
  6911. * to the change position with respect to the modified sequence.
  6912. * @param originalIndex The index of the original element that provides corresponding position in the original sequence.
  6913. * @param modifiedIndex The index of the modified element to add.
  6914. */
  6915. AddModifiedElement(originalIndex, modifiedIndex) {
  6916. // The 'true' start index is the smallest of the ones we've seen
  6917. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  6918. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  6919. this.m_modifiedCount++;
  6920. }
  6921. /**
  6922. * Retrieves all of the changes marked by the class.
  6923. */
  6924. getChanges() {
  6925. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  6926. // Finish up on whatever is left
  6927. this.MarkNextChange();
  6928. }
  6929. return this.m_changes;
  6930. }
  6931. /**
  6932. * Retrieves all of the changes marked by the class in the reverse order
  6933. */
  6934. getReverseChanges() {
  6935. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  6936. // Finish up on whatever is left
  6937. this.MarkNextChange();
  6938. }
  6939. this.m_changes.reverse();
  6940. return this.m_changes;
  6941. }
  6942. }
  6943. /**
  6944. * An implementation of the difference algorithm described in
  6945. * "An O(ND) Difference Algorithm and its variations" by Eugene W. Myers
  6946. */
  6947. class LcsDiff {
  6948. /**
  6949. * Constructs the DiffFinder
  6950. */
  6951. constructor(originalSequence, modifiedSequence, continueProcessingPredicate = null) {
  6952. this.ContinueProcessingPredicate = continueProcessingPredicate;
  6953. this._originalSequence = originalSequence;
  6954. this._modifiedSequence = modifiedSequence;
  6955. const [originalStringElements, originalElementsOrHash, originalHasStrings] = LcsDiff._getElements(originalSequence);
  6956. const [modifiedStringElements, modifiedElementsOrHash, modifiedHasStrings] = LcsDiff._getElements(modifiedSequence);
  6957. this._hasStrings = (originalHasStrings && modifiedHasStrings);
  6958. this._originalStringElements = originalStringElements;
  6959. this._originalElementsOrHash = originalElementsOrHash;
  6960. this._modifiedStringElements = modifiedStringElements;
  6961. this._modifiedElementsOrHash = modifiedElementsOrHash;
  6962. this.m_forwardHistory = [];
  6963. this.m_reverseHistory = [];
  6964. }
  6965. static _isStringArray(arr) {
  6966. return (arr.length > 0 && typeof arr[0] === 'string');
  6967. }
  6968. static _getElements(sequence) {
  6969. const elements = sequence.getElements();
  6970. if (LcsDiff._isStringArray(elements)) {
  6971. const hashes = new Int32Array(elements.length);
  6972. for (let i = 0, len = elements.length; i < len; i++) {
  6973. hashes[i] = (0, hash_1.stringHash)(elements[i], 0);
  6974. }
  6975. return [elements, hashes, true];
  6976. }
  6977. if (elements instanceof Int32Array) {
  6978. return [[], elements, false];
  6979. }
  6980. return [[], new Int32Array(elements), false];
  6981. }
  6982. ElementsAreEqual(originalIndex, newIndex) {
  6983. if (this._originalElementsOrHash[originalIndex] !== this._modifiedElementsOrHash[newIndex]) {
  6984. return false;
  6985. }
  6986. return (this._hasStrings ? this._originalStringElements[originalIndex] === this._modifiedStringElements[newIndex] : true);
  6987. }
  6988. ElementsAreStrictEqual(originalIndex, newIndex) {
  6989. if (!this.ElementsAreEqual(originalIndex, newIndex)) {
  6990. return false;
  6991. }
  6992. const originalElement = LcsDiff._getStrictElement(this._originalSequence, originalIndex);
  6993. const modifiedElement = LcsDiff._getStrictElement(this._modifiedSequence, newIndex);
  6994. return (originalElement === modifiedElement);
  6995. }
  6996. static _getStrictElement(sequence, index) {
  6997. if (typeof sequence.getStrictElement === 'function') {
  6998. return sequence.getStrictElement(index);
  6999. }
  7000. return null;
  7001. }
  7002. OriginalElementsAreEqual(index1, index2) {
  7003. if (this._originalElementsOrHash[index1] !== this._originalElementsOrHash[index2]) {
  7004. return false;
  7005. }
  7006. return (this._hasStrings ? this._originalStringElements[index1] === this._originalStringElements[index2] : true);
  7007. }
  7008. ModifiedElementsAreEqual(index1, index2) {
  7009. if (this._modifiedElementsOrHash[index1] !== this._modifiedElementsOrHash[index2]) {
  7010. return false;
  7011. }
  7012. return (this._hasStrings ? this._modifiedStringElements[index1] === this._modifiedStringElements[index2] : true);
  7013. }
  7014. ComputeDiff(pretty) {
  7015. return this._ComputeDiff(0, this._originalElementsOrHash.length - 1, 0, this._modifiedElementsOrHash.length - 1, pretty);
  7016. }
  7017. /**
  7018. * Computes the differences between the original and modified input
  7019. * sequences on the bounded range.
  7020. * @returns An array of the differences between the two input sequences.
  7021. */
  7022. _ComputeDiff(originalStart, originalEnd, modifiedStart, modifiedEnd, pretty) {
  7023. const quitEarlyArr = [false];
  7024. let changes = this.ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr);
  7025. if (pretty) {
  7026. // We have to clean up the computed diff to be more intuitive
  7027. // but it turns out this cannot be done correctly until the entire set
  7028. // of diffs have been computed
  7029. changes = this.PrettifyChanges(changes);
  7030. }
  7031. return {
  7032. quitEarly: quitEarlyArr[0],
  7033. changes: changes
  7034. };
  7035. }
  7036. /**
  7037. * Private helper method which computes the differences on the bounded range
  7038. * recursively.
  7039. * @returns An array of the differences between the two input sequences.
  7040. */
  7041. ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr) {
  7042. quitEarlyArr[0] = false;
  7043. // Find the start of the differences
  7044. while (originalStart <= originalEnd && modifiedStart <= modifiedEnd && this.ElementsAreEqual(originalStart, modifiedStart)) {
  7045. originalStart++;
  7046. modifiedStart++;
  7047. }
  7048. // Find the end of the differences
  7049. while (originalEnd >= originalStart && modifiedEnd >= modifiedStart && this.ElementsAreEqual(originalEnd, modifiedEnd)) {
  7050. originalEnd--;
  7051. modifiedEnd--;
  7052. }
  7053. // In the special case where we either have all insertions or all deletions or the sequences are identical
  7054. if (originalStart > originalEnd || modifiedStart > modifiedEnd) {
  7055. let changes;
  7056. if (modifiedStart <= modifiedEnd) {
  7057. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  7058. // All insertions
  7059. changes = [
  7060. new diffChange_1.DiffChange(originalStart, 0, modifiedStart, modifiedEnd - modifiedStart + 1)
  7061. ];
  7062. }
  7063. else if (originalStart <= originalEnd) {
  7064. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  7065. // All deletions
  7066. changes = [
  7067. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, 0)
  7068. ];
  7069. }
  7070. else {
  7071. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  7072. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  7073. // Identical sequences - No differences
  7074. changes = [];
  7075. }
  7076. return changes;
  7077. }
  7078. // This problem can be solved using the Divide-And-Conquer technique.
  7079. const midOriginalArr = [0];
  7080. const midModifiedArr = [0];
  7081. const result = this.ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr);
  7082. const midOriginal = midOriginalArr[0];
  7083. const midModified = midModifiedArr[0];
  7084. if (result !== null) {
  7085. // Result is not-null when there was enough memory to compute the changes while
  7086. // searching for the recursion point
  7087. return result;
  7088. }
  7089. else if (!quitEarlyArr[0]) {
  7090. // We can break the problem down recursively by finding the changes in the
  7091. // First Half: (originalStart, modifiedStart) to (midOriginal, midModified)
  7092. // Second Half: (midOriginal + 1, minModified + 1) to (originalEnd, modifiedEnd)
  7093. // NOTE: ComputeDiff() is inclusive, therefore the second range starts on the next point
  7094. const leftChanges = this.ComputeDiffRecursive(originalStart, midOriginal, modifiedStart, midModified, quitEarlyArr);
  7095. let rightChanges = [];
  7096. if (!quitEarlyArr[0]) {
  7097. rightChanges = this.ComputeDiffRecursive(midOriginal + 1, originalEnd, midModified + 1, modifiedEnd, quitEarlyArr);
  7098. }
  7099. else {
  7100. // We didn't have time to finish the first half, so we don't have time to compute this half.
  7101. // Consider the entire rest of the sequence different.
  7102. rightChanges = [
  7103. new diffChange_1.DiffChange(midOriginal + 1, originalEnd - (midOriginal + 1) + 1, midModified + 1, modifiedEnd - (midModified + 1) + 1)
  7104. ];
  7105. }
  7106. return this.ConcatenateChanges(leftChanges, rightChanges);
  7107. }
  7108. // If we hit here, we quit early, and so can't return anything meaningful
  7109. return [
  7110. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  7111. ];
  7112. }
  7113. WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr) {
  7114. let forwardChanges = null;
  7115. let reverseChanges = null;
  7116. // First, walk backward through the forward diagonals history
  7117. let changeHelper = new DiffChangeHelper();
  7118. let diagonalMin = diagonalForwardStart;
  7119. let diagonalMax = diagonalForwardEnd;
  7120. let diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalForwardOffset;
  7121. let lastOriginalIndex = -1073741824 /* MIN_SAFE_SMALL_INTEGER */;
  7122. let historyIndex = this.m_forwardHistory.length - 1;
  7123. do {
  7124. // Get the diagonal index from the relative diagonal number
  7125. const diagonal = diagonalRelative + diagonalForwardBase;
  7126. // Figure out where we came from
  7127. if (diagonal === diagonalMin || (diagonal < diagonalMax && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  7128. // Vertical line (the element is an insert)
  7129. originalIndex = forwardPoints[diagonal + 1];
  7130. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  7131. if (originalIndex < lastOriginalIndex) {
  7132. changeHelper.MarkNextChange();
  7133. }
  7134. lastOriginalIndex = originalIndex;
  7135. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex);
  7136. diagonalRelative = (diagonal + 1) - diagonalForwardBase; //Setup for the next iteration
  7137. }
  7138. else {
  7139. // Horizontal line (the element is a deletion)
  7140. originalIndex = forwardPoints[diagonal - 1] + 1;
  7141. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  7142. if (originalIndex < lastOriginalIndex) {
  7143. changeHelper.MarkNextChange();
  7144. }
  7145. lastOriginalIndex = originalIndex - 1;
  7146. changeHelper.AddOriginalElement(originalIndex, modifiedIndex + 1);
  7147. diagonalRelative = (diagonal - 1) - diagonalForwardBase; //Setup for the next iteration
  7148. }
  7149. if (historyIndex >= 0) {
  7150. forwardPoints = this.m_forwardHistory[historyIndex];
  7151. diagonalForwardBase = forwardPoints[0]; //We stored this in the first spot
  7152. diagonalMin = 1;
  7153. diagonalMax = forwardPoints.length - 1;
  7154. }
  7155. } while (--historyIndex >= -1);
  7156. // Ironically, we get the forward changes as the reverse of the
  7157. // order we added them since we technically added them backwards
  7158. forwardChanges = changeHelper.getReverseChanges();
  7159. if (quitEarlyArr[0]) {
  7160. // TODO: Calculate a partial from the reverse diagonals.
  7161. // For now, just assume everything after the midOriginal/midModified point is a diff
  7162. let originalStartPoint = midOriginalArr[0] + 1;
  7163. let modifiedStartPoint = midModifiedArr[0] + 1;
  7164. if (forwardChanges !== null && forwardChanges.length > 0) {
  7165. const lastForwardChange = forwardChanges[forwardChanges.length - 1];
  7166. originalStartPoint = Math.max(originalStartPoint, lastForwardChange.getOriginalEnd());
  7167. modifiedStartPoint = Math.max(modifiedStartPoint, lastForwardChange.getModifiedEnd());
  7168. }
  7169. reverseChanges = [
  7170. new diffChange_1.DiffChange(originalStartPoint, originalEnd - originalStartPoint + 1, modifiedStartPoint, modifiedEnd - modifiedStartPoint + 1)
  7171. ];
  7172. }
  7173. else {
  7174. // Now walk backward through the reverse diagonals history
  7175. changeHelper = new DiffChangeHelper();
  7176. diagonalMin = diagonalReverseStart;
  7177. diagonalMax = diagonalReverseEnd;
  7178. diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalReverseOffset;
  7179. lastOriginalIndex = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  7180. historyIndex = (deltaIsEven) ? this.m_reverseHistory.length - 1 : this.m_reverseHistory.length - 2;
  7181. do {
  7182. // Get the diagonal index from the relative diagonal number
  7183. const diagonal = diagonalRelative + diagonalReverseBase;
  7184. // Figure out where we came from
  7185. if (diagonal === diagonalMin || (diagonal < diagonalMax && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  7186. // Horizontal line (the element is a deletion))
  7187. originalIndex = reversePoints[diagonal + 1] - 1;
  7188. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  7189. if (originalIndex > lastOriginalIndex) {
  7190. changeHelper.MarkNextChange();
  7191. }
  7192. lastOriginalIndex = originalIndex + 1;
  7193. changeHelper.AddOriginalElement(originalIndex + 1, modifiedIndex + 1);
  7194. diagonalRelative = (diagonal + 1) - diagonalReverseBase; //Setup for the next iteration
  7195. }
  7196. else {
  7197. // Vertical line (the element is an insertion)
  7198. originalIndex = reversePoints[diagonal - 1];
  7199. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  7200. if (originalIndex > lastOriginalIndex) {
  7201. changeHelper.MarkNextChange();
  7202. }
  7203. lastOriginalIndex = originalIndex;
  7204. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex + 1);
  7205. diagonalRelative = (diagonal - 1) - diagonalReverseBase; //Setup for the next iteration
  7206. }
  7207. if (historyIndex >= 0) {
  7208. reversePoints = this.m_reverseHistory[historyIndex];
  7209. diagonalReverseBase = reversePoints[0]; //We stored this in the first spot
  7210. diagonalMin = 1;
  7211. diagonalMax = reversePoints.length - 1;
  7212. }
  7213. } while (--historyIndex >= -1);
  7214. // There are cases where the reverse history will find diffs that
  7215. // are correct, but not intuitive, so we need shift them.
  7216. reverseChanges = changeHelper.getChanges();
  7217. }
  7218. return this.ConcatenateChanges(forwardChanges, reverseChanges);
  7219. }
  7220. /**
  7221. * Given the range to compute the diff on, this method finds the point:
  7222. * (midOriginal, midModified)
  7223. * that exists in the middle of the LCS of the two sequences and
  7224. * is the point at which the LCS problem may be broken down recursively.
  7225. * This method will try to keep the LCS trace in memory. If the LCS recursion
  7226. * point is calculated and the full trace is available in memory, then this method
  7227. * will return the change list.
  7228. * @param originalStart The start bound of the original sequence range
  7229. * @param originalEnd The end bound of the original sequence range
  7230. * @param modifiedStart The start bound of the modified sequence range
  7231. * @param modifiedEnd The end bound of the modified sequence range
  7232. * @param midOriginal The middle point of the original sequence range
  7233. * @param midModified The middle point of the modified sequence range
  7234. * @returns The diff changes, if available, otherwise null
  7235. */
  7236. ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr) {
  7237. let originalIndex = 0, modifiedIndex = 0;
  7238. let diagonalForwardStart = 0, diagonalForwardEnd = 0;
  7239. let diagonalReverseStart = 0, diagonalReverseEnd = 0;
  7240. // To traverse the edit graph and produce the proper LCS, our actual
  7241. // start position is just outside the given boundary
  7242. originalStart--;
  7243. modifiedStart--;
  7244. // We set these up to make the compiler happy, but they will
  7245. // be replaced before we return with the actual recursion point
  7246. midOriginalArr[0] = 0;
  7247. midModifiedArr[0] = 0;
  7248. // Clear out the history
  7249. this.m_forwardHistory = [];
  7250. this.m_reverseHistory = [];
  7251. // Each cell in the two arrays corresponds to a diagonal in the edit graph.
  7252. // The integer value in the cell represents the originalIndex of the furthest
  7253. // reaching point found so far that ends in that diagonal.
  7254. // The modifiedIndex can be computed mathematically from the originalIndex and the diagonal number.
  7255. const maxDifferences = (originalEnd - originalStart) + (modifiedEnd - modifiedStart);
  7256. const numDiagonals = maxDifferences + 1;
  7257. const forwardPoints = new Int32Array(numDiagonals);
  7258. const reversePoints = new Int32Array(numDiagonals);
  7259. // diagonalForwardBase: Index into forwardPoints of the diagonal which passes through (originalStart, modifiedStart)
  7260. // diagonalReverseBase: Index into reversePoints of the diagonal which passes through (originalEnd, modifiedEnd)
  7261. const diagonalForwardBase = (modifiedEnd - modifiedStart);
  7262. const diagonalReverseBase = (originalEnd - originalStart);
  7263. // diagonalForwardOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  7264. // diagonal number (relative to diagonalForwardBase)
  7265. // diagonalReverseOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  7266. // diagonal number (relative to diagonalReverseBase)
  7267. const diagonalForwardOffset = (originalStart - modifiedStart);
  7268. const diagonalReverseOffset = (originalEnd - modifiedEnd);
  7269. // delta: The difference between the end diagonal and the start diagonal. This is used to relate diagonal numbers
  7270. // relative to the start diagonal with diagonal numbers relative to the end diagonal.
  7271. // The Even/Oddn-ness of this delta is important for determining when we should check for overlap
  7272. const delta = diagonalReverseBase - diagonalForwardBase;
  7273. const deltaIsEven = (delta % 2 === 0);
  7274. // Here we set up the start and end points as the furthest points found so far
  7275. // in both the forward and reverse directions, respectively
  7276. forwardPoints[diagonalForwardBase] = originalStart;
  7277. reversePoints[diagonalReverseBase] = originalEnd;
  7278. // Remember if we quit early, and thus need to do a best-effort result instead of a real result.
  7279. quitEarlyArr[0] = false;
  7280. // A couple of points:
  7281. // --With this method, we iterate on the number of differences between the two sequences.
  7282. // The more differences there actually are, the longer this will take.
  7283. // --Also, as the number of differences increases, we have to search on diagonals further
  7284. // away from the reference diagonal (which is diagonalForwardBase for forward, diagonalReverseBase for reverse).
  7285. // --We extend on even diagonals (relative to the reference diagonal) only when numDifferences
  7286. // is even and odd diagonals only when numDifferences is odd.
  7287. for (let numDifferences = 1; numDifferences <= (maxDifferences / 2) + 1; numDifferences++) {
  7288. let furthestOriginalIndex = 0;
  7289. let furthestModifiedIndex = 0;
  7290. // Run the algorithm in the forward direction
  7291. diagonalForwardStart = this.ClipDiagonalBound(diagonalForwardBase - numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  7292. diagonalForwardEnd = this.ClipDiagonalBound(diagonalForwardBase + numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  7293. for (let diagonal = diagonalForwardStart; diagonal <= diagonalForwardEnd; diagonal += 2) {
  7294. // STEP 1: We extend the furthest reaching point in the present diagonal
  7295. // by looking at the diagonals above and below and picking the one whose point
  7296. // is further away from the start point (originalStart, modifiedStart)
  7297. if (diagonal === diagonalForwardStart || (diagonal < diagonalForwardEnd && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  7298. originalIndex = forwardPoints[diagonal + 1];
  7299. }
  7300. else {
  7301. originalIndex = forwardPoints[diagonal - 1] + 1;
  7302. }
  7303. modifiedIndex = originalIndex - (diagonal - diagonalForwardBase) - diagonalForwardOffset;
  7304. // Save the current originalIndex so we can test for false overlap in step 3
  7305. const tempOriginalIndex = originalIndex;
  7306. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  7307. // so long as the elements are equal.
  7308. while (originalIndex < originalEnd && modifiedIndex < modifiedEnd && this.ElementsAreEqual(originalIndex + 1, modifiedIndex + 1)) {
  7309. originalIndex++;
  7310. modifiedIndex++;
  7311. }
  7312. forwardPoints[diagonal] = originalIndex;
  7313. if (originalIndex + modifiedIndex > furthestOriginalIndex + furthestModifiedIndex) {
  7314. furthestOriginalIndex = originalIndex;
  7315. furthestModifiedIndex = modifiedIndex;
  7316. }
  7317. // STEP 3: If delta is odd (overlap first happens on forward when delta is odd)
  7318. // and diagonal is in the range of reverse diagonals computed for numDifferences-1
  7319. // (the previous iteration; we haven't computed reverse diagonals for numDifferences yet)
  7320. // then check for overlap.
  7321. if (!deltaIsEven && Math.abs(diagonal - diagonalReverseBase) <= (numDifferences - 1)) {
  7322. if (originalIndex >= reversePoints[diagonal]) {
  7323. midOriginalArr[0] = originalIndex;
  7324. midModifiedArr[0] = modifiedIndex;
  7325. if (tempOriginalIndex <= reversePoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  7326. // BINGO! We overlapped, and we have the full trace in memory!
  7327. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  7328. }
  7329. else {
  7330. // Either false overlap, or we didn't have enough memory for the full trace
  7331. // Just return the recursion point
  7332. return null;
  7333. }
  7334. }
  7335. }
  7336. }
  7337. // Check to see if we should be quitting early, before moving on to the next iteration.
  7338. const matchLengthOfLongest = ((furthestOriginalIndex - originalStart) + (furthestModifiedIndex - modifiedStart) - numDifferences) / 2;
  7339. if (this.ContinueProcessingPredicate !== null && !this.ContinueProcessingPredicate(furthestOriginalIndex, matchLengthOfLongest)) {
  7340. // We can't finish, so skip ahead to generating a result from what we have.
  7341. quitEarlyArr[0] = true;
  7342. // Use the furthest distance we got in the forward direction.
  7343. midOriginalArr[0] = furthestOriginalIndex;
  7344. midModifiedArr[0] = furthestModifiedIndex;
  7345. if (matchLengthOfLongest > 0 && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  7346. // Enough of the history is in memory to walk it backwards
  7347. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  7348. }
  7349. else {
  7350. // We didn't actually remember enough of the history.
  7351. //Since we are quitting the diff early, we need to shift back the originalStart and modified start
  7352. //back into the boundary limits since we decremented their value above beyond the boundary limit.
  7353. originalStart++;
  7354. modifiedStart++;
  7355. return [
  7356. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  7357. ];
  7358. }
  7359. }
  7360. // Run the algorithm in the reverse direction
  7361. diagonalReverseStart = this.ClipDiagonalBound(diagonalReverseBase - numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  7362. diagonalReverseEnd = this.ClipDiagonalBound(diagonalReverseBase + numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  7363. for (let diagonal = diagonalReverseStart; diagonal <= diagonalReverseEnd; diagonal += 2) {
  7364. // STEP 1: We extend the furthest reaching point in the present diagonal
  7365. // by looking at the diagonals above and below and picking the one whose point
  7366. // is further away from the start point (originalEnd, modifiedEnd)
  7367. if (diagonal === diagonalReverseStart || (diagonal < diagonalReverseEnd && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  7368. originalIndex = reversePoints[diagonal + 1] - 1;
  7369. }
  7370. else {
  7371. originalIndex = reversePoints[diagonal - 1];
  7372. }
  7373. modifiedIndex = originalIndex - (diagonal - diagonalReverseBase) - diagonalReverseOffset;
  7374. // Save the current originalIndex so we can test for false overlap
  7375. const tempOriginalIndex = originalIndex;
  7376. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  7377. // as long as the elements are equal.
  7378. while (originalIndex > originalStart && modifiedIndex > modifiedStart && this.ElementsAreEqual(originalIndex, modifiedIndex)) {
  7379. originalIndex--;
  7380. modifiedIndex--;
  7381. }
  7382. reversePoints[diagonal] = originalIndex;
  7383. // STEP 4: If delta is even (overlap first happens on reverse when delta is even)
  7384. // and diagonal is in the range of forward diagonals computed for numDifferences
  7385. // then check for overlap.
  7386. if (deltaIsEven && Math.abs(diagonal - diagonalForwardBase) <= numDifferences) {
  7387. if (originalIndex <= forwardPoints[diagonal]) {
  7388. midOriginalArr[0] = originalIndex;
  7389. midModifiedArr[0] = modifiedIndex;
  7390. if (tempOriginalIndex >= forwardPoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  7391. // BINGO! We overlapped, and we have the full trace in memory!
  7392. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  7393. }
  7394. else {
  7395. // Either false overlap, or we didn't have enough memory for the full trace
  7396. // Just return the recursion point
  7397. return null;
  7398. }
  7399. }
  7400. }
  7401. }
  7402. // Save current vectors to history before the next iteration
  7403. if (numDifferences <= 1447 /* MaxDifferencesHistory */) {
  7404. // We are allocating space for one extra int, which we fill with
  7405. // the index of the diagonal base index
  7406. let temp = new Int32Array(diagonalForwardEnd - diagonalForwardStart + 2);
  7407. temp[0] = diagonalForwardBase - diagonalForwardStart + 1;
  7408. MyArray.Copy2(forwardPoints, diagonalForwardStart, temp, 1, diagonalForwardEnd - diagonalForwardStart + 1);
  7409. this.m_forwardHistory.push(temp);
  7410. temp = new Int32Array(diagonalReverseEnd - diagonalReverseStart + 2);
  7411. temp[0] = diagonalReverseBase - diagonalReverseStart + 1;
  7412. MyArray.Copy2(reversePoints, diagonalReverseStart, temp, 1, diagonalReverseEnd - diagonalReverseStart + 1);
  7413. this.m_reverseHistory.push(temp);
  7414. }
  7415. }
  7416. // If we got here, then we have the full trace in history. We just have to convert it to a change list
  7417. // NOTE: This part is a bit messy
  7418. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  7419. }
  7420. /**
  7421. * Shifts the given changes to provide a more intuitive diff.
  7422. * While the first element in a diff matches the first element after the diff,
  7423. * we shift the diff down.
  7424. *
  7425. * @param changes The list of changes to shift
  7426. * @returns The shifted changes
  7427. */
  7428. PrettifyChanges(changes) {
  7429. // Shift all the changes down first
  7430. for (let i = 0; i < changes.length; i++) {
  7431. const change = changes[i];
  7432. const originalStop = (i < changes.length - 1) ? changes[i + 1].originalStart : this._originalElementsOrHash.length;
  7433. const modifiedStop = (i < changes.length - 1) ? changes[i + 1].modifiedStart : this._modifiedElementsOrHash.length;
  7434. const checkOriginal = change.originalLength > 0;
  7435. const checkModified = change.modifiedLength > 0;
  7436. while (change.originalStart + change.originalLength < originalStop
  7437. && change.modifiedStart + change.modifiedLength < modifiedStop
  7438. && (!checkOriginal || this.OriginalElementsAreEqual(change.originalStart, change.originalStart + change.originalLength))
  7439. && (!checkModified || this.ModifiedElementsAreEqual(change.modifiedStart, change.modifiedStart + change.modifiedLength))) {
  7440. const startStrictEqual = this.ElementsAreStrictEqual(change.originalStart, change.modifiedStart);
  7441. const endStrictEqual = this.ElementsAreStrictEqual(change.originalStart + change.originalLength, change.modifiedStart + change.modifiedLength);
  7442. if (endStrictEqual && !startStrictEqual) {
  7443. // moving the change down would create an equal change, but the elements are not strict equal
  7444. break;
  7445. }
  7446. change.originalStart++;
  7447. change.modifiedStart++;
  7448. }
  7449. let mergedChangeArr = [null];
  7450. if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
  7451. changes[i] = mergedChangeArr[0];
  7452. changes.splice(i + 1, 1);
  7453. i--;
  7454. continue;
  7455. }
  7456. }
  7457. // Shift changes back up until we hit empty or whitespace-only lines
  7458. for (let i = changes.length - 1; i >= 0; i--) {
  7459. const change = changes[i];
  7460. let originalStop = 0;
  7461. let modifiedStop = 0;
  7462. if (i > 0) {
  7463. const prevChange = changes[i - 1];
  7464. originalStop = prevChange.originalStart + prevChange.originalLength;
  7465. modifiedStop = prevChange.modifiedStart + prevChange.modifiedLength;
  7466. }
  7467. const checkOriginal = change.originalLength > 0;
  7468. const checkModified = change.modifiedLength > 0;
  7469. let bestDelta = 0;
  7470. let bestScore = this._boundaryScore(change.originalStart, change.originalLength, change.modifiedStart, change.modifiedLength);
  7471. for (let delta = 1;; delta++) {
  7472. const originalStart = change.originalStart - delta;
  7473. const modifiedStart = change.modifiedStart - delta;
  7474. if (originalStart < originalStop || modifiedStart < modifiedStop) {
  7475. break;
  7476. }
  7477. if (checkOriginal && !this.OriginalElementsAreEqual(originalStart, originalStart + change.originalLength)) {
  7478. break;
  7479. }
  7480. if (checkModified && !this.ModifiedElementsAreEqual(modifiedStart, modifiedStart + change.modifiedLength)) {
  7481. break;
  7482. }
  7483. const touchingPreviousChange = (originalStart === originalStop && modifiedStart === modifiedStop);
  7484. const score = ((touchingPreviousChange ? 5 : 0)
  7485. + this._boundaryScore(originalStart, change.originalLength, modifiedStart, change.modifiedLength));
  7486. if (score > bestScore) {
  7487. bestScore = score;
  7488. bestDelta = delta;
  7489. }
  7490. }
  7491. change.originalStart -= bestDelta;
  7492. change.modifiedStart -= bestDelta;
  7493. const mergedChangeArr = [null];
  7494. if (i > 0 && this.ChangesOverlap(changes[i - 1], changes[i], mergedChangeArr)) {
  7495. changes[i - 1] = mergedChangeArr[0];
  7496. changes.splice(i, 1);
  7497. i++;
  7498. continue;
  7499. }
  7500. }
  7501. // There could be multiple longest common substrings.
  7502. // Give preference to the ones containing longer lines
  7503. if (this._hasStrings) {
  7504. for (let i = 1, len = changes.length; i < len; i++) {
  7505. const aChange = changes[i - 1];
  7506. const bChange = changes[i];
  7507. const matchedLength = bChange.originalStart - aChange.originalStart - aChange.originalLength;
  7508. const aOriginalStart = aChange.originalStart;
  7509. const bOriginalEnd = bChange.originalStart + bChange.originalLength;
  7510. const abOriginalLength = bOriginalEnd - aOriginalStart;
  7511. const aModifiedStart = aChange.modifiedStart;
  7512. const bModifiedEnd = bChange.modifiedStart + bChange.modifiedLength;
  7513. const abModifiedLength = bModifiedEnd - aModifiedStart;
  7514. // Avoid wasting a lot of time with these searches
  7515. if (matchedLength < 5 && abOriginalLength < 20 && abModifiedLength < 20) {
  7516. const t = this._findBetterContiguousSequence(aOriginalStart, abOriginalLength, aModifiedStart, abModifiedLength, matchedLength);
  7517. if (t) {
  7518. const [originalMatchStart, modifiedMatchStart] = t;
  7519. if (originalMatchStart !== aChange.originalStart + aChange.originalLength || modifiedMatchStart !== aChange.modifiedStart + aChange.modifiedLength) {
  7520. // switch to another sequence that has a better score
  7521. aChange.originalLength = originalMatchStart - aChange.originalStart;
  7522. aChange.modifiedLength = modifiedMatchStart - aChange.modifiedStart;
  7523. bChange.originalStart = originalMatchStart + matchedLength;
  7524. bChange.modifiedStart = modifiedMatchStart + matchedLength;
  7525. bChange.originalLength = bOriginalEnd - bChange.originalStart;
  7526. bChange.modifiedLength = bModifiedEnd - bChange.modifiedStart;
  7527. }
  7528. }
  7529. }
  7530. }
  7531. }
  7532. return changes;
  7533. }
  7534. _findBetterContiguousSequence(originalStart, originalLength, modifiedStart, modifiedLength, desiredLength) {
  7535. if (originalLength < desiredLength || modifiedLength < desiredLength) {
  7536. return null;
  7537. }
  7538. const originalMax = originalStart + originalLength - desiredLength + 1;
  7539. const modifiedMax = modifiedStart + modifiedLength - desiredLength + 1;
  7540. let bestScore = 0;
  7541. let bestOriginalStart = 0;
  7542. let bestModifiedStart = 0;
  7543. for (let i = originalStart; i < originalMax; i++) {
  7544. for (let j = modifiedStart; j < modifiedMax; j++) {
  7545. const score = this._contiguousSequenceScore(i, j, desiredLength);
  7546. if (score > 0 && score > bestScore) {
  7547. bestScore = score;
  7548. bestOriginalStart = i;
  7549. bestModifiedStart = j;
  7550. }
  7551. }
  7552. }
  7553. if (bestScore > 0) {
  7554. return [bestOriginalStart, bestModifiedStart];
  7555. }
  7556. return null;
  7557. }
  7558. _contiguousSequenceScore(originalStart, modifiedStart, length) {
  7559. let score = 0;
  7560. for (let l = 0; l < length; l++) {
  7561. if (!this.ElementsAreEqual(originalStart + l, modifiedStart + l)) {
  7562. return 0;
  7563. }
  7564. score += this._originalStringElements[originalStart + l].length;
  7565. }
  7566. return score;
  7567. }
  7568. _OriginalIsBoundary(index) {
  7569. if (index <= 0 || index >= this._originalElementsOrHash.length - 1) {
  7570. return true;
  7571. }
  7572. return (this._hasStrings && /^\s*$/.test(this._originalStringElements[index]));
  7573. }
  7574. _OriginalRegionIsBoundary(originalStart, originalLength) {
  7575. if (this._OriginalIsBoundary(originalStart) || this._OriginalIsBoundary(originalStart - 1)) {
  7576. return true;
  7577. }
  7578. if (originalLength > 0) {
  7579. const originalEnd = originalStart + originalLength;
  7580. if (this._OriginalIsBoundary(originalEnd - 1) || this._OriginalIsBoundary(originalEnd)) {
  7581. return true;
  7582. }
  7583. }
  7584. return false;
  7585. }
  7586. _ModifiedIsBoundary(index) {
  7587. if (index <= 0 || index >= this._modifiedElementsOrHash.length - 1) {
  7588. return true;
  7589. }
  7590. return (this._hasStrings && /^\s*$/.test(this._modifiedStringElements[index]));
  7591. }
  7592. _ModifiedRegionIsBoundary(modifiedStart, modifiedLength) {
  7593. if (this._ModifiedIsBoundary(modifiedStart) || this._ModifiedIsBoundary(modifiedStart - 1)) {
  7594. return true;
  7595. }
  7596. if (modifiedLength > 0) {
  7597. const modifiedEnd = modifiedStart + modifiedLength;
  7598. if (this._ModifiedIsBoundary(modifiedEnd - 1) || this._ModifiedIsBoundary(modifiedEnd)) {
  7599. return true;
  7600. }
  7601. }
  7602. return false;
  7603. }
  7604. _boundaryScore(originalStart, originalLength, modifiedStart, modifiedLength) {
  7605. const originalScore = (this._OriginalRegionIsBoundary(originalStart, originalLength) ? 1 : 0);
  7606. const modifiedScore = (this._ModifiedRegionIsBoundary(modifiedStart, modifiedLength) ? 1 : 0);
  7607. return (originalScore + modifiedScore);
  7608. }
  7609. /**
  7610. * Concatenates the two input DiffChange lists and returns the resulting
  7611. * list.
  7612. * @param The left changes
  7613. * @param The right changes
  7614. * @returns The concatenated list
  7615. */
  7616. ConcatenateChanges(left, right) {
  7617. let mergedChangeArr = [];
  7618. if (left.length === 0 || right.length === 0) {
  7619. return (right.length > 0) ? right : left;
  7620. }
  7621. else if (this.ChangesOverlap(left[left.length - 1], right[0], mergedChangeArr)) {
  7622. // Since we break the problem down recursively, it is possible that we
  7623. // might recurse in the middle of a change thereby splitting it into
  7624. // two changes. Here in the combining stage, we detect and fuse those
  7625. // changes back together
  7626. const result = new Array(left.length + right.length - 1);
  7627. MyArray.Copy(left, 0, result, 0, left.length - 1);
  7628. result[left.length - 1] = mergedChangeArr[0];
  7629. MyArray.Copy(right, 1, result, left.length, right.length - 1);
  7630. return result;
  7631. }
  7632. else {
  7633. const result = new Array(left.length + right.length);
  7634. MyArray.Copy(left, 0, result, 0, left.length);
  7635. MyArray.Copy(right, 0, result, left.length, right.length);
  7636. return result;
  7637. }
  7638. }
  7639. /**
  7640. * Returns true if the two changes overlap and can be merged into a single
  7641. * change
  7642. * @param left The left change
  7643. * @param right The right change
  7644. * @param mergedChange The merged change if the two overlap, null otherwise
  7645. * @returns True if the two changes overlap
  7646. */
  7647. ChangesOverlap(left, right, mergedChangeArr) {
  7648. Debug.Assert(left.originalStart <= right.originalStart, 'Left change is not less than or equal to right change');
  7649. Debug.Assert(left.modifiedStart <= right.modifiedStart, 'Left change is not less than or equal to right change');
  7650. if (left.originalStart + left.originalLength >= right.originalStart || left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  7651. const originalStart = left.originalStart;
  7652. let originalLength = left.originalLength;
  7653. const modifiedStart = left.modifiedStart;
  7654. let modifiedLength = left.modifiedLength;
  7655. if (left.originalStart + left.originalLength >= right.originalStart) {
  7656. originalLength = right.originalStart + right.originalLength - left.originalStart;
  7657. }
  7658. if (left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  7659. modifiedLength = right.modifiedStart + right.modifiedLength - left.modifiedStart;
  7660. }
  7661. mergedChangeArr[0] = new diffChange_1.DiffChange(originalStart, originalLength, modifiedStart, modifiedLength);
  7662. return true;
  7663. }
  7664. else {
  7665. mergedChangeArr[0] = null;
  7666. return false;
  7667. }
  7668. }
  7669. /**
  7670. * Helper method used to clip a diagonal index to the range of valid
  7671. * diagonals. This also decides whether or not the diagonal index,
  7672. * if it exceeds the boundary, should be clipped to the boundary or clipped
  7673. * one inside the boundary depending on the Even/Odd status of the boundary
  7674. * and numDifferences.
  7675. * @param diagonal The index of the diagonal to clip.
  7676. * @param numDifferences The current number of differences being iterated upon.
  7677. * @param diagonalBaseIndex The base reference diagonal.
  7678. * @param numDiagonals The total number of diagonals.
  7679. * @returns The clipped diagonal index.
  7680. */
  7681. ClipDiagonalBound(diagonal, numDifferences, diagonalBaseIndex, numDiagonals) {
  7682. if (diagonal >= 0 && diagonal < numDiagonals) {
  7683. // Nothing to clip, its in range
  7684. return diagonal;
  7685. }
  7686. // diagonalsBelow: The number of diagonals below the reference diagonal
  7687. // diagonalsAbove: The number of diagonals above the reference diagonal
  7688. const diagonalsBelow = diagonalBaseIndex;
  7689. const diagonalsAbove = numDiagonals - diagonalBaseIndex - 1;
  7690. const diffEven = (numDifferences % 2 === 0);
  7691. if (diagonal < 0) {
  7692. const lowerBoundEven = (diagonalsBelow % 2 === 0);
  7693. return (diffEven === lowerBoundEven) ? 0 : 1;
  7694. }
  7695. else {
  7696. const upperBoundEven = (diagonalsAbove % 2 === 0);
  7697. return (diffEven === upperBoundEven) ? numDiagonals - 1 : numDiagonals - 2;
  7698. }
  7699. }
  7700. }
  7701. exports.LcsDiff = LcsDiff;
  7702. });
  7703. define(__m[6/*vs/base/common/types*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  7704. "use strict";
  7705. Object.defineProperty(exports, "__esModule", { value: true });
  7706. exports.assertNever = exports.withNullAsUndefined = exports.createProxyObject = exports.getAllMethodNames = exports.getAllPropertyNames = exports.validateConstraint = exports.validateConstraints = exports.isFunction = exports.assertIsDefined = exports.assertType = exports.isUndefinedOrNull = exports.isDefined = exports.isUndefined = exports.isBoolean = exports.isNumber = exports.isObject = exports.isString = exports.isArray = void 0;
  7707. /**
  7708. * @returns whether the provided parameter is a JavaScript Array or not.
  7709. */
  7710. function isArray(array) {
  7711. return Array.isArray(array);
  7712. }
  7713. exports.isArray = isArray;
  7714. /**
  7715. * @returns whether the provided parameter is a JavaScript String or not.
  7716. */
  7717. function isString(str) {
  7718. return (typeof str === 'string');
  7719. }
  7720. exports.isString = isString;
  7721. /**
  7722. *
  7723. * @returns whether the provided parameter is of type `object` but **not**
  7724. * `null`, an `array`, a `regexp`, nor a `date`.
  7725. */
  7726. function isObject(obj) {
  7727. // The method can't do a type cast since there are type (like strings) which
  7728. // are subclasses of any put not positvely matched by the function. Hence type
  7729. // narrowing results in wrong results.
  7730. return typeof obj === 'object'
  7731. && obj !== null
  7732. && !Array.isArray(obj)
  7733. && !(obj instanceof RegExp)
  7734. && !(obj instanceof Date);
  7735. }
  7736. exports.isObject = isObject;
  7737. /**
  7738. * In **contrast** to just checking `typeof` this will return `false` for `NaN`.
  7739. * @returns whether the provided parameter is a JavaScript Number or not.
  7740. */
  7741. function isNumber(obj) {
  7742. return (typeof obj === 'number' && !isNaN(obj));
  7743. }
  7744. exports.isNumber = isNumber;
  7745. /**
  7746. * @returns whether the provided parameter is a JavaScript Boolean or not.
  7747. */
  7748. function isBoolean(obj) {
  7749. return (obj === true || obj === false);
  7750. }
  7751. exports.isBoolean = isBoolean;
  7752. /**
  7753. * @returns whether the provided parameter is undefined.
  7754. */
  7755. function isUndefined(obj) {
  7756. return (typeof obj === 'undefined');
  7757. }
  7758. exports.isUndefined = isUndefined;
  7759. /**
  7760. * @returns whether the provided parameter is defined.
  7761. */
  7762. function isDefined(arg) {
  7763. return !isUndefinedOrNull(arg);
  7764. }
  7765. exports.isDefined = isDefined;
  7766. /**
  7767. * @returns whether the provided parameter is undefined or null.
  7768. */
  7769. function isUndefinedOrNull(obj) {
  7770. return (isUndefined(obj) || obj === null);
  7771. }
  7772. exports.isUndefinedOrNull = isUndefinedOrNull;
  7773. function assertType(condition, type) {
  7774. if (!condition) {
  7775. throw new Error(type ? `Unexpected type, expected '${type}'` : 'Unexpected type');
  7776. }
  7777. }
  7778. exports.assertType = assertType;
  7779. /**
  7780. * Asserts that the argument passed in is neither undefined nor null.
  7781. */
  7782. function assertIsDefined(arg) {
  7783. if (isUndefinedOrNull(arg)) {
  7784. throw new Error('Assertion Failed: argument is undefined or null');
  7785. }
  7786. return arg;
  7787. }
  7788. exports.assertIsDefined = assertIsDefined;
  7789. /**
  7790. * @returns whether the provided parameter is a JavaScript Function or not.
  7791. */
  7792. function isFunction(obj) {
  7793. return (typeof obj === 'function');
  7794. }
  7795. exports.isFunction = isFunction;
  7796. function validateConstraints(args, constraints) {
  7797. const len = Math.min(args.length, constraints.length);
  7798. for (let i = 0; i < len; i++) {
  7799. validateConstraint(args[i], constraints[i]);
  7800. }
  7801. }
  7802. exports.validateConstraints = validateConstraints;
  7803. function validateConstraint(arg, constraint) {
  7804. if (isString(constraint)) {
  7805. if (typeof arg !== constraint) {
  7806. throw new Error(`argument does not match constraint: typeof ${constraint}`);
  7807. }
  7808. }
  7809. else if (isFunction(constraint)) {
  7810. try {
  7811. if (arg instanceof constraint) {
  7812. return;
  7813. }
  7814. }
  7815. catch (_a) {
  7816. // ignore
  7817. }
  7818. if (!isUndefinedOrNull(arg) && arg.constructor === constraint) {
  7819. return;
  7820. }
  7821. if (constraint.length === 1 && constraint.call(undefined, arg) === true) {
  7822. return;
  7823. }
  7824. throw new Error(`argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true`);
  7825. }
  7826. }
  7827. exports.validateConstraint = validateConstraint;
  7828. function getAllPropertyNames(obj) {
  7829. let res = [];
  7830. let proto = Object.getPrototypeOf(obj);
  7831. while (Object.prototype !== proto) {
  7832. res = res.concat(Object.getOwnPropertyNames(proto));
  7833. proto = Object.getPrototypeOf(proto);
  7834. }
  7835. return res;
  7836. }
  7837. exports.getAllPropertyNames = getAllPropertyNames;
  7838. function getAllMethodNames(obj) {
  7839. const methods = [];
  7840. for (const prop of getAllPropertyNames(obj)) {
  7841. if (typeof obj[prop] === 'function') {
  7842. methods.push(prop);
  7843. }
  7844. }
  7845. return methods;
  7846. }
  7847. exports.getAllMethodNames = getAllMethodNames;
  7848. function createProxyObject(methodNames, invoke) {
  7849. const createProxyMethod = (method) => {
  7850. return function () {
  7851. const args = Array.prototype.slice.call(arguments, 0);
  7852. return invoke(method, args);
  7853. };
  7854. };
  7855. let result = {};
  7856. for (const methodName of methodNames) {
  7857. result[methodName] = createProxyMethod(methodName);
  7858. }
  7859. return result;
  7860. }
  7861. exports.createProxyObject = createProxyObject;
  7862. /**
  7863. * Converts null to undefined, passes all other values through.
  7864. */
  7865. function withNullAsUndefined(x) {
  7866. return x === null ? undefined : x;
  7867. }
  7868. exports.withNullAsUndefined = withNullAsUndefined;
  7869. function assertNever(value, message = 'Unreachable') {
  7870. throw new Error(message);
  7871. }
  7872. exports.assertNever = assertNever;
  7873. });
  7874. /*---------------------------------------------------------------------------------------------
  7875. * Copyright (c) Microsoft Corporation. All rights reserved.
  7876. * Licensed under the MIT License. See License.txt in the project root for license information.
  7877. *--------------------------------------------------------------------------------------------*/
  7878. define(__m[25/*vs/base/common/objects*/], __M([0/*require*/,1/*exports*/,6/*vs/base/common/types*/]), function (require, exports, types_1) {
  7879. "use strict";
  7880. Object.defineProperty(exports, "__esModule", { value: true });
  7881. exports.getOrDefault = exports.equals = exports.mixin = exports.cloneAndChange = exports.deepFreeze = exports.deepClone = void 0;
  7882. function deepClone(obj) {
  7883. if (!obj || typeof obj !== 'object') {
  7884. return obj;
  7885. }
  7886. if (obj instanceof RegExp) {
  7887. // See https://github.com/microsoft/TypeScript/issues/10990
  7888. return obj;
  7889. }
  7890. const result = Array.isArray(obj) ? [] : {};
  7891. Object.keys(obj).forEach((key) => {
  7892. if (obj[key] && typeof obj[key] === 'object') {
  7893. result[key] = deepClone(obj[key]);
  7894. }
  7895. else {
  7896. result[key] = obj[key];
  7897. }
  7898. });
  7899. return result;
  7900. }
  7901. exports.deepClone = deepClone;
  7902. function deepFreeze(obj) {
  7903. if (!obj || typeof obj !== 'object') {
  7904. return obj;
  7905. }
  7906. const stack = [obj];
  7907. while (stack.length > 0) {
  7908. const obj = stack.shift();
  7909. Object.freeze(obj);
  7910. for (const key in obj) {
  7911. if (_hasOwnProperty.call(obj, key)) {
  7912. const prop = obj[key];
  7913. if (typeof prop === 'object' && !Object.isFrozen(prop)) {
  7914. stack.push(prop);
  7915. }
  7916. }
  7917. }
  7918. }
  7919. return obj;
  7920. }
  7921. exports.deepFreeze = deepFreeze;
  7922. const _hasOwnProperty = Object.prototype.hasOwnProperty;
  7923. function cloneAndChange(obj, changer) {
  7924. return _cloneAndChange(obj, changer, new Set());
  7925. }
  7926. exports.cloneAndChange = cloneAndChange;
  7927. function _cloneAndChange(obj, changer, seen) {
  7928. if ((0, types_1.isUndefinedOrNull)(obj)) {
  7929. return obj;
  7930. }
  7931. const changed = changer(obj);
  7932. if (typeof changed !== 'undefined') {
  7933. return changed;
  7934. }
  7935. if ((0, types_1.isArray)(obj)) {
  7936. const r1 = [];
  7937. for (const e of obj) {
  7938. r1.push(_cloneAndChange(e, changer, seen));
  7939. }
  7940. return r1;
  7941. }
  7942. if ((0, types_1.isObject)(obj)) {
  7943. if (seen.has(obj)) {
  7944. throw new Error('Cannot clone recursive data-structure');
  7945. }
  7946. seen.add(obj);
  7947. const r2 = {};
  7948. for (let i2 in obj) {
  7949. if (_hasOwnProperty.call(obj, i2)) {
  7950. r2[i2] = _cloneAndChange(obj[i2], changer, seen);
  7951. }
  7952. }
  7953. seen.delete(obj);
  7954. return r2;
  7955. }
  7956. return obj;
  7957. }
  7958. /**
  7959. * Copies all properties of source into destination. The optional parameter "overwrite" allows to control
  7960. * if existing properties on the destination should be overwritten or not. Defaults to true (overwrite).
  7961. */
  7962. function mixin(destination, source, overwrite = true) {
  7963. if (!(0, types_1.isObject)(destination)) {
  7964. return source;
  7965. }
  7966. if ((0, types_1.isObject)(source)) {
  7967. Object.keys(source).forEach(key => {
  7968. if (key in destination) {
  7969. if (overwrite) {
  7970. if ((0, types_1.isObject)(destination[key]) && (0, types_1.isObject)(source[key])) {
  7971. mixin(destination[key], source[key], overwrite);
  7972. }
  7973. else {
  7974. destination[key] = source[key];
  7975. }
  7976. }
  7977. }
  7978. else {
  7979. destination[key] = source[key];
  7980. }
  7981. });
  7982. }
  7983. return destination;
  7984. }
  7985. exports.mixin = mixin;
  7986. function equals(one, other) {
  7987. if (one === other) {
  7988. return true;
  7989. }
  7990. if (one === null || one === undefined || other === null || other === undefined) {
  7991. return false;
  7992. }
  7993. if (typeof one !== typeof other) {
  7994. return false;
  7995. }
  7996. if (typeof one !== 'object') {
  7997. return false;
  7998. }
  7999. if ((Array.isArray(one)) !== (Array.isArray(other))) {
  8000. return false;
  8001. }
  8002. let i;
  8003. let key;
  8004. if (Array.isArray(one)) {
  8005. if (one.length !== other.length) {
  8006. return false;
  8007. }
  8008. for (i = 0; i < one.length; i++) {
  8009. if (!equals(one[i], other[i])) {
  8010. return false;
  8011. }
  8012. }
  8013. }
  8014. else {
  8015. const oneKeys = [];
  8016. for (key in one) {
  8017. oneKeys.push(key);
  8018. }
  8019. oneKeys.sort();
  8020. const otherKeys = [];
  8021. for (key in other) {
  8022. otherKeys.push(key);
  8023. }
  8024. otherKeys.sort();
  8025. if (!equals(oneKeys, otherKeys)) {
  8026. return false;
  8027. }
  8028. for (i = 0; i < oneKeys.length; i++) {
  8029. if (!equals(one[oneKeys[i]], other[oneKeys[i]])) {
  8030. return false;
  8031. }
  8032. }
  8033. }
  8034. return true;
  8035. }
  8036. exports.equals = equals;
  8037. function getOrDefault(obj, fn, defaultValue) {
  8038. const result = fn(obj);
  8039. return typeof result === 'undefined' ? defaultValue : result;
  8040. }
  8041. exports.getOrDefault = getOrDefault;
  8042. });
  8043. /*---------------------------------------------------------------------------------------------
  8044. * Copyright (c) Microsoft Corporation. All rights reserved.
  8045. * Licensed under the MIT License. See License.txt in the project root for license information.
  8046. *--------------------------------------------------------------------------------------------*/
  8047. define(__m[12/*vs/base/common/uint*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  8048. "use strict";
  8049. Object.defineProperty(exports, "__esModule", { value: true });
  8050. exports.toUint32 = exports.toUint8 = void 0;
  8051. function toUint8(v) {
  8052. if (v < 0) {
  8053. return 0;
  8054. }
  8055. if (v > 255 /* MAX_UINT_8 */) {
  8056. return 255 /* MAX_UINT_8 */;
  8057. }
  8058. return v | 0;
  8059. }
  8060. exports.toUint8 = toUint8;
  8061. function toUint32(v) {
  8062. if (v < 0) {
  8063. return 0;
  8064. }
  8065. if (v > 4294967295 /* MAX_UINT_32 */) {
  8066. return 4294967295 /* MAX_UINT_32 */;
  8067. }
  8068. return v | 0;
  8069. }
  8070. exports.toUint32 = toUint32;
  8071. });
  8072. /*---------------------------------------------------------------------------------------------
  8073. * Copyright (c) Microsoft Corporation. All rights reserved.
  8074. * Licensed under the MIT License. See License.txt in the project root for license information.
  8075. *--------------------------------------------------------------------------------------------*/
  8076. define(__m[13/*vs/base/common/uri*/], __M([0/*require*/,1/*exports*/,22/*vs/base/common/path*/,2/*vs/base/common/platform*/]), function (require, exports, paths, platform_1) {
  8077. "use strict";
  8078. Object.defineProperty(exports, "__esModule", { value: true });
  8079. exports.uriToFsPath = exports.URI = void 0;
  8080. const _schemePattern = /^\w[\w\d+.-]*$/;
  8081. const _singleSlashStart = /^\//;
  8082. const _doubleSlashStart = /^\/\//;
  8083. function _validateUri(ret, _strict) {
  8084. // scheme, must be set
  8085. if (!ret.scheme && _strict) {
  8086. throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
  8087. }
  8088. // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
  8089. // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  8090. if (ret.scheme && !_schemePattern.test(ret.scheme)) {
  8091. throw new Error('[UriError]: Scheme contains illegal characters.');
  8092. }
  8093. // path, http://tools.ietf.org/html/rfc3986#section-3.3
  8094. // If a URI contains an authority component, then the path component
  8095. // must either be empty or begin with a slash ("/") character. If a URI
  8096. // does not contain an authority component, then the path cannot begin
  8097. // with two slash characters ("//").
  8098. if (ret.path) {
  8099. if (ret.authority) {
  8100. if (!_singleSlashStart.test(ret.path)) {
  8101. throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
  8102. }
  8103. }
  8104. else {
  8105. if (_doubleSlashStart.test(ret.path)) {
  8106. throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
  8107. }
  8108. }
  8109. }
  8110. }
  8111. // for a while we allowed uris *without* schemes and this is the migration
  8112. // for them, e.g. an uri without scheme and without strict-mode warns and falls
  8113. // back to the file-scheme. that should cause the least carnage and still be a
  8114. // clear warning
  8115. function _schemeFix(scheme, _strict) {
  8116. if (!scheme && !_strict) {
  8117. return 'file';
  8118. }
  8119. return scheme;
  8120. }
  8121. // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
  8122. function _referenceResolution(scheme, path) {
  8123. // the slash-character is our 'default base' as we don't
  8124. // support constructing URIs relative to other URIs. This
  8125. // also means that we alter and potentially break paths.
  8126. // see https://tools.ietf.org/html/rfc3986#section-5.1.4
  8127. switch (scheme) {
  8128. case 'https':
  8129. case 'http':
  8130. case 'file':
  8131. if (!path) {
  8132. path = _slash;
  8133. }
  8134. else if (path[0] !== _slash) {
  8135. path = _slash + path;
  8136. }
  8137. break;
  8138. }
  8139. return path;
  8140. }
  8141. const _empty = '';
  8142. const _slash = '/';
  8143. const _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
  8144. /**
  8145. * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
  8146. * This class is a simple parser which creates the basic component parts
  8147. * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
  8148. * and encoding.
  8149. *
  8150. * ```txt
  8151. * foo://example.com:8042/over/there?name=ferret#nose
  8152. * \_/ \______________/\_________/ \_________/ \__/
  8153. * | | | | |
  8154. * scheme authority path query fragment
  8155. * | _____________________|__
  8156. * / \ / \
  8157. * urn:example:animal:ferret:nose
  8158. * ```
  8159. */
  8160. class URI {
  8161. /**
  8162. * @internal
  8163. */
  8164. constructor(schemeOrData, authority, path, query, fragment, _strict = false) {
  8165. if (typeof schemeOrData === 'object') {
  8166. this.scheme = schemeOrData.scheme || _empty;
  8167. this.authority = schemeOrData.authority || _empty;
  8168. this.path = schemeOrData.path || _empty;
  8169. this.query = schemeOrData.query || _empty;
  8170. this.fragment = schemeOrData.fragment || _empty;
  8171. // no validation because it's this URI
  8172. // that creates uri components.
  8173. // _validateUri(this);
  8174. }
  8175. else {
  8176. this.scheme = _schemeFix(schemeOrData, _strict);
  8177. this.authority = authority || _empty;
  8178. this.path = _referenceResolution(this.scheme, path || _empty);
  8179. this.query = query || _empty;
  8180. this.fragment = fragment || _empty;
  8181. _validateUri(this, _strict);
  8182. }
  8183. }
  8184. static isUri(thing) {
  8185. if (thing instanceof URI) {
  8186. return true;
  8187. }
  8188. if (!thing) {
  8189. return false;
  8190. }
  8191. return typeof thing.authority === 'string'
  8192. && typeof thing.fragment === 'string'
  8193. && typeof thing.path === 'string'
  8194. && typeof thing.query === 'string'
  8195. && typeof thing.scheme === 'string'
  8196. && typeof thing.fsPath === 'string'
  8197. && typeof thing.with === 'function'
  8198. && typeof thing.toString === 'function';
  8199. }
  8200. // ---- filesystem path -----------------------
  8201. /**
  8202. * Returns a string representing the corresponding file system path of this URI.
  8203. * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
  8204. * platform specific path separator.
  8205. *
  8206. * * Will *not* validate the path for invalid characters and semantics.
  8207. * * Will *not* look at the scheme of this URI.
  8208. * * The result shall *not* be used for display purposes but for accessing a file on disk.
  8209. *
  8210. *
  8211. * The *difference* to `URI#path` is the use of the platform specific separator and the handling
  8212. * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
  8213. *
  8214. * ```ts
  8215. const u = URI.parse('file://server/c$/folder/file.txt')
  8216. u.authority === 'server'
  8217. u.path === '/shares/c$/file.txt'
  8218. u.fsPath === '\\server\c$\folder\file.txt'
  8219. ```
  8220. *
  8221. * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
  8222. * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
  8223. * with URIs that represent files on disk (`file` scheme).
  8224. */
  8225. get fsPath() {
  8226. // if (this.scheme !== 'file') {
  8227. // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
  8228. // }
  8229. return uriToFsPath(this, false);
  8230. }
  8231. // ---- modify to new -------------------------
  8232. with(change) {
  8233. if (!change) {
  8234. return this;
  8235. }
  8236. let { scheme, authority, path, query, fragment } = change;
  8237. if (scheme === undefined) {
  8238. scheme = this.scheme;
  8239. }
  8240. else if (scheme === null) {
  8241. scheme = _empty;
  8242. }
  8243. if (authority === undefined) {
  8244. authority = this.authority;
  8245. }
  8246. else if (authority === null) {
  8247. authority = _empty;
  8248. }
  8249. if (path === undefined) {
  8250. path = this.path;
  8251. }
  8252. else if (path === null) {
  8253. path = _empty;
  8254. }
  8255. if (query === undefined) {
  8256. query = this.query;
  8257. }
  8258. else if (query === null) {
  8259. query = _empty;
  8260. }
  8261. if (fragment === undefined) {
  8262. fragment = this.fragment;
  8263. }
  8264. else if (fragment === null) {
  8265. fragment = _empty;
  8266. }
  8267. if (scheme === this.scheme
  8268. && authority === this.authority
  8269. && path === this.path
  8270. && query === this.query
  8271. && fragment === this.fragment) {
  8272. return this;
  8273. }
  8274. return new Uri(scheme, authority, path, query, fragment);
  8275. }
  8276. // ---- parse & validate ------------------------
  8277. /**
  8278. * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
  8279. * `file:///usr/home`, or `scheme:with/path`.
  8280. *
  8281. * @param value A string which represents an URI (see `URI#toString`).
  8282. */
  8283. static parse(value, _strict = false) {
  8284. const match = _regexp.exec(value);
  8285. if (!match) {
  8286. return new Uri(_empty, _empty, _empty, _empty, _empty);
  8287. }
  8288. return new Uri(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict);
  8289. }
  8290. /**
  8291. * Creates a new URI from a file system path, e.g. `c:\my\files`,
  8292. * `/usr/home`, or `\\server\share\some\path`.
  8293. *
  8294. * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
  8295. * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
  8296. * `URI.parse('file://' + path)` because the path might contain characters that are
  8297. * interpreted (# and ?). See the following sample:
  8298. * ```ts
  8299. const good = URI.file('/coding/c#/project1');
  8300. good.scheme === 'file';
  8301. good.path === '/coding/c#/project1';
  8302. good.fragment === '';
  8303. const bad = URI.parse('file://' + '/coding/c#/project1');
  8304. bad.scheme === 'file';
  8305. bad.path === '/coding/c'; // path is now broken
  8306. bad.fragment === '/project1';
  8307. ```
  8308. *
  8309. * @param path A file system path (see `URI#fsPath`)
  8310. */
  8311. static file(path) {
  8312. let authority = _empty;
  8313. // normalize to fwd-slashes on windows,
  8314. // on other systems bwd-slashes are valid
  8315. // filename character, eg /f\oo/ba\r.txt
  8316. if (platform_1.isWindows) {
  8317. path = path.replace(/\\/g, _slash);
  8318. }
  8319. // check for authority as used in UNC shares
  8320. // or use the path as given
  8321. if (path[0] === _slash && path[1] === _slash) {
  8322. const idx = path.indexOf(_slash, 2);
  8323. if (idx === -1) {
  8324. authority = path.substring(2);
  8325. path = _slash;
  8326. }
  8327. else {
  8328. authority = path.substring(2, idx);
  8329. path = path.substring(idx) || _slash;
  8330. }
  8331. }
  8332. return new Uri('file', authority, path, _empty, _empty);
  8333. }
  8334. static from(components) {
  8335. const result = new Uri(components.scheme, components.authority, components.path, components.query, components.fragment);
  8336. _validateUri(result, true);
  8337. return result;
  8338. }
  8339. /**
  8340. * Join a URI path with path fragments and normalizes the resulting path.
  8341. *
  8342. * @param uri The input URI.
  8343. * @param pathFragment The path fragment to add to the URI path.
  8344. * @returns The resulting URI.
  8345. */
  8346. static joinPath(uri, ...pathFragment) {
  8347. if (!uri.path) {
  8348. throw new Error(`[UriError]: cannot call joinPath on URI without path`);
  8349. }
  8350. let newPath;
  8351. if (platform_1.isWindows && uri.scheme === 'file') {
  8352. newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path;
  8353. }
  8354. else {
  8355. newPath = paths.posix.join(uri.path, ...pathFragment);
  8356. }
  8357. return uri.with({ path: newPath });
  8358. }
  8359. // ---- printing/externalize ---------------------------
  8360. /**
  8361. * Creates a string representation for this URI. It's guaranteed that calling
  8362. * `URI.parse` with the result of this function creates an URI which is equal
  8363. * to this URI.
  8364. *
  8365. * * The result shall *not* be used for display purposes but for externalization or transport.
  8366. * * The result will be encoded using the percentage encoding and encoding happens mostly
  8367. * ignore the scheme-specific encoding rules.
  8368. *
  8369. * @param skipEncoding Do not encode the result, default is `false`
  8370. */
  8371. toString(skipEncoding = false) {
  8372. return _asFormatted(this, skipEncoding);
  8373. }
  8374. toJSON() {
  8375. return this;
  8376. }
  8377. static revive(data) {
  8378. if (!data) {
  8379. return data;
  8380. }
  8381. else if (data instanceof URI) {
  8382. return data;
  8383. }
  8384. else {
  8385. const result = new Uri(data);
  8386. result._formatted = data.external;
  8387. result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
  8388. return result;
  8389. }
  8390. }
  8391. }
  8392. exports.URI = URI;
  8393. const _pathSepMarker = platform_1.isWindows ? 1 : undefined;
  8394. // This class exists so that URI is compatible with vscode.Uri (API).
  8395. class Uri extends URI {
  8396. constructor() {
  8397. super(...arguments);
  8398. this._formatted = null;
  8399. this._fsPath = null;
  8400. }
  8401. get fsPath() {
  8402. if (!this._fsPath) {
  8403. this._fsPath = uriToFsPath(this, false);
  8404. }
  8405. return this._fsPath;
  8406. }
  8407. toString(skipEncoding = false) {
  8408. if (!skipEncoding) {
  8409. if (!this._formatted) {
  8410. this._formatted = _asFormatted(this, false);
  8411. }
  8412. return this._formatted;
  8413. }
  8414. else {
  8415. // we don't cache that
  8416. return _asFormatted(this, true);
  8417. }
  8418. }
  8419. toJSON() {
  8420. const res = {
  8421. $mid: 1 /* Uri */
  8422. };
  8423. // cached state
  8424. if (this._fsPath) {
  8425. res.fsPath = this._fsPath;
  8426. res._sep = _pathSepMarker;
  8427. }
  8428. if (this._formatted) {
  8429. res.external = this._formatted;
  8430. }
  8431. // uri components
  8432. if (this.path) {
  8433. res.path = this.path;
  8434. }
  8435. if (this.scheme) {
  8436. res.scheme = this.scheme;
  8437. }
  8438. if (this.authority) {
  8439. res.authority = this.authority;
  8440. }
  8441. if (this.query) {
  8442. res.query = this.query;
  8443. }
  8444. if (this.fragment) {
  8445. res.fragment = this.fragment;
  8446. }
  8447. return res;
  8448. }
  8449. }
  8450. // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
  8451. const encodeTable = {
  8452. [58 /* Colon */]: '%3A',
  8453. [47 /* Slash */]: '%2F',
  8454. [63 /* QuestionMark */]: '%3F',
  8455. [35 /* Hash */]: '%23',
  8456. [91 /* OpenSquareBracket */]: '%5B',
  8457. [93 /* CloseSquareBracket */]: '%5D',
  8458. [64 /* AtSign */]: '%40',
  8459. [33 /* ExclamationMark */]: '%21',
  8460. [36 /* DollarSign */]: '%24',
  8461. [38 /* Ampersand */]: '%26',
  8462. [39 /* SingleQuote */]: '%27',
  8463. [40 /* OpenParen */]: '%28',
  8464. [41 /* CloseParen */]: '%29',
  8465. [42 /* Asterisk */]: '%2A',
  8466. [43 /* Plus */]: '%2B',
  8467. [44 /* Comma */]: '%2C',
  8468. [59 /* Semicolon */]: '%3B',
  8469. [61 /* Equals */]: '%3D',
  8470. [32 /* Space */]: '%20',
  8471. };
  8472. function encodeURIComponentFast(uriComponent, allowSlash) {
  8473. let res = undefined;
  8474. let nativeEncodePos = -1;
  8475. for (let pos = 0; pos < uriComponent.length; pos++) {
  8476. const code = uriComponent.charCodeAt(pos);
  8477. // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
  8478. if ((code >= 97 /* a */ && code <= 122 /* z */)
  8479. || (code >= 65 /* A */ && code <= 90 /* Z */)
  8480. || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
  8481. || code === 45 /* Dash */
  8482. || code === 46 /* Period */
  8483. || code === 95 /* Underline */
  8484. || code === 126 /* Tilde */
  8485. || (allowSlash && code === 47 /* Slash */)) {
  8486. // check if we are delaying native encode
  8487. if (nativeEncodePos !== -1) {
  8488. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  8489. nativeEncodePos = -1;
  8490. }
  8491. // check if we write into a new string (by default we try to return the param)
  8492. if (res !== undefined) {
  8493. res += uriComponent.charAt(pos);
  8494. }
  8495. }
  8496. else {
  8497. // encoding needed, we need to allocate a new string
  8498. if (res === undefined) {
  8499. res = uriComponent.substr(0, pos);
  8500. }
  8501. // check with default table first
  8502. const escaped = encodeTable[code];
  8503. if (escaped !== undefined) {
  8504. // check if we are delaying native encode
  8505. if (nativeEncodePos !== -1) {
  8506. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  8507. nativeEncodePos = -1;
  8508. }
  8509. // append escaped variant to result
  8510. res += escaped;
  8511. }
  8512. else if (nativeEncodePos === -1) {
  8513. // use native encode only when needed
  8514. nativeEncodePos = pos;
  8515. }
  8516. }
  8517. }
  8518. if (nativeEncodePos !== -1) {
  8519. res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
  8520. }
  8521. return res !== undefined ? res : uriComponent;
  8522. }
  8523. function encodeURIComponentMinimal(path) {
  8524. let res = undefined;
  8525. for (let pos = 0; pos < path.length; pos++) {
  8526. const code = path.charCodeAt(pos);
  8527. if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
  8528. if (res === undefined) {
  8529. res = path.substr(0, pos);
  8530. }
  8531. res += encodeTable[code];
  8532. }
  8533. else {
  8534. if (res !== undefined) {
  8535. res += path[pos];
  8536. }
  8537. }
  8538. }
  8539. return res !== undefined ? res : path;
  8540. }
  8541. /**
  8542. * Compute `fsPath` for the given uri
  8543. */
  8544. function uriToFsPath(uri, keepDriveLetterCasing) {
  8545. let value;
  8546. if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
  8547. // unc path: file://shares/c$/far/boo
  8548. value = `//${uri.authority}${uri.path}`;
  8549. }
  8550. else if (uri.path.charCodeAt(0) === 47 /* Slash */
  8551. && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
  8552. && uri.path.charCodeAt(2) === 58 /* Colon */) {
  8553. if (!keepDriveLetterCasing) {
  8554. // windows drive letter: file:///c:/far/boo
  8555. value = uri.path[1].toLowerCase() + uri.path.substr(2);
  8556. }
  8557. else {
  8558. value = uri.path.substr(1);
  8559. }
  8560. }
  8561. else {
  8562. // other path
  8563. value = uri.path;
  8564. }
  8565. if (platform_1.isWindows) {
  8566. value = value.replace(/\//g, '\\');
  8567. }
  8568. return value;
  8569. }
  8570. exports.uriToFsPath = uriToFsPath;
  8571. /**
  8572. * Create the external version of a uri
  8573. */
  8574. function _asFormatted(uri, skipEncoding) {
  8575. const encoder = !skipEncoding
  8576. ? encodeURIComponentFast
  8577. : encodeURIComponentMinimal;
  8578. let res = '';
  8579. let { scheme, authority, path, query, fragment } = uri;
  8580. if (scheme) {
  8581. res += scheme;
  8582. res += ':';
  8583. }
  8584. if (authority || scheme === 'file') {
  8585. res += _slash;
  8586. res += _slash;
  8587. }
  8588. if (authority) {
  8589. let idx = authority.indexOf('@');
  8590. if (idx !== -1) {
  8591. // <user>@<auth>
  8592. const userinfo = authority.substr(0, idx);
  8593. authority = authority.substr(idx + 1);
  8594. idx = userinfo.indexOf(':');
  8595. if (idx === -1) {
  8596. res += encoder(userinfo, false);
  8597. }
  8598. else {
  8599. // <user>:<pass>@<auth>
  8600. res += encoder(userinfo.substr(0, idx), false);
  8601. res += ':';
  8602. res += encoder(userinfo.substr(idx + 1), false);
  8603. }
  8604. res += '@';
  8605. }
  8606. authority = authority.toLowerCase();
  8607. idx = authority.indexOf(':');
  8608. if (idx === -1) {
  8609. res += encoder(authority, false);
  8610. }
  8611. else {
  8612. // <auth>:<port>
  8613. res += encoder(authority.substr(0, idx), false);
  8614. res += authority.substr(idx);
  8615. }
  8616. }
  8617. if (path) {
  8618. // lower-case windows drive letters in /C:/fff or C:/fff
  8619. if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
  8620. const code = path.charCodeAt(1);
  8621. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  8622. path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; // "/c:".length === 3
  8623. }
  8624. }
  8625. else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
  8626. const code = path.charCodeAt(0);
  8627. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  8628. path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3
  8629. }
  8630. }
  8631. // encode the rest of the path
  8632. res += encoder(path, true);
  8633. }
  8634. if (query) {
  8635. res += '?';
  8636. res += encoder(query, false);
  8637. }
  8638. if (fragment) {
  8639. res += '#';
  8640. res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
  8641. }
  8642. return res;
  8643. }
  8644. // --- decode
  8645. function decodeURIComponentGraceful(str) {
  8646. try {
  8647. return decodeURIComponent(str);
  8648. }
  8649. catch (_a) {
  8650. if (str.length > 3) {
  8651. return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
  8652. }
  8653. else {
  8654. return str;
  8655. }
  8656. }
  8657. }
  8658. const _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
  8659. function percentDecode(str) {
  8660. if (!str.match(_rEncodedAsHex)) {
  8661. return str;
  8662. }
  8663. return str.replace(_rEncodedAsHex, (match) => decodeURIComponentGraceful(match));
  8664. }
  8665. });
  8666. /*---------------------------------------------------------------------------------------------
  8667. * Copyright (c) Microsoft Corporation. All rights reserved.
  8668. * Licensed under the MIT License. See License.txt in the project root for license information.
  8669. *--------------------------------------------------------------------------------------------*/
  8670. define(__m[40/*vs/base/common/worker/simpleWorker*/], __M([0/*require*/,1/*exports*/,8/*vs/base/common/errors*/,7/*vs/base/common/event*/,9/*vs/base/common/lifecycle*/,2/*vs/base/common/platform*/,6/*vs/base/common/types*/,3/*vs/base/common/strings*/]), function (require, exports, errors_1, event_1, lifecycle_1, platform_1, types, strings) {
  8671. "use strict";
  8672. Object.defineProperty(exports, "__esModule", { value: true });
  8673. exports.create = exports.SimpleWorkerServer = exports.SimpleWorkerClient = exports.logOnceWebWorkerWarning = void 0;
  8674. const INITIALIZE = '$initialize';
  8675. let webWorkerWarningLogged = false;
  8676. function logOnceWebWorkerWarning(err) {
  8677. if (!platform_1.isWeb) {
  8678. // running tests
  8679. return;
  8680. }
  8681. if (!webWorkerWarningLogged) {
  8682. webWorkerWarningLogged = true;
  8683. console.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq');
  8684. }
  8685. console.warn(err.message);
  8686. }
  8687. exports.logOnceWebWorkerWarning = logOnceWebWorkerWarning;
  8688. class RequestMessage {
  8689. constructor(vsWorker, req, method, args) {
  8690. this.vsWorker = vsWorker;
  8691. this.req = req;
  8692. this.method = method;
  8693. this.args = args;
  8694. this.type = 0 /* Request */;
  8695. }
  8696. }
  8697. class ReplyMessage {
  8698. constructor(vsWorker, seq, res, err) {
  8699. this.vsWorker = vsWorker;
  8700. this.seq = seq;
  8701. this.res = res;
  8702. this.err = err;
  8703. this.type = 1 /* Reply */;
  8704. }
  8705. }
  8706. class SubscribeEventMessage {
  8707. constructor(vsWorker, req, eventName, arg) {
  8708. this.vsWorker = vsWorker;
  8709. this.req = req;
  8710. this.eventName = eventName;
  8711. this.arg = arg;
  8712. this.type = 2 /* SubscribeEvent */;
  8713. }
  8714. }
  8715. class EventMessage {
  8716. constructor(vsWorker, req, event) {
  8717. this.vsWorker = vsWorker;
  8718. this.req = req;
  8719. this.event = event;
  8720. this.type = 3 /* Event */;
  8721. }
  8722. }
  8723. class UnsubscribeEventMessage {
  8724. constructor(vsWorker, req) {
  8725. this.vsWorker = vsWorker;
  8726. this.req = req;
  8727. this.type = 4 /* UnsubscribeEvent */;
  8728. }
  8729. }
  8730. class SimpleWorkerProtocol {
  8731. constructor(handler) {
  8732. this._workerId = -1;
  8733. this._handler = handler;
  8734. this._lastSentReq = 0;
  8735. this._pendingReplies = Object.create(null);
  8736. this._pendingEmitters = new Map();
  8737. this._pendingEvents = new Map();
  8738. }
  8739. setWorkerId(workerId) {
  8740. this._workerId = workerId;
  8741. }
  8742. sendMessage(method, args) {
  8743. const req = String(++this._lastSentReq);
  8744. return new Promise((resolve, reject) => {
  8745. this._pendingReplies[req] = {
  8746. resolve: resolve,
  8747. reject: reject
  8748. };
  8749. this._send(new RequestMessage(this._workerId, req, method, args));
  8750. });
  8751. }
  8752. listen(eventName, arg) {
  8753. let req = null;
  8754. const emitter = new event_1.Emitter({
  8755. onFirstListenerAdd: () => {
  8756. req = String(++this._lastSentReq);
  8757. this._pendingEmitters.set(req, emitter);
  8758. this._send(new SubscribeEventMessage(this._workerId, req, eventName, arg));
  8759. },
  8760. onLastListenerRemove: () => {
  8761. this._pendingEmitters.delete(req);
  8762. this._send(new UnsubscribeEventMessage(this._workerId, req));
  8763. req = null;
  8764. }
  8765. });
  8766. return emitter.event;
  8767. }
  8768. handleMessage(message) {
  8769. if (!message || !message.vsWorker) {
  8770. return;
  8771. }
  8772. if (this._workerId !== -1 && message.vsWorker !== this._workerId) {
  8773. return;
  8774. }
  8775. this._handleMessage(message);
  8776. }
  8777. _handleMessage(msg) {
  8778. switch (msg.type) {
  8779. case 1 /* Reply */:
  8780. return this._handleReplyMessage(msg);
  8781. case 0 /* Request */:
  8782. return this._handleRequestMessage(msg);
  8783. case 2 /* SubscribeEvent */:
  8784. return this._handleSubscribeEventMessage(msg);
  8785. case 3 /* Event */:
  8786. return this._handleEventMessage(msg);
  8787. case 4 /* UnsubscribeEvent */:
  8788. return this._handleUnsubscribeEventMessage(msg);
  8789. }
  8790. }
  8791. _handleReplyMessage(replyMessage) {
  8792. if (!this._pendingReplies[replyMessage.seq]) {
  8793. console.warn('Got reply to unknown seq');
  8794. return;
  8795. }
  8796. let reply = this._pendingReplies[replyMessage.seq];
  8797. delete this._pendingReplies[replyMessage.seq];
  8798. if (replyMessage.err) {
  8799. let err = replyMessage.err;
  8800. if (replyMessage.err.$isError) {
  8801. err = new Error();
  8802. err.name = replyMessage.err.name;
  8803. err.message = replyMessage.err.message;
  8804. err.stack = replyMessage.err.stack;
  8805. }
  8806. reply.reject(err);
  8807. return;
  8808. }
  8809. reply.resolve(replyMessage.res);
  8810. }
  8811. _handleRequestMessage(requestMessage) {
  8812. let req = requestMessage.req;
  8813. let result = this._handler.handleMessage(requestMessage.method, requestMessage.args);
  8814. result.then((r) => {
  8815. this._send(new ReplyMessage(this._workerId, req, r, undefined));
  8816. }, (e) => {
  8817. if (e.detail instanceof Error) {
  8818. // Loading errors have a detail property that points to the actual error
  8819. e.detail = (0, errors_1.transformErrorForSerialization)(e.detail);
  8820. }
  8821. this._send(new ReplyMessage(this._workerId, req, undefined, (0, errors_1.transformErrorForSerialization)(e)));
  8822. });
  8823. }
  8824. _handleSubscribeEventMessage(msg) {
  8825. const req = msg.req;
  8826. const disposable = this._handler.handleEvent(msg.eventName, msg.arg)((event) => {
  8827. this._send(new EventMessage(this._workerId, req, event));
  8828. });
  8829. this._pendingEvents.set(req, disposable);
  8830. }
  8831. _handleEventMessage(msg) {
  8832. if (!this._pendingEmitters.has(msg.req)) {
  8833. console.warn('Got event for unknown req');
  8834. return;
  8835. }
  8836. this._pendingEmitters.get(msg.req).fire(msg.event);
  8837. }
  8838. _handleUnsubscribeEventMessage(msg) {
  8839. if (!this._pendingEvents.has(msg.req)) {
  8840. console.warn('Got unsubscribe for unknown req');
  8841. return;
  8842. }
  8843. this._pendingEvents.get(msg.req).dispose();
  8844. this._pendingEvents.delete(msg.req);
  8845. }
  8846. _send(msg) {
  8847. let transfer = [];
  8848. if (msg.type === 0 /* Request */) {
  8849. for (let i = 0; i < msg.args.length; i++) {
  8850. if (msg.args[i] instanceof ArrayBuffer) {
  8851. transfer.push(msg.args[i]);
  8852. }
  8853. }
  8854. }
  8855. else if (msg.type === 1 /* Reply */) {
  8856. if (msg.res instanceof ArrayBuffer) {
  8857. transfer.push(msg.res);
  8858. }
  8859. }
  8860. this._handler.sendMessage(msg, transfer);
  8861. }
  8862. }
  8863. /**
  8864. * Main thread side
  8865. */
  8866. class SimpleWorkerClient extends lifecycle_1.Disposable {
  8867. constructor(workerFactory, moduleId, host) {
  8868. super();
  8869. let lazyProxyReject = null;
  8870. this._worker = this._register(workerFactory.create('vs/base/common/worker/simpleWorker', (msg) => {
  8871. this._protocol.handleMessage(msg);
  8872. }, (err) => {
  8873. // in Firefox, web workers fail lazily :(
  8874. // we will reject the proxy
  8875. if (lazyProxyReject) {
  8876. lazyProxyReject(err);
  8877. }
  8878. }));
  8879. this._protocol = new SimpleWorkerProtocol({
  8880. sendMessage: (msg, transfer) => {
  8881. this._worker.postMessage(msg, transfer);
  8882. },
  8883. handleMessage: (method, args) => {
  8884. if (typeof host[method] !== 'function') {
  8885. return Promise.reject(new Error('Missing method ' + method + ' on main thread host.'));
  8886. }
  8887. try {
  8888. return Promise.resolve(host[method].apply(host, args));
  8889. }
  8890. catch (e) {
  8891. return Promise.reject(e);
  8892. }
  8893. },
  8894. handleEvent: (eventName, arg) => {
  8895. if (propertyIsDynamicEvent(eventName)) {
  8896. const event = host[eventName].call(host, arg);
  8897. if (typeof event !== 'function') {
  8898. throw new Error(`Missing dynamic event ${eventName} on main thread host.`);
  8899. }
  8900. return event;
  8901. }
  8902. if (propertyIsEvent(eventName)) {
  8903. const event = host[eventName];
  8904. if (typeof event !== 'function') {
  8905. throw new Error(`Missing event ${eventName} on main thread host.`);
  8906. }
  8907. return event;
  8908. }
  8909. throw new Error(`Malformed event name ${eventName}`);
  8910. }
  8911. });
  8912. this._protocol.setWorkerId(this._worker.getId());
  8913. // Gather loader configuration
  8914. let loaderConfiguration = null;
  8915. if (typeof platform_1.globals.require !== 'undefined' && typeof platform_1.globals.require.getConfig === 'function') {
  8916. // Get the configuration from the Monaco AMD Loader
  8917. loaderConfiguration = platform_1.globals.require.getConfig();
  8918. }
  8919. else if (typeof platform_1.globals.requirejs !== 'undefined') {
  8920. // Get the configuration from requirejs
  8921. loaderConfiguration = platform_1.globals.requirejs.s.contexts._.config;
  8922. }
  8923. const hostMethods = types.getAllMethodNames(host);
  8924. // Send initialize message
  8925. this._onModuleLoaded = this._protocol.sendMessage(INITIALIZE, [
  8926. this._worker.getId(),
  8927. JSON.parse(JSON.stringify(loaderConfiguration)),
  8928. moduleId,
  8929. hostMethods,
  8930. ]);
  8931. // Create proxy to loaded code
  8932. const proxyMethodRequest = (method, args) => {
  8933. return this._request(method, args);
  8934. };
  8935. const proxyListen = (eventName, arg) => {
  8936. return this._protocol.listen(eventName, arg);
  8937. };
  8938. this._lazyProxy = new Promise((resolve, reject) => {
  8939. lazyProxyReject = reject;
  8940. this._onModuleLoaded.then((availableMethods) => {
  8941. resolve(createProxyObject(availableMethods, proxyMethodRequest, proxyListen));
  8942. }, (e) => {
  8943. reject(e);
  8944. this._onError('Worker failed to load ' + moduleId, e);
  8945. });
  8946. });
  8947. }
  8948. getProxyObject() {
  8949. return this._lazyProxy;
  8950. }
  8951. _request(method, args) {
  8952. return new Promise((resolve, reject) => {
  8953. this._onModuleLoaded.then(() => {
  8954. this._protocol.sendMessage(method, args).then(resolve, reject);
  8955. }, reject);
  8956. });
  8957. }
  8958. _onError(message, error) {
  8959. console.error(message);
  8960. console.info(error);
  8961. }
  8962. }
  8963. exports.SimpleWorkerClient = SimpleWorkerClient;
  8964. function propertyIsEvent(name) {
  8965. // Assume a property is an event if it has a form of "onSomething"
  8966. return name[0] === 'o' && name[1] === 'n' && strings.isUpperAsciiLetter(name.charCodeAt(2));
  8967. }
  8968. function propertyIsDynamicEvent(name) {
  8969. // Assume a property is a dynamic event (a method that returns an event) if it has a form of "onDynamicSomething"
  8970. return /^onDynamic/.test(name) && strings.isUpperAsciiLetter(name.charCodeAt(9));
  8971. }
  8972. function createProxyObject(methodNames, invoke, proxyListen) {
  8973. const createProxyMethod = (method) => {
  8974. return function () {
  8975. const args = Array.prototype.slice.call(arguments, 0);
  8976. return invoke(method, args);
  8977. };
  8978. };
  8979. const createProxyDynamicEvent = (eventName) => {
  8980. return function (arg) {
  8981. return proxyListen(eventName, arg);
  8982. };
  8983. };
  8984. let result = {};
  8985. for (const methodName of methodNames) {
  8986. if (propertyIsDynamicEvent(methodName)) {
  8987. result[methodName] = createProxyDynamicEvent(methodName);
  8988. continue;
  8989. }
  8990. if (propertyIsEvent(methodName)) {
  8991. result[methodName] = proxyListen(methodName, undefined);
  8992. continue;
  8993. }
  8994. result[methodName] = createProxyMethod(methodName);
  8995. }
  8996. return result;
  8997. }
  8998. /**
  8999. * Worker side
  9000. */
  9001. class SimpleWorkerServer {
  9002. constructor(postMessage, requestHandlerFactory) {
  9003. this._requestHandlerFactory = requestHandlerFactory;
  9004. this._requestHandler = null;
  9005. this._protocol = new SimpleWorkerProtocol({
  9006. sendMessage: (msg, transfer) => {
  9007. postMessage(msg, transfer);
  9008. },
  9009. handleMessage: (method, args) => this._handleMessage(method, args),
  9010. handleEvent: (eventName, arg) => this._handleEvent(eventName, arg)
  9011. });
  9012. }
  9013. onmessage(msg) {
  9014. this._protocol.handleMessage(msg);
  9015. }
  9016. _handleMessage(method, args) {
  9017. if (method === INITIALIZE) {
  9018. return this.initialize(args[0], args[1], args[2], args[3]);
  9019. }
  9020. if (!this._requestHandler || typeof this._requestHandler[method] !== 'function') {
  9021. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  9022. }
  9023. try {
  9024. return Promise.resolve(this._requestHandler[method].apply(this._requestHandler, args));
  9025. }
  9026. catch (e) {
  9027. return Promise.reject(e);
  9028. }
  9029. }
  9030. _handleEvent(eventName, arg) {
  9031. if (!this._requestHandler) {
  9032. throw new Error(`Missing requestHandler`);
  9033. }
  9034. if (propertyIsDynamicEvent(eventName)) {
  9035. const event = this._requestHandler[eventName].call(this._requestHandler, arg);
  9036. if (typeof event !== 'function') {
  9037. throw new Error(`Missing dynamic event ${eventName} on request handler.`);
  9038. }
  9039. return event;
  9040. }
  9041. if (propertyIsEvent(eventName)) {
  9042. const event = this._requestHandler[eventName];
  9043. if (typeof event !== 'function') {
  9044. throw new Error(`Missing event ${eventName} on request handler.`);
  9045. }
  9046. return event;
  9047. }
  9048. throw new Error(`Malformed event name ${eventName}`);
  9049. }
  9050. initialize(workerId, loaderConfig, moduleId, hostMethods) {
  9051. this._protocol.setWorkerId(workerId);
  9052. const proxyMethodRequest = (method, args) => {
  9053. return this._protocol.sendMessage(method, args);
  9054. };
  9055. const proxyListen = (eventName, arg) => {
  9056. return this._protocol.listen(eventName, arg);
  9057. };
  9058. const hostProxy = createProxyObject(hostMethods, proxyMethodRequest, proxyListen);
  9059. if (this._requestHandlerFactory) {
  9060. // static request handler
  9061. this._requestHandler = this._requestHandlerFactory(hostProxy);
  9062. return Promise.resolve(types.getAllMethodNames(this._requestHandler));
  9063. }
  9064. if (loaderConfig) {
  9065. // Remove 'baseUrl', handling it is beyond scope for now
  9066. if (typeof loaderConfig.baseUrl !== 'undefined') {
  9067. delete loaderConfig['baseUrl'];
  9068. }
  9069. if (typeof loaderConfig.paths !== 'undefined') {
  9070. if (typeof loaderConfig.paths.vs !== 'undefined') {
  9071. delete loaderConfig.paths['vs'];
  9072. }
  9073. }
  9074. if (typeof loaderConfig.trustedTypesPolicy !== undefined) {
  9075. // don't use, it has been destroyed during serialize
  9076. delete loaderConfig['trustedTypesPolicy'];
  9077. }
  9078. // Since this is in a web worker, enable catching errors
  9079. loaderConfig.catchError = true;
  9080. platform_1.globals.require.config(loaderConfig);
  9081. }
  9082. return new Promise((resolve, reject) => {
  9083. // Use the global require to be sure to get the global config
  9084. // ESM-comment-begin
  9085. const req = (platform_1.globals.require || require);
  9086. // ESM-comment-end
  9087. // ESM-uncomment-begin
  9088. // const req = globals.require;
  9089. // ESM-uncomment-end
  9090. req([moduleId], (module) => {
  9091. this._requestHandler = module.create(hostProxy);
  9092. if (!this._requestHandler) {
  9093. reject(new Error(`No RequestHandler!`));
  9094. return;
  9095. }
  9096. resolve(types.getAllMethodNames(this._requestHandler));
  9097. }, reject);
  9098. });
  9099. }
  9100. }
  9101. exports.SimpleWorkerServer = SimpleWorkerServer;
  9102. /**
  9103. * Called on the worker side
  9104. */
  9105. function create(postMessage) {
  9106. return new SimpleWorkerServer(postMessage, null);
  9107. }
  9108. exports.create = create;
  9109. });
  9110. /*---------------------------------------------------------------------------------------------
  9111. * Copyright (c) Microsoft Corporation. All rights reserved.
  9112. * Licensed under the MIT License. See License.txt in the project root for license information.
  9113. *--------------------------------------------------------------------------------------------*/
  9114. define(__m[14/*vs/editor/common/core/characterClassifier*/], __M([0/*require*/,1/*exports*/,12/*vs/base/common/uint*/]), function (require, exports, uint_1) {
  9115. "use strict";
  9116. Object.defineProperty(exports, "__esModule", { value: true });
  9117. exports.CharacterSet = exports.CharacterClassifier = void 0;
  9118. /**
  9119. * A fast character classifier that uses a compact array for ASCII values.
  9120. */
  9121. class CharacterClassifier {
  9122. constructor(_defaultValue) {
  9123. let defaultValue = (0, uint_1.toUint8)(_defaultValue);
  9124. this._defaultValue = defaultValue;
  9125. this._asciiMap = CharacterClassifier._createAsciiMap(defaultValue);
  9126. this._map = new Map();
  9127. }
  9128. static _createAsciiMap(defaultValue) {
  9129. let asciiMap = new Uint8Array(256);
  9130. for (let i = 0; i < 256; i++) {
  9131. asciiMap[i] = defaultValue;
  9132. }
  9133. return asciiMap;
  9134. }
  9135. set(charCode, _value) {
  9136. let value = (0, uint_1.toUint8)(_value);
  9137. if (charCode >= 0 && charCode < 256) {
  9138. this._asciiMap[charCode] = value;
  9139. }
  9140. else {
  9141. this._map.set(charCode, value);
  9142. }
  9143. }
  9144. get(charCode) {
  9145. if (charCode >= 0 && charCode < 256) {
  9146. return this._asciiMap[charCode];
  9147. }
  9148. else {
  9149. return (this._map.get(charCode) || this._defaultValue);
  9150. }
  9151. }
  9152. }
  9153. exports.CharacterClassifier = CharacterClassifier;
  9154. class CharacterSet {
  9155. constructor() {
  9156. this._actual = new CharacterClassifier(0 /* False */);
  9157. }
  9158. add(charCode) {
  9159. this._actual.set(charCode, 1 /* True */);
  9160. }
  9161. has(charCode) {
  9162. return (this._actual.get(charCode) === 1 /* True */);
  9163. }
  9164. }
  9165. exports.CharacterSet = CharacterSet;
  9166. });
  9167. /*---------------------------------------------------------------------------------------------
  9168. * Copyright (c) Microsoft Corporation. All rights reserved.
  9169. * Licensed under the MIT License. See License.txt in the project root for license information.
  9170. *--------------------------------------------------------------------------------------------*/
  9171. define(__m[26/*vs/editor/common/controller/wordCharacterClassifier*/], __M([0/*require*/,1/*exports*/,14/*vs/editor/common/core/characterClassifier*/]), function (require, exports, characterClassifier_1) {
  9172. "use strict";
  9173. Object.defineProperty(exports, "__esModule", { value: true });
  9174. exports.getMapForWordSeparators = exports.WordCharacterClassifier = void 0;
  9175. class WordCharacterClassifier extends characterClassifier_1.CharacterClassifier {
  9176. constructor(wordSeparators) {
  9177. super(0 /* Regular */);
  9178. for (let i = 0, len = wordSeparators.length; i < len; i++) {
  9179. this.set(wordSeparators.charCodeAt(i), 2 /* WordSeparator */);
  9180. }
  9181. this.set(32 /* Space */, 1 /* Whitespace */);
  9182. this.set(9 /* Tab */, 1 /* Whitespace */);
  9183. }
  9184. }
  9185. exports.WordCharacterClassifier = WordCharacterClassifier;
  9186. function once(computeFn) {
  9187. let cache = {}; // TODO@Alex unbounded cache
  9188. return (input) => {
  9189. if (!cache.hasOwnProperty(input)) {
  9190. cache[input] = computeFn(input);
  9191. }
  9192. return cache[input];
  9193. };
  9194. }
  9195. exports.getMapForWordSeparators = once((input) => new WordCharacterClassifier(input));
  9196. });
  9197. /*---------------------------------------------------------------------------------------------
  9198. * Copyright (c) Microsoft Corporation. All rights reserved.
  9199. * Licensed under the MIT License. See License.txt in the project root for license information.
  9200. *--------------------------------------------------------------------------------------------*/
  9201. define(__m[4/*vs/editor/common/core/position*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  9202. "use strict";
  9203. Object.defineProperty(exports, "__esModule", { value: true });
  9204. exports.Position = void 0;
  9205. /**
  9206. * A position in the editor.
  9207. */
  9208. class Position {
  9209. constructor(lineNumber, column) {
  9210. this.lineNumber = lineNumber;
  9211. this.column = column;
  9212. }
  9213. /**
  9214. * Create a new position from this position.
  9215. *
  9216. * @param newLineNumber new line number
  9217. * @param newColumn new column
  9218. */
  9219. with(newLineNumber = this.lineNumber, newColumn = this.column) {
  9220. if (newLineNumber === this.lineNumber && newColumn === this.column) {
  9221. return this;
  9222. }
  9223. else {
  9224. return new Position(newLineNumber, newColumn);
  9225. }
  9226. }
  9227. /**
  9228. * Derive a new position from this position.
  9229. *
  9230. * @param deltaLineNumber line number delta
  9231. * @param deltaColumn column delta
  9232. */
  9233. delta(deltaLineNumber = 0, deltaColumn = 0) {
  9234. return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
  9235. }
  9236. /**
  9237. * Test if this position equals other position
  9238. */
  9239. equals(other) {
  9240. return Position.equals(this, other);
  9241. }
  9242. /**
  9243. * Test if position `a` equals position `b`
  9244. */
  9245. static equals(a, b) {
  9246. if (!a && !b) {
  9247. return true;
  9248. }
  9249. return (!!a &&
  9250. !!b &&
  9251. a.lineNumber === b.lineNumber &&
  9252. a.column === b.column);
  9253. }
  9254. /**
  9255. * Test if this position is before other position.
  9256. * If the two positions are equal, the result will be false.
  9257. */
  9258. isBefore(other) {
  9259. return Position.isBefore(this, other);
  9260. }
  9261. /**
  9262. * Test if position `a` is before position `b`.
  9263. * If the two positions are equal, the result will be false.
  9264. */
  9265. static isBefore(a, b) {
  9266. if (a.lineNumber < b.lineNumber) {
  9267. return true;
  9268. }
  9269. if (b.lineNumber < a.lineNumber) {
  9270. return false;
  9271. }
  9272. return a.column < b.column;
  9273. }
  9274. /**
  9275. * Test if this position is before other position.
  9276. * If the two positions are equal, the result will be true.
  9277. */
  9278. isBeforeOrEqual(other) {
  9279. return Position.isBeforeOrEqual(this, other);
  9280. }
  9281. /**
  9282. * Test if position `a` is before position `b`.
  9283. * If the two positions are equal, the result will be true.
  9284. */
  9285. static isBeforeOrEqual(a, b) {
  9286. if (a.lineNumber < b.lineNumber) {
  9287. return true;
  9288. }
  9289. if (b.lineNumber < a.lineNumber) {
  9290. return false;
  9291. }
  9292. return a.column <= b.column;
  9293. }
  9294. /**
  9295. * A function that compares positions, useful for sorting
  9296. */
  9297. static compare(a, b) {
  9298. let aLineNumber = a.lineNumber | 0;
  9299. let bLineNumber = b.lineNumber | 0;
  9300. if (aLineNumber === bLineNumber) {
  9301. let aColumn = a.column | 0;
  9302. let bColumn = b.column | 0;
  9303. return aColumn - bColumn;
  9304. }
  9305. return aLineNumber - bLineNumber;
  9306. }
  9307. /**
  9308. * Clone this position.
  9309. */
  9310. clone() {
  9311. return new Position(this.lineNumber, this.column);
  9312. }
  9313. /**
  9314. * Convert to a human-readable representation.
  9315. */
  9316. toString() {
  9317. return '(' + this.lineNumber + ',' + this.column + ')';
  9318. }
  9319. // ---
  9320. /**
  9321. * Create a `Position` from an `IPosition`.
  9322. */
  9323. static lift(pos) {
  9324. return new Position(pos.lineNumber, pos.column);
  9325. }
  9326. /**
  9327. * Test if `obj` is an `IPosition`.
  9328. */
  9329. static isIPosition(obj) {
  9330. return (obj
  9331. && (typeof obj.lineNumber === 'number')
  9332. && (typeof obj.column === 'number'));
  9333. }
  9334. }
  9335. exports.Position = Position;
  9336. });
  9337. /*---------------------------------------------------------------------------------------------
  9338. * Copyright (c) Microsoft Corporation. All rights reserved.
  9339. * Licensed under the MIT License. See License.txt in the project root for license information.
  9340. *--------------------------------------------------------------------------------------------*/
  9341. define(__m[5/*vs/editor/common/core/range*/], __M([0/*require*/,1/*exports*/,4/*vs/editor/common/core/position*/]), function (require, exports, position_1) {
  9342. "use strict";
  9343. Object.defineProperty(exports, "__esModule", { value: true });
  9344. exports.Range = void 0;
  9345. /**
  9346. * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
  9347. */
  9348. class Range {
  9349. constructor(startLineNumber, startColumn, endLineNumber, endColumn) {
  9350. if ((startLineNumber > endLineNumber) || (startLineNumber === endLineNumber && startColumn > endColumn)) {
  9351. this.startLineNumber = endLineNumber;
  9352. this.startColumn = endColumn;
  9353. this.endLineNumber = startLineNumber;
  9354. this.endColumn = startColumn;
  9355. }
  9356. else {
  9357. this.startLineNumber = startLineNumber;
  9358. this.startColumn = startColumn;
  9359. this.endLineNumber = endLineNumber;
  9360. this.endColumn = endColumn;
  9361. }
  9362. }
  9363. /**
  9364. * Test if this range is empty.
  9365. */
  9366. isEmpty() {
  9367. return Range.isEmpty(this);
  9368. }
  9369. /**
  9370. * Test if `range` is empty.
  9371. */
  9372. static isEmpty(range) {
  9373. return (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn);
  9374. }
  9375. /**
  9376. * Test if position is in this range. If the position is at the edges, will return true.
  9377. */
  9378. containsPosition(position) {
  9379. return Range.containsPosition(this, position);
  9380. }
  9381. /**
  9382. * Test if `position` is in `range`. If the position is at the edges, will return true.
  9383. */
  9384. static containsPosition(range, position) {
  9385. if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
  9386. return false;
  9387. }
  9388. if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
  9389. return false;
  9390. }
  9391. if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
  9392. return false;
  9393. }
  9394. return true;
  9395. }
  9396. /**
  9397. * Test if `position` is in `range`. If the position is at the edges, will return false.
  9398. * @internal
  9399. */
  9400. static strictContainsPosition(range, position) {
  9401. if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
  9402. return false;
  9403. }
  9404. if (position.lineNumber === range.startLineNumber && position.column <= range.startColumn) {
  9405. return false;
  9406. }
  9407. if (position.lineNumber === range.endLineNumber && position.column >= range.endColumn) {
  9408. return false;
  9409. }
  9410. return true;
  9411. }
  9412. /**
  9413. * Test if range is in this range. If the range is equal to this range, will return true.
  9414. */
  9415. containsRange(range) {
  9416. return Range.containsRange(this, range);
  9417. }
  9418. /**
  9419. * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
  9420. */
  9421. static containsRange(range, otherRange) {
  9422. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  9423. return false;
  9424. }
  9425. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  9426. return false;
  9427. }
  9428. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
  9429. return false;
  9430. }
  9431. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
  9432. return false;
  9433. }
  9434. return true;
  9435. }
  9436. /**
  9437. * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
  9438. */
  9439. strictContainsRange(range) {
  9440. return Range.strictContainsRange(this, range);
  9441. }
  9442. /**
  9443. * Test if `otherRange` is strictly in `range` (must start after, and end before). If the ranges are equal, will return false.
  9444. */
  9445. static strictContainsRange(range, otherRange) {
  9446. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  9447. return false;
  9448. }
  9449. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  9450. return false;
  9451. }
  9452. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn <= range.startColumn) {
  9453. return false;
  9454. }
  9455. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn >= range.endColumn) {
  9456. return false;
  9457. }
  9458. return true;
  9459. }
  9460. /**
  9461. * A reunion of the two ranges.
  9462. * The smallest position will be used as the start point, and the largest one as the end point.
  9463. */
  9464. plusRange(range) {
  9465. return Range.plusRange(this, range);
  9466. }
  9467. /**
  9468. * A reunion of the two ranges.
  9469. * The smallest position will be used as the start point, and the largest one as the end point.
  9470. */
  9471. static plusRange(a, b) {
  9472. let startLineNumber;
  9473. let startColumn;
  9474. let endLineNumber;
  9475. let endColumn;
  9476. if (b.startLineNumber < a.startLineNumber) {
  9477. startLineNumber = b.startLineNumber;
  9478. startColumn = b.startColumn;
  9479. }
  9480. else if (b.startLineNumber === a.startLineNumber) {
  9481. startLineNumber = b.startLineNumber;
  9482. startColumn = Math.min(b.startColumn, a.startColumn);
  9483. }
  9484. else {
  9485. startLineNumber = a.startLineNumber;
  9486. startColumn = a.startColumn;
  9487. }
  9488. if (b.endLineNumber > a.endLineNumber) {
  9489. endLineNumber = b.endLineNumber;
  9490. endColumn = b.endColumn;
  9491. }
  9492. else if (b.endLineNumber === a.endLineNumber) {
  9493. endLineNumber = b.endLineNumber;
  9494. endColumn = Math.max(b.endColumn, a.endColumn);
  9495. }
  9496. else {
  9497. endLineNumber = a.endLineNumber;
  9498. endColumn = a.endColumn;
  9499. }
  9500. return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
  9501. }
  9502. /**
  9503. * A intersection of the two ranges.
  9504. */
  9505. intersectRanges(range) {
  9506. return Range.intersectRanges(this, range);
  9507. }
  9508. /**
  9509. * A intersection of the two ranges.
  9510. */
  9511. static intersectRanges(a, b) {
  9512. let resultStartLineNumber = a.startLineNumber;
  9513. let resultStartColumn = a.startColumn;
  9514. let resultEndLineNumber = a.endLineNumber;
  9515. let resultEndColumn = a.endColumn;
  9516. let otherStartLineNumber = b.startLineNumber;
  9517. let otherStartColumn = b.startColumn;
  9518. let otherEndLineNumber = b.endLineNumber;
  9519. let otherEndColumn = b.endColumn;
  9520. if (resultStartLineNumber < otherStartLineNumber) {
  9521. resultStartLineNumber = otherStartLineNumber;
  9522. resultStartColumn = otherStartColumn;
  9523. }
  9524. else if (resultStartLineNumber === otherStartLineNumber) {
  9525. resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
  9526. }
  9527. if (resultEndLineNumber > otherEndLineNumber) {
  9528. resultEndLineNumber = otherEndLineNumber;
  9529. resultEndColumn = otherEndColumn;
  9530. }
  9531. else if (resultEndLineNumber === otherEndLineNumber) {
  9532. resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
  9533. }
  9534. // Check if selection is now empty
  9535. if (resultStartLineNumber > resultEndLineNumber) {
  9536. return null;
  9537. }
  9538. if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
  9539. return null;
  9540. }
  9541. return new Range(resultStartLineNumber, resultStartColumn, resultEndLineNumber, resultEndColumn);
  9542. }
  9543. /**
  9544. * Test if this range equals other.
  9545. */
  9546. equalsRange(other) {
  9547. return Range.equalsRange(this, other);
  9548. }
  9549. /**
  9550. * Test if range `a` equals `b`.
  9551. */
  9552. static equalsRange(a, b) {
  9553. return (!!a &&
  9554. !!b &&
  9555. a.startLineNumber === b.startLineNumber &&
  9556. a.startColumn === b.startColumn &&
  9557. a.endLineNumber === b.endLineNumber &&
  9558. a.endColumn === b.endColumn);
  9559. }
  9560. /**
  9561. * Return the end position (which will be after or equal to the start position)
  9562. */
  9563. getEndPosition() {
  9564. return Range.getEndPosition(this);
  9565. }
  9566. /**
  9567. * Return the end position (which will be after or equal to the start position)
  9568. */
  9569. static getEndPosition(range) {
  9570. return new position_1.Position(range.endLineNumber, range.endColumn);
  9571. }
  9572. /**
  9573. * Return the start position (which will be before or equal to the end position)
  9574. */
  9575. getStartPosition() {
  9576. return Range.getStartPosition(this);
  9577. }
  9578. /**
  9579. * Return the start position (which will be before or equal to the end position)
  9580. */
  9581. static getStartPosition(range) {
  9582. return new position_1.Position(range.startLineNumber, range.startColumn);
  9583. }
  9584. /**
  9585. * Transform to a user presentable string representation.
  9586. */
  9587. toString() {
  9588. return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
  9589. }
  9590. /**
  9591. * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
  9592. */
  9593. setEndPosition(endLineNumber, endColumn) {
  9594. return new Range(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  9595. }
  9596. /**
  9597. * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
  9598. */
  9599. setStartPosition(startLineNumber, startColumn) {
  9600. return new Range(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  9601. }
  9602. /**
  9603. * Create a new empty range using this range's start position.
  9604. */
  9605. collapseToStart() {
  9606. return Range.collapseToStart(this);
  9607. }
  9608. /**
  9609. * Create a new empty range using this range's start position.
  9610. */
  9611. static collapseToStart(range) {
  9612. return new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
  9613. }
  9614. // ---
  9615. static fromPositions(start, end = start) {
  9616. return new Range(start.lineNumber, start.column, end.lineNumber, end.column);
  9617. }
  9618. static lift(range) {
  9619. if (!range) {
  9620. return null;
  9621. }
  9622. return new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  9623. }
  9624. /**
  9625. * Test if `obj` is an `IRange`.
  9626. */
  9627. static isIRange(obj) {
  9628. return (obj
  9629. && (typeof obj.startLineNumber === 'number')
  9630. && (typeof obj.startColumn === 'number')
  9631. && (typeof obj.endLineNumber === 'number')
  9632. && (typeof obj.endColumn === 'number'));
  9633. }
  9634. /**
  9635. * Test if the two ranges are touching in any way.
  9636. */
  9637. static areIntersectingOrTouching(a, b) {
  9638. // Check if `a` is before `b`
  9639. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn)) {
  9640. return false;
  9641. }
  9642. // Check if `b` is before `a`
  9643. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn)) {
  9644. return false;
  9645. }
  9646. // These ranges must intersect
  9647. return true;
  9648. }
  9649. /**
  9650. * Test if the two ranges are intersecting. If the ranges are touching it returns true.
  9651. */
  9652. static areIntersecting(a, b) {
  9653. // Check if `a` is before `b`
  9654. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn)) {
  9655. return false;
  9656. }
  9657. // Check if `b` is before `a`
  9658. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn)) {
  9659. return false;
  9660. }
  9661. // These ranges must intersect
  9662. return true;
  9663. }
  9664. /**
  9665. * A function that compares ranges, useful for sorting ranges
  9666. * It will first compare ranges on the startPosition and then on the endPosition
  9667. */
  9668. static compareRangesUsingStarts(a, b) {
  9669. if (a && b) {
  9670. const aStartLineNumber = a.startLineNumber | 0;
  9671. const bStartLineNumber = b.startLineNumber | 0;
  9672. if (aStartLineNumber === bStartLineNumber) {
  9673. const aStartColumn = a.startColumn | 0;
  9674. const bStartColumn = b.startColumn | 0;
  9675. if (aStartColumn === bStartColumn) {
  9676. const aEndLineNumber = a.endLineNumber | 0;
  9677. const bEndLineNumber = b.endLineNumber | 0;
  9678. if (aEndLineNumber === bEndLineNumber) {
  9679. const aEndColumn = a.endColumn | 0;
  9680. const bEndColumn = b.endColumn | 0;
  9681. return aEndColumn - bEndColumn;
  9682. }
  9683. return aEndLineNumber - bEndLineNumber;
  9684. }
  9685. return aStartColumn - bStartColumn;
  9686. }
  9687. return aStartLineNumber - bStartLineNumber;
  9688. }
  9689. const aExists = (a ? 1 : 0);
  9690. const bExists = (b ? 1 : 0);
  9691. return aExists - bExists;
  9692. }
  9693. /**
  9694. * A function that compares ranges, useful for sorting ranges
  9695. * It will first compare ranges on the endPosition and then on the startPosition
  9696. */
  9697. static compareRangesUsingEnds(a, b) {
  9698. if (a.endLineNumber === b.endLineNumber) {
  9699. if (a.endColumn === b.endColumn) {
  9700. if (a.startLineNumber === b.startLineNumber) {
  9701. return a.startColumn - b.startColumn;
  9702. }
  9703. return a.startLineNumber - b.startLineNumber;
  9704. }
  9705. return a.endColumn - b.endColumn;
  9706. }
  9707. return a.endLineNumber - b.endLineNumber;
  9708. }
  9709. /**
  9710. * Test if the range spans multiple lines.
  9711. */
  9712. static spansMultipleLines(range) {
  9713. return range.endLineNumber > range.startLineNumber;
  9714. }
  9715. }
  9716. exports.Range = Range;
  9717. });
  9718. /*---------------------------------------------------------------------------------------------
  9719. * Copyright (c) Microsoft Corporation. All rights reserved.
  9720. * Licensed under the MIT License. See License.txt in the project root for license information.
  9721. *--------------------------------------------------------------------------------------------*/
  9722. define(__m[27/*vs/editor/common/core/selection*/], __M([0/*require*/,1/*exports*/,4/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/]), function (require, exports, position_1, range_1) {
  9723. "use strict";
  9724. Object.defineProperty(exports, "__esModule", { value: true });
  9725. exports.Selection = void 0;
  9726. /**
  9727. * A selection in the editor.
  9728. * The selection is a range that has an orientation.
  9729. */
  9730. class Selection extends range_1.Range {
  9731. constructor(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) {
  9732. super(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn);
  9733. this.selectionStartLineNumber = selectionStartLineNumber;
  9734. this.selectionStartColumn = selectionStartColumn;
  9735. this.positionLineNumber = positionLineNumber;
  9736. this.positionColumn = positionColumn;
  9737. }
  9738. /**
  9739. * Transform to a human-readable representation.
  9740. */
  9741. toString() {
  9742. return '[' + this.selectionStartLineNumber + ',' + this.selectionStartColumn + ' -> ' + this.positionLineNumber + ',' + this.positionColumn + ']';
  9743. }
  9744. /**
  9745. * Test if equals other selection.
  9746. */
  9747. equalsSelection(other) {
  9748. return (Selection.selectionsEqual(this, other));
  9749. }
  9750. /**
  9751. * Test if the two selections are equal.
  9752. */
  9753. static selectionsEqual(a, b) {
  9754. return (a.selectionStartLineNumber === b.selectionStartLineNumber &&
  9755. a.selectionStartColumn === b.selectionStartColumn &&
  9756. a.positionLineNumber === b.positionLineNumber &&
  9757. a.positionColumn === b.positionColumn);
  9758. }
  9759. /**
  9760. * Get directions (LTR or RTL).
  9761. */
  9762. getDirection() {
  9763. if (this.selectionStartLineNumber === this.startLineNumber && this.selectionStartColumn === this.startColumn) {
  9764. return 0 /* LTR */;
  9765. }
  9766. return 1 /* RTL */;
  9767. }
  9768. /**
  9769. * Create a new selection with a different `positionLineNumber` and `positionColumn`.
  9770. */
  9771. setEndPosition(endLineNumber, endColumn) {
  9772. if (this.getDirection() === 0 /* LTR */) {
  9773. return new Selection(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  9774. }
  9775. return new Selection(endLineNumber, endColumn, this.startLineNumber, this.startColumn);
  9776. }
  9777. /**
  9778. * Get the position at `positionLineNumber` and `positionColumn`.
  9779. */
  9780. getPosition() {
  9781. return new position_1.Position(this.positionLineNumber, this.positionColumn);
  9782. }
  9783. /**
  9784. * Get the position at the start of the selection.
  9785. */
  9786. getSelectionStart() {
  9787. return new position_1.Position(this.selectionStartLineNumber, this.selectionStartColumn);
  9788. }
  9789. /**
  9790. * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
  9791. */
  9792. setStartPosition(startLineNumber, startColumn) {
  9793. if (this.getDirection() === 0 /* LTR */) {
  9794. return new Selection(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  9795. }
  9796. return new Selection(this.endLineNumber, this.endColumn, startLineNumber, startColumn);
  9797. }
  9798. // ----
  9799. /**
  9800. * Create a `Selection` from one or two positions
  9801. */
  9802. static fromPositions(start, end = start) {
  9803. return new Selection(start.lineNumber, start.column, end.lineNumber, end.column);
  9804. }
  9805. /**
  9806. * Creates a `Selection` from a range, given a direction.
  9807. */
  9808. static fromRange(range, direction) {
  9809. if (direction === 0 /* LTR */) {
  9810. return new Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  9811. }
  9812. else {
  9813. return new Selection(range.endLineNumber, range.endColumn, range.startLineNumber, range.startColumn);
  9814. }
  9815. }
  9816. /**
  9817. * Create a `Selection` from an `ISelection`.
  9818. */
  9819. static liftSelection(sel) {
  9820. return new Selection(sel.selectionStartLineNumber, sel.selectionStartColumn, sel.positionLineNumber, sel.positionColumn);
  9821. }
  9822. /**
  9823. * `a` equals `b`.
  9824. */
  9825. static selectionsArrEqual(a, b) {
  9826. if (a && !b || !a && b) {
  9827. return false;
  9828. }
  9829. if (!a && !b) {
  9830. return true;
  9831. }
  9832. if (a.length !== b.length) {
  9833. return false;
  9834. }
  9835. for (let i = 0, len = a.length; i < len; i++) {
  9836. if (!this.selectionsEqual(a[i], b[i])) {
  9837. return false;
  9838. }
  9839. }
  9840. return true;
  9841. }
  9842. /**
  9843. * Test if `obj` is an `ISelection`.
  9844. */
  9845. static isISelection(obj) {
  9846. return (obj
  9847. && (typeof obj.selectionStartLineNumber === 'number')
  9848. && (typeof obj.selectionStartColumn === 'number')
  9849. && (typeof obj.positionLineNumber === 'number')
  9850. && (typeof obj.positionColumn === 'number'));
  9851. }
  9852. /**
  9853. * Create with a direction.
  9854. */
  9855. static createWithDirection(startLineNumber, startColumn, endLineNumber, endColumn, direction) {
  9856. if (direction === 0 /* LTR */) {
  9857. return new Selection(startLineNumber, startColumn, endLineNumber, endColumn);
  9858. }
  9859. return new Selection(endLineNumber, endColumn, startLineNumber, startColumn);
  9860. }
  9861. }
  9862. exports.Selection = Selection;
  9863. });
  9864. /*---------------------------------------------------------------------------------------------
  9865. * Copyright (c) Microsoft Corporation. All rights reserved.
  9866. * Licensed under the MIT License. See License.txt in the project root for license information.
  9867. *--------------------------------------------------------------------------------------------*/
  9868. define(__m[28/*vs/editor/common/core/token*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  9869. "use strict";
  9870. Object.defineProperty(exports, "__esModule", { value: true });
  9871. exports.TokenizationResult2 = exports.TokenizationResult = exports.Token = void 0;
  9872. class Token {
  9873. constructor(offset, type, language) {
  9874. this._tokenBrand = undefined;
  9875. this.offset = offset;
  9876. this.type = type;
  9877. this.language = language;
  9878. }
  9879. toString() {
  9880. return '(' + this.offset + ', ' + this.type + ')';
  9881. }
  9882. }
  9883. exports.Token = Token;
  9884. class TokenizationResult {
  9885. constructor(tokens, endState) {
  9886. this._tokenizationResultBrand = undefined;
  9887. this.tokens = tokens;
  9888. this.endState = endState;
  9889. }
  9890. }
  9891. exports.TokenizationResult = TokenizationResult;
  9892. class TokenizationResult2 {
  9893. constructor(tokens, endState) {
  9894. this._tokenizationResult2Brand = undefined;
  9895. this.tokens = tokens;
  9896. this.endState = endState;
  9897. }
  9898. }
  9899. exports.TokenizationResult2 = TokenizationResult2;
  9900. });
  9901. /*---------------------------------------------------------------------------------------------
  9902. * Copyright (c) Microsoft Corporation. All rights reserved.
  9903. * Licensed under the MIT License. See License.txt in the project root for license information.
  9904. *--------------------------------------------------------------------------------------------*/
  9905. define(__m[29/*vs/editor/common/diff/diffComputer*/], __M([0/*require*/,1/*exports*/,11/*vs/base/common/diff/diff*/,3/*vs/base/common/strings*/]), function (require, exports, diff_1, strings) {
  9906. "use strict";
  9907. Object.defineProperty(exports, "__esModule", { value: true });
  9908. exports.DiffComputer = void 0;
  9909. const MINIMUM_MATCHING_CHARACTER_LENGTH = 3;
  9910. function computeDiff(originalSequence, modifiedSequence, continueProcessingPredicate, pretty) {
  9911. const diffAlgo = new diff_1.LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate);
  9912. return diffAlgo.ComputeDiff(pretty);
  9913. }
  9914. class LineSequence {
  9915. constructor(lines) {
  9916. const startColumns = [];
  9917. const endColumns = [];
  9918. for (let i = 0, length = lines.length; i < length; i++) {
  9919. startColumns[i] = getFirstNonBlankColumn(lines[i], 1);
  9920. endColumns[i] = getLastNonBlankColumn(lines[i], 1);
  9921. }
  9922. this.lines = lines;
  9923. this._startColumns = startColumns;
  9924. this._endColumns = endColumns;
  9925. }
  9926. getElements() {
  9927. const elements = [];
  9928. for (let i = 0, len = this.lines.length; i < len; i++) {
  9929. elements[i] = this.lines[i].substring(this._startColumns[i] - 1, this._endColumns[i] - 1);
  9930. }
  9931. return elements;
  9932. }
  9933. getStrictElement(index) {
  9934. return this.lines[index];
  9935. }
  9936. getStartLineNumber(i) {
  9937. return i + 1;
  9938. }
  9939. getEndLineNumber(i) {
  9940. return i + 1;
  9941. }
  9942. createCharSequence(shouldIgnoreTrimWhitespace, startIndex, endIndex) {
  9943. const charCodes = [];
  9944. const lineNumbers = [];
  9945. const columns = [];
  9946. let len = 0;
  9947. for (let index = startIndex; index <= endIndex; index++) {
  9948. const lineContent = this.lines[index];
  9949. const startColumn = (shouldIgnoreTrimWhitespace ? this._startColumns[index] : 1);
  9950. const endColumn = (shouldIgnoreTrimWhitespace ? this._endColumns[index] : lineContent.length + 1);
  9951. for (let col = startColumn; col < endColumn; col++) {
  9952. charCodes[len] = lineContent.charCodeAt(col - 1);
  9953. lineNumbers[len] = index + 1;
  9954. columns[len] = col;
  9955. len++;
  9956. }
  9957. }
  9958. return new CharSequence(charCodes, lineNumbers, columns);
  9959. }
  9960. }
  9961. class CharSequence {
  9962. constructor(charCodes, lineNumbers, columns) {
  9963. this._charCodes = charCodes;
  9964. this._lineNumbers = lineNumbers;
  9965. this._columns = columns;
  9966. }
  9967. getElements() {
  9968. return this._charCodes;
  9969. }
  9970. getStartLineNumber(i) {
  9971. return this._lineNumbers[i];
  9972. }
  9973. getStartColumn(i) {
  9974. return this._columns[i];
  9975. }
  9976. getEndLineNumber(i) {
  9977. return this._lineNumbers[i];
  9978. }
  9979. getEndColumn(i) {
  9980. return this._columns[i] + 1;
  9981. }
  9982. }
  9983. class CharChange {
  9984. constructor(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn) {
  9985. this.originalStartLineNumber = originalStartLineNumber;
  9986. this.originalStartColumn = originalStartColumn;
  9987. this.originalEndLineNumber = originalEndLineNumber;
  9988. this.originalEndColumn = originalEndColumn;
  9989. this.modifiedStartLineNumber = modifiedStartLineNumber;
  9990. this.modifiedStartColumn = modifiedStartColumn;
  9991. this.modifiedEndLineNumber = modifiedEndLineNumber;
  9992. this.modifiedEndColumn = modifiedEndColumn;
  9993. }
  9994. static createFromDiffChange(diffChange, originalCharSequence, modifiedCharSequence) {
  9995. let originalStartLineNumber;
  9996. let originalStartColumn;
  9997. let originalEndLineNumber;
  9998. let originalEndColumn;
  9999. let modifiedStartLineNumber;
  10000. let modifiedStartColumn;
  10001. let modifiedEndLineNumber;
  10002. let modifiedEndColumn;
  10003. if (diffChange.originalLength === 0) {
  10004. originalStartLineNumber = 0;
  10005. originalStartColumn = 0;
  10006. originalEndLineNumber = 0;
  10007. originalEndColumn = 0;
  10008. }
  10009. else {
  10010. originalStartLineNumber = originalCharSequence.getStartLineNumber(diffChange.originalStart);
  10011. originalStartColumn = originalCharSequence.getStartColumn(diffChange.originalStart);
  10012. originalEndLineNumber = originalCharSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  10013. originalEndColumn = originalCharSequence.getEndColumn(diffChange.originalStart + diffChange.originalLength - 1);
  10014. }
  10015. if (diffChange.modifiedLength === 0) {
  10016. modifiedStartLineNumber = 0;
  10017. modifiedStartColumn = 0;
  10018. modifiedEndLineNumber = 0;
  10019. modifiedEndColumn = 0;
  10020. }
  10021. else {
  10022. modifiedStartLineNumber = modifiedCharSequence.getStartLineNumber(diffChange.modifiedStart);
  10023. modifiedStartColumn = modifiedCharSequence.getStartColumn(diffChange.modifiedStart);
  10024. modifiedEndLineNumber = modifiedCharSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  10025. modifiedEndColumn = modifiedCharSequence.getEndColumn(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  10026. }
  10027. return new CharChange(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn);
  10028. }
  10029. }
  10030. function postProcessCharChanges(rawChanges) {
  10031. if (rawChanges.length <= 1) {
  10032. return rawChanges;
  10033. }
  10034. const result = [rawChanges[0]];
  10035. let prevChange = result[0];
  10036. for (let i = 1, len = rawChanges.length; i < len; i++) {
  10037. const currChange = rawChanges[i];
  10038. const originalMatchingLength = currChange.originalStart - (prevChange.originalStart + prevChange.originalLength);
  10039. const modifiedMatchingLength = currChange.modifiedStart - (prevChange.modifiedStart + prevChange.modifiedLength);
  10040. // Both of the above should be equal, but the continueProcessingPredicate may prevent this from being true
  10041. const matchingLength = Math.min(originalMatchingLength, modifiedMatchingLength);
  10042. if (matchingLength < MINIMUM_MATCHING_CHARACTER_LENGTH) {
  10043. // Merge the current change into the previous one
  10044. prevChange.originalLength = (currChange.originalStart + currChange.originalLength) - prevChange.originalStart;
  10045. prevChange.modifiedLength = (currChange.modifiedStart + currChange.modifiedLength) - prevChange.modifiedStart;
  10046. }
  10047. else {
  10048. // Add the current change
  10049. result.push(currChange);
  10050. prevChange = currChange;
  10051. }
  10052. }
  10053. return result;
  10054. }
  10055. class LineChange {
  10056. constructor(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges) {
  10057. this.originalStartLineNumber = originalStartLineNumber;
  10058. this.originalEndLineNumber = originalEndLineNumber;
  10059. this.modifiedStartLineNumber = modifiedStartLineNumber;
  10060. this.modifiedEndLineNumber = modifiedEndLineNumber;
  10061. this.charChanges = charChanges;
  10062. }
  10063. static createFromDiffResult(shouldIgnoreTrimWhitespace, diffChange, originalLineSequence, modifiedLineSequence, continueCharDiff, shouldComputeCharChanges, shouldPostProcessCharChanges) {
  10064. let originalStartLineNumber;
  10065. let originalEndLineNumber;
  10066. let modifiedStartLineNumber;
  10067. let modifiedEndLineNumber;
  10068. let charChanges = undefined;
  10069. if (diffChange.originalLength === 0) {
  10070. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart) - 1;
  10071. originalEndLineNumber = 0;
  10072. }
  10073. else {
  10074. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart);
  10075. originalEndLineNumber = originalLineSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  10076. }
  10077. if (diffChange.modifiedLength === 0) {
  10078. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart) - 1;
  10079. modifiedEndLineNumber = 0;
  10080. }
  10081. else {
  10082. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart);
  10083. modifiedEndLineNumber = modifiedLineSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  10084. }
  10085. if (shouldComputeCharChanges && diffChange.originalLength > 0 && diffChange.originalLength < 20 && diffChange.modifiedLength > 0 && diffChange.modifiedLength < 20 && continueCharDiff()) {
  10086. // Compute character changes for diff chunks of at most 20 lines...
  10087. const originalCharSequence = originalLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength - 1);
  10088. const modifiedCharSequence = modifiedLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength - 1);
  10089. let rawChanges = computeDiff(originalCharSequence, modifiedCharSequence, continueCharDiff, true).changes;
  10090. if (shouldPostProcessCharChanges) {
  10091. rawChanges = postProcessCharChanges(rawChanges);
  10092. }
  10093. charChanges = [];
  10094. for (let i = 0, length = rawChanges.length; i < length; i++) {
  10095. charChanges.push(CharChange.createFromDiffChange(rawChanges[i], originalCharSequence, modifiedCharSequence));
  10096. }
  10097. }
  10098. return new LineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges);
  10099. }
  10100. }
  10101. class DiffComputer {
  10102. constructor(originalLines, modifiedLines, opts) {
  10103. this.shouldComputeCharChanges = opts.shouldComputeCharChanges;
  10104. this.shouldPostProcessCharChanges = opts.shouldPostProcessCharChanges;
  10105. this.shouldIgnoreTrimWhitespace = opts.shouldIgnoreTrimWhitespace;
  10106. this.shouldMakePrettyDiff = opts.shouldMakePrettyDiff;
  10107. this.originalLines = originalLines;
  10108. this.modifiedLines = modifiedLines;
  10109. this.original = new LineSequence(originalLines);
  10110. this.modified = new LineSequence(modifiedLines);
  10111. this.continueLineDiff = createContinueProcessingPredicate(opts.maxComputationTime);
  10112. this.continueCharDiff = createContinueProcessingPredicate(opts.maxComputationTime === 0 ? 0 : Math.min(opts.maxComputationTime, 5000)); // never run after 5s for character changes...
  10113. }
  10114. computeDiff() {
  10115. if (this.original.lines.length === 1 && this.original.lines[0].length === 0) {
  10116. // empty original => fast path
  10117. if (this.modified.lines.length === 1 && this.modified.lines[0].length === 0) {
  10118. return {
  10119. quitEarly: false,
  10120. changes: []
  10121. };
  10122. }
  10123. return {
  10124. quitEarly: false,
  10125. changes: [{
  10126. originalStartLineNumber: 1,
  10127. originalEndLineNumber: 1,
  10128. modifiedStartLineNumber: 1,
  10129. modifiedEndLineNumber: this.modified.lines.length,
  10130. charChanges: [{
  10131. modifiedEndColumn: 0,
  10132. modifiedEndLineNumber: 0,
  10133. modifiedStartColumn: 0,
  10134. modifiedStartLineNumber: 0,
  10135. originalEndColumn: 0,
  10136. originalEndLineNumber: 0,
  10137. originalStartColumn: 0,
  10138. originalStartLineNumber: 0
  10139. }]
  10140. }]
  10141. };
  10142. }
  10143. if (this.modified.lines.length === 1 && this.modified.lines[0].length === 0) {
  10144. // empty modified => fast path
  10145. return {
  10146. quitEarly: false,
  10147. changes: [{
  10148. originalStartLineNumber: 1,
  10149. originalEndLineNumber: this.original.lines.length,
  10150. modifiedStartLineNumber: 1,
  10151. modifiedEndLineNumber: 1,
  10152. charChanges: [{
  10153. modifiedEndColumn: 0,
  10154. modifiedEndLineNumber: 0,
  10155. modifiedStartColumn: 0,
  10156. modifiedStartLineNumber: 0,
  10157. originalEndColumn: 0,
  10158. originalEndLineNumber: 0,
  10159. originalStartColumn: 0,
  10160. originalStartLineNumber: 0
  10161. }]
  10162. }]
  10163. };
  10164. }
  10165. const diffResult = computeDiff(this.original, this.modified, this.continueLineDiff, this.shouldMakePrettyDiff);
  10166. const rawChanges = diffResult.changes;
  10167. const quitEarly = diffResult.quitEarly;
  10168. // The diff is always computed with ignoring trim whitespace
  10169. // This ensures we get the prettiest diff
  10170. if (this.shouldIgnoreTrimWhitespace) {
  10171. const lineChanges = [];
  10172. for (let i = 0, length = rawChanges.length; i < length; i++) {
  10173. lineChanges.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, rawChanges[i], this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  10174. }
  10175. return {
  10176. quitEarly: quitEarly,
  10177. changes: lineChanges
  10178. };
  10179. }
  10180. // Need to post-process and introduce changes where the trim whitespace is different
  10181. // Note that we are looping starting at -1 to also cover the lines before the first change
  10182. const result = [];
  10183. let originalLineIndex = 0;
  10184. let modifiedLineIndex = 0;
  10185. for (let i = -1 /* !!!! */, len = rawChanges.length; i < len; i++) {
  10186. const nextChange = (i + 1 < len ? rawChanges[i + 1] : null);
  10187. const originalStop = (nextChange ? nextChange.originalStart : this.originalLines.length);
  10188. const modifiedStop = (nextChange ? nextChange.modifiedStart : this.modifiedLines.length);
  10189. while (originalLineIndex < originalStop && modifiedLineIndex < modifiedStop) {
  10190. const originalLine = this.originalLines[originalLineIndex];
  10191. const modifiedLine = this.modifiedLines[modifiedLineIndex];
  10192. if (originalLine !== modifiedLine) {
  10193. // These lines differ only in trim whitespace
  10194. // Check the leading whitespace
  10195. {
  10196. let originalStartColumn = getFirstNonBlankColumn(originalLine, 1);
  10197. let modifiedStartColumn = getFirstNonBlankColumn(modifiedLine, 1);
  10198. while (originalStartColumn > 1 && modifiedStartColumn > 1) {
  10199. const originalChar = originalLine.charCodeAt(originalStartColumn - 2);
  10200. const modifiedChar = modifiedLine.charCodeAt(modifiedStartColumn - 2);
  10201. if (originalChar !== modifiedChar) {
  10202. break;
  10203. }
  10204. originalStartColumn--;
  10205. modifiedStartColumn--;
  10206. }
  10207. if (originalStartColumn > 1 || modifiedStartColumn > 1) {
  10208. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, 1, originalStartColumn, modifiedLineIndex + 1, 1, modifiedStartColumn);
  10209. }
  10210. }
  10211. // Check the trailing whitespace
  10212. {
  10213. let originalEndColumn = getLastNonBlankColumn(originalLine, 1);
  10214. let modifiedEndColumn = getLastNonBlankColumn(modifiedLine, 1);
  10215. const originalMaxColumn = originalLine.length + 1;
  10216. const modifiedMaxColumn = modifiedLine.length + 1;
  10217. while (originalEndColumn < originalMaxColumn && modifiedEndColumn < modifiedMaxColumn) {
  10218. const originalChar = originalLine.charCodeAt(originalEndColumn - 1);
  10219. const modifiedChar = originalLine.charCodeAt(modifiedEndColumn - 1);
  10220. if (originalChar !== modifiedChar) {
  10221. break;
  10222. }
  10223. originalEndColumn++;
  10224. modifiedEndColumn++;
  10225. }
  10226. if (originalEndColumn < originalMaxColumn || modifiedEndColumn < modifiedMaxColumn) {
  10227. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, originalEndColumn, originalMaxColumn, modifiedLineIndex + 1, modifiedEndColumn, modifiedMaxColumn);
  10228. }
  10229. }
  10230. }
  10231. originalLineIndex++;
  10232. modifiedLineIndex++;
  10233. }
  10234. if (nextChange) {
  10235. // Emit the actual change
  10236. result.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, nextChange, this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  10237. originalLineIndex += nextChange.originalLength;
  10238. modifiedLineIndex += nextChange.modifiedLength;
  10239. }
  10240. }
  10241. return {
  10242. quitEarly: quitEarly,
  10243. changes: result
  10244. };
  10245. }
  10246. _pushTrimWhitespaceCharChange(result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  10247. if (this._mergeTrimWhitespaceCharChange(result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn)) {
  10248. // Merged into previous
  10249. return;
  10250. }
  10251. let charChanges = undefined;
  10252. if (this.shouldComputeCharChanges) {
  10253. charChanges = [new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn)];
  10254. }
  10255. result.push(new LineChange(originalLineNumber, originalLineNumber, modifiedLineNumber, modifiedLineNumber, charChanges));
  10256. }
  10257. _mergeTrimWhitespaceCharChange(result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  10258. const len = result.length;
  10259. if (len === 0) {
  10260. return false;
  10261. }
  10262. const prevChange = result[len - 1];
  10263. if (prevChange.originalEndLineNumber === 0 || prevChange.modifiedEndLineNumber === 0) {
  10264. // Don't merge with inserts/deletes
  10265. return false;
  10266. }
  10267. if (prevChange.originalEndLineNumber + 1 === originalLineNumber && prevChange.modifiedEndLineNumber + 1 === modifiedLineNumber) {
  10268. prevChange.originalEndLineNumber = originalLineNumber;
  10269. prevChange.modifiedEndLineNumber = modifiedLineNumber;
  10270. if (this.shouldComputeCharChanges && prevChange.charChanges) {
  10271. prevChange.charChanges.push(new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn));
  10272. }
  10273. return true;
  10274. }
  10275. return false;
  10276. }
  10277. }
  10278. exports.DiffComputer = DiffComputer;
  10279. function getFirstNonBlankColumn(txt, defaultValue) {
  10280. const r = strings.firstNonWhitespaceIndex(txt);
  10281. if (r === -1) {
  10282. return defaultValue;
  10283. }
  10284. return r + 1;
  10285. }
  10286. function getLastNonBlankColumn(txt, defaultValue) {
  10287. const r = strings.lastNonWhitespaceIndex(txt);
  10288. if (r === -1) {
  10289. return defaultValue;
  10290. }
  10291. return r + 2;
  10292. }
  10293. function createContinueProcessingPredicate(maximumRuntime) {
  10294. if (maximumRuntime === 0) {
  10295. return () => true;
  10296. }
  10297. const startTime = Date.now();
  10298. return () => {
  10299. return Date.now() - startTime < maximumRuntime;
  10300. };
  10301. }
  10302. });
  10303. define(__m[30/*vs/editor/common/model*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/objects*/]), function (require, exports, objects_1) {
  10304. "use strict";
  10305. Object.defineProperty(exports, "__esModule", { value: true });
  10306. exports.ApplyEditsResult = exports.ValidAnnotatedEditOperation = exports.IndentGuideHorizontalLine = exports.IndentGuide = exports.HorizontalGuidesState = exports.FindMatch = exports.TextModelResolvedOptions = exports.MinimapPosition = exports.OverviewRulerLane = void 0;
  10307. /**
  10308. * Vertical Lane in the overview ruler of the editor.
  10309. */
  10310. var OverviewRulerLane;
  10311. (function (OverviewRulerLane) {
  10312. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  10313. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  10314. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  10315. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  10316. })(OverviewRulerLane = exports.OverviewRulerLane || (exports.OverviewRulerLane = {}));
  10317. /**
  10318. * Position in the minimap to render the decoration.
  10319. */
  10320. var MinimapPosition;
  10321. (function (MinimapPosition) {
  10322. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  10323. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  10324. })(MinimapPosition = exports.MinimapPosition || (exports.MinimapPosition = {}));
  10325. class TextModelResolvedOptions {
  10326. /**
  10327. * @internal
  10328. */
  10329. constructor(src) {
  10330. this._textModelResolvedOptionsBrand = undefined;
  10331. this.tabSize = Math.max(1, src.tabSize | 0);
  10332. this.indentSize = src.tabSize | 0;
  10333. this.insertSpaces = Boolean(src.insertSpaces);
  10334. this.defaultEOL = src.defaultEOL | 0;
  10335. this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
  10336. this.bracketPairColorizationOptions = src.bracketPairColorizationOptions;
  10337. }
  10338. /**
  10339. * @internal
  10340. */
  10341. equals(other) {
  10342. return (this.tabSize === other.tabSize
  10343. && this.indentSize === other.indentSize
  10344. && this.insertSpaces === other.insertSpaces
  10345. && this.defaultEOL === other.defaultEOL
  10346. && this.trimAutoWhitespace === other.trimAutoWhitespace
  10347. && (0, objects_1.equals)(this.bracketPairColorizationOptions, other.bracketPairColorizationOptions));
  10348. }
  10349. /**
  10350. * @internal
  10351. */
  10352. createChangeEvent(newOpts) {
  10353. return {
  10354. tabSize: this.tabSize !== newOpts.tabSize,
  10355. indentSize: this.indentSize !== newOpts.indentSize,
  10356. insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
  10357. trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
  10358. };
  10359. }
  10360. }
  10361. exports.TextModelResolvedOptions = TextModelResolvedOptions;
  10362. class FindMatch {
  10363. /**
  10364. * @internal
  10365. */
  10366. constructor(range, matches) {
  10367. this._findMatchBrand = undefined;
  10368. this.range = range;
  10369. this.matches = matches;
  10370. }
  10371. }
  10372. exports.FindMatch = FindMatch;
  10373. /**
  10374. * @internal
  10375. */
  10376. var HorizontalGuidesState;
  10377. (function (HorizontalGuidesState) {
  10378. HorizontalGuidesState[HorizontalGuidesState["Disabled"] = 0] = "Disabled";
  10379. HorizontalGuidesState[HorizontalGuidesState["EnabledForActive"] = 1] = "EnabledForActive";
  10380. HorizontalGuidesState[HorizontalGuidesState["Enabled"] = 2] = "Enabled";
  10381. })(HorizontalGuidesState = exports.HorizontalGuidesState || (exports.HorizontalGuidesState = {}));
  10382. /**
  10383. * @internal
  10384. */
  10385. class IndentGuide {
  10386. constructor(visibleColumn, className,
  10387. /**
  10388. * If set, this indent guide is a horizontal guide (no vertical part).
  10389. * It starts at visibleColumn and continues until endColumn.
  10390. */
  10391. horizontalLine) {
  10392. this.visibleColumn = visibleColumn;
  10393. this.className = className;
  10394. this.horizontalLine = horizontalLine;
  10395. }
  10396. }
  10397. exports.IndentGuide = IndentGuide;
  10398. /**
  10399. * @internal
  10400. */
  10401. class IndentGuideHorizontalLine {
  10402. constructor(top, endColumn) {
  10403. this.top = top;
  10404. this.endColumn = endColumn;
  10405. }
  10406. }
  10407. exports.IndentGuideHorizontalLine = IndentGuideHorizontalLine;
  10408. /**
  10409. * @internal
  10410. */
  10411. class ValidAnnotatedEditOperation {
  10412. constructor(identifier, range, text, forceMoveMarkers, isAutoWhitespaceEdit, _isTracked) {
  10413. this.identifier = identifier;
  10414. this.range = range;
  10415. this.text = text;
  10416. this.forceMoveMarkers = forceMoveMarkers;
  10417. this.isAutoWhitespaceEdit = isAutoWhitespaceEdit;
  10418. this._isTracked = _isTracked;
  10419. }
  10420. }
  10421. exports.ValidAnnotatedEditOperation = ValidAnnotatedEditOperation;
  10422. /**
  10423. * @internal
  10424. */
  10425. class ApplyEditsResult {
  10426. constructor(reverseEdits, changes, trimAutoWhitespaceLineNumbers) {
  10427. this.reverseEdits = reverseEdits;
  10428. this.changes = changes;
  10429. this.trimAutoWhitespaceLineNumbers = trimAutoWhitespaceLineNumbers;
  10430. }
  10431. }
  10432. exports.ApplyEditsResult = ApplyEditsResult;
  10433. });
  10434. /*---------------------------------------------------------------------------------------------
  10435. * Copyright (c) Microsoft Corporation. All rights reserved.
  10436. * Licensed under the MIT License. See License.txt in the project root for license information.
  10437. *--------------------------------------------------------------------------------------------*/
  10438. define(__m[31/*vs/editor/common/model/textModelSearch*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/strings*/,26/*vs/editor/common/controller/wordCharacterClassifier*/,4/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/,30/*vs/editor/common/model*/]), function (require, exports, strings, wordCharacterClassifier_1, position_1, range_1, model_1) {
  10439. "use strict";
  10440. Object.defineProperty(exports, "__esModule", { value: true });
  10441. exports.Searcher = exports.isValidMatch = exports.TextModelSearch = exports.createFindMatch = exports.SearchData = exports.isMultilineRegexSource = exports.SearchParams = void 0;
  10442. const LIMIT_FIND_COUNT = 999;
  10443. class SearchParams {
  10444. constructor(searchString, isRegex, matchCase, wordSeparators) {
  10445. this.searchString = searchString;
  10446. this.isRegex = isRegex;
  10447. this.matchCase = matchCase;
  10448. this.wordSeparators = wordSeparators;
  10449. }
  10450. parseSearchRequest() {
  10451. if (this.searchString === '') {
  10452. return null;
  10453. }
  10454. // Try to create a RegExp out of the params
  10455. let multiline;
  10456. if (this.isRegex) {
  10457. multiline = isMultilineRegexSource(this.searchString);
  10458. }
  10459. else {
  10460. multiline = (this.searchString.indexOf('\n') >= 0);
  10461. }
  10462. let regex = null;
  10463. try {
  10464. regex = strings.createRegExp(this.searchString, this.isRegex, {
  10465. matchCase: this.matchCase,
  10466. wholeWord: false,
  10467. multiline: multiline,
  10468. global: true,
  10469. unicode: true
  10470. });
  10471. }
  10472. catch (err) {
  10473. return null;
  10474. }
  10475. if (!regex) {
  10476. return null;
  10477. }
  10478. let canUseSimpleSearch = (!this.isRegex && !multiline);
  10479. if (canUseSimpleSearch && this.searchString.toLowerCase() !== this.searchString.toUpperCase()) {
  10480. // casing might make a difference
  10481. canUseSimpleSearch = this.matchCase;
  10482. }
  10483. return new SearchData(regex, this.wordSeparators ? (0, wordCharacterClassifier_1.getMapForWordSeparators)(this.wordSeparators) : null, canUseSimpleSearch ? this.searchString : null);
  10484. }
  10485. }
  10486. exports.SearchParams = SearchParams;
  10487. function isMultilineRegexSource(searchString) {
  10488. if (!searchString || searchString.length === 0) {
  10489. return false;
  10490. }
  10491. for (let i = 0, len = searchString.length; i < len; i++) {
  10492. const chCode = searchString.charCodeAt(i);
  10493. if (chCode === 92 /* Backslash */) {
  10494. // move to next char
  10495. i++;
  10496. if (i >= len) {
  10497. // string ends with a \
  10498. break;
  10499. }
  10500. const nextChCode = searchString.charCodeAt(i);
  10501. if (nextChCode === 110 /* n */ || nextChCode === 114 /* r */ || nextChCode === 87 /* W */) {
  10502. return true;
  10503. }
  10504. }
  10505. }
  10506. return false;
  10507. }
  10508. exports.isMultilineRegexSource = isMultilineRegexSource;
  10509. class SearchData {
  10510. constructor(regex, wordSeparators, simpleSearch) {
  10511. this.regex = regex;
  10512. this.wordSeparators = wordSeparators;
  10513. this.simpleSearch = simpleSearch;
  10514. }
  10515. }
  10516. exports.SearchData = SearchData;
  10517. function createFindMatch(range, rawMatches, captureMatches) {
  10518. if (!captureMatches) {
  10519. return new model_1.FindMatch(range, null);
  10520. }
  10521. let matches = [];
  10522. for (let i = 0, len = rawMatches.length; i < len; i++) {
  10523. matches[i] = rawMatches[i];
  10524. }
  10525. return new model_1.FindMatch(range, matches);
  10526. }
  10527. exports.createFindMatch = createFindMatch;
  10528. class LineFeedCounter {
  10529. constructor(text) {
  10530. let lineFeedsOffsets = [];
  10531. let lineFeedsOffsetsLen = 0;
  10532. for (let i = 0, textLen = text.length; i < textLen; i++) {
  10533. if (text.charCodeAt(i) === 10 /* LineFeed */) {
  10534. lineFeedsOffsets[lineFeedsOffsetsLen++] = i;
  10535. }
  10536. }
  10537. this._lineFeedsOffsets = lineFeedsOffsets;
  10538. }
  10539. findLineFeedCountBeforeOffset(offset) {
  10540. const lineFeedsOffsets = this._lineFeedsOffsets;
  10541. let min = 0;
  10542. let max = lineFeedsOffsets.length - 1;
  10543. if (max === -1) {
  10544. // no line feeds
  10545. return 0;
  10546. }
  10547. if (offset <= lineFeedsOffsets[0]) {
  10548. // before first line feed
  10549. return 0;
  10550. }
  10551. while (min < max) {
  10552. const mid = min + ((max - min) / 2 >> 0);
  10553. if (lineFeedsOffsets[mid] >= offset) {
  10554. max = mid - 1;
  10555. }
  10556. else {
  10557. if (lineFeedsOffsets[mid + 1] >= offset) {
  10558. // bingo!
  10559. min = mid;
  10560. max = mid;
  10561. }
  10562. else {
  10563. min = mid + 1;
  10564. }
  10565. }
  10566. }
  10567. return min + 1;
  10568. }
  10569. }
  10570. class TextModelSearch {
  10571. static findMatches(model, searchParams, searchRange, captureMatches, limitResultCount) {
  10572. const searchData = searchParams.parseSearchRequest();
  10573. if (!searchData) {
  10574. return [];
  10575. }
  10576. if (searchData.regex.multiline) {
  10577. return this._doFindMatchesMultiline(model, searchRange, new Searcher(searchData.wordSeparators, searchData.regex), captureMatches, limitResultCount);
  10578. }
  10579. return this._doFindMatchesLineByLine(model, searchRange, searchData, captureMatches, limitResultCount);
  10580. }
  10581. /**
  10582. * Multiline search always executes on the lines concatenated with \n.
  10583. * We must therefore compensate for the count of \n in case the model is CRLF
  10584. */
  10585. static _getMultilineMatchRange(model, deltaOffset, text, lfCounter, matchIndex, match0) {
  10586. let startOffset;
  10587. let lineFeedCountBeforeMatch = 0;
  10588. if (lfCounter) {
  10589. lineFeedCountBeforeMatch = lfCounter.findLineFeedCountBeforeOffset(matchIndex);
  10590. startOffset = deltaOffset + matchIndex + lineFeedCountBeforeMatch /* add as many \r as there were \n */;
  10591. }
  10592. else {
  10593. startOffset = deltaOffset + matchIndex;
  10594. }
  10595. let endOffset;
  10596. if (lfCounter) {
  10597. let lineFeedCountBeforeEndOfMatch = lfCounter.findLineFeedCountBeforeOffset(matchIndex + match0.length);
  10598. let lineFeedCountInMatch = lineFeedCountBeforeEndOfMatch - lineFeedCountBeforeMatch;
  10599. endOffset = startOffset + match0.length + lineFeedCountInMatch /* add as many \r as there were \n */;
  10600. }
  10601. else {
  10602. endOffset = startOffset + match0.length;
  10603. }
  10604. const startPosition = model.getPositionAt(startOffset);
  10605. const endPosition = model.getPositionAt(endOffset);
  10606. return new range_1.Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column);
  10607. }
  10608. static _doFindMatchesMultiline(model, searchRange, searcher, captureMatches, limitResultCount) {
  10609. const deltaOffset = model.getOffsetAt(searchRange.getStartPosition());
  10610. // We always execute multiline search over the lines joined with \n
  10611. // This makes it that \n will match the EOL for both CRLF and LF models
  10612. // We compensate for offset errors in `_getMultilineMatchRange`
  10613. const text = model.getValueInRange(searchRange, 1 /* LF */);
  10614. const lfCounter = (model.getEOL() === '\r\n' ? new LineFeedCounter(text) : null);
  10615. const result = [];
  10616. let counter = 0;
  10617. let m;
  10618. searcher.reset(0);
  10619. while ((m = searcher.next(text))) {
  10620. result[counter++] = createFindMatch(this._getMultilineMatchRange(model, deltaOffset, text, lfCounter, m.index, m[0]), m, captureMatches);
  10621. if (counter >= limitResultCount) {
  10622. return result;
  10623. }
  10624. }
  10625. return result;
  10626. }
  10627. static _doFindMatchesLineByLine(model, searchRange, searchData, captureMatches, limitResultCount) {
  10628. const result = [];
  10629. let resultLen = 0;
  10630. // Early case for a search range that starts & stops on the same line number
  10631. if (searchRange.startLineNumber === searchRange.endLineNumber) {
  10632. const text = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1, searchRange.endColumn - 1);
  10633. resultLen = this._findMatchesInLine(searchData, text, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);
  10634. return result;
  10635. }
  10636. // Collect results from first line
  10637. const text = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1);
  10638. resultLen = this._findMatchesInLine(searchData, text, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);
  10639. // Collect results from middle lines
  10640. for (let lineNumber = searchRange.startLineNumber + 1; lineNumber < searchRange.endLineNumber && resultLen < limitResultCount; lineNumber++) {
  10641. resultLen = this._findMatchesInLine(searchData, model.getLineContent(lineNumber), lineNumber, 0, resultLen, result, captureMatches, limitResultCount);
  10642. }
  10643. // Collect results from last line
  10644. if (resultLen < limitResultCount) {
  10645. const text = model.getLineContent(searchRange.endLineNumber).substring(0, searchRange.endColumn - 1);
  10646. resultLen = this._findMatchesInLine(searchData, text, searchRange.endLineNumber, 0, resultLen, result, captureMatches, limitResultCount);
  10647. }
  10648. return result;
  10649. }
  10650. static _findMatchesInLine(searchData, text, lineNumber, deltaOffset, resultLen, result, captureMatches, limitResultCount) {
  10651. const wordSeparators = searchData.wordSeparators;
  10652. if (!captureMatches && searchData.simpleSearch) {
  10653. const searchString = searchData.simpleSearch;
  10654. const searchStringLen = searchString.length;
  10655. const textLength = text.length;
  10656. let lastMatchIndex = -searchStringLen;
  10657. while ((lastMatchIndex = text.indexOf(searchString, lastMatchIndex + searchStringLen)) !== -1) {
  10658. if (!wordSeparators || isValidMatch(wordSeparators, text, textLength, lastMatchIndex, searchStringLen)) {
  10659. result[resultLen++] = new model_1.FindMatch(new range_1.Range(lineNumber, lastMatchIndex + 1 + deltaOffset, lineNumber, lastMatchIndex + 1 + searchStringLen + deltaOffset), null);
  10660. if (resultLen >= limitResultCount) {
  10661. return resultLen;
  10662. }
  10663. }
  10664. }
  10665. return resultLen;
  10666. }
  10667. const searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  10668. let m;
  10669. // Reset regex to search from the beginning
  10670. searcher.reset(0);
  10671. do {
  10672. m = searcher.next(text);
  10673. if (m) {
  10674. result[resultLen++] = createFindMatch(new range_1.Range(lineNumber, m.index + 1 + deltaOffset, lineNumber, m.index + 1 + m[0].length + deltaOffset), m, captureMatches);
  10675. if (resultLen >= limitResultCount) {
  10676. return resultLen;
  10677. }
  10678. }
  10679. } while (m);
  10680. return resultLen;
  10681. }
  10682. static findNextMatch(model, searchParams, searchStart, captureMatches) {
  10683. const searchData = searchParams.parseSearchRequest();
  10684. if (!searchData) {
  10685. return null;
  10686. }
  10687. const searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  10688. if (searchData.regex.multiline) {
  10689. return this._doFindNextMatchMultiline(model, searchStart, searcher, captureMatches);
  10690. }
  10691. return this._doFindNextMatchLineByLine(model, searchStart, searcher, captureMatches);
  10692. }
  10693. static _doFindNextMatchMultiline(model, searchStart, searcher, captureMatches) {
  10694. const searchTextStart = new position_1.Position(searchStart.lineNumber, 1);
  10695. const deltaOffset = model.getOffsetAt(searchTextStart);
  10696. const lineCount = model.getLineCount();
  10697. // We always execute multiline search over the lines joined with \n
  10698. // This makes it that \n will match the EOL for both CRLF and LF models
  10699. // We compensate for offset errors in `_getMultilineMatchRange`
  10700. const text = model.getValueInRange(new range_1.Range(searchTextStart.lineNumber, searchTextStart.column, lineCount, model.getLineMaxColumn(lineCount)), 1 /* LF */);
  10701. const lfCounter = (model.getEOL() === '\r\n' ? new LineFeedCounter(text) : null);
  10702. searcher.reset(searchStart.column - 1);
  10703. let m = searcher.next(text);
  10704. if (m) {
  10705. return createFindMatch(this._getMultilineMatchRange(model, deltaOffset, text, lfCounter, m.index, m[0]), m, captureMatches);
  10706. }
  10707. if (searchStart.lineNumber !== 1 || searchStart.column !== 1) {
  10708. // Try again from the top
  10709. return this._doFindNextMatchMultiline(model, new position_1.Position(1, 1), searcher, captureMatches);
  10710. }
  10711. return null;
  10712. }
  10713. static _doFindNextMatchLineByLine(model, searchStart, searcher, captureMatches) {
  10714. const lineCount = model.getLineCount();
  10715. const startLineNumber = searchStart.lineNumber;
  10716. // Look in first line
  10717. const text = model.getLineContent(startLineNumber);
  10718. const r = this._findFirstMatchInLine(searcher, text, startLineNumber, searchStart.column, captureMatches);
  10719. if (r) {
  10720. return r;
  10721. }
  10722. for (let i = 1; i <= lineCount; i++) {
  10723. const lineIndex = (startLineNumber + i - 1) % lineCount;
  10724. const text = model.getLineContent(lineIndex + 1);
  10725. const r = this._findFirstMatchInLine(searcher, text, lineIndex + 1, 1, captureMatches);
  10726. if (r) {
  10727. return r;
  10728. }
  10729. }
  10730. return null;
  10731. }
  10732. static _findFirstMatchInLine(searcher, text, lineNumber, fromColumn, captureMatches) {
  10733. // Set regex to search from column
  10734. searcher.reset(fromColumn - 1);
  10735. const m = searcher.next(text);
  10736. if (m) {
  10737. return createFindMatch(new range_1.Range(lineNumber, m.index + 1, lineNumber, m.index + 1 + m[0].length), m, captureMatches);
  10738. }
  10739. return null;
  10740. }
  10741. static findPreviousMatch(model, searchParams, searchStart, captureMatches) {
  10742. const searchData = searchParams.parseSearchRequest();
  10743. if (!searchData) {
  10744. return null;
  10745. }
  10746. const searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  10747. if (searchData.regex.multiline) {
  10748. return this._doFindPreviousMatchMultiline(model, searchStart, searcher, captureMatches);
  10749. }
  10750. return this._doFindPreviousMatchLineByLine(model, searchStart, searcher, captureMatches);
  10751. }
  10752. static _doFindPreviousMatchMultiline(model, searchStart, searcher, captureMatches) {
  10753. const matches = this._doFindMatchesMultiline(model, new range_1.Range(1, 1, searchStart.lineNumber, searchStart.column), searcher, captureMatches, 10 * LIMIT_FIND_COUNT);
  10754. if (matches.length > 0) {
  10755. return matches[matches.length - 1];
  10756. }
  10757. const lineCount = model.getLineCount();
  10758. if (searchStart.lineNumber !== lineCount || searchStart.column !== model.getLineMaxColumn(lineCount)) {
  10759. // Try again with all content
  10760. return this._doFindPreviousMatchMultiline(model, new position_1.Position(lineCount, model.getLineMaxColumn(lineCount)), searcher, captureMatches);
  10761. }
  10762. return null;
  10763. }
  10764. static _doFindPreviousMatchLineByLine(model, searchStart, searcher, captureMatches) {
  10765. const lineCount = model.getLineCount();
  10766. const startLineNumber = searchStart.lineNumber;
  10767. // Look in first line
  10768. const text = model.getLineContent(startLineNumber).substring(0, searchStart.column - 1);
  10769. const r = this._findLastMatchInLine(searcher, text, startLineNumber, captureMatches);
  10770. if (r) {
  10771. return r;
  10772. }
  10773. for (let i = 1; i <= lineCount; i++) {
  10774. const lineIndex = (lineCount + startLineNumber - i - 1) % lineCount;
  10775. const text = model.getLineContent(lineIndex + 1);
  10776. const r = this._findLastMatchInLine(searcher, text, lineIndex + 1, captureMatches);
  10777. if (r) {
  10778. return r;
  10779. }
  10780. }
  10781. return null;
  10782. }
  10783. static _findLastMatchInLine(searcher, text, lineNumber, captureMatches) {
  10784. let bestResult = null;
  10785. let m;
  10786. searcher.reset(0);
  10787. while ((m = searcher.next(text))) {
  10788. bestResult = createFindMatch(new range_1.Range(lineNumber, m.index + 1, lineNumber, m.index + 1 + m[0].length), m, captureMatches);
  10789. }
  10790. return bestResult;
  10791. }
  10792. }
  10793. exports.TextModelSearch = TextModelSearch;
  10794. function leftIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  10795. if (matchStartIndex === 0) {
  10796. // Match starts at start of string
  10797. return true;
  10798. }
  10799. const charBefore = text.charCodeAt(matchStartIndex - 1);
  10800. if (wordSeparators.get(charBefore) !== 0 /* Regular */) {
  10801. // The character before the match is a word separator
  10802. return true;
  10803. }
  10804. if (charBefore === 13 /* CarriageReturn */ || charBefore === 10 /* LineFeed */) {
  10805. // The character before the match is line break or carriage return.
  10806. return true;
  10807. }
  10808. if (matchLength > 0) {
  10809. const firstCharInMatch = text.charCodeAt(matchStartIndex);
  10810. if (wordSeparators.get(firstCharInMatch) !== 0 /* Regular */) {
  10811. // The first character inside the match is a word separator
  10812. return true;
  10813. }
  10814. }
  10815. return false;
  10816. }
  10817. function rightIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  10818. if (matchStartIndex + matchLength === textLength) {
  10819. // Match ends at end of string
  10820. return true;
  10821. }
  10822. const charAfter = text.charCodeAt(matchStartIndex + matchLength);
  10823. if (wordSeparators.get(charAfter) !== 0 /* Regular */) {
  10824. // The character after the match is a word separator
  10825. return true;
  10826. }
  10827. if (charAfter === 13 /* CarriageReturn */ || charAfter === 10 /* LineFeed */) {
  10828. // The character after the match is line break or carriage return.
  10829. return true;
  10830. }
  10831. if (matchLength > 0) {
  10832. const lastCharInMatch = text.charCodeAt(matchStartIndex + matchLength - 1);
  10833. if (wordSeparators.get(lastCharInMatch) !== 0 /* Regular */) {
  10834. // The last character in the match is a word separator
  10835. return true;
  10836. }
  10837. }
  10838. return false;
  10839. }
  10840. function isValidMatch(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  10841. return (leftIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength)
  10842. && rightIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength));
  10843. }
  10844. exports.isValidMatch = isValidMatch;
  10845. class Searcher {
  10846. constructor(wordSeparators, searchRegex) {
  10847. this._wordSeparators = wordSeparators;
  10848. this._searchRegex = searchRegex;
  10849. this._prevMatchStartIndex = -1;
  10850. this._prevMatchLength = 0;
  10851. }
  10852. reset(lastIndex) {
  10853. this._searchRegex.lastIndex = lastIndex;
  10854. this._prevMatchStartIndex = -1;
  10855. this._prevMatchLength = 0;
  10856. }
  10857. next(text) {
  10858. const textLength = text.length;
  10859. let m;
  10860. do {
  10861. if (this._prevMatchStartIndex + this._prevMatchLength === textLength) {
  10862. // Reached the end of the line
  10863. return null;
  10864. }
  10865. m = this._searchRegex.exec(text);
  10866. if (!m) {
  10867. return null;
  10868. }
  10869. const matchStartIndex = m.index;
  10870. const matchLength = m[0].length;
  10871. if (matchStartIndex === this._prevMatchStartIndex && matchLength === this._prevMatchLength) {
  10872. if (matchLength === 0) {
  10873. // the search result is an empty string and won't advance `regex.lastIndex`, so `regex.exec` will stuck here
  10874. // we attempt to recover from that by advancing by two if surrogate pair found and by one otherwise
  10875. if (strings.getNextCodePoint(text, textLength, this._searchRegex.lastIndex) > 0xFFFF) {
  10876. this._searchRegex.lastIndex += 2;
  10877. }
  10878. else {
  10879. this._searchRegex.lastIndex += 1;
  10880. }
  10881. continue;
  10882. }
  10883. // Exit early if the regex matches the same range twice
  10884. return null;
  10885. }
  10886. this._prevMatchStartIndex = matchStartIndex;
  10887. this._prevMatchLength = matchLength;
  10888. if (!this._wordSeparators || isValidMatch(this._wordSeparators, text, textLength, matchStartIndex, matchLength)) {
  10889. return m;
  10890. }
  10891. } while (m);
  10892. return null;
  10893. }
  10894. }
  10895. exports.Searcher = Searcher;
  10896. });
  10897. /*---------------------------------------------------------------------------------------------
  10898. * Copyright (c) Microsoft Corporation. All rights reserved.
  10899. * Licensed under the MIT License. See License.txt in the project root for license information.
  10900. *--------------------------------------------------------------------------------------------*/
  10901. define(__m[32/*vs/editor/common/model/wordHelper*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  10902. "use strict";
  10903. Object.defineProperty(exports, "__esModule", { value: true });
  10904. exports.getWordAtText = exports.ensureValidWordDefinition = exports.DEFAULT_WORD_REGEXP = exports.USUAL_WORD_SEPARATORS = void 0;
  10905. exports.USUAL_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?';
  10906. /**
  10907. * Create a word definition regular expression based on default word separators.
  10908. * Optionally provide allowed separators that should be included in words.
  10909. *
  10910. * The default would look like this:
  10911. * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
  10912. */
  10913. function createWordRegExp(allowInWords = '') {
  10914. let source = '(-?\\d*\\.\\d\\w*)|([^';
  10915. for (const sep of exports.USUAL_WORD_SEPARATORS) {
  10916. if (allowInWords.indexOf(sep) >= 0) {
  10917. continue;
  10918. }
  10919. source += '\\' + sep;
  10920. }
  10921. source += '\\s]+)';
  10922. return new RegExp(source, 'g');
  10923. }
  10924. // catches numbers (including floating numbers) in the first group, and alphanum in the second
  10925. exports.DEFAULT_WORD_REGEXP = createWordRegExp();
  10926. function ensureValidWordDefinition(wordDefinition) {
  10927. let result = exports.DEFAULT_WORD_REGEXP;
  10928. if (wordDefinition && (wordDefinition instanceof RegExp)) {
  10929. if (!wordDefinition.global) {
  10930. let flags = 'g';
  10931. if (wordDefinition.ignoreCase) {
  10932. flags += 'i';
  10933. }
  10934. if (wordDefinition.multiline) {
  10935. flags += 'm';
  10936. }
  10937. if (wordDefinition.unicode) {
  10938. flags += 'u';
  10939. }
  10940. result = new RegExp(wordDefinition.source, flags);
  10941. }
  10942. else {
  10943. result = wordDefinition;
  10944. }
  10945. }
  10946. result.lastIndex = 0;
  10947. return result;
  10948. }
  10949. exports.ensureValidWordDefinition = ensureValidWordDefinition;
  10950. const _defaultConfig = {
  10951. maxLen: 1000,
  10952. windowSize: 15,
  10953. timeBudget: 150
  10954. };
  10955. function getWordAtText(column, wordDefinition, text, textOffset, config = _defaultConfig) {
  10956. if (text.length > config.maxLen) {
  10957. // don't throw strings that long at the regexp
  10958. // but use a sub-string in which a word must occur
  10959. let start = column - config.maxLen / 2;
  10960. if (start < 0) {
  10961. start = 0;
  10962. }
  10963. else {
  10964. textOffset += start;
  10965. }
  10966. text = text.substring(start, column + config.maxLen / 2);
  10967. return getWordAtText(column, wordDefinition, text, textOffset, config);
  10968. }
  10969. const t1 = Date.now();
  10970. const pos = column - 1 - textOffset;
  10971. let prevRegexIndex = -1;
  10972. let match = null;
  10973. for (let i = 1;; i++) {
  10974. // check time budget
  10975. if (Date.now() - t1 >= config.timeBudget) {
  10976. break;
  10977. }
  10978. // reset the index at which the regexp should start matching, also know where it
  10979. // should stop so that subsequent search don't repeat previous searches
  10980. const regexIndex = pos - config.windowSize * i;
  10981. wordDefinition.lastIndex = Math.max(0, regexIndex);
  10982. const thisMatch = _findRegexMatchEnclosingPosition(wordDefinition, text, pos, prevRegexIndex);
  10983. if (!thisMatch && match) {
  10984. // stop: we have something
  10985. break;
  10986. }
  10987. match = thisMatch;
  10988. // stop: searched at start
  10989. if (regexIndex <= 0) {
  10990. break;
  10991. }
  10992. prevRegexIndex = regexIndex;
  10993. }
  10994. if (match) {
  10995. let result = {
  10996. word: match[0],
  10997. startColumn: textOffset + 1 + match.index,
  10998. endColumn: textOffset + 1 + match.index + match[0].length
  10999. };
  11000. wordDefinition.lastIndex = 0;
  11001. return result;
  11002. }
  11003. return null;
  11004. }
  11005. exports.getWordAtText = getWordAtText;
  11006. function _findRegexMatchEnclosingPosition(wordDefinition, text, pos, stopPos) {
  11007. let match;
  11008. while (match = wordDefinition.exec(text)) {
  11009. const matchIndex = match.index || 0;
  11010. if (matchIndex <= pos && wordDefinition.lastIndex >= pos) {
  11011. return match;
  11012. }
  11013. else if (stopPos > 0 && matchIndex > stopPos) {
  11014. return null;
  11015. }
  11016. }
  11017. return null;
  11018. }
  11019. });
  11020. /*---------------------------------------------------------------------------------------------
  11021. * Copyright (c) Microsoft Corporation. All rights reserved.
  11022. * Licensed under the MIT License. See License.txt in the project root for license information.
  11023. *--------------------------------------------------------------------------------------------*/
  11024. define(__m[33/*vs/editor/common/modes/linkComputer*/], __M([0/*require*/,1/*exports*/,14/*vs/editor/common/core/characterClassifier*/]), function (require, exports, characterClassifier_1) {
  11025. "use strict";
  11026. Object.defineProperty(exports, "__esModule", { value: true });
  11027. exports.computeLinks = exports.LinkComputer = exports.StateMachine = exports.Uint8Matrix = void 0;
  11028. class Uint8Matrix {
  11029. constructor(rows, cols, defaultValue) {
  11030. const data = new Uint8Array(rows * cols);
  11031. for (let i = 0, len = rows * cols; i < len; i++) {
  11032. data[i] = defaultValue;
  11033. }
  11034. this._data = data;
  11035. this.rows = rows;
  11036. this.cols = cols;
  11037. }
  11038. get(row, col) {
  11039. return this._data[row * this.cols + col];
  11040. }
  11041. set(row, col, value) {
  11042. this._data[row * this.cols + col] = value;
  11043. }
  11044. }
  11045. exports.Uint8Matrix = Uint8Matrix;
  11046. class StateMachine {
  11047. constructor(edges) {
  11048. let maxCharCode = 0;
  11049. let maxState = 0 /* Invalid */;
  11050. for (let i = 0, len = edges.length; i < len; i++) {
  11051. let [from, chCode, to] = edges[i];
  11052. if (chCode > maxCharCode) {
  11053. maxCharCode = chCode;
  11054. }
  11055. if (from > maxState) {
  11056. maxState = from;
  11057. }
  11058. if (to > maxState) {
  11059. maxState = to;
  11060. }
  11061. }
  11062. maxCharCode++;
  11063. maxState++;
  11064. let states = new Uint8Matrix(maxState, maxCharCode, 0 /* Invalid */);
  11065. for (let i = 0, len = edges.length; i < len; i++) {
  11066. let [from, chCode, to] = edges[i];
  11067. states.set(from, chCode, to);
  11068. }
  11069. this._states = states;
  11070. this._maxCharCode = maxCharCode;
  11071. }
  11072. nextState(currentState, chCode) {
  11073. if (chCode < 0 || chCode >= this._maxCharCode) {
  11074. return 0 /* Invalid */;
  11075. }
  11076. return this._states.get(currentState, chCode);
  11077. }
  11078. }
  11079. exports.StateMachine = StateMachine;
  11080. // State machine for http:// or https:// or file://
  11081. let _stateMachine = null;
  11082. function getStateMachine() {
  11083. if (_stateMachine === null) {
  11084. _stateMachine = new StateMachine([
  11085. [1 /* Start */, 104 /* h */, 2 /* H */],
  11086. [1 /* Start */, 72 /* H */, 2 /* H */],
  11087. [1 /* Start */, 102 /* f */, 6 /* F */],
  11088. [1 /* Start */, 70 /* F */, 6 /* F */],
  11089. [2 /* H */, 116 /* t */, 3 /* HT */],
  11090. [2 /* H */, 84 /* T */, 3 /* HT */],
  11091. [3 /* HT */, 116 /* t */, 4 /* HTT */],
  11092. [3 /* HT */, 84 /* T */, 4 /* HTT */],
  11093. [4 /* HTT */, 112 /* p */, 5 /* HTTP */],
  11094. [4 /* HTT */, 80 /* P */, 5 /* HTTP */],
  11095. [5 /* HTTP */, 115 /* s */, 9 /* BeforeColon */],
  11096. [5 /* HTTP */, 83 /* S */, 9 /* BeforeColon */],
  11097. [5 /* HTTP */, 58 /* Colon */, 10 /* AfterColon */],
  11098. [6 /* F */, 105 /* i */, 7 /* FI */],
  11099. [6 /* F */, 73 /* I */, 7 /* FI */],
  11100. [7 /* FI */, 108 /* l */, 8 /* FIL */],
  11101. [7 /* FI */, 76 /* L */, 8 /* FIL */],
  11102. [8 /* FIL */, 101 /* e */, 9 /* BeforeColon */],
  11103. [8 /* FIL */, 69 /* E */, 9 /* BeforeColon */],
  11104. [9 /* BeforeColon */, 58 /* Colon */, 10 /* AfterColon */],
  11105. [10 /* AfterColon */, 47 /* Slash */, 11 /* AlmostThere */],
  11106. [11 /* AlmostThere */, 47 /* Slash */, 12 /* End */],
  11107. ]);
  11108. }
  11109. return _stateMachine;
  11110. }
  11111. let _classifier = null;
  11112. function getClassifier() {
  11113. if (_classifier === null) {
  11114. _classifier = new characterClassifier_1.CharacterClassifier(0 /* None */);
  11115. // allow-any-unicode-next-line
  11116. const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘〈「『〔([{「」}])〕』」〉’`~…';
  11117. for (let i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
  11118. _classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), 1 /* ForceTermination */);
  11119. }
  11120. const CANNOT_END_WITH_CHARACTERS = '.,;';
  11121. for (let i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
  11122. _classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), 2 /* CannotEndIn */);
  11123. }
  11124. }
  11125. return _classifier;
  11126. }
  11127. class LinkComputer {
  11128. static _createLink(classifier, line, lineNumber, linkBeginIndex, linkEndIndex) {
  11129. // Do not allow to end link in certain characters...
  11130. let lastIncludedCharIndex = linkEndIndex - 1;
  11131. do {
  11132. const chCode = line.charCodeAt(lastIncludedCharIndex);
  11133. const chClass = classifier.get(chCode);
  11134. if (chClass !== 2 /* CannotEndIn */) {
  11135. break;
  11136. }
  11137. lastIncludedCharIndex--;
  11138. } while (lastIncludedCharIndex > linkBeginIndex);
  11139. // Handle links enclosed in parens, square brackets and curlys.
  11140. if (linkBeginIndex > 0) {
  11141. const charCodeBeforeLink = line.charCodeAt(linkBeginIndex - 1);
  11142. const lastCharCodeInLink = line.charCodeAt(lastIncludedCharIndex);
  11143. if ((charCodeBeforeLink === 40 /* OpenParen */ && lastCharCodeInLink === 41 /* CloseParen */)
  11144. || (charCodeBeforeLink === 91 /* OpenSquareBracket */ && lastCharCodeInLink === 93 /* CloseSquareBracket */)
  11145. || (charCodeBeforeLink === 123 /* OpenCurlyBrace */ && lastCharCodeInLink === 125 /* CloseCurlyBrace */)) {
  11146. // Do not end in ) if ( is before the link start
  11147. // Do not end in ] if [ is before the link start
  11148. // Do not end in } if { is before the link start
  11149. lastIncludedCharIndex--;
  11150. }
  11151. }
  11152. return {
  11153. range: {
  11154. startLineNumber: lineNumber,
  11155. startColumn: linkBeginIndex + 1,
  11156. endLineNumber: lineNumber,
  11157. endColumn: lastIncludedCharIndex + 2
  11158. },
  11159. url: line.substring(linkBeginIndex, lastIncludedCharIndex + 1)
  11160. };
  11161. }
  11162. static computeLinks(model, stateMachine = getStateMachine()) {
  11163. const classifier = getClassifier();
  11164. let result = [];
  11165. for (let i = 1, lineCount = model.getLineCount(); i <= lineCount; i++) {
  11166. const line = model.getLineContent(i);
  11167. const len = line.length;
  11168. let j = 0;
  11169. let linkBeginIndex = 0;
  11170. let linkBeginChCode = 0;
  11171. let state = 1 /* Start */;
  11172. let hasOpenParens = false;
  11173. let hasOpenSquareBracket = false;
  11174. let inSquareBrackets = false;
  11175. let hasOpenCurlyBracket = false;
  11176. while (j < len) {
  11177. let resetStateMachine = false;
  11178. const chCode = line.charCodeAt(j);
  11179. if (state === 13 /* Accept */) {
  11180. let chClass;
  11181. switch (chCode) {
  11182. case 40 /* OpenParen */:
  11183. hasOpenParens = true;
  11184. chClass = 0 /* None */;
  11185. break;
  11186. case 41 /* CloseParen */:
  11187. chClass = (hasOpenParens ? 0 /* None */ : 1 /* ForceTermination */);
  11188. break;
  11189. case 91 /* OpenSquareBracket */:
  11190. inSquareBrackets = true;
  11191. hasOpenSquareBracket = true;
  11192. chClass = 0 /* None */;
  11193. break;
  11194. case 93 /* CloseSquareBracket */:
  11195. inSquareBrackets = false;
  11196. chClass = (hasOpenSquareBracket ? 0 /* None */ : 1 /* ForceTermination */);
  11197. break;
  11198. case 123 /* OpenCurlyBrace */:
  11199. hasOpenCurlyBracket = true;
  11200. chClass = 0 /* None */;
  11201. break;
  11202. case 125 /* CloseCurlyBrace */:
  11203. chClass = (hasOpenCurlyBracket ? 0 /* None */ : 1 /* ForceTermination */);
  11204. break;
  11205. /* The following three rules make it that ' or " or ` are allowed inside links if the link began with a different one */
  11206. case 39 /* SingleQuote */:
  11207. chClass = (linkBeginChCode === 34 /* DoubleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  11208. break;
  11209. case 34 /* DoubleQuote */:
  11210. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  11211. break;
  11212. case 96 /* BackTick */:
  11213. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 34 /* DoubleQuote */) ? 0 /* None */ : 1 /* ForceTermination */;
  11214. break;
  11215. case 42 /* Asterisk */:
  11216. // `*` terminates a link if the link began with `*`
  11217. chClass = (linkBeginChCode === 42 /* Asterisk */) ? 1 /* ForceTermination */ : 0 /* None */;
  11218. break;
  11219. case 124 /* Pipe */:
  11220. // `|` terminates a link if the link began with `|`
  11221. chClass = (linkBeginChCode === 124 /* Pipe */) ? 1 /* ForceTermination */ : 0 /* None */;
  11222. break;
  11223. case 32 /* Space */:
  11224. // ` ` allow space in between [ and ]
  11225. chClass = (inSquareBrackets ? 0 /* None */ : 1 /* ForceTermination */);
  11226. break;
  11227. default:
  11228. chClass = classifier.get(chCode);
  11229. }
  11230. // Check if character terminates link
  11231. if (chClass === 1 /* ForceTermination */) {
  11232. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j));
  11233. resetStateMachine = true;
  11234. }
  11235. }
  11236. else if (state === 12 /* End */) {
  11237. let chClass;
  11238. if (chCode === 91 /* OpenSquareBracket */) {
  11239. // Allow for the authority part to contain ipv6 addresses which contain [ and ]
  11240. hasOpenSquareBracket = true;
  11241. chClass = 0 /* None */;
  11242. }
  11243. else {
  11244. chClass = classifier.get(chCode);
  11245. }
  11246. // Check if character terminates link
  11247. if (chClass === 1 /* ForceTermination */) {
  11248. resetStateMachine = true;
  11249. }
  11250. else {
  11251. state = 13 /* Accept */;
  11252. }
  11253. }
  11254. else {
  11255. state = stateMachine.nextState(state, chCode);
  11256. if (state === 0 /* Invalid */) {
  11257. resetStateMachine = true;
  11258. }
  11259. }
  11260. if (resetStateMachine) {
  11261. state = 1 /* Start */;
  11262. hasOpenParens = false;
  11263. hasOpenSquareBracket = false;
  11264. hasOpenCurlyBracket = false;
  11265. // Record where the link started
  11266. linkBeginIndex = j + 1;
  11267. linkBeginChCode = chCode;
  11268. }
  11269. j++;
  11270. }
  11271. if (state === 13 /* Accept */) {
  11272. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, len));
  11273. }
  11274. }
  11275. return result;
  11276. }
  11277. }
  11278. exports.LinkComputer = LinkComputer;
  11279. /**
  11280. * Returns an array of all links contains in the provided
  11281. * document. *Note* that this operation is computational
  11282. * expensive and should not run in the UI thread.
  11283. */
  11284. function computeLinks(model) {
  11285. if (!model || typeof model.getLineCount !== 'function' || typeof model.getLineContent !== 'function') {
  11286. // Unknown caller!
  11287. return [];
  11288. }
  11289. return LinkComputer.computeLinks(model);
  11290. }
  11291. exports.computeLinks = computeLinks;
  11292. });
  11293. /*---------------------------------------------------------------------------------------------
  11294. * Copyright (c) Microsoft Corporation. All rights reserved.
  11295. * Licensed under the MIT License. See License.txt in the project root for license information.
  11296. *--------------------------------------------------------------------------------------------*/
  11297. define(__m[34/*vs/editor/common/modes/supports/inplaceReplaceSupport*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  11298. "use strict";
  11299. Object.defineProperty(exports, "__esModule", { value: true });
  11300. exports.BasicInplaceReplace = void 0;
  11301. class BasicInplaceReplace {
  11302. constructor() {
  11303. this._defaultValueSet = [
  11304. ['true', 'false'],
  11305. ['True', 'False'],
  11306. ['Private', 'Public', 'Friend', 'ReadOnly', 'Partial', 'Protected', 'WriteOnly'],
  11307. ['public', 'protected', 'private'],
  11308. ];
  11309. }
  11310. navigateValueSet(range1, text1, range2, text2, up) {
  11311. if (range1 && text1) {
  11312. let result = this.doNavigateValueSet(text1, up);
  11313. if (result) {
  11314. return {
  11315. range: range1,
  11316. value: result
  11317. };
  11318. }
  11319. }
  11320. if (range2 && text2) {
  11321. let result = this.doNavigateValueSet(text2, up);
  11322. if (result) {
  11323. return {
  11324. range: range2,
  11325. value: result
  11326. };
  11327. }
  11328. }
  11329. return null;
  11330. }
  11331. doNavigateValueSet(text, up) {
  11332. let numberResult = this.numberReplace(text, up);
  11333. if (numberResult !== null) {
  11334. return numberResult;
  11335. }
  11336. return this.textReplace(text, up);
  11337. }
  11338. numberReplace(value, up) {
  11339. let precision = Math.pow(10, value.length - (value.lastIndexOf('.') + 1));
  11340. let n1 = Number(value);
  11341. let n2 = parseFloat(value);
  11342. if (!isNaN(n1) && !isNaN(n2) && n1 === n2) {
  11343. if (n1 === 0 && !up) {
  11344. return null; // don't do negative
  11345. // } else if(n1 === 9 && up) {
  11346. // return null; // don't insert 10 into a number
  11347. }
  11348. else {
  11349. n1 = Math.floor(n1 * precision);
  11350. n1 += up ? precision : -precision;
  11351. return String(n1 / precision);
  11352. }
  11353. }
  11354. return null;
  11355. }
  11356. textReplace(value, up) {
  11357. return this.valueSetsReplace(this._defaultValueSet, value, up);
  11358. }
  11359. valueSetsReplace(valueSets, value, up) {
  11360. let result = null;
  11361. for (let i = 0, len = valueSets.length; result === null && i < len; i++) {
  11362. result = this.valueSetReplace(valueSets[i], value, up);
  11363. }
  11364. return result;
  11365. }
  11366. valueSetReplace(valueSet, value, up) {
  11367. let idx = valueSet.indexOf(value);
  11368. if (idx >= 0) {
  11369. idx += up ? +1 : -1;
  11370. if (idx < 0) {
  11371. idx = valueSet.length - 1;
  11372. }
  11373. else {
  11374. idx %= valueSet.length;
  11375. }
  11376. return valueSet[idx];
  11377. }
  11378. return null;
  11379. }
  11380. }
  11381. exports.BasicInplaceReplace = BasicInplaceReplace;
  11382. BasicInplaceReplace.INSTANCE = new BasicInplaceReplace();
  11383. });
  11384. /*---------------------------------------------------------------------------------------------
  11385. * Copyright (c) Microsoft Corporation. All rights reserved.
  11386. * Licensed under the MIT License. See License.txt in the project root for license information.
  11387. *--------------------------------------------------------------------------------------------*/
  11388. define(__m[35/*vs/editor/common/modes/unicodeTextModelHighlighter*/], __M([0/*require*/,1/*exports*/,5/*vs/editor/common/core/range*/,31/*vs/editor/common/model/textModelSearch*/,3/*vs/base/common/strings*/,6/*vs/base/common/types*/]), function (require, exports, range_1, textModelSearch_1, strings, types_1) {
  11389. "use strict";
  11390. Object.defineProperty(exports, "__esModule", { value: true });
  11391. exports.UnicodeTextModelHighlighter = void 0;
  11392. class UnicodeTextModelHighlighter {
  11393. static computeUnicodeHighlights(model, options, range) {
  11394. const startLine = range ? range.startLineNumber : 1;
  11395. const endLine = range ? range.endLineNumber : model.getLineCount();
  11396. const codePointHighlighter = new CodePointHighlighter(options);
  11397. const candidates = codePointHighlighter.getCandidateCodePoints();
  11398. let regex;
  11399. if (candidates === 'allNonBasicAscii') {
  11400. regex = new RegExp('[^\\t\\n\\r\\x20-\\x7E]', 'g');
  11401. }
  11402. else {
  11403. regex = new RegExp(`${buildRegExpCharClassExpr(Array.from(candidates))}`, 'g');
  11404. }
  11405. const searcher = new textModelSearch_1.Searcher(null, regex);
  11406. const ranges = [];
  11407. let hasMore = false;
  11408. let m;
  11409. let ambiguousCharacterCount = 0;
  11410. let invisibleCharacterCount = 0;
  11411. let nonBasicAsciiCharacterCount = 0;
  11412. forLoop: for (let lineNumber = startLine, lineCount = endLine; lineNumber <= lineCount; lineNumber++) {
  11413. const lineContent = model.getLineContent(lineNumber);
  11414. const lineLength = lineContent.length;
  11415. // Reset regex to search from the beginning
  11416. searcher.reset(0);
  11417. do {
  11418. m = searcher.next(lineContent);
  11419. if (m) {
  11420. let startIndex = m.index;
  11421. let endIndex = m.index + m[0].length;
  11422. // Extend range to entire code point
  11423. if (startIndex > 0) {
  11424. const charCodeBefore = lineContent.charCodeAt(startIndex - 1);
  11425. if (strings.isHighSurrogate(charCodeBefore)) {
  11426. startIndex--;
  11427. }
  11428. }
  11429. if (endIndex + 1 < lineLength) {
  11430. const charCodeBefore = lineContent.charCodeAt(endIndex - 1);
  11431. if (strings.isHighSurrogate(charCodeBefore)) {
  11432. endIndex++;
  11433. }
  11434. }
  11435. const str = lineContent.substring(startIndex, endIndex);
  11436. const highlightReason = codePointHighlighter.shouldHighlightNonBasicASCII(str);
  11437. if (highlightReason !== 0 /* None */) {
  11438. if (highlightReason === 3 /* Ambiguous */) {
  11439. ambiguousCharacterCount++;
  11440. }
  11441. else if (highlightReason === 2 /* Invisible */) {
  11442. invisibleCharacterCount++;
  11443. }
  11444. else if (highlightReason === 1 /* NonBasicASCII */) {
  11445. nonBasicAsciiCharacterCount++;
  11446. }
  11447. else {
  11448. (0, types_1.assertNever)(highlightReason);
  11449. }
  11450. const MAX_RESULT_LENGTH = 1000;
  11451. if (ranges.length >= MAX_RESULT_LENGTH) {
  11452. hasMore = true;
  11453. break forLoop;
  11454. }
  11455. ranges.push(new range_1.Range(lineNumber, startIndex + 1, lineNumber, endIndex + 1));
  11456. }
  11457. }
  11458. } while (m);
  11459. }
  11460. return {
  11461. ranges,
  11462. hasMore,
  11463. ambiguousCharacterCount,
  11464. invisibleCharacterCount,
  11465. nonBasicAsciiCharacterCount
  11466. };
  11467. }
  11468. static computeUnicodeHighlightReason(char, options) {
  11469. const codePointHighlighter = new CodePointHighlighter(options);
  11470. const reason = codePointHighlighter.shouldHighlightNonBasicASCII(char);
  11471. switch (reason) {
  11472. case 0 /* None */:
  11473. return null;
  11474. case 2 /* Invisible */:
  11475. return { kind: 1 /* Invisible */ };
  11476. case 3 /* Ambiguous */:
  11477. const primaryConfusable = strings.AmbiguousCharacters.getPrimaryConfusable(char.codePointAt(0));
  11478. return { kind: 0 /* Ambiguous */, confusableWith: String.fromCodePoint(primaryConfusable) };
  11479. case 1 /* NonBasicASCII */:
  11480. return { kind: 2 /* NonBasicAscii */ };
  11481. }
  11482. }
  11483. }
  11484. exports.UnicodeTextModelHighlighter = UnicodeTextModelHighlighter;
  11485. function buildRegExpCharClassExpr(codePoints, flags) {
  11486. const src = `[${strings.escapeRegExpCharacters(codePoints.map((i) => String.fromCodePoint(i)).join(''))}]`;
  11487. return src;
  11488. }
  11489. class CodePointHighlighter {
  11490. constructor(options) {
  11491. this.options = options;
  11492. this.allowedCodePoints = new Set(options.allowedCodePoints);
  11493. }
  11494. getCandidateCodePoints() {
  11495. if (this.options.nonBasicASCII) {
  11496. return 'allNonBasicAscii';
  11497. }
  11498. const set = new Set();
  11499. if (this.options.invisibleCharacters) {
  11500. for (const cp of strings.InvisibleCharacters.codePoints) {
  11501. set.add(cp);
  11502. }
  11503. }
  11504. if (this.options.ambiguousCharacters) {
  11505. for (const cp of strings.AmbiguousCharacters.getPrimaryConfusableCodePoints()) {
  11506. set.add(cp);
  11507. }
  11508. }
  11509. for (const cp of this.allowedCodePoints) {
  11510. set.delete(cp);
  11511. }
  11512. return set;
  11513. }
  11514. shouldHighlightNonBasicASCII(character) {
  11515. const codePoint = character.codePointAt(0);
  11516. if (this.allowedCodePoints.has(codePoint)) {
  11517. return 0 /* None */;
  11518. }
  11519. if (this.options.nonBasicASCII) {
  11520. return 1 /* NonBasicASCII */;
  11521. }
  11522. if (this.options.invisibleCharacters) {
  11523. const isAllowedInvisibleCharacter = character === ' ' || character === '\n' || character === '\t';
  11524. // TODO check for emojis
  11525. if (!isAllowedInvisibleCharacter && strings.InvisibleCharacters.isInvisibleCharacter(codePoint)) {
  11526. return 2 /* Invisible */;
  11527. }
  11528. }
  11529. if (this.options.ambiguousCharacters) {
  11530. if (strings.AmbiguousCharacters.isAmbiguous(codePoint)) {
  11531. return 3 /* Ambiguous */;
  11532. }
  11533. }
  11534. return 0 /* None */;
  11535. }
  11536. }
  11537. });
  11538. /*---------------------------------------------------------------------------------------------
  11539. * Copyright (c) Microsoft Corporation. All rights reserved.
  11540. * Licensed under the MIT License. See License.txt in the project root for license information.
  11541. *--------------------------------------------------------------------------------------------*/
  11542. define(__m[36/*vs/editor/common/standalone/standaloneEnums*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  11543. "use strict";
  11544. Object.defineProperty(exports, "__esModule", { value: true });
  11545. exports.WrappingIndent = exports.TrackedRangeStickiness = exports.TextEditorCursorStyle = exports.TextEditorCursorBlinkingStyle = exports.SymbolTag = exports.SymbolKind = exports.SignatureHelpTriggerKind = exports.SelectionDirection = exports.ScrollbarVisibility = exports.ScrollType = exports.RenderMinimap = exports.RenderLineNumbersType = exports.OverviewRulerLane = exports.OverlayWidgetPositionPreference = exports.MouseTargetType = exports.MinimapPosition = exports.MarkerTag = exports.MarkerSeverity = exports.KeyCode = exports.InlineCompletionTriggerKind = exports.InlayHintKind = exports.IndentAction = exports.EndOfLineSequence = exports.EndOfLinePreference = exports.EditorOption = exports.EditorAutoIndentStrategy = exports.DocumentHighlightKind = exports.DefaultEndOfLine = exports.CursorChangeReason = exports.ContentWidgetPositionPreference = exports.CompletionTriggerKind = exports.CompletionItemTag = exports.CompletionItemKind = exports.CompletionItemInsertTextRule = exports.AccessibilitySupport = void 0;
  11546. // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.
  11547. var AccessibilitySupport;
  11548. (function (AccessibilitySupport) {
  11549. /**
  11550. * This should be the browser case where it is not known if a screen reader is attached or no.
  11551. */
  11552. AccessibilitySupport[AccessibilitySupport["Unknown"] = 0] = "Unknown";
  11553. AccessibilitySupport[AccessibilitySupport["Disabled"] = 1] = "Disabled";
  11554. AccessibilitySupport[AccessibilitySupport["Enabled"] = 2] = "Enabled";
  11555. })(AccessibilitySupport = exports.AccessibilitySupport || (exports.AccessibilitySupport = {}));
  11556. var CompletionItemInsertTextRule;
  11557. (function (CompletionItemInsertTextRule) {
  11558. /**
  11559. * Adjust whitespace/indentation of multiline insert texts to
  11560. * match the current line indentation.
  11561. */
  11562. CompletionItemInsertTextRule[CompletionItemInsertTextRule["KeepWhitespace"] = 1] = "KeepWhitespace";
  11563. /**
  11564. * `insertText` is a snippet.
  11565. */
  11566. CompletionItemInsertTextRule[CompletionItemInsertTextRule["InsertAsSnippet"] = 4] = "InsertAsSnippet";
  11567. })(CompletionItemInsertTextRule = exports.CompletionItemInsertTextRule || (exports.CompletionItemInsertTextRule = {}));
  11568. var CompletionItemKind;
  11569. (function (CompletionItemKind) {
  11570. CompletionItemKind[CompletionItemKind["Method"] = 0] = "Method";
  11571. CompletionItemKind[CompletionItemKind["Function"] = 1] = "Function";
  11572. CompletionItemKind[CompletionItemKind["Constructor"] = 2] = "Constructor";
  11573. CompletionItemKind[CompletionItemKind["Field"] = 3] = "Field";
  11574. CompletionItemKind[CompletionItemKind["Variable"] = 4] = "Variable";
  11575. CompletionItemKind[CompletionItemKind["Class"] = 5] = "Class";
  11576. CompletionItemKind[CompletionItemKind["Struct"] = 6] = "Struct";
  11577. CompletionItemKind[CompletionItemKind["Interface"] = 7] = "Interface";
  11578. CompletionItemKind[CompletionItemKind["Module"] = 8] = "Module";
  11579. CompletionItemKind[CompletionItemKind["Property"] = 9] = "Property";
  11580. CompletionItemKind[CompletionItemKind["Event"] = 10] = "Event";
  11581. CompletionItemKind[CompletionItemKind["Operator"] = 11] = "Operator";
  11582. CompletionItemKind[CompletionItemKind["Unit"] = 12] = "Unit";
  11583. CompletionItemKind[CompletionItemKind["Value"] = 13] = "Value";
  11584. CompletionItemKind[CompletionItemKind["Constant"] = 14] = "Constant";
  11585. CompletionItemKind[CompletionItemKind["Enum"] = 15] = "Enum";
  11586. CompletionItemKind[CompletionItemKind["EnumMember"] = 16] = "EnumMember";
  11587. CompletionItemKind[CompletionItemKind["Keyword"] = 17] = "Keyword";
  11588. CompletionItemKind[CompletionItemKind["Text"] = 18] = "Text";
  11589. CompletionItemKind[CompletionItemKind["Color"] = 19] = "Color";
  11590. CompletionItemKind[CompletionItemKind["File"] = 20] = "File";
  11591. CompletionItemKind[CompletionItemKind["Reference"] = 21] = "Reference";
  11592. CompletionItemKind[CompletionItemKind["Customcolor"] = 22] = "Customcolor";
  11593. CompletionItemKind[CompletionItemKind["Folder"] = 23] = "Folder";
  11594. CompletionItemKind[CompletionItemKind["TypeParameter"] = 24] = "TypeParameter";
  11595. CompletionItemKind[CompletionItemKind["User"] = 25] = "User";
  11596. CompletionItemKind[CompletionItemKind["Issue"] = 26] = "Issue";
  11597. CompletionItemKind[CompletionItemKind["Snippet"] = 27] = "Snippet";
  11598. })(CompletionItemKind = exports.CompletionItemKind || (exports.CompletionItemKind = {}));
  11599. var CompletionItemTag;
  11600. (function (CompletionItemTag) {
  11601. CompletionItemTag[CompletionItemTag["Deprecated"] = 1] = "Deprecated";
  11602. })(CompletionItemTag = exports.CompletionItemTag || (exports.CompletionItemTag = {}));
  11603. /**
  11604. * How a suggest provider was triggered.
  11605. */
  11606. var CompletionTriggerKind;
  11607. (function (CompletionTriggerKind) {
  11608. CompletionTriggerKind[CompletionTriggerKind["Invoke"] = 0] = "Invoke";
  11609. CompletionTriggerKind[CompletionTriggerKind["TriggerCharacter"] = 1] = "TriggerCharacter";
  11610. CompletionTriggerKind[CompletionTriggerKind["TriggerForIncompleteCompletions"] = 2] = "TriggerForIncompleteCompletions";
  11611. })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
  11612. /**
  11613. * A positioning preference for rendering content widgets.
  11614. */
  11615. var ContentWidgetPositionPreference;
  11616. (function (ContentWidgetPositionPreference) {
  11617. /**
  11618. * Place the content widget exactly at a position
  11619. */
  11620. ContentWidgetPositionPreference[ContentWidgetPositionPreference["EXACT"] = 0] = "EXACT";
  11621. /**
  11622. * Place the content widget above a position
  11623. */
  11624. ContentWidgetPositionPreference[ContentWidgetPositionPreference["ABOVE"] = 1] = "ABOVE";
  11625. /**
  11626. * Place the content widget below a position
  11627. */
  11628. ContentWidgetPositionPreference[ContentWidgetPositionPreference["BELOW"] = 2] = "BELOW";
  11629. })(ContentWidgetPositionPreference = exports.ContentWidgetPositionPreference || (exports.ContentWidgetPositionPreference = {}));
  11630. /**
  11631. * Describes the reason the cursor has changed its position.
  11632. */
  11633. var CursorChangeReason;
  11634. (function (CursorChangeReason) {
  11635. /**
  11636. * Unknown or not set.
  11637. */
  11638. CursorChangeReason[CursorChangeReason["NotSet"] = 0] = "NotSet";
  11639. /**
  11640. * A `model.setValue()` was called.
  11641. */
  11642. CursorChangeReason[CursorChangeReason["ContentFlush"] = 1] = "ContentFlush";
  11643. /**
  11644. * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
  11645. */
  11646. CursorChangeReason[CursorChangeReason["RecoverFromMarkers"] = 2] = "RecoverFromMarkers";
  11647. /**
  11648. * There was an explicit user gesture.
  11649. */
  11650. CursorChangeReason[CursorChangeReason["Explicit"] = 3] = "Explicit";
  11651. /**
  11652. * There was a Paste.
  11653. */
  11654. CursorChangeReason[CursorChangeReason["Paste"] = 4] = "Paste";
  11655. /**
  11656. * There was an Undo.
  11657. */
  11658. CursorChangeReason[CursorChangeReason["Undo"] = 5] = "Undo";
  11659. /**
  11660. * There was a Redo.
  11661. */
  11662. CursorChangeReason[CursorChangeReason["Redo"] = 6] = "Redo";
  11663. })(CursorChangeReason = exports.CursorChangeReason || (exports.CursorChangeReason = {}));
  11664. /**
  11665. * The default end of line to use when instantiating models.
  11666. */
  11667. var DefaultEndOfLine;
  11668. (function (DefaultEndOfLine) {
  11669. /**
  11670. * Use line feed (\n) as the end of line character.
  11671. */
  11672. DefaultEndOfLine[DefaultEndOfLine["LF"] = 1] = "LF";
  11673. /**
  11674. * Use carriage return and line feed (\r\n) as the end of line character.
  11675. */
  11676. DefaultEndOfLine[DefaultEndOfLine["CRLF"] = 2] = "CRLF";
  11677. })(DefaultEndOfLine = exports.DefaultEndOfLine || (exports.DefaultEndOfLine = {}));
  11678. /**
  11679. * A document highlight kind.
  11680. */
  11681. var DocumentHighlightKind;
  11682. (function (DocumentHighlightKind) {
  11683. /**
  11684. * A textual occurrence.
  11685. */
  11686. DocumentHighlightKind[DocumentHighlightKind["Text"] = 0] = "Text";
  11687. /**
  11688. * Read-access of a symbol, like reading a variable.
  11689. */
  11690. DocumentHighlightKind[DocumentHighlightKind["Read"] = 1] = "Read";
  11691. /**
  11692. * Write-access of a symbol, like writing to a variable.
  11693. */
  11694. DocumentHighlightKind[DocumentHighlightKind["Write"] = 2] = "Write";
  11695. })(DocumentHighlightKind = exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {}));
  11696. /**
  11697. * Configuration options for auto indentation in the editor
  11698. */
  11699. var EditorAutoIndentStrategy;
  11700. (function (EditorAutoIndentStrategy) {
  11701. EditorAutoIndentStrategy[EditorAutoIndentStrategy["None"] = 0] = "None";
  11702. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Keep"] = 1] = "Keep";
  11703. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Brackets"] = 2] = "Brackets";
  11704. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Advanced"] = 3] = "Advanced";
  11705. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Full"] = 4] = "Full";
  11706. })(EditorAutoIndentStrategy = exports.EditorAutoIndentStrategy || (exports.EditorAutoIndentStrategy = {}));
  11707. var EditorOption;
  11708. (function (EditorOption) {
  11709. EditorOption[EditorOption["acceptSuggestionOnCommitCharacter"] = 0] = "acceptSuggestionOnCommitCharacter";
  11710. EditorOption[EditorOption["acceptSuggestionOnEnter"] = 1] = "acceptSuggestionOnEnter";
  11711. EditorOption[EditorOption["accessibilitySupport"] = 2] = "accessibilitySupport";
  11712. EditorOption[EditorOption["accessibilityPageSize"] = 3] = "accessibilityPageSize";
  11713. EditorOption[EditorOption["ariaLabel"] = 4] = "ariaLabel";
  11714. EditorOption[EditorOption["autoClosingBrackets"] = 5] = "autoClosingBrackets";
  11715. EditorOption[EditorOption["autoClosingDelete"] = 6] = "autoClosingDelete";
  11716. EditorOption[EditorOption["autoClosingOvertype"] = 7] = "autoClosingOvertype";
  11717. EditorOption[EditorOption["autoClosingQuotes"] = 8] = "autoClosingQuotes";
  11718. EditorOption[EditorOption["autoIndent"] = 9] = "autoIndent";
  11719. EditorOption[EditorOption["automaticLayout"] = 10] = "automaticLayout";
  11720. EditorOption[EditorOption["autoSurround"] = 11] = "autoSurround";
  11721. EditorOption[EditorOption["bracketPairColorization"] = 12] = "bracketPairColorization";
  11722. EditorOption[EditorOption["guides"] = 13] = "guides";
  11723. EditorOption[EditorOption["codeLens"] = 14] = "codeLens";
  11724. EditorOption[EditorOption["codeLensFontFamily"] = 15] = "codeLensFontFamily";
  11725. EditorOption[EditorOption["codeLensFontSize"] = 16] = "codeLensFontSize";
  11726. EditorOption[EditorOption["colorDecorators"] = 17] = "colorDecorators";
  11727. EditorOption[EditorOption["columnSelection"] = 18] = "columnSelection";
  11728. EditorOption[EditorOption["comments"] = 19] = "comments";
  11729. EditorOption[EditorOption["contextmenu"] = 20] = "contextmenu";
  11730. EditorOption[EditorOption["copyWithSyntaxHighlighting"] = 21] = "copyWithSyntaxHighlighting";
  11731. EditorOption[EditorOption["cursorBlinking"] = 22] = "cursorBlinking";
  11732. EditorOption[EditorOption["cursorSmoothCaretAnimation"] = 23] = "cursorSmoothCaretAnimation";
  11733. EditorOption[EditorOption["cursorStyle"] = 24] = "cursorStyle";
  11734. EditorOption[EditorOption["cursorSurroundingLines"] = 25] = "cursorSurroundingLines";
  11735. EditorOption[EditorOption["cursorSurroundingLinesStyle"] = 26] = "cursorSurroundingLinesStyle";
  11736. EditorOption[EditorOption["cursorWidth"] = 27] = "cursorWidth";
  11737. EditorOption[EditorOption["disableLayerHinting"] = 28] = "disableLayerHinting";
  11738. EditorOption[EditorOption["disableMonospaceOptimizations"] = 29] = "disableMonospaceOptimizations";
  11739. EditorOption[EditorOption["domReadOnly"] = 30] = "domReadOnly";
  11740. EditorOption[EditorOption["dragAndDrop"] = 31] = "dragAndDrop";
  11741. EditorOption[EditorOption["emptySelectionClipboard"] = 32] = "emptySelectionClipboard";
  11742. EditorOption[EditorOption["extraEditorClassName"] = 33] = "extraEditorClassName";
  11743. EditorOption[EditorOption["fastScrollSensitivity"] = 34] = "fastScrollSensitivity";
  11744. EditorOption[EditorOption["find"] = 35] = "find";
  11745. EditorOption[EditorOption["fixedOverflowWidgets"] = 36] = "fixedOverflowWidgets";
  11746. EditorOption[EditorOption["folding"] = 37] = "folding";
  11747. EditorOption[EditorOption["foldingStrategy"] = 38] = "foldingStrategy";
  11748. EditorOption[EditorOption["foldingHighlight"] = 39] = "foldingHighlight";
  11749. EditorOption[EditorOption["foldingImportsByDefault"] = 40] = "foldingImportsByDefault";
  11750. EditorOption[EditorOption["unfoldOnClickAfterEndOfLine"] = 41] = "unfoldOnClickAfterEndOfLine";
  11751. EditorOption[EditorOption["fontFamily"] = 42] = "fontFamily";
  11752. EditorOption[EditorOption["fontInfo"] = 43] = "fontInfo";
  11753. EditorOption[EditorOption["fontLigatures"] = 44] = "fontLigatures";
  11754. EditorOption[EditorOption["fontSize"] = 45] = "fontSize";
  11755. EditorOption[EditorOption["fontWeight"] = 46] = "fontWeight";
  11756. EditorOption[EditorOption["formatOnPaste"] = 47] = "formatOnPaste";
  11757. EditorOption[EditorOption["formatOnType"] = 48] = "formatOnType";
  11758. EditorOption[EditorOption["glyphMargin"] = 49] = "glyphMargin";
  11759. EditorOption[EditorOption["gotoLocation"] = 50] = "gotoLocation";
  11760. EditorOption[EditorOption["hideCursorInOverviewRuler"] = 51] = "hideCursorInOverviewRuler";
  11761. EditorOption[EditorOption["hover"] = 52] = "hover";
  11762. EditorOption[EditorOption["inDiffEditor"] = 53] = "inDiffEditor";
  11763. EditorOption[EditorOption["inlineSuggest"] = 54] = "inlineSuggest";
  11764. EditorOption[EditorOption["letterSpacing"] = 55] = "letterSpacing";
  11765. EditorOption[EditorOption["lightbulb"] = 56] = "lightbulb";
  11766. EditorOption[EditorOption["lineDecorationsWidth"] = 57] = "lineDecorationsWidth";
  11767. EditorOption[EditorOption["lineHeight"] = 58] = "lineHeight";
  11768. EditorOption[EditorOption["lineNumbers"] = 59] = "lineNumbers";
  11769. EditorOption[EditorOption["lineNumbersMinChars"] = 60] = "lineNumbersMinChars";
  11770. EditorOption[EditorOption["linkedEditing"] = 61] = "linkedEditing";
  11771. EditorOption[EditorOption["links"] = 62] = "links";
  11772. EditorOption[EditorOption["matchBrackets"] = 63] = "matchBrackets";
  11773. EditorOption[EditorOption["minimap"] = 64] = "minimap";
  11774. EditorOption[EditorOption["mouseStyle"] = 65] = "mouseStyle";
  11775. EditorOption[EditorOption["mouseWheelScrollSensitivity"] = 66] = "mouseWheelScrollSensitivity";
  11776. EditorOption[EditorOption["mouseWheelZoom"] = 67] = "mouseWheelZoom";
  11777. EditorOption[EditorOption["multiCursorMergeOverlapping"] = 68] = "multiCursorMergeOverlapping";
  11778. EditorOption[EditorOption["multiCursorModifier"] = 69] = "multiCursorModifier";
  11779. EditorOption[EditorOption["multiCursorPaste"] = 70] = "multiCursorPaste";
  11780. EditorOption[EditorOption["occurrencesHighlight"] = 71] = "occurrencesHighlight";
  11781. EditorOption[EditorOption["overviewRulerBorder"] = 72] = "overviewRulerBorder";
  11782. EditorOption[EditorOption["overviewRulerLanes"] = 73] = "overviewRulerLanes";
  11783. EditorOption[EditorOption["padding"] = 74] = "padding";
  11784. EditorOption[EditorOption["parameterHints"] = 75] = "parameterHints";
  11785. EditorOption[EditorOption["peekWidgetDefaultFocus"] = 76] = "peekWidgetDefaultFocus";
  11786. EditorOption[EditorOption["definitionLinkOpensInPeek"] = 77] = "definitionLinkOpensInPeek";
  11787. EditorOption[EditorOption["quickSuggestions"] = 78] = "quickSuggestions";
  11788. EditorOption[EditorOption["quickSuggestionsDelay"] = 79] = "quickSuggestionsDelay";
  11789. EditorOption[EditorOption["readOnly"] = 80] = "readOnly";
  11790. EditorOption[EditorOption["renameOnType"] = 81] = "renameOnType";
  11791. EditorOption[EditorOption["renderControlCharacters"] = 82] = "renderControlCharacters";
  11792. EditorOption[EditorOption["renderFinalNewline"] = 83] = "renderFinalNewline";
  11793. EditorOption[EditorOption["renderLineHighlight"] = 84] = "renderLineHighlight";
  11794. EditorOption[EditorOption["renderLineHighlightOnlyWhenFocus"] = 85] = "renderLineHighlightOnlyWhenFocus";
  11795. EditorOption[EditorOption["renderValidationDecorations"] = 86] = "renderValidationDecorations";
  11796. EditorOption[EditorOption["renderWhitespace"] = 87] = "renderWhitespace";
  11797. EditorOption[EditorOption["revealHorizontalRightPadding"] = 88] = "revealHorizontalRightPadding";
  11798. EditorOption[EditorOption["roundedSelection"] = 89] = "roundedSelection";
  11799. EditorOption[EditorOption["rulers"] = 90] = "rulers";
  11800. EditorOption[EditorOption["scrollbar"] = 91] = "scrollbar";
  11801. EditorOption[EditorOption["scrollBeyondLastColumn"] = 92] = "scrollBeyondLastColumn";
  11802. EditorOption[EditorOption["scrollBeyondLastLine"] = 93] = "scrollBeyondLastLine";
  11803. EditorOption[EditorOption["scrollPredominantAxis"] = 94] = "scrollPredominantAxis";
  11804. EditorOption[EditorOption["selectionClipboard"] = 95] = "selectionClipboard";
  11805. EditorOption[EditorOption["selectionHighlight"] = 96] = "selectionHighlight";
  11806. EditorOption[EditorOption["selectOnLineNumbers"] = 97] = "selectOnLineNumbers";
  11807. EditorOption[EditorOption["showFoldingControls"] = 98] = "showFoldingControls";
  11808. EditorOption[EditorOption["showUnused"] = 99] = "showUnused";
  11809. EditorOption[EditorOption["snippetSuggestions"] = 100] = "snippetSuggestions";
  11810. EditorOption[EditorOption["smartSelect"] = 101] = "smartSelect";
  11811. EditorOption[EditorOption["smoothScrolling"] = 102] = "smoothScrolling";
  11812. EditorOption[EditorOption["stickyTabStops"] = 103] = "stickyTabStops";
  11813. EditorOption[EditorOption["stopRenderingLineAfter"] = 104] = "stopRenderingLineAfter";
  11814. EditorOption[EditorOption["suggest"] = 105] = "suggest";
  11815. EditorOption[EditorOption["suggestFontSize"] = 106] = "suggestFontSize";
  11816. EditorOption[EditorOption["suggestLineHeight"] = 107] = "suggestLineHeight";
  11817. EditorOption[EditorOption["suggestOnTriggerCharacters"] = 108] = "suggestOnTriggerCharacters";
  11818. EditorOption[EditorOption["suggestSelection"] = 109] = "suggestSelection";
  11819. EditorOption[EditorOption["tabCompletion"] = 110] = "tabCompletion";
  11820. EditorOption[EditorOption["tabIndex"] = 111] = "tabIndex";
  11821. EditorOption[EditorOption["unicodeHighlighting"] = 112] = "unicodeHighlighting";
  11822. EditorOption[EditorOption["unusualLineTerminators"] = 113] = "unusualLineTerminators";
  11823. EditorOption[EditorOption["useShadowDOM"] = 114] = "useShadowDOM";
  11824. EditorOption[EditorOption["useTabStops"] = 115] = "useTabStops";
  11825. EditorOption[EditorOption["wordSeparators"] = 116] = "wordSeparators";
  11826. EditorOption[EditorOption["wordWrap"] = 117] = "wordWrap";
  11827. EditorOption[EditorOption["wordWrapBreakAfterCharacters"] = 118] = "wordWrapBreakAfterCharacters";
  11828. EditorOption[EditorOption["wordWrapBreakBeforeCharacters"] = 119] = "wordWrapBreakBeforeCharacters";
  11829. EditorOption[EditorOption["wordWrapColumn"] = 120] = "wordWrapColumn";
  11830. EditorOption[EditorOption["wordWrapOverride1"] = 121] = "wordWrapOverride1";
  11831. EditorOption[EditorOption["wordWrapOverride2"] = 122] = "wordWrapOverride2";
  11832. EditorOption[EditorOption["wrappingIndent"] = 123] = "wrappingIndent";
  11833. EditorOption[EditorOption["wrappingStrategy"] = 124] = "wrappingStrategy";
  11834. EditorOption[EditorOption["showDeprecated"] = 125] = "showDeprecated";
  11835. EditorOption[EditorOption["inlayHints"] = 126] = "inlayHints";
  11836. EditorOption[EditorOption["editorClassName"] = 127] = "editorClassName";
  11837. EditorOption[EditorOption["pixelRatio"] = 128] = "pixelRatio";
  11838. EditorOption[EditorOption["tabFocusMode"] = 129] = "tabFocusMode";
  11839. EditorOption[EditorOption["layoutInfo"] = 130] = "layoutInfo";
  11840. EditorOption[EditorOption["wrappingInfo"] = 131] = "wrappingInfo";
  11841. })(EditorOption = exports.EditorOption || (exports.EditorOption = {}));
  11842. /**
  11843. * End of line character preference.
  11844. */
  11845. var EndOfLinePreference;
  11846. (function (EndOfLinePreference) {
  11847. /**
  11848. * Use the end of line character identified in the text buffer.
  11849. */
  11850. EndOfLinePreference[EndOfLinePreference["TextDefined"] = 0] = "TextDefined";
  11851. /**
  11852. * Use line feed (\n) as the end of line character.
  11853. */
  11854. EndOfLinePreference[EndOfLinePreference["LF"] = 1] = "LF";
  11855. /**
  11856. * Use carriage return and line feed (\r\n) as the end of line character.
  11857. */
  11858. EndOfLinePreference[EndOfLinePreference["CRLF"] = 2] = "CRLF";
  11859. })(EndOfLinePreference = exports.EndOfLinePreference || (exports.EndOfLinePreference = {}));
  11860. /**
  11861. * End of line character preference.
  11862. */
  11863. var EndOfLineSequence;
  11864. (function (EndOfLineSequence) {
  11865. /**
  11866. * Use line feed (\n) as the end of line character.
  11867. */
  11868. EndOfLineSequence[EndOfLineSequence["LF"] = 0] = "LF";
  11869. /**
  11870. * Use carriage return and line feed (\r\n) as the end of line character.
  11871. */
  11872. EndOfLineSequence[EndOfLineSequence["CRLF"] = 1] = "CRLF";
  11873. })(EndOfLineSequence = exports.EndOfLineSequence || (exports.EndOfLineSequence = {}));
  11874. /**
  11875. * Describes what to do with the indentation when pressing Enter.
  11876. */
  11877. var IndentAction;
  11878. (function (IndentAction) {
  11879. /**
  11880. * Insert new line and copy the previous line's indentation.
  11881. */
  11882. IndentAction[IndentAction["None"] = 0] = "None";
  11883. /**
  11884. * Insert new line and indent once (relative to the previous line's indentation).
  11885. */
  11886. IndentAction[IndentAction["Indent"] = 1] = "Indent";
  11887. /**
  11888. * Insert two new lines:
  11889. * - the first one indented which will hold the cursor
  11890. * - the second one at the same indentation level
  11891. */
  11892. IndentAction[IndentAction["IndentOutdent"] = 2] = "IndentOutdent";
  11893. /**
  11894. * Insert new line and outdent once (relative to the previous line's indentation).
  11895. */
  11896. IndentAction[IndentAction["Outdent"] = 3] = "Outdent";
  11897. })(IndentAction = exports.IndentAction || (exports.IndentAction = {}));
  11898. var InlayHintKind;
  11899. (function (InlayHintKind) {
  11900. InlayHintKind[InlayHintKind["Other"] = 0] = "Other";
  11901. InlayHintKind[InlayHintKind["Type"] = 1] = "Type";
  11902. InlayHintKind[InlayHintKind["Parameter"] = 2] = "Parameter";
  11903. })(InlayHintKind = exports.InlayHintKind || (exports.InlayHintKind = {}));
  11904. /**
  11905. * How an {@link InlineCompletionsProvider inline completion provider} was triggered.
  11906. */
  11907. var InlineCompletionTriggerKind;
  11908. (function (InlineCompletionTriggerKind) {
  11909. /**
  11910. * Completion was triggered automatically while editing.
  11911. * It is sufficient to return a single completion item in this case.
  11912. */
  11913. InlineCompletionTriggerKind[InlineCompletionTriggerKind["Automatic"] = 0] = "Automatic";
  11914. /**
  11915. * Completion was triggered explicitly by a user gesture.
  11916. * Return multiple completion items to enable cycling through them.
  11917. */
  11918. InlineCompletionTriggerKind[InlineCompletionTriggerKind["Explicit"] = 1] = "Explicit";
  11919. })(InlineCompletionTriggerKind = exports.InlineCompletionTriggerKind || (exports.InlineCompletionTriggerKind = {}));
  11920. /**
  11921. * Virtual Key Codes, the value does not hold any inherent meaning.
  11922. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  11923. * But these are "more general", as they should work across browsers & OS`s.
  11924. */
  11925. var KeyCode;
  11926. (function (KeyCode) {
  11927. KeyCode[KeyCode["DependsOnKbLayout"] = -1] = "DependsOnKbLayout";
  11928. /**
  11929. * Placed first to cover the 0 value of the enum.
  11930. */
  11931. KeyCode[KeyCode["Unknown"] = 0] = "Unknown";
  11932. KeyCode[KeyCode["Backspace"] = 1] = "Backspace";
  11933. KeyCode[KeyCode["Tab"] = 2] = "Tab";
  11934. KeyCode[KeyCode["Enter"] = 3] = "Enter";
  11935. KeyCode[KeyCode["Shift"] = 4] = "Shift";
  11936. KeyCode[KeyCode["Ctrl"] = 5] = "Ctrl";
  11937. KeyCode[KeyCode["Alt"] = 6] = "Alt";
  11938. KeyCode[KeyCode["PauseBreak"] = 7] = "PauseBreak";
  11939. KeyCode[KeyCode["CapsLock"] = 8] = "CapsLock";
  11940. KeyCode[KeyCode["Escape"] = 9] = "Escape";
  11941. KeyCode[KeyCode["Space"] = 10] = "Space";
  11942. KeyCode[KeyCode["PageUp"] = 11] = "PageUp";
  11943. KeyCode[KeyCode["PageDown"] = 12] = "PageDown";
  11944. KeyCode[KeyCode["End"] = 13] = "End";
  11945. KeyCode[KeyCode["Home"] = 14] = "Home";
  11946. KeyCode[KeyCode["LeftArrow"] = 15] = "LeftArrow";
  11947. KeyCode[KeyCode["UpArrow"] = 16] = "UpArrow";
  11948. KeyCode[KeyCode["RightArrow"] = 17] = "RightArrow";
  11949. KeyCode[KeyCode["DownArrow"] = 18] = "DownArrow";
  11950. KeyCode[KeyCode["Insert"] = 19] = "Insert";
  11951. KeyCode[KeyCode["Delete"] = 20] = "Delete";
  11952. KeyCode[KeyCode["Digit0"] = 21] = "Digit0";
  11953. KeyCode[KeyCode["Digit1"] = 22] = "Digit1";
  11954. KeyCode[KeyCode["Digit2"] = 23] = "Digit2";
  11955. KeyCode[KeyCode["Digit3"] = 24] = "Digit3";
  11956. KeyCode[KeyCode["Digit4"] = 25] = "Digit4";
  11957. KeyCode[KeyCode["Digit5"] = 26] = "Digit5";
  11958. KeyCode[KeyCode["Digit6"] = 27] = "Digit6";
  11959. KeyCode[KeyCode["Digit7"] = 28] = "Digit7";
  11960. KeyCode[KeyCode["Digit8"] = 29] = "Digit8";
  11961. KeyCode[KeyCode["Digit9"] = 30] = "Digit9";
  11962. KeyCode[KeyCode["KeyA"] = 31] = "KeyA";
  11963. KeyCode[KeyCode["KeyB"] = 32] = "KeyB";
  11964. KeyCode[KeyCode["KeyC"] = 33] = "KeyC";
  11965. KeyCode[KeyCode["KeyD"] = 34] = "KeyD";
  11966. KeyCode[KeyCode["KeyE"] = 35] = "KeyE";
  11967. KeyCode[KeyCode["KeyF"] = 36] = "KeyF";
  11968. KeyCode[KeyCode["KeyG"] = 37] = "KeyG";
  11969. KeyCode[KeyCode["KeyH"] = 38] = "KeyH";
  11970. KeyCode[KeyCode["KeyI"] = 39] = "KeyI";
  11971. KeyCode[KeyCode["KeyJ"] = 40] = "KeyJ";
  11972. KeyCode[KeyCode["KeyK"] = 41] = "KeyK";
  11973. KeyCode[KeyCode["KeyL"] = 42] = "KeyL";
  11974. KeyCode[KeyCode["KeyM"] = 43] = "KeyM";
  11975. KeyCode[KeyCode["KeyN"] = 44] = "KeyN";
  11976. KeyCode[KeyCode["KeyO"] = 45] = "KeyO";
  11977. KeyCode[KeyCode["KeyP"] = 46] = "KeyP";
  11978. KeyCode[KeyCode["KeyQ"] = 47] = "KeyQ";
  11979. KeyCode[KeyCode["KeyR"] = 48] = "KeyR";
  11980. KeyCode[KeyCode["KeyS"] = 49] = "KeyS";
  11981. KeyCode[KeyCode["KeyT"] = 50] = "KeyT";
  11982. KeyCode[KeyCode["KeyU"] = 51] = "KeyU";
  11983. KeyCode[KeyCode["KeyV"] = 52] = "KeyV";
  11984. KeyCode[KeyCode["KeyW"] = 53] = "KeyW";
  11985. KeyCode[KeyCode["KeyX"] = 54] = "KeyX";
  11986. KeyCode[KeyCode["KeyY"] = 55] = "KeyY";
  11987. KeyCode[KeyCode["KeyZ"] = 56] = "KeyZ";
  11988. KeyCode[KeyCode["Meta"] = 57] = "Meta";
  11989. KeyCode[KeyCode["ContextMenu"] = 58] = "ContextMenu";
  11990. KeyCode[KeyCode["F1"] = 59] = "F1";
  11991. KeyCode[KeyCode["F2"] = 60] = "F2";
  11992. KeyCode[KeyCode["F3"] = 61] = "F3";
  11993. KeyCode[KeyCode["F4"] = 62] = "F4";
  11994. KeyCode[KeyCode["F5"] = 63] = "F5";
  11995. KeyCode[KeyCode["F6"] = 64] = "F6";
  11996. KeyCode[KeyCode["F7"] = 65] = "F7";
  11997. KeyCode[KeyCode["F8"] = 66] = "F8";
  11998. KeyCode[KeyCode["F9"] = 67] = "F9";
  11999. KeyCode[KeyCode["F10"] = 68] = "F10";
  12000. KeyCode[KeyCode["F11"] = 69] = "F11";
  12001. KeyCode[KeyCode["F12"] = 70] = "F12";
  12002. KeyCode[KeyCode["F13"] = 71] = "F13";
  12003. KeyCode[KeyCode["F14"] = 72] = "F14";
  12004. KeyCode[KeyCode["F15"] = 73] = "F15";
  12005. KeyCode[KeyCode["F16"] = 74] = "F16";
  12006. KeyCode[KeyCode["F17"] = 75] = "F17";
  12007. KeyCode[KeyCode["F18"] = 76] = "F18";
  12008. KeyCode[KeyCode["F19"] = 77] = "F19";
  12009. KeyCode[KeyCode["NumLock"] = 78] = "NumLock";
  12010. KeyCode[KeyCode["ScrollLock"] = 79] = "ScrollLock";
  12011. /**
  12012. * Used for miscellaneous characters; it can vary by keyboard.
  12013. * For the US standard keyboard, the ';:' key
  12014. */
  12015. KeyCode[KeyCode["Semicolon"] = 80] = "Semicolon";
  12016. /**
  12017. * For any country/region, the '+' key
  12018. * For the US standard keyboard, the '=+' key
  12019. */
  12020. KeyCode[KeyCode["Equal"] = 81] = "Equal";
  12021. /**
  12022. * For any country/region, the ',' key
  12023. * For the US standard keyboard, the ',<' key
  12024. */
  12025. KeyCode[KeyCode["Comma"] = 82] = "Comma";
  12026. /**
  12027. * For any country/region, the '-' key
  12028. * For the US standard keyboard, the '-_' key
  12029. */
  12030. KeyCode[KeyCode["Minus"] = 83] = "Minus";
  12031. /**
  12032. * For any country/region, the '.' key
  12033. * For the US standard keyboard, the '.>' key
  12034. */
  12035. KeyCode[KeyCode["Period"] = 84] = "Period";
  12036. /**
  12037. * Used for miscellaneous characters; it can vary by keyboard.
  12038. * For the US standard keyboard, the '/?' key
  12039. */
  12040. KeyCode[KeyCode["Slash"] = 85] = "Slash";
  12041. /**
  12042. * Used for miscellaneous characters; it can vary by keyboard.
  12043. * For the US standard keyboard, the '`~' key
  12044. */
  12045. KeyCode[KeyCode["Backquote"] = 86] = "Backquote";
  12046. /**
  12047. * Used for miscellaneous characters; it can vary by keyboard.
  12048. * For the US standard keyboard, the '[{' key
  12049. */
  12050. KeyCode[KeyCode["BracketLeft"] = 87] = "BracketLeft";
  12051. /**
  12052. * Used for miscellaneous characters; it can vary by keyboard.
  12053. * For the US standard keyboard, the '\|' key
  12054. */
  12055. KeyCode[KeyCode["Backslash"] = 88] = "Backslash";
  12056. /**
  12057. * Used for miscellaneous characters; it can vary by keyboard.
  12058. * For the US standard keyboard, the ']}' key
  12059. */
  12060. KeyCode[KeyCode["BracketRight"] = 89] = "BracketRight";
  12061. /**
  12062. * Used for miscellaneous characters; it can vary by keyboard.
  12063. * For the US standard keyboard, the ''"' key
  12064. */
  12065. KeyCode[KeyCode["Quote"] = 90] = "Quote";
  12066. /**
  12067. * Used for miscellaneous characters; it can vary by keyboard.
  12068. */
  12069. KeyCode[KeyCode["OEM_8"] = 91] = "OEM_8";
  12070. /**
  12071. * Either the angle bracket key or the backslash key on the RT 102-key keyboard.
  12072. */
  12073. KeyCode[KeyCode["IntlBackslash"] = 92] = "IntlBackslash";
  12074. KeyCode[KeyCode["Numpad0"] = 93] = "Numpad0";
  12075. KeyCode[KeyCode["Numpad1"] = 94] = "Numpad1";
  12076. KeyCode[KeyCode["Numpad2"] = 95] = "Numpad2";
  12077. KeyCode[KeyCode["Numpad3"] = 96] = "Numpad3";
  12078. KeyCode[KeyCode["Numpad4"] = 97] = "Numpad4";
  12079. KeyCode[KeyCode["Numpad5"] = 98] = "Numpad5";
  12080. KeyCode[KeyCode["Numpad6"] = 99] = "Numpad6";
  12081. KeyCode[KeyCode["Numpad7"] = 100] = "Numpad7";
  12082. KeyCode[KeyCode["Numpad8"] = 101] = "Numpad8";
  12083. KeyCode[KeyCode["Numpad9"] = 102] = "Numpad9";
  12084. KeyCode[KeyCode["NumpadMultiply"] = 103] = "NumpadMultiply";
  12085. KeyCode[KeyCode["NumpadAdd"] = 104] = "NumpadAdd";
  12086. KeyCode[KeyCode["NUMPAD_SEPARATOR"] = 105] = "NUMPAD_SEPARATOR";
  12087. KeyCode[KeyCode["NumpadSubtract"] = 106] = "NumpadSubtract";
  12088. KeyCode[KeyCode["NumpadDecimal"] = 107] = "NumpadDecimal";
  12089. KeyCode[KeyCode["NumpadDivide"] = 108] = "NumpadDivide";
  12090. /**
  12091. * Cover all key codes when IME is processing input.
  12092. */
  12093. KeyCode[KeyCode["KEY_IN_COMPOSITION"] = 109] = "KEY_IN_COMPOSITION";
  12094. KeyCode[KeyCode["ABNT_C1"] = 110] = "ABNT_C1";
  12095. KeyCode[KeyCode["ABNT_C2"] = 111] = "ABNT_C2";
  12096. KeyCode[KeyCode["AudioVolumeMute"] = 112] = "AudioVolumeMute";
  12097. KeyCode[KeyCode["AudioVolumeUp"] = 113] = "AudioVolumeUp";
  12098. KeyCode[KeyCode["AudioVolumeDown"] = 114] = "AudioVolumeDown";
  12099. KeyCode[KeyCode["BrowserSearch"] = 115] = "BrowserSearch";
  12100. KeyCode[KeyCode["BrowserHome"] = 116] = "BrowserHome";
  12101. KeyCode[KeyCode["BrowserBack"] = 117] = "BrowserBack";
  12102. KeyCode[KeyCode["BrowserForward"] = 118] = "BrowserForward";
  12103. KeyCode[KeyCode["MediaTrackNext"] = 119] = "MediaTrackNext";
  12104. KeyCode[KeyCode["MediaTrackPrevious"] = 120] = "MediaTrackPrevious";
  12105. KeyCode[KeyCode["MediaStop"] = 121] = "MediaStop";
  12106. KeyCode[KeyCode["MediaPlayPause"] = 122] = "MediaPlayPause";
  12107. KeyCode[KeyCode["LaunchMediaPlayer"] = 123] = "LaunchMediaPlayer";
  12108. KeyCode[KeyCode["LaunchMail"] = 124] = "LaunchMail";
  12109. KeyCode[KeyCode["LaunchApp2"] = 125] = "LaunchApp2";
  12110. /**
  12111. * Placed last to cover the length of the enum.
  12112. * Please do not depend on this value!
  12113. */
  12114. KeyCode[KeyCode["MAX_VALUE"] = 126] = "MAX_VALUE";
  12115. })(KeyCode = exports.KeyCode || (exports.KeyCode = {}));
  12116. var MarkerSeverity;
  12117. (function (MarkerSeverity) {
  12118. MarkerSeverity[MarkerSeverity["Hint"] = 1] = "Hint";
  12119. MarkerSeverity[MarkerSeverity["Info"] = 2] = "Info";
  12120. MarkerSeverity[MarkerSeverity["Warning"] = 4] = "Warning";
  12121. MarkerSeverity[MarkerSeverity["Error"] = 8] = "Error";
  12122. })(MarkerSeverity = exports.MarkerSeverity || (exports.MarkerSeverity = {}));
  12123. var MarkerTag;
  12124. (function (MarkerTag) {
  12125. MarkerTag[MarkerTag["Unnecessary"] = 1] = "Unnecessary";
  12126. MarkerTag[MarkerTag["Deprecated"] = 2] = "Deprecated";
  12127. })(MarkerTag = exports.MarkerTag || (exports.MarkerTag = {}));
  12128. /**
  12129. * Position in the minimap to render the decoration.
  12130. */
  12131. var MinimapPosition;
  12132. (function (MinimapPosition) {
  12133. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  12134. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  12135. })(MinimapPosition = exports.MinimapPosition || (exports.MinimapPosition = {}));
  12136. /**
  12137. * Type of hit element with the mouse in the editor.
  12138. */
  12139. var MouseTargetType;
  12140. (function (MouseTargetType) {
  12141. /**
  12142. * Mouse is on top of an unknown element.
  12143. */
  12144. MouseTargetType[MouseTargetType["UNKNOWN"] = 0] = "UNKNOWN";
  12145. /**
  12146. * Mouse is on top of the textarea used for input.
  12147. */
  12148. MouseTargetType[MouseTargetType["TEXTAREA"] = 1] = "TEXTAREA";
  12149. /**
  12150. * Mouse is on top of the glyph margin
  12151. */
  12152. MouseTargetType[MouseTargetType["GUTTER_GLYPH_MARGIN"] = 2] = "GUTTER_GLYPH_MARGIN";
  12153. /**
  12154. * Mouse is on top of the line numbers
  12155. */
  12156. MouseTargetType[MouseTargetType["GUTTER_LINE_NUMBERS"] = 3] = "GUTTER_LINE_NUMBERS";
  12157. /**
  12158. * Mouse is on top of the line decorations
  12159. */
  12160. MouseTargetType[MouseTargetType["GUTTER_LINE_DECORATIONS"] = 4] = "GUTTER_LINE_DECORATIONS";
  12161. /**
  12162. * Mouse is on top of the whitespace left in the gutter by a view zone.
  12163. */
  12164. MouseTargetType[MouseTargetType["GUTTER_VIEW_ZONE"] = 5] = "GUTTER_VIEW_ZONE";
  12165. /**
  12166. * Mouse is on top of text in the content.
  12167. */
  12168. MouseTargetType[MouseTargetType["CONTENT_TEXT"] = 6] = "CONTENT_TEXT";
  12169. /**
  12170. * Mouse is on top of empty space in the content (e.g. after line text or below last line)
  12171. */
  12172. MouseTargetType[MouseTargetType["CONTENT_EMPTY"] = 7] = "CONTENT_EMPTY";
  12173. /**
  12174. * Mouse is on top of a view zone in the content.
  12175. */
  12176. MouseTargetType[MouseTargetType["CONTENT_VIEW_ZONE"] = 8] = "CONTENT_VIEW_ZONE";
  12177. /**
  12178. * Mouse is on top of a content widget.
  12179. */
  12180. MouseTargetType[MouseTargetType["CONTENT_WIDGET"] = 9] = "CONTENT_WIDGET";
  12181. /**
  12182. * Mouse is on top of the decorations overview ruler.
  12183. */
  12184. MouseTargetType[MouseTargetType["OVERVIEW_RULER"] = 10] = "OVERVIEW_RULER";
  12185. /**
  12186. * Mouse is on top of a scrollbar.
  12187. */
  12188. MouseTargetType[MouseTargetType["SCROLLBAR"] = 11] = "SCROLLBAR";
  12189. /**
  12190. * Mouse is on top of an overlay widget.
  12191. */
  12192. MouseTargetType[MouseTargetType["OVERLAY_WIDGET"] = 12] = "OVERLAY_WIDGET";
  12193. /**
  12194. * Mouse is outside of the editor.
  12195. */
  12196. MouseTargetType[MouseTargetType["OUTSIDE_EDITOR"] = 13] = "OUTSIDE_EDITOR";
  12197. })(MouseTargetType = exports.MouseTargetType || (exports.MouseTargetType = {}));
  12198. /**
  12199. * A positioning preference for rendering overlay widgets.
  12200. */
  12201. var OverlayWidgetPositionPreference;
  12202. (function (OverlayWidgetPositionPreference) {
  12203. /**
  12204. * Position the overlay widget in the top right corner
  12205. */
  12206. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_RIGHT_CORNER"] = 0] = "TOP_RIGHT_CORNER";
  12207. /**
  12208. * Position the overlay widget in the bottom right corner
  12209. */
  12210. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["BOTTOM_RIGHT_CORNER"] = 1] = "BOTTOM_RIGHT_CORNER";
  12211. /**
  12212. * Position the overlay widget in the top center
  12213. */
  12214. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_CENTER"] = 2] = "TOP_CENTER";
  12215. })(OverlayWidgetPositionPreference = exports.OverlayWidgetPositionPreference || (exports.OverlayWidgetPositionPreference = {}));
  12216. /**
  12217. * Vertical Lane in the overview ruler of the editor.
  12218. */
  12219. var OverviewRulerLane;
  12220. (function (OverviewRulerLane) {
  12221. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  12222. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  12223. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  12224. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  12225. })(OverviewRulerLane = exports.OverviewRulerLane || (exports.OverviewRulerLane = {}));
  12226. var RenderLineNumbersType;
  12227. (function (RenderLineNumbersType) {
  12228. RenderLineNumbersType[RenderLineNumbersType["Off"] = 0] = "Off";
  12229. RenderLineNumbersType[RenderLineNumbersType["On"] = 1] = "On";
  12230. RenderLineNumbersType[RenderLineNumbersType["Relative"] = 2] = "Relative";
  12231. RenderLineNumbersType[RenderLineNumbersType["Interval"] = 3] = "Interval";
  12232. RenderLineNumbersType[RenderLineNumbersType["Custom"] = 4] = "Custom";
  12233. })(RenderLineNumbersType = exports.RenderLineNumbersType || (exports.RenderLineNumbersType = {}));
  12234. var RenderMinimap;
  12235. (function (RenderMinimap) {
  12236. RenderMinimap[RenderMinimap["None"] = 0] = "None";
  12237. RenderMinimap[RenderMinimap["Text"] = 1] = "Text";
  12238. RenderMinimap[RenderMinimap["Blocks"] = 2] = "Blocks";
  12239. })(RenderMinimap = exports.RenderMinimap || (exports.RenderMinimap = {}));
  12240. var ScrollType;
  12241. (function (ScrollType) {
  12242. ScrollType[ScrollType["Smooth"] = 0] = "Smooth";
  12243. ScrollType[ScrollType["Immediate"] = 1] = "Immediate";
  12244. })(ScrollType = exports.ScrollType || (exports.ScrollType = {}));
  12245. var ScrollbarVisibility;
  12246. (function (ScrollbarVisibility) {
  12247. ScrollbarVisibility[ScrollbarVisibility["Auto"] = 1] = "Auto";
  12248. ScrollbarVisibility[ScrollbarVisibility["Hidden"] = 2] = "Hidden";
  12249. ScrollbarVisibility[ScrollbarVisibility["Visible"] = 3] = "Visible";
  12250. })(ScrollbarVisibility = exports.ScrollbarVisibility || (exports.ScrollbarVisibility = {}));
  12251. /**
  12252. * The direction of a selection.
  12253. */
  12254. var SelectionDirection;
  12255. (function (SelectionDirection) {
  12256. /**
  12257. * The selection starts above where it ends.
  12258. */
  12259. SelectionDirection[SelectionDirection["LTR"] = 0] = "LTR";
  12260. /**
  12261. * The selection starts below where it ends.
  12262. */
  12263. SelectionDirection[SelectionDirection["RTL"] = 1] = "RTL";
  12264. })(SelectionDirection = exports.SelectionDirection || (exports.SelectionDirection = {}));
  12265. var SignatureHelpTriggerKind;
  12266. (function (SignatureHelpTriggerKind) {
  12267. SignatureHelpTriggerKind[SignatureHelpTriggerKind["Invoke"] = 1] = "Invoke";
  12268. SignatureHelpTriggerKind[SignatureHelpTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter";
  12269. SignatureHelpTriggerKind[SignatureHelpTriggerKind["ContentChange"] = 3] = "ContentChange";
  12270. })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
  12271. /**
  12272. * A symbol kind.
  12273. */
  12274. var SymbolKind;
  12275. (function (SymbolKind) {
  12276. SymbolKind[SymbolKind["File"] = 0] = "File";
  12277. SymbolKind[SymbolKind["Module"] = 1] = "Module";
  12278. SymbolKind[SymbolKind["Namespace"] = 2] = "Namespace";
  12279. SymbolKind[SymbolKind["Package"] = 3] = "Package";
  12280. SymbolKind[SymbolKind["Class"] = 4] = "Class";
  12281. SymbolKind[SymbolKind["Method"] = 5] = "Method";
  12282. SymbolKind[SymbolKind["Property"] = 6] = "Property";
  12283. SymbolKind[SymbolKind["Field"] = 7] = "Field";
  12284. SymbolKind[SymbolKind["Constructor"] = 8] = "Constructor";
  12285. SymbolKind[SymbolKind["Enum"] = 9] = "Enum";
  12286. SymbolKind[SymbolKind["Interface"] = 10] = "Interface";
  12287. SymbolKind[SymbolKind["Function"] = 11] = "Function";
  12288. SymbolKind[SymbolKind["Variable"] = 12] = "Variable";
  12289. SymbolKind[SymbolKind["Constant"] = 13] = "Constant";
  12290. SymbolKind[SymbolKind["String"] = 14] = "String";
  12291. SymbolKind[SymbolKind["Number"] = 15] = "Number";
  12292. SymbolKind[SymbolKind["Boolean"] = 16] = "Boolean";
  12293. SymbolKind[SymbolKind["Array"] = 17] = "Array";
  12294. SymbolKind[SymbolKind["Object"] = 18] = "Object";
  12295. SymbolKind[SymbolKind["Key"] = 19] = "Key";
  12296. SymbolKind[SymbolKind["Null"] = 20] = "Null";
  12297. SymbolKind[SymbolKind["EnumMember"] = 21] = "EnumMember";
  12298. SymbolKind[SymbolKind["Struct"] = 22] = "Struct";
  12299. SymbolKind[SymbolKind["Event"] = 23] = "Event";
  12300. SymbolKind[SymbolKind["Operator"] = 24] = "Operator";
  12301. SymbolKind[SymbolKind["TypeParameter"] = 25] = "TypeParameter";
  12302. })(SymbolKind = exports.SymbolKind || (exports.SymbolKind = {}));
  12303. var SymbolTag;
  12304. (function (SymbolTag) {
  12305. SymbolTag[SymbolTag["Deprecated"] = 1] = "Deprecated";
  12306. })(SymbolTag = exports.SymbolTag || (exports.SymbolTag = {}));
  12307. /**
  12308. * The kind of animation in which the editor's cursor should be rendered.
  12309. */
  12310. var TextEditorCursorBlinkingStyle;
  12311. (function (TextEditorCursorBlinkingStyle) {
  12312. /**
  12313. * Hidden
  12314. */
  12315. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Hidden"] = 0] = "Hidden";
  12316. /**
  12317. * Blinking
  12318. */
  12319. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Blink"] = 1] = "Blink";
  12320. /**
  12321. * Blinking with smooth fading
  12322. */
  12323. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Smooth"] = 2] = "Smooth";
  12324. /**
  12325. * Blinking with prolonged filled state and smooth fading
  12326. */
  12327. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Phase"] = 3] = "Phase";
  12328. /**
  12329. * Expand collapse animation on the y axis
  12330. */
  12331. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Expand"] = 4] = "Expand";
  12332. /**
  12333. * No-Blinking
  12334. */
  12335. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Solid"] = 5] = "Solid";
  12336. })(TextEditorCursorBlinkingStyle = exports.TextEditorCursorBlinkingStyle || (exports.TextEditorCursorBlinkingStyle = {}));
  12337. /**
  12338. * The style in which the editor's cursor should be rendered.
  12339. */
  12340. var TextEditorCursorStyle;
  12341. (function (TextEditorCursorStyle) {
  12342. /**
  12343. * As a vertical line (sitting between two characters).
  12344. */
  12345. TextEditorCursorStyle[TextEditorCursorStyle["Line"] = 1] = "Line";
  12346. /**
  12347. * As a block (sitting on top of a character).
  12348. */
  12349. TextEditorCursorStyle[TextEditorCursorStyle["Block"] = 2] = "Block";
  12350. /**
  12351. * As a horizontal line (sitting under a character).
  12352. */
  12353. TextEditorCursorStyle[TextEditorCursorStyle["Underline"] = 3] = "Underline";
  12354. /**
  12355. * As a thin vertical line (sitting between two characters).
  12356. */
  12357. TextEditorCursorStyle[TextEditorCursorStyle["LineThin"] = 4] = "LineThin";
  12358. /**
  12359. * As an outlined block (sitting on top of a character).
  12360. */
  12361. TextEditorCursorStyle[TextEditorCursorStyle["BlockOutline"] = 5] = "BlockOutline";
  12362. /**
  12363. * As a thin horizontal line (sitting under a character).
  12364. */
  12365. TextEditorCursorStyle[TextEditorCursorStyle["UnderlineThin"] = 6] = "UnderlineThin";
  12366. })(TextEditorCursorStyle = exports.TextEditorCursorStyle || (exports.TextEditorCursorStyle = {}));
  12367. /**
  12368. * Describes the behavior of decorations when typing/editing near their edges.
  12369. * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
  12370. */
  12371. var TrackedRangeStickiness;
  12372. (function (TrackedRangeStickiness) {
  12373. TrackedRangeStickiness[TrackedRangeStickiness["AlwaysGrowsWhenTypingAtEdges"] = 0] = "AlwaysGrowsWhenTypingAtEdges";
  12374. TrackedRangeStickiness[TrackedRangeStickiness["NeverGrowsWhenTypingAtEdges"] = 1] = "NeverGrowsWhenTypingAtEdges";
  12375. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingBefore"] = 2] = "GrowsOnlyWhenTypingBefore";
  12376. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingAfter"] = 3] = "GrowsOnlyWhenTypingAfter";
  12377. })(TrackedRangeStickiness = exports.TrackedRangeStickiness || (exports.TrackedRangeStickiness = {}));
  12378. /**
  12379. * Describes how to indent wrapped lines.
  12380. */
  12381. var WrappingIndent;
  12382. (function (WrappingIndent) {
  12383. /**
  12384. * No indentation => wrapped lines begin at column 1.
  12385. */
  12386. WrappingIndent[WrappingIndent["None"] = 0] = "None";
  12387. /**
  12388. * Same => wrapped lines get the same indentation as the parent.
  12389. */
  12390. WrappingIndent[WrappingIndent["Same"] = 1] = "Same";
  12391. /**
  12392. * Indent => wrapped lines get +1 indentation toward the parent.
  12393. */
  12394. WrappingIndent[WrappingIndent["Indent"] = 2] = "Indent";
  12395. /**
  12396. * DeepIndent => wrapped lines get +2 indentation toward the parent.
  12397. */
  12398. WrappingIndent[WrappingIndent["DeepIndent"] = 3] = "DeepIndent";
  12399. })(WrappingIndent = exports.WrappingIndent || (exports.WrappingIndent = {}));
  12400. });
  12401. /*---------------------------------------------------------------------------------------------
  12402. * Copyright (c) Microsoft Corporation. All rights reserved.
  12403. * Licensed under the MIT License. See License.txt in the project root for license information.
  12404. *--------------------------------------------------------------------------------------------*/
  12405. define(__m[37/*vs/editor/common/standalone/standaloneBase*/], __M([0/*require*/,1/*exports*/,23/*vs/base/common/cancellation*/,7/*vs/base/common/event*/,19/*vs/base/common/keyCodes*/,13/*vs/base/common/uri*/,4/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/,27/*vs/editor/common/core/selection*/,28/*vs/editor/common/core/token*/,36/*vs/editor/common/standalone/standaloneEnums*/]), function (require, exports, cancellation_1, event_1, keyCodes_1, uri_1, position_1, range_1, selection_1, token_1, standaloneEnums) {
  12406. "use strict";
  12407. Object.defineProperty(exports, "__esModule", { value: true });
  12408. exports.createMonacoBaseAPI = exports.KeyMod = void 0;
  12409. class KeyMod {
  12410. static chord(firstPart, secondPart) {
  12411. return (0, keyCodes_1.KeyChord)(firstPart, secondPart);
  12412. }
  12413. }
  12414. exports.KeyMod = KeyMod;
  12415. KeyMod.CtrlCmd = 2048 /* CtrlCmd */;
  12416. KeyMod.Shift = 1024 /* Shift */;
  12417. KeyMod.Alt = 512 /* Alt */;
  12418. KeyMod.WinCtrl = 256 /* WinCtrl */;
  12419. function createMonacoBaseAPI() {
  12420. return {
  12421. editor: undefined,
  12422. languages: undefined,
  12423. CancellationTokenSource: cancellation_1.CancellationTokenSource,
  12424. Emitter: event_1.Emitter,
  12425. KeyCode: standaloneEnums.KeyCode,
  12426. KeyMod: KeyMod,
  12427. Position: position_1.Position,
  12428. Range: range_1.Range,
  12429. Selection: selection_1.Selection,
  12430. SelectionDirection: standaloneEnums.SelectionDirection,
  12431. MarkerSeverity: standaloneEnums.MarkerSeverity,
  12432. MarkerTag: standaloneEnums.MarkerTag,
  12433. Uri: uri_1.URI,
  12434. Token: token_1.Token
  12435. };
  12436. }
  12437. exports.createMonacoBaseAPI = createMonacoBaseAPI;
  12438. });
  12439. /*---------------------------------------------------------------------------------------------
  12440. * Copyright (c) Microsoft Corporation. All rights reserved.
  12441. * Licensed under the MIT License. See License.txt in the project root for license information.
  12442. *--------------------------------------------------------------------------------------------*/
  12443. define(__m[38/*vs/editor/common/viewModel/prefixSumComputer*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/arrays*/,12/*vs/base/common/uint*/]), function (require, exports, arrays_1, uint_1) {
  12444. "use strict";
  12445. Object.defineProperty(exports, "__esModule", { value: true });
  12446. exports.PrefixSumIndexOfResult = exports.ConstantTimePrefixSumComputer = exports.PrefixSumComputer = void 0;
  12447. class PrefixSumComputer {
  12448. constructor(values) {
  12449. this.values = values;
  12450. this.prefixSum = new Uint32Array(values.length);
  12451. this.prefixSumValidIndex = new Int32Array(1);
  12452. this.prefixSumValidIndex[0] = -1;
  12453. }
  12454. insertValues(insertIndex, insertValues) {
  12455. insertIndex = (0, uint_1.toUint32)(insertIndex);
  12456. const oldValues = this.values;
  12457. const oldPrefixSum = this.prefixSum;
  12458. const insertValuesLen = insertValues.length;
  12459. if (insertValuesLen === 0) {
  12460. return false;
  12461. }
  12462. this.values = new Uint32Array(oldValues.length + insertValuesLen);
  12463. this.values.set(oldValues.subarray(0, insertIndex), 0);
  12464. this.values.set(oldValues.subarray(insertIndex), insertIndex + insertValuesLen);
  12465. this.values.set(insertValues, insertIndex);
  12466. if (insertIndex - 1 < this.prefixSumValidIndex[0]) {
  12467. this.prefixSumValidIndex[0] = insertIndex - 1;
  12468. }
  12469. this.prefixSum = new Uint32Array(this.values.length);
  12470. if (this.prefixSumValidIndex[0] >= 0) {
  12471. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  12472. }
  12473. return true;
  12474. }
  12475. setValue(index, value) {
  12476. index = (0, uint_1.toUint32)(index);
  12477. value = (0, uint_1.toUint32)(value);
  12478. if (this.values[index] === value) {
  12479. return false;
  12480. }
  12481. this.values[index] = value;
  12482. if (index - 1 < this.prefixSumValidIndex[0]) {
  12483. this.prefixSumValidIndex[0] = index - 1;
  12484. }
  12485. return true;
  12486. }
  12487. removeValues(startIndex, count) {
  12488. startIndex = (0, uint_1.toUint32)(startIndex);
  12489. count = (0, uint_1.toUint32)(count);
  12490. const oldValues = this.values;
  12491. const oldPrefixSum = this.prefixSum;
  12492. if (startIndex >= oldValues.length) {
  12493. return false;
  12494. }
  12495. let maxCount = oldValues.length - startIndex;
  12496. if (count >= maxCount) {
  12497. count = maxCount;
  12498. }
  12499. if (count === 0) {
  12500. return false;
  12501. }
  12502. this.values = new Uint32Array(oldValues.length - count);
  12503. this.values.set(oldValues.subarray(0, startIndex), 0);
  12504. this.values.set(oldValues.subarray(startIndex + count), startIndex);
  12505. this.prefixSum = new Uint32Array(this.values.length);
  12506. if (startIndex - 1 < this.prefixSumValidIndex[0]) {
  12507. this.prefixSumValidIndex[0] = startIndex - 1;
  12508. }
  12509. if (this.prefixSumValidIndex[0] >= 0) {
  12510. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  12511. }
  12512. return true;
  12513. }
  12514. getTotalSum() {
  12515. if (this.values.length === 0) {
  12516. return 0;
  12517. }
  12518. return this._getPrefixSum(this.values.length - 1);
  12519. }
  12520. /**
  12521. * Returns the sum of the first `index + 1` many items.
  12522. * @returns `SUM(0 <= j <= index, values[j])`.
  12523. */
  12524. getPrefixSum(index) {
  12525. if (index < 0) {
  12526. return 0;
  12527. }
  12528. index = (0, uint_1.toUint32)(index);
  12529. return this._getPrefixSum(index);
  12530. }
  12531. _getPrefixSum(index) {
  12532. if (index <= this.prefixSumValidIndex[0]) {
  12533. return this.prefixSum[index];
  12534. }
  12535. let startIndex = this.prefixSumValidIndex[0] + 1;
  12536. if (startIndex === 0) {
  12537. this.prefixSum[0] = this.values[0];
  12538. startIndex++;
  12539. }
  12540. if (index >= this.values.length) {
  12541. index = this.values.length - 1;
  12542. }
  12543. for (let i = startIndex; i <= index; i++) {
  12544. this.prefixSum[i] = this.prefixSum[i - 1] + this.values[i];
  12545. }
  12546. this.prefixSumValidIndex[0] = Math.max(this.prefixSumValidIndex[0], index);
  12547. return this.prefixSum[index];
  12548. }
  12549. getIndexOf(sum) {
  12550. sum = Math.floor(sum);
  12551. // Compute all sums (to get a fully valid prefixSum)
  12552. this.getTotalSum();
  12553. let low = 0;
  12554. let high = this.values.length - 1;
  12555. let mid = 0;
  12556. let midStop = 0;
  12557. let midStart = 0;
  12558. while (low <= high) {
  12559. mid = low + ((high - low) / 2) | 0;
  12560. midStop = this.prefixSum[mid];
  12561. midStart = midStop - this.values[mid];
  12562. if (sum < midStart) {
  12563. high = mid - 1;
  12564. }
  12565. else if (sum >= midStop) {
  12566. low = mid + 1;
  12567. }
  12568. else {
  12569. break;
  12570. }
  12571. }
  12572. return new PrefixSumIndexOfResult(mid, sum - midStart);
  12573. }
  12574. }
  12575. exports.PrefixSumComputer = PrefixSumComputer;
  12576. /**
  12577. * {@link getIndexOf} has an amortized runtime complexity of O(1).
  12578. *
  12579. * ({@link PrefixSumComputer.getIndexOf} is just O(log n))
  12580. */
  12581. class ConstantTimePrefixSumComputer {
  12582. constructor(values) {
  12583. this._values = values;
  12584. this._isValid = false;
  12585. this._validEndIndex = -1;
  12586. this._prefixSum = [];
  12587. this._indexBySum = [];
  12588. }
  12589. /**
  12590. * @returns SUM(0 <= j < values.length, values[j])
  12591. */
  12592. getTotalSum() {
  12593. this._ensureValid();
  12594. return this._indexBySum.length;
  12595. }
  12596. /**
  12597. * Returns the sum of the first `count` many items.
  12598. * @returns `SUM(0 <= j < count, values[j])`.
  12599. */
  12600. getPrefixSum(count) {
  12601. this._ensureValid();
  12602. if (count === 0) {
  12603. return 0;
  12604. }
  12605. return this._prefixSum[count - 1];
  12606. }
  12607. /**
  12608. * @returns `result`, such that `getPrefixSum(result.index) + result.remainder = sum`
  12609. */
  12610. getIndexOf(sum) {
  12611. this._ensureValid();
  12612. const idx = this._indexBySum[sum];
  12613. const viewLinesAbove = idx > 0 ? this._prefixSum[idx - 1] : 0;
  12614. return new PrefixSumIndexOfResult(idx, sum - viewLinesAbove);
  12615. }
  12616. removeValues(start, deleteCount) {
  12617. this._values.splice(start, deleteCount);
  12618. this._invalidate(start);
  12619. }
  12620. insertValues(insertIndex, insertArr) {
  12621. this._values = (0, arrays_1.arrayInsert)(this._values, insertIndex, insertArr);
  12622. this._invalidate(insertIndex);
  12623. }
  12624. _invalidate(index) {
  12625. this._isValid = false;
  12626. this._validEndIndex = Math.min(this._validEndIndex, index - 1);
  12627. }
  12628. _ensureValid() {
  12629. if (this._isValid) {
  12630. return;
  12631. }
  12632. for (let i = this._validEndIndex + 1, len = this._values.length; i < len; i++) {
  12633. const value = this._values[i];
  12634. const sumAbove = i > 0 ? this._prefixSum[i - 1] : 0;
  12635. this._prefixSum[i] = sumAbove + value;
  12636. for (let j = 0; j < value; j++) {
  12637. this._indexBySum[sumAbove + j] = i;
  12638. }
  12639. }
  12640. // trim things
  12641. this._prefixSum.length = this._values.length;
  12642. this._indexBySum.length = this._prefixSum[this._prefixSum.length - 1];
  12643. // mark as valid
  12644. this._isValid = true;
  12645. this._validEndIndex = this._values.length - 1;
  12646. }
  12647. setValue(index, value) {
  12648. if (this._values[index] === value) {
  12649. // no change
  12650. return;
  12651. }
  12652. this._values[index] = value;
  12653. this._invalidate(index);
  12654. }
  12655. }
  12656. exports.ConstantTimePrefixSumComputer = ConstantTimePrefixSumComputer;
  12657. class PrefixSumIndexOfResult {
  12658. constructor(index, remainder) {
  12659. this.index = index;
  12660. this.remainder = remainder;
  12661. this._prefixSumIndexOfResultBrand = undefined;
  12662. this.index = index;
  12663. this.remainder = remainder;
  12664. }
  12665. }
  12666. exports.PrefixSumIndexOfResult = PrefixSumIndexOfResult;
  12667. });
  12668. /*---------------------------------------------------------------------------------------------
  12669. * Copyright (c) Microsoft Corporation. All rights reserved.
  12670. * Licensed under the MIT License. See License.txt in the project root for license information.
  12671. *--------------------------------------------------------------------------------------------*/
  12672. define(__m[39/*vs/editor/common/model/mirrorTextModel*/], __M([0/*require*/,1/*exports*/,3/*vs/base/common/strings*/,4/*vs/editor/common/core/position*/,38/*vs/editor/common/viewModel/prefixSumComputer*/]), function (require, exports, strings_1, position_1, prefixSumComputer_1) {
  12673. "use strict";
  12674. Object.defineProperty(exports, "__esModule", { value: true });
  12675. exports.MirrorTextModel = void 0;
  12676. class MirrorTextModel {
  12677. constructor(uri, lines, eol, versionId) {
  12678. this._uri = uri;
  12679. this._lines = lines;
  12680. this._eol = eol;
  12681. this._versionId = versionId;
  12682. this._lineStarts = null;
  12683. this._cachedTextValue = null;
  12684. }
  12685. dispose() {
  12686. this._lines.length = 0;
  12687. }
  12688. get version() {
  12689. return this._versionId;
  12690. }
  12691. getText() {
  12692. if (this._cachedTextValue === null) {
  12693. this._cachedTextValue = this._lines.join(this._eol);
  12694. }
  12695. return this._cachedTextValue;
  12696. }
  12697. onEvents(e) {
  12698. if (e.eol && e.eol !== this._eol) {
  12699. this._eol = e.eol;
  12700. this._lineStarts = null;
  12701. }
  12702. // Update my lines
  12703. const changes = e.changes;
  12704. for (const change of changes) {
  12705. this._acceptDeleteRange(change.range);
  12706. this._acceptInsertText(new position_1.Position(change.range.startLineNumber, change.range.startColumn), change.text);
  12707. }
  12708. this._versionId = e.versionId;
  12709. this._cachedTextValue = null;
  12710. }
  12711. _ensureLineStarts() {
  12712. if (!this._lineStarts) {
  12713. const eolLength = this._eol.length;
  12714. const linesLength = this._lines.length;
  12715. const lineStartValues = new Uint32Array(linesLength);
  12716. for (let i = 0; i < linesLength; i++) {
  12717. lineStartValues[i] = this._lines[i].length + eolLength;
  12718. }
  12719. this._lineStarts = new prefixSumComputer_1.PrefixSumComputer(lineStartValues);
  12720. }
  12721. }
  12722. /**
  12723. * All changes to a line's text go through this method
  12724. */
  12725. _setLineText(lineIndex, newValue) {
  12726. this._lines[lineIndex] = newValue;
  12727. if (this._lineStarts) {
  12728. // update prefix sum
  12729. this._lineStarts.setValue(lineIndex, this._lines[lineIndex].length + this._eol.length);
  12730. }
  12731. }
  12732. _acceptDeleteRange(range) {
  12733. if (range.startLineNumber === range.endLineNumber) {
  12734. if (range.startColumn === range.endColumn) {
  12735. // Nothing to delete
  12736. return;
  12737. }
  12738. // Delete text on the affected line
  12739. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  12740. + this._lines[range.startLineNumber - 1].substring(range.endColumn - 1));
  12741. return;
  12742. }
  12743. // Take remaining text on last line and append it to remaining text on first line
  12744. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  12745. + this._lines[range.endLineNumber - 1].substring(range.endColumn - 1));
  12746. // Delete middle lines
  12747. this._lines.splice(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  12748. if (this._lineStarts) {
  12749. // update prefix sum
  12750. this._lineStarts.removeValues(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  12751. }
  12752. }
  12753. _acceptInsertText(position, insertText) {
  12754. if (insertText.length === 0) {
  12755. // Nothing to insert
  12756. return;
  12757. }
  12758. let insertLines = (0, strings_1.splitLines)(insertText);
  12759. if (insertLines.length === 1) {
  12760. // Inserting text on one line
  12761. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  12762. + insertLines[0]
  12763. + this._lines[position.lineNumber - 1].substring(position.column - 1));
  12764. return;
  12765. }
  12766. // Append overflowing text from first line to the end of text to insert
  12767. insertLines[insertLines.length - 1] += this._lines[position.lineNumber - 1].substring(position.column - 1);
  12768. // Delete overflowing text from first line and insert text on first line
  12769. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  12770. + insertLines[0]);
  12771. // Insert new lines & store lengths
  12772. let newLengths = new Uint32Array(insertLines.length - 1);
  12773. for (let i = 1; i < insertLines.length; i++) {
  12774. this._lines.splice(position.lineNumber + i - 1, 0, insertLines[i]);
  12775. newLengths[i - 1] = insertLines[i].length + this._eol.length;
  12776. }
  12777. if (this._lineStarts) {
  12778. // update prefix sum
  12779. this._lineStarts.insertValues(position.lineNumber, newLengths);
  12780. }
  12781. }
  12782. }
  12783. exports.MirrorTextModel = MirrorTextModel;
  12784. });
  12785. /*---------------------------------------------------------------------------------------------
  12786. * Copyright (c) Microsoft Corporation. All rights reserved.
  12787. * Licensed under the MIT License. See License.txt in the project root for license information.
  12788. *--------------------------------------------------------------------------------------------*/
  12789. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  12790. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  12791. return new (P || (P = Promise))(function (resolve, reject) {
  12792. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  12793. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  12794. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  12795. step((generator = generator.apply(thisArg, _arguments || [])).next());
  12796. });
  12797. };
  12798. define(__m[41/*vs/editor/common/services/editorSimpleWorker*/], __M([0/*require*/,1/*exports*/,11/*vs/base/common/diff/diff*/,2/*vs/base/common/platform*/,13/*vs/base/common/uri*/,4/*vs/editor/common/core/position*/,5/*vs/editor/common/core/range*/,29/*vs/editor/common/diff/diffComputer*/,39/*vs/editor/common/model/mirrorTextModel*/,32/*vs/editor/common/model/wordHelper*/,33/*vs/editor/common/modes/linkComputer*/,34/*vs/editor/common/modes/supports/inplaceReplaceSupport*/,37/*vs/editor/common/standalone/standaloneBase*/,6/*vs/base/common/types*/,10/*vs/base/common/stopwatch*/,35/*vs/editor/common/modes/unicodeTextModelHighlighter*/]), function (require, exports, diff_1, platform_1, uri_1, position_1, range_1, diffComputer_1, mirrorTextModel_1, wordHelper_1, linkComputer_1, inplaceReplaceSupport_1, standaloneBase_1, types, stopwatch_1, unicodeTextModelHighlighter_1) {
  12799. "use strict";
  12800. Object.defineProperty(exports, "__esModule", { value: true });
  12801. exports.create = exports.EditorSimpleWorker = exports.MirrorModel = void 0;
  12802. /**
  12803. * @internal
  12804. */
  12805. class MirrorModel extends mirrorTextModel_1.MirrorTextModel {
  12806. get uri() {
  12807. return this._uri;
  12808. }
  12809. get eol() {
  12810. return this._eol;
  12811. }
  12812. getValue() {
  12813. return this.getText();
  12814. }
  12815. getLinesContent() {
  12816. return this._lines.slice(0);
  12817. }
  12818. getLineCount() {
  12819. return this._lines.length;
  12820. }
  12821. getLineContent(lineNumber) {
  12822. return this._lines[lineNumber - 1];
  12823. }
  12824. getWordAtPosition(position, wordDefinition) {
  12825. let wordAtText = (0, wordHelper_1.getWordAtText)(position.column, (0, wordHelper_1.ensureValidWordDefinition)(wordDefinition), this._lines[position.lineNumber - 1], 0);
  12826. if (wordAtText) {
  12827. return new range_1.Range(position.lineNumber, wordAtText.startColumn, position.lineNumber, wordAtText.endColumn);
  12828. }
  12829. return null;
  12830. }
  12831. words(wordDefinition) {
  12832. const lines = this._lines;
  12833. const wordenize = this._wordenize.bind(this);
  12834. let lineNumber = 0;
  12835. let lineText = '';
  12836. let wordRangesIdx = 0;
  12837. let wordRanges = [];
  12838. return {
  12839. *[Symbol.iterator]() {
  12840. while (true) {
  12841. if (wordRangesIdx < wordRanges.length) {
  12842. const value = lineText.substring(wordRanges[wordRangesIdx].start, wordRanges[wordRangesIdx].end);
  12843. wordRangesIdx += 1;
  12844. yield value;
  12845. }
  12846. else {
  12847. if (lineNumber < lines.length) {
  12848. lineText = lines[lineNumber];
  12849. wordRanges = wordenize(lineText, wordDefinition);
  12850. wordRangesIdx = 0;
  12851. lineNumber += 1;
  12852. }
  12853. else {
  12854. break;
  12855. }
  12856. }
  12857. }
  12858. }
  12859. };
  12860. }
  12861. getLineWords(lineNumber, wordDefinition) {
  12862. let content = this._lines[lineNumber - 1];
  12863. let ranges = this._wordenize(content, wordDefinition);
  12864. let words = [];
  12865. for (const range of ranges) {
  12866. words.push({
  12867. word: content.substring(range.start, range.end),
  12868. startColumn: range.start + 1,
  12869. endColumn: range.end + 1
  12870. });
  12871. }
  12872. return words;
  12873. }
  12874. _wordenize(content, wordDefinition) {
  12875. const result = [];
  12876. let match;
  12877. wordDefinition.lastIndex = 0; // reset lastIndex just to be sure
  12878. while (match = wordDefinition.exec(content)) {
  12879. if (match[0].length === 0) {
  12880. // it did match the empty string
  12881. break;
  12882. }
  12883. result.push({ start: match.index, end: match.index + match[0].length });
  12884. }
  12885. return result;
  12886. }
  12887. getValueInRange(range) {
  12888. range = this._validateRange(range);
  12889. if (range.startLineNumber === range.endLineNumber) {
  12890. return this._lines[range.startLineNumber - 1].substring(range.startColumn - 1, range.endColumn - 1);
  12891. }
  12892. let lineEnding = this._eol;
  12893. let startLineIndex = range.startLineNumber - 1;
  12894. let endLineIndex = range.endLineNumber - 1;
  12895. let resultLines = [];
  12896. resultLines.push(this._lines[startLineIndex].substring(range.startColumn - 1));
  12897. for (let i = startLineIndex + 1; i < endLineIndex; i++) {
  12898. resultLines.push(this._lines[i]);
  12899. }
  12900. resultLines.push(this._lines[endLineIndex].substring(0, range.endColumn - 1));
  12901. return resultLines.join(lineEnding);
  12902. }
  12903. offsetAt(position) {
  12904. position = this._validatePosition(position);
  12905. this._ensureLineStarts();
  12906. return this._lineStarts.getPrefixSum(position.lineNumber - 2) + (position.column - 1);
  12907. }
  12908. positionAt(offset) {
  12909. offset = Math.floor(offset);
  12910. offset = Math.max(0, offset);
  12911. this._ensureLineStarts();
  12912. let out = this._lineStarts.getIndexOf(offset);
  12913. let lineLength = this._lines[out.index].length;
  12914. // Ensure we return a valid position
  12915. return {
  12916. lineNumber: 1 + out.index,
  12917. column: 1 + Math.min(out.remainder, lineLength)
  12918. };
  12919. }
  12920. _validateRange(range) {
  12921. const start = this._validatePosition({ lineNumber: range.startLineNumber, column: range.startColumn });
  12922. const end = this._validatePosition({ lineNumber: range.endLineNumber, column: range.endColumn });
  12923. if (start.lineNumber !== range.startLineNumber
  12924. || start.column !== range.startColumn
  12925. || end.lineNumber !== range.endLineNumber
  12926. || end.column !== range.endColumn) {
  12927. return {
  12928. startLineNumber: start.lineNumber,
  12929. startColumn: start.column,
  12930. endLineNumber: end.lineNumber,
  12931. endColumn: end.column
  12932. };
  12933. }
  12934. return range;
  12935. }
  12936. _validatePosition(position) {
  12937. if (!position_1.Position.isIPosition(position)) {
  12938. throw new Error('bad position');
  12939. }
  12940. let { lineNumber, column } = position;
  12941. let hasChanged = false;
  12942. if (lineNumber < 1) {
  12943. lineNumber = 1;
  12944. column = 1;
  12945. hasChanged = true;
  12946. }
  12947. else if (lineNumber > this._lines.length) {
  12948. lineNumber = this._lines.length;
  12949. column = this._lines[lineNumber - 1].length + 1;
  12950. hasChanged = true;
  12951. }
  12952. else {
  12953. let maxCharacter = this._lines[lineNumber - 1].length + 1;
  12954. if (column < 1) {
  12955. column = 1;
  12956. hasChanged = true;
  12957. }
  12958. else if (column > maxCharacter) {
  12959. column = maxCharacter;
  12960. hasChanged = true;
  12961. }
  12962. }
  12963. if (!hasChanged) {
  12964. return position;
  12965. }
  12966. else {
  12967. return { lineNumber, column };
  12968. }
  12969. }
  12970. }
  12971. exports.MirrorModel = MirrorModel;
  12972. /**
  12973. * @internal
  12974. */
  12975. class EditorSimpleWorker {
  12976. constructor(host, foreignModuleFactory) {
  12977. this._host = host;
  12978. this._models = Object.create(null);
  12979. this._foreignModuleFactory = foreignModuleFactory;
  12980. this._foreignModule = null;
  12981. }
  12982. dispose() {
  12983. this._models = Object.create(null);
  12984. }
  12985. _getModel(uri) {
  12986. return this._models[uri];
  12987. }
  12988. _getModels() {
  12989. let all = [];
  12990. Object.keys(this._models).forEach((key) => all.push(this._models[key]));
  12991. return all;
  12992. }
  12993. acceptNewModel(data) {
  12994. this._models[data.url] = new MirrorModel(uri_1.URI.parse(data.url), data.lines, data.EOL, data.versionId);
  12995. }
  12996. acceptModelChanged(strURL, e) {
  12997. if (!this._models[strURL]) {
  12998. return;
  12999. }
  13000. let model = this._models[strURL];
  13001. model.onEvents(e);
  13002. }
  13003. acceptRemovedModel(strURL) {
  13004. if (!this._models[strURL]) {
  13005. return;
  13006. }
  13007. delete this._models[strURL];
  13008. }
  13009. computeUnicodeHighlights(url, options, range) {
  13010. return __awaiter(this, void 0, void 0, function* () {
  13011. const model = this._getModel(url);
  13012. if (!model) {
  13013. return { ranges: [], hasMore: false, ambiguousCharacterCount: 0, invisibleCharacterCount: 0, nonBasicAsciiCharacterCount: 0 };
  13014. }
  13015. return unicodeTextModelHighlighter_1.UnicodeTextModelHighlighter.computeUnicodeHighlights(model, options, range);
  13016. });
  13017. }
  13018. // ---- BEGIN diff --------------------------------------------------------------------------
  13019. computeDiff(originalUrl, modifiedUrl, ignoreTrimWhitespace, maxComputationTime) {
  13020. return __awaiter(this, void 0, void 0, function* () {
  13021. const original = this._getModel(originalUrl);
  13022. const modified = this._getModel(modifiedUrl);
  13023. if (!original || !modified) {
  13024. return null;
  13025. }
  13026. const originalLines = original.getLinesContent();
  13027. const modifiedLines = modified.getLinesContent();
  13028. const diffComputer = new diffComputer_1.DiffComputer(originalLines, modifiedLines, {
  13029. shouldComputeCharChanges: true,
  13030. shouldPostProcessCharChanges: true,
  13031. shouldIgnoreTrimWhitespace: ignoreTrimWhitespace,
  13032. shouldMakePrettyDiff: true,
  13033. maxComputationTime: maxComputationTime
  13034. });
  13035. const diffResult = diffComputer.computeDiff();
  13036. const identical = (diffResult.changes.length > 0 ? false : this._modelsAreIdentical(original, modified));
  13037. return {
  13038. quitEarly: diffResult.quitEarly,
  13039. identical: identical,
  13040. changes: diffResult.changes
  13041. };
  13042. });
  13043. }
  13044. _modelsAreIdentical(original, modified) {
  13045. const originalLineCount = original.getLineCount();
  13046. const modifiedLineCount = modified.getLineCount();
  13047. if (originalLineCount !== modifiedLineCount) {
  13048. return false;
  13049. }
  13050. for (let line = 1; line <= originalLineCount; line++) {
  13051. const originalLine = original.getLineContent(line);
  13052. const modifiedLine = modified.getLineContent(line);
  13053. if (originalLine !== modifiedLine) {
  13054. return false;
  13055. }
  13056. }
  13057. return true;
  13058. }
  13059. computeMoreMinimalEdits(modelUrl, edits) {
  13060. return __awaiter(this, void 0, void 0, function* () {
  13061. const model = this._getModel(modelUrl);
  13062. if (!model) {
  13063. return edits;
  13064. }
  13065. const result = [];
  13066. let lastEol = undefined;
  13067. edits = edits.slice(0).sort((a, b) => {
  13068. if (a.range && b.range) {
  13069. return range_1.Range.compareRangesUsingStarts(a.range, b.range);
  13070. }
  13071. // eol only changes should go to the end
  13072. let aRng = a.range ? 0 : 1;
  13073. let bRng = b.range ? 0 : 1;
  13074. return aRng - bRng;
  13075. });
  13076. for (let { range, text, eol } of edits) {
  13077. if (typeof eol === 'number') {
  13078. lastEol = eol;
  13079. }
  13080. if (range_1.Range.isEmpty(range) && !text) {
  13081. // empty change
  13082. continue;
  13083. }
  13084. const original = model.getValueInRange(range);
  13085. text = text.replace(/\r\n|\n|\r/g, model.eol);
  13086. if (original === text) {
  13087. // noop
  13088. continue;
  13089. }
  13090. // make sure diff won't take too long
  13091. if (Math.max(text.length, original.length) > EditorSimpleWorker._diffLimit) {
  13092. result.push({ range, text });
  13093. continue;
  13094. }
  13095. // compute diff between original and edit.text
  13096. const changes = (0, diff_1.stringDiff)(original, text, false);
  13097. const editOffset = model.offsetAt(range_1.Range.lift(range).getStartPosition());
  13098. for (const change of changes) {
  13099. const start = model.positionAt(editOffset + change.originalStart);
  13100. const end = model.positionAt(editOffset + change.originalStart + change.originalLength);
  13101. const newEdit = {
  13102. text: text.substr(change.modifiedStart, change.modifiedLength),
  13103. range: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }
  13104. };
  13105. if (model.getValueInRange(newEdit.range) !== newEdit.text) {
  13106. result.push(newEdit);
  13107. }
  13108. }
  13109. }
  13110. if (typeof lastEol === 'number') {
  13111. result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
  13112. }
  13113. return result;
  13114. });
  13115. }
  13116. // ---- END minimal edits ---------------------------------------------------------------
  13117. computeLinks(modelUrl) {
  13118. return __awaiter(this, void 0, void 0, function* () {
  13119. let model = this._getModel(modelUrl);
  13120. if (!model) {
  13121. return null;
  13122. }
  13123. return (0, linkComputer_1.computeLinks)(model);
  13124. });
  13125. }
  13126. textualSuggest(modelUrls, leadingWord, wordDef, wordDefFlags) {
  13127. return __awaiter(this, void 0, void 0, function* () {
  13128. const sw = new stopwatch_1.StopWatch(true);
  13129. const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  13130. const seen = new Set();
  13131. outer: for (let url of modelUrls) {
  13132. const model = this._getModel(url);
  13133. if (!model) {
  13134. continue;
  13135. }
  13136. for (let word of model.words(wordDefRegExp)) {
  13137. if (word === leadingWord || !isNaN(Number(word))) {
  13138. continue;
  13139. }
  13140. seen.add(word);
  13141. if (seen.size > EditorSimpleWorker._suggestionsLimit) {
  13142. break outer;
  13143. }
  13144. }
  13145. }
  13146. return { words: Array.from(seen), duration: sw.elapsed() };
  13147. });
  13148. }
  13149. // ---- END suggest --------------------------------------------------------------------------
  13150. //#region -- word ranges --
  13151. computeWordRanges(modelUrl, range, wordDef, wordDefFlags) {
  13152. return __awaiter(this, void 0, void 0, function* () {
  13153. let model = this._getModel(modelUrl);
  13154. if (!model) {
  13155. return Object.create(null);
  13156. }
  13157. const wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  13158. const result = Object.create(null);
  13159. for (let line = range.startLineNumber; line < range.endLineNumber; line++) {
  13160. let words = model.getLineWords(line, wordDefRegExp);
  13161. for (const word of words) {
  13162. if (!isNaN(Number(word.word))) {
  13163. continue;
  13164. }
  13165. let array = result[word.word];
  13166. if (!array) {
  13167. array = [];
  13168. result[word.word] = array;
  13169. }
  13170. array.push({
  13171. startLineNumber: line,
  13172. startColumn: word.startColumn,
  13173. endLineNumber: line,
  13174. endColumn: word.endColumn
  13175. });
  13176. }
  13177. }
  13178. return result;
  13179. });
  13180. }
  13181. //#endregion
  13182. navigateValueSet(modelUrl, range, up, wordDef, wordDefFlags) {
  13183. return __awaiter(this, void 0, void 0, function* () {
  13184. let model = this._getModel(modelUrl);
  13185. if (!model) {
  13186. return null;
  13187. }
  13188. let wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  13189. if (range.startColumn === range.endColumn) {
  13190. range = {
  13191. startLineNumber: range.startLineNumber,
  13192. startColumn: range.startColumn,
  13193. endLineNumber: range.endLineNumber,
  13194. endColumn: range.endColumn + 1
  13195. };
  13196. }
  13197. let selectionText = model.getValueInRange(range);
  13198. let wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);
  13199. if (!wordRange) {
  13200. return null;
  13201. }
  13202. let word = model.getValueInRange(wordRange);
  13203. let result = inplaceReplaceSupport_1.BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);
  13204. return result;
  13205. });
  13206. }
  13207. // ---- BEGIN foreign module support --------------------------------------------------------------------------
  13208. loadForeignModule(moduleId, createData, foreignHostMethods) {
  13209. const proxyMethodRequest = (method, args) => {
  13210. return this._host.fhr(method, args);
  13211. };
  13212. const foreignHost = types.createProxyObject(foreignHostMethods, proxyMethodRequest);
  13213. let ctx = {
  13214. host: foreignHost,
  13215. getMirrorModels: () => {
  13216. return this._getModels();
  13217. }
  13218. };
  13219. if (this._foreignModuleFactory) {
  13220. this._foreignModule = this._foreignModuleFactory(ctx, createData);
  13221. // static foreing module
  13222. return Promise.resolve(types.getAllMethodNames(this._foreignModule));
  13223. }
  13224. // ESM-comment-begin
  13225. return new Promise((resolve, reject) => {
  13226. require([moduleId], (foreignModule) => {
  13227. this._foreignModule = foreignModule.create(ctx, createData);
  13228. resolve(types.getAllMethodNames(this._foreignModule));
  13229. }, reject);
  13230. });
  13231. // ESM-comment-end
  13232. // ESM-uncomment-begin
  13233. // return Promise.reject(new Error(`Unexpected usage`));
  13234. // ESM-uncomment-end
  13235. }
  13236. // foreign method request
  13237. fmr(method, args) {
  13238. if (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {
  13239. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  13240. }
  13241. try {
  13242. return Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));
  13243. }
  13244. catch (e) {
  13245. return Promise.reject(e);
  13246. }
  13247. }
  13248. }
  13249. exports.EditorSimpleWorker = EditorSimpleWorker;
  13250. // ---- END diff --------------------------------------------------------------------------
  13251. // ---- BEGIN minimal edits ---------------------------------------------------------------
  13252. EditorSimpleWorker._diffLimit = 100000;
  13253. // ---- BEGIN suggest --------------------------------------------------------------------------
  13254. EditorSimpleWorker._suggestionsLimit = 10000;
  13255. /**
  13256. * Called on the worker side
  13257. * @internal
  13258. */
  13259. function create(host) {
  13260. return new EditorSimpleWorker(host, null);
  13261. }
  13262. exports.create = create;
  13263. if (typeof importScripts === 'function') {
  13264. // Running in a web worker
  13265. platform_1.globals.monaco = (0, standaloneBase_1.createMonacoBaseAPI)();
  13266. }
  13267. });
  13268. "use strict";
  13269. /*---------------------------------------------------------------------------------------------
  13270. * Copyright (c) Microsoft Corporation. All rights reserved.
  13271. * Licensed under the MIT License. See License.txt in the project root for license information.
  13272. *--------------------------------------------------------------------------------------------*/
  13273. (function () {
  13274. var _a, _b;
  13275. const MonacoEnvironment = self.MonacoEnvironment;
  13276. const monacoBaseUrl = MonacoEnvironment && MonacoEnvironment.baseUrl ? MonacoEnvironment.baseUrl : '../../../';
  13277. const trustedTypesPolicy = (typeof ((_a = self.trustedTypes) === null || _a === void 0 ? void 0 : _a.createPolicy) === 'function'
  13278. ? (_b = self.trustedTypes) === null || _b === void 0 ? void 0 : _b.createPolicy('amdLoader', {
  13279. createScriptURL: value => value,
  13280. createScript: (_, ...args) => {
  13281. // workaround a chrome issue not allowing to create new functions
  13282. // see https://github.com/w3c/webappsec-trusted-types/wiki/Trusted-Types-for-function-constructor
  13283. const fnArgs = args.slice(0, -1).join(',');
  13284. const fnBody = args.pop().toString();
  13285. const body = `(function anonymous(${fnArgs}) {\n${fnBody}\n})`;
  13286. return body;
  13287. }
  13288. })
  13289. : undefined);
  13290. function canUseEval() {
  13291. try {
  13292. const func = (trustedTypesPolicy
  13293. ? self.eval(trustedTypesPolicy.createScript('', 'true'))
  13294. : new Function('true'));
  13295. func.call(self);
  13296. return true;
  13297. }
  13298. catch (err) {
  13299. return false;
  13300. }
  13301. }
  13302. function loadAMDLoader() {
  13303. return new Promise((resolve, reject) => {
  13304. if (typeof self.define === 'function' && self.define.amd) {
  13305. return resolve();
  13306. }
  13307. const loaderSrc = monacoBaseUrl + 'vs/loader.js';
  13308. const isCrossOrigin = (/^((http:)|(https:)|(file:))/.test(loaderSrc) && loaderSrc.substring(0, self.origin.length) !== self.origin);
  13309. if (!isCrossOrigin && canUseEval()) {
  13310. // use `fetch` if possible because `importScripts`
  13311. // is synchronous and can lead to deadlocks on Safari
  13312. fetch(loaderSrc).then((response) => {
  13313. if (response.status !== 200) {
  13314. throw new Error(response.statusText);
  13315. }
  13316. return response.text();
  13317. }).then((text) => {
  13318. text = `${text}\n//# sourceURL=${loaderSrc}`;
  13319. const func = (trustedTypesPolicy
  13320. ? self.eval(trustedTypesPolicy.createScript('', text))
  13321. : new Function(text));
  13322. func.call(self);
  13323. resolve();
  13324. }).then(undefined, reject);
  13325. return;
  13326. }
  13327. if (trustedTypesPolicy) {
  13328. importScripts(trustedTypesPolicy.createScriptURL(loaderSrc));
  13329. }
  13330. else {
  13331. importScripts(loaderSrc);
  13332. }
  13333. resolve();
  13334. });
  13335. }
  13336. const loadCode = function (moduleId) {
  13337. loadAMDLoader().then(() => {
  13338. require.config({
  13339. baseUrl: monacoBaseUrl,
  13340. catchError: true,
  13341. trustedTypesPolicy,
  13342. amdModulesPattern: /^vs\//
  13343. });
  13344. require([moduleId], function (ws) {
  13345. setTimeout(function () {
  13346. let messageHandler = ws.create((msg, transfer) => {
  13347. self.postMessage(msg, transfer);
  13348. }, null);
  13349. self.onmessage = (e) => messageHandler.onmessage(e.data, e.ports);
  13350. while (beforeReadyMessages.length > 0) {
  13351. self.onmessage(beforeReadyMessages.shift());
  13352. }
  13353. }, 0);
  13354. });
  13355. });
  13356. };
  13357. let isFirstMessage = true;
  13358. let beforeReadyMessages = [];
  13359. self.onmessage = (message) => {
  13360. if (!isFirstMessage) {
  13361. beforeReadyMessages.push(message);
  13362. return;
  13363. }
  13364. isFirstMessage = false;
  13365. loadCode(message.data);
  13366. };
  13367. })();
  13368. }).call(this);
  13369. //# sourceMappingURL=workerMain.js.map