converse.js 2.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 8926:
  4. /***/ ((module) => {
  5. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  6. try {
  7. var info = gen[key](arg);
  8. var value = info.value;
  9. } catch (error) {
  10. reject(error);
  11. return;
  12. }
  13. if (info.done) {
  14. resolve(value);
  15. } else {
  16. Promise.resolve(value).then(_next, _throw);
  17. }
  18. }
  19. function _asyncToGenerator(fn) {
  20. return function () {
  21. var self = this,
  22. args = arguments;
  23. return new Promise(function (resolve, reject) {
  24. var gen = fn.apply(self, args);
  25. function _next(value) {
  26. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  27. }
  28. function _throw(err) {
  29. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  30. }
  31. _next(undefined);
  32. });
  33. };
  34. }
  35. module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
  36. /***/ }),
  37. /***/ 9713:
  38. /***/ ((module) => {
  39. function _defineProperty(obj, key, value) {
  40. if (key in obj) {
  41. Object.defineProperty(obj, key, {
  42. value: value,
  43. enumerable: true,
  44. configurable: true,
  45. writable: true
  46. });
  47. } else {
  48. obj[key] = value;
  49. }
  50. return obj;
  51. }
  52. module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
  53. /***/ }),
  54. /***/ 5318:
  55. /***/ ((module) => {
  56. function _interopRequireDefault(obj) {
  57. return obj && obj.__esModule ? obj : {
  58. "default": obj
  59. };
  60. }
  61. module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
  62. /***/ }),
  63. /***/ 1553:
  64. /***/ ((module) => {
  65. /**
  66. * Copyright (c) 2014-present, Facebook, Inc.
  67. *
  68. * This source code is licensed under the MIT license found in the
  69. * LICENSE file in the root directory of this source tree.
  70. */
  71. var runtime = (function (exports) {
  72. "use strict";
  73. var Op = Object.prototype;
  74. var hasOwn = Op.hasOwnProperty;
  75. var undefined; // More compressible than void 0.
  76. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  77. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  78. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  79. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  80. function define(obj, key, value) {
  81. Object.defineProperty(obj, key, {
  82. value: value,
  83. enumerable: true,
  84. configurable: true,
  85. writable: true
  86. });
  87. return obj[key];
  88. }
  89. try {
  90. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  91. define({}, "");
  92. } catch (err) {
  93. define = function(obj, key, value) {
  94. return obj[key] = value;
  95. };
  96. }
  97. function wrap(innerFn, outerFn, self, tryLocsList) {
  98. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  99. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  100. var generator = Object.create(protoGenerator.prototype);
  101. var context = new Context(tryLocsList || []);
  102. // The ._invoke method unifies the implementations of the .next,
  103. // .throw, and .return methods.
  104. generator._invoke = makeInvokeMethod(innerFn, self, context);
  105. return generator;
  106. }
  107. exports.wrap = wrap;
  108. // Try/catch helper to minimize deoptimizations. Returns a completion
  109. // record like context.tryEntries[i].completion. This interface could
  110. // have been (and was previously) designed to take a closure to be
  111. // invoked without arguments, but in all the cases we care about we
  112. // already have an existing method we want to call, so there's no need
  113. // to create a new function object. We can even get away with assuming
  114. // the method takes exactly one argument, since that happens to be true
  115. // in every case, so we don't have to touch the arguments object. The
  116. // only additional allocation required is the completion record, which
  117. // has a stable shape and so hopefully should be cheap to allocate.
  118. function tryCatch(fn, obj, arg) {
  119. try {
  120. return { type: "normal", arg: fn.call(obj, arg) };
  121. } catch (err) {
  122. return { type: "throw", arg: err };
  123. }
  124. }
  125. var GenStateSuspendedStart = "suspendedStart";
  126. var GenStateSuspendedYield = "suspendedYield";
  127. var GenStateExecuting = "executing";
  128. var GenStateCompleted = "completed";
  129. // Returning this object from the innerFn has the same effect as
  130. // breaking out of the dispatch switch statement.
  131. var ContinueSentinel = {};
  132. // Dummy constructor functions that we use as the .constructor and
  133. // .constructor.prototype properties for functions that return Generator
  134. // objects. For full spec compliance, you may wish to configure your
  135. // minifier not to mangle the names of these two functions.
  136. function Generator() {}
  137. function GeneratorFunction() {}
  138. function GeneratorFunctionPrototype() {}
  139. // This is a polyfill for %IteratorPrototype% for environments that
  140. // don't natively support it.
  141. var IteratorPrototype = {};
  142. define(IteratorPrototype, iteratorSymbol, function () {
  143. return this;
  144. });
  145. var getProto = Object.getPrototypeOf;
  146. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  147. if (NativeIteratorPrototype &&
  148. NativeIteratorPrototype !== Op &&
  149. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  150. // This environment has a native %IteratorPrototype%; use it instead
  151. // of the polyfill.
  152. IteratorPrototype = NativeIteratorPrototype;
  153. }
  154. var Gp = GeneratorFunctionPrototype.prototype =
  155. Generator.prototype = Object.create(IteratorPrototype);
  156. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  157. define(Gp, "constructor", GeneratorFunctionPrototype);
  158. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  159. GeneratorFunction.displayName = define(
  160. GeneratorFunctionPrototype,
  161. toStringTagSymbol,
  162. "GeneratorFunction"
  163. );
  164. // Helper for defining the .next, .throw, and .return methods of the
  165. // Iterator interface in terms of a single ._invoke method.
  166. function defineIteratorMethods(prototype) {
  167. ["next", "throw", "return"].forEach(function(method) {
  168. define(prototype, method, function(arg) {
  169. return this._invoke(method, arg);
  170. });
  171. });
  172. }
  173. exports.isGeneratorFunction = function(genFun) {
  174. var ctor = typeof genFun === "function" && genFun.constructor;
  175. return ctor
  176. ? ctor === GeneratorFunction ||
  177. // For the native GeneratorFunction constructor, the best we can
  178. // do is to check its .name property.
  179. (ctor.displayName || ctor.name) === "GeneratorFunction"
  180. : false;
  181. };
  182. exports.mark = function(genFun) {
  183. if (Object.setPrototypeOf) {
  184. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  185. } else {
  186. genFun.__proto__ = GeneratorFunctionPrototype;
  187. define(genFun, toStringTagSymbol, "GeneratorFunction");
  188. }
  189. genFun.prototype = Object.create(Gp);
  190. return genFun;
  191. };
  192. // Within the body of any async function, `await x` is transformed to
  193. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  194. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  195. // meant to be awaited.
  196. exports.awrap = function(arg) {
  197. return { __await: arg };
  198. };
  199. function AsyncIterator(generator, PromiseImpl) {
  200. function invoke(method, arg, resolve, reject) {
  201. var record = tryCatch(generator[method], generator, arg);
  202. if (record.type === "throw") {
  203. reject(record.arg);
  204. } else {
  205. var result = record.arg;
  206. var value = result.value;
  207. if (value &&
  208. typeof value === "object" &&
  209. hasOwn.call(value, "__await")) {
  210. return PromiseImpl.resolve(value.__await).then(function(value) {
  211. invoke("next", value, resolve, reject);
  212. }, function(err) {
  213. invoke("throw", err, resolve, reject);
  214. });
  215. }
  216. return PromiseImpl.resolve(value).then(function(unwrapped) {
  217. // When a yielded Promise is resolved, its final value becomes
  218. // the .value of the Promise<{value,done}> result for the
  219. // current iteration.
  220. result.value = unwrapped;
  221. resolve(result);
  222. }, function(error) {
  223. // If a rejected Promise was yielded, throw the rejection back
  224. // into the async generator function so it can be handled there.
  225. return invoke("throw", error, resolve, reject);
  226. });
  227. }
  228. }
  229. var previousPromise;
  230. function enqueue(method, arg) {
  231. function callInvokeWithMethodAndArg() {
  232. return new PromiseImpl(function(resolve, reject) {
  233. invoke(method, arg, resolve, reject);
  234. });
  235. }
  236. return previousPromise =
  237. // If enqueue has been called before, then we want to wait until
  238. // all previous Promises have been resolved before calling invoke,
  239. // so that results are always delivered in the correct order. If
  240. // enqueue has not been called before, then it is important to
  241. // call invoke immediately, without waiting on a callback to fire,
  242. // so that the async generator function has the opportunity to do
  243. // any necessary setup in a predictable way. This predictability
  244. // is why the Promise constructor synchronously invokes its
  245. // executor callback, and why async functions synchronously
  246. // execute code before the first await. Since we implement simple
  247. // async functions in terms of async generators, it is especially
  248. // important to get this right, even though it requires care.
  249. previousPromise ? previousPromise.then(
  250. callInvokeWithMethodAndArg,
  251. // Avoid propagating failures to Promises returned by later
  252. // invocations of the iterator.
  253. callInvokeWithMethodAndArg
  254. ) : callInvokeWithMethodAndArg();
  255. }
  256. // Define the unified helper method that is used to implement .next,
  257. // .throw, and .return (see defineIteratorMethods).
  258. this._invoke = enqueue;
  259. }
  260. defineIteratorMethods(AsyncIterator.prototype);
  261. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  262. return this;
  263. });
  264. exports.AsyncIterator = AsyncIterator;
  265. // Note that simple async functions are implemented on top of
  266. // AsyncIterator objects; they just return a Promise for the value of
  267. // the final result produced by the iterator.
  268. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  269. if (PromiseImpl === void 0) PromiseImpl = Promise;
  270. var iter = new AsyncIterator(
  271. wrap(innerFn, outerFn, self, tryLocsList),
  272. PromiseImpl
  273. );
  274. return exports.isGeneratorFunction(outerFn)
  275. ? iter // If outerFn is a generator, return the full iterator.
  276. : iter.next().then(function(result) {
  277. return result.done ? result.value : iter.next();
  278. });
  279. };
  280. function makeInvokeMethod(innerFn, self, context) {
  281. var state = GenStateSuspendedStart;
  282. return function invoke(method, arg) {
  283. if (state === GenStateExecuting) {
  284. throw new Error("Generator is already running");
  285. }
  286. if (state === GenStateCompleted) {
  287. if (method === "throw") {
  288. throw arg;
  289. }
  290. // Be forgiving, per 25.3.3.3.3 of the spec:
  291. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  292. return doneResult();
  293. }
  294. context.method = method;
  295. context.arg = arg;
  296. while (true) {
  297. var delegate = context.delegate;
  298. if (delegate) {
  299. var delegateResult = maybeInvokeDelegate(delegate, context);
  300. if (delegateResult) {
  301. if (delegateResult === ContinueSentinel) continue;
  302. return delegateResult;
  303. }
  304. }
  305. if (context.method === "next") {
  306. // Setting context._sent for legacy support of Babel's
  307. // function.sent implementation.
  308. context.sent = context._sent = context.arg;
  309. } else if (context.method === "throw") {
  310. if (state === GenStateSuspendedStart) {
  311. state = GenStateCompleted;
  312. throw context.arg;
  313. }
  314. context.dispatchException(context.arg);
  315. } else if (context.method === "return") {
  316. context.abrupt("return", context.arg);
  317. }
  318. state = GenStateExecuting;
  319. var record = tryCatch(innerFn, self, context);
  320. if (record.type === "normal") {
  321. // If an exception is thrown from innerFn, we leave state ===
  322. // GenStateExecuting and loop back for another invocation.
  323. state = context.done
  324. ? GenStateCompleted
  325. : GenStateSuspendedYield;
  326. if (record.arg === ContinueSentinel) {
  327. continue;
  328. }
  329. return {
  330. value: record.arg,
  331. done: context.done
  332. };
  333. } else if (record.type === "throw") {
  334. state = GenStateCompleted;
  335. // Dispatch the exception by looping back around to the
  336. // context.dispatchException(context.arg) call above.
  337. context.method = "throw";
  338. context.arg = record.arg;
  339. }
  340. }
  341. };
  342. }
  343. // Call delegate.iterator[context.method](context.arg) and handle the
  344. // result, either by returning a { value, done } result from the
  345. // delegate iterator, or by modifying context.method and context.arg,
  346. // setting context.delegate to null, and returning the ContinueSentinel.
  347. function maybeInvokeDelegate(delegate, context) {
  348. var method = delegate.iterator[context.method];
  349. if (method === undefined) {
  350. // A .throw or .return when the delegate iterator has no .throw
  351. // method always terminates the yield* loop.
  352. context.delegate = null;
  353. if (context.method === "throw") {
  354. // Note: ["return"] must be used for ES3 parsing compatibility.
  355. if (delegate.iterator["return"]) {
  356. // If the delegate iterator has a return method, give it a
  357. // chance to clean up.
  358. context.method = "return";
  359. context.arg = undefined;
  360. maybeInvokeDelegate(delegate, context);
  361. if (context.method === "throw") {
  362. // If maybeInvokeDelegate(context) changed context.method from
  363. // "return" to "throw", let that override the TypeError below.
  364. return ContinueSentinel;
  365. }
  366. }
  367. context.method = "throw";
  368. context.arg = new TypeError(
  369. "The iterator does not provide a 'throw' method");
  370. }
  371. return ContinueSentinel;
  372. }
  373. var record = tryCatch(method, delegate.iterator, context.arg);
  374. if (record.type === "throw") {
  375. context.method = "throw";
  376. context.arg = record.arg;
  377. context.delegate = null;
  378. return ContinueSentinel;
  379. }
  380. var info = record.arg;
  381. if (! info) {
  382. context.method = "throw";
  383. context.arg = new TypeError("iterator result is not an object");
  384. context.delegate = null;
  385. return ContinueSentinel;
  386. }
  387. if (info.done) {
  388. // Assign the result of the finished delegate to the temporary
  389. // variable specified by delegate.resultName (see delegateYield).
  390. context[delegate.resultName] = info.value;
  391. // Resume execution at the desired location (see delegateYield).
  392. context.next = delegate.nextLoc;
  393. // If context.method was "throw" but the delegate handled the
  394. // exception, let the outer generator proceed normally. If
  395. // context.method was "next", forget context.arg since it has been
  396. // "consumed" by the delegate iterator. If context.method was
  397. // "return", allow the original .return call to continue in the
  398. // outer generator.
  399. if (context.method !== "return") {
  400. context.method = "next";
  401. context.arg = undefined;
  402. }
  403. } else {
  404. // Re-yield the result returned by the delegate method.
  405. return info;
  406. }
  407. // The delegate iterator is finished, so forget it and continue with
  408. // the outer generator.
  409. context.delegate = null;
  410. return ContinueSentinel;
  411. }
  412. // Define Generator.prototype.{next,throw,return} in terms of the
  413. // unified ._invoke helper method.
  414. defineIteratorMethods(Gp);
  415. define(Gp, toStringTagSymbol, "Generator");
  416. // A Generator should always return itself as the iterator object when the
  417. // @@iterator function is called on it. Some browsers' implementations of the
  418. // iterator prototype chain incorrectly implement this, causing the Generator
  419. // object to not be returned from this call. This ensures that doesn't happen.
  420. // See https://github.com/facebook/regenerator/issues/274 for more details.
  421. define(Gp, iteratorSymbol, function() {
  422. return this;
  423. });
  424. define(Gp, "toString", function() {
  425. return "[object Generator]";
  426. });
  427. function pushTryEntry(locs) {
  428. var entry = { tryLoc: locs[0] };
  429. if (1 in locs) {
  430. entry.catchLoc = locs[1];
  431. }
  432. if (2 in locs) {
  433. entry.finallyLoc = locs[2];
  434. entry.afterLoc = locs[3];
  435. }
  436. this.tryEntries.push(entry);
  437. }
  438. function resetTryEntry(entry) {
  439. var record = entry.completion || {};
  440. record.type = "normal";
  441. delete record.arg;
  442. entry.completion = record;
  443. }
  444. function Context(tryLocsList) {
  445. // The root entry object (effectively a try statement without a catch
  446. // or a finally block) gives us a place to store values thrown from
  447. // locations where there is no enclosing try statement.
  448. this.tryEntries = [{ tryLoc: "root" }];
  449. tryLocsList.forEach(pushTryEntry, this);
  450. this.reset(true);
  451. }
  452. exports.keys = function(object) {
  453. var keys = [];
  454. for (var key in object) {
  455. keys.push(key);
  456. }
  457. keys.reverse();
  458. // Rather than returning an object with a next method, we keep
  459. // things simple and return the next function itself.
  460. return function next() {
  461. while (keys.length) {
  462. var key = keys.pop();
  463. if (key in object) {
  464. next.value = key;
  465. next.done = false;
  466. return next;
  467. }
  468. }
  469. // To avoid creating an additional object, we just hang the .value
  470. // and .done properties off the next function object itself. This
  471. // also ensures that the minifier will not anonymize the function.
  472. next.done = true;
  473. return next;
  474. };
  475. };
  476. function values(iterable) {
  477. if (iterable) {
  478. var iteratorMethod = iterable[iteratorSymbol];
  479. if (iteratorMethod) {
  480. return iteratorMethod.call(iterable);
  481. }
  482. if (typeof iterable.next === "function") {
  483. return iterable;
  484. }
  485. if (!isNaN(iterable.length)) {
  486. var i = -1, next = function next() {
  487. while (++i < iterable.length) {
  488. if (hasOwn.call(iterable, i)) {
  489. next.value = iterable[i];
  490. next.done = false;
  491. return next;
  492. }
  493. }
  494. next.value = undefined;
  495. next.done = true;
  496. return next;
  497. };
  498. return next.next = next;
  499. }
  500. }
  501. // Return an iterator with no values.
  502. return { next: doneResult };
  503. }
  504. exports.values = values;
  505. function doneResult() {
  506. return { value: undefined, done: true };
  507. }
  508. Context.prototype = {
  509. constructor: Context,
  510. reset: function(skipTempReset) {
  511. this.prev = 0;
  512. this.next = 0;
  513. // Resetting context._sent for legacy support of Babel's
  514. // function.sent implementation.
  515. this.sent = this._sent = undefined;
  516. this.done = false;
  517. this.delegate = null;
  518. this.method = "next";
  519. this.arg = undefined;
  520. this.tryEntries.forEach(resetTryEntry);
  521. if (!skipTempReset) {
  522. for (var name in this) {
  523. // Not sure about the optimal order of these conditions:
  524. if (name.charAt(0) === "t" &&
  525. hasOwn.call(this, name) &&
  526. !isNaN(+name.slice(1))) {
  527. this[name] = undefined;
  528. }
  529. }
  530. }
  531. },
  532. stop: function() {
  533. this.done = true;
  534. var rootEntry = this.tryEntries[0];
  535. var rootRecord = rootEntry.completion;
  536. if (rootRecord.type === "throw") {
  537. throw rootRecord.arg;
  538. }
  539. return this.rval;
  540. },
  541. dispatchException: function(exception) {
  542. if (this.done) {
  543. throw exception;
  544. }
  545. var context = this;
  546. function handle(loc, caught) {
  547. record.type = "throw";
  548. record.arg = exception;
  549. context.next = loc;
  550. if (caught) {
  551. // If the dispatched exception was caught by a catch block,
  552. // then let that catch block handle the exception normally.
  553. context.method = "next";
  554. context.arg = undefined;
  555. }
  556. return !! caught;
  557. }
  558. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  559. var entry = this.tryEntries[i];
  560. var record = entry.completion;
  561. if (entry.tryLoc === "root") {
  562. // Exception thrown outside of any try block that could handle
  563. // it, so set the completion value of the entire function to
  564. // throw the exception.
  565. return handle("end");
  566. }
  567. if (entry.tryLoc <= this.prev) {
  568. var hasCatch = hasOwn.call(entry, "catchLoc");
  569. var hasFinally = hasOwn.call(entry, "finallyLoc");
  570. if (hasCatch && hasFinally) {
  571. if (this.prev < entry.catchLoc) {
  572. return handle(entry.catchLoc, true);
  573. } else if (this.prev < entry.finallyLoc) {
  574. return handle(entry.finallyLoc);
  575. }
  576. } else if (hasCatch) {
  577. if (this.prev < entry.catchLoc) {
  578. return handle(entry.catchLoc, true);
  579. }
  580. } else if (hasFinally) {
  581. if (this.prev < entry.finallyLoc) {
  582. return handle(entry.finallyLoc);
  583. }
  584. } else {
  585. throw new Error("try statement without catch or finally");
  586. }
  587. }
  588. }
  589. },
  590. abrupt: function(type, arg) {
  591. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  592. var entry = this.tryEntries[i];
  593. if (entry.tryLoc <= this.prev &&
  594. hasOwn.call(entry, "finallyLoc") &&
  595. this.prev < entry.finallyLoc) {
  596. var finallyEntry = entry;
  597. break;
  598. }
  599. }
  600. if (finallyEntry &&
  601. (type === "break" ||
  602. type === "continue") &&
  603. finallyEntry.tryLoc <= arg &&
  604. arg <= finallyEntry.finallyLoc) {
  605. // Ignore the finally entry if control is not jumping to a
  606. // location outside the try/catch block.
  607. finallyEntry = null;
  608. }
  609. var record = finallyEntry ? finallyEntry.completion : {};
  610. record.type = type;
  611. record.arg = arg;
  612. if (finallyEntry) {
  613. this.method = "next";
  614. this.next = finallyEntry.finallyLoc;
  615. return ContinueSentinel;
  616. }
  617. return this.complete(record);
  618. },
  619. complete: function(record, afterLoc) {
  620. if (record.type === "throw") {
  621. throw record.arg;
  622. }
  623. if (record.type === "break" ||
  624. record.type === "continue") {
  625. this.next = record.arg;
  626. } else if (record.type === "return") {
  627. this.rval = this.arg = record.arg;
  628. this.method = "return";
  629. this.next = "end";
  630. } else if (record.type === "normal" && afterLoc) {
  631. this.next = afterLoc;
  632. }
  633. return ContinueSentinel;
  634. },
  635. finish: function(finallyLoc) {
  636. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  637. var entry = this.tryEntries[i];
  638. if (entry.finallyLoc === finallyLoc) {
  639. this.complete(entry.completion, entry.afterLoc);
  640. resetTryEntry(entry);
  641. return ContinueSentinel;
  642. }
  643. }
  644. },
  645. "catch": function(tryLoc) {
  646. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  647. var entry = this.tryEntries[i];
  648. if (entry.tryLoc === tryLoc) {
  649. var record = entry.completion;
  650. if (record.type === "throw") {
  651. var thrown = record.arg;
  652. resetTryEntry(entry);
  653. }
  654. return thrown;
  655. }
  656. }
  657. // The context.catch method must only be called with a location
  658. // argument that corresponds to a known catch block.
  659. throw new Error("illegal catch attempt");
  660. },
  661. delegateYield: function(iterable, resultName, nextLoc) {
  662. this.delegate = {
  663. iterator: values(iterable),
  664. resultName: resultName,
  665. nextLoc: nextLoc
  666. };
  667. if (this.method === "next") {
  668. // Deliberately forget the last sent value so that we don't
  669. // accidentally pass it on to the delegate.
  670. this.arg = undefined;
  671. }
  672. return ContinueSentinel;
  673. }
  674. };
  675. // Regardless of whether this script is executing as a CommonJS module
  676. // or not, return the runtime object so that we can declare the variable
  677. // regeneratorRuntime in the outer scope, which allows this module to be
  678. // injected easily by `bin/regenerator --include-runtime script.js`.
  679. return exports;
  680. }(
  681. // If this script is executing as a CommonJS module, use module.exports
  682. // as the regeneratorRuntime namespace. Otherwise create a new empty
  683. // object. Either way, the resulting object will be used to initialize
  684. // the regeneratorRuntime variable at the top of this file.
  685. true ? module.exports : 0
  686. ));
  687. try {
  688. regeneratorRuntime = runtime;
  689. } catch (accidentalStrictMode) {
  690. // This module should not be running in strict mode, so the above
  691. // assignment should always work unless something is misconfigured. Just
  692. // in case runtime.js accidentally runs in strict mode, in modern engines
  693. // we can explicitly access globalThis. In older engines we can escape
  694. // strict mode using a global Function call. This could conceivably fail
  695. // if a Content Security Policy forbids using Function, but in that case
  696. // the proper solution is to fix the accidental strict mode problem. If
  697. // you've misconfigured your bundler to force strict mode and applied a
  698. // CSP to forbid Function, and you're not willing to fix either of those
  699. // problems, please detail your unique predicament in a GitHub issue.
  700. if (typeof globalThis === "object") {
  701. globalThis.regeneratorRuntime = runtime;
  702. } else {
  703. Function("r", "regeneratorRuntime = r")(runtime);
  704. }
  705. }
  706. /***/ }),
  707. /***/ 7757:
  708. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  709. module.exports = __webpack_require__(1553);
  710. /***/ }),
  711. /***/ 9494:
  712. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  713. "use strict";
  714. const atob = __webpack_require__(7672);
  715. const btoa = __webpack_require__(4817);
  716. module.exports = {
  717. atob,
  718. btoa
  719. };
  720. /***/ }),
  721. /***/ 7672:
  722. /***/ ((module) => {
  723. "use strict";
  724. /**
  725. * Implementation of atob() according to the HTML and Infra specs, except that
  726. * instead of throwing INVALID_CHARACTER_ERR we return null.
  727. */
  728. function atob(data) {
  729. // Web IDL requires DOMStrings to just be converted using ECMAScript
  730. // ToString, which in our case amounts to using a template literal.
  731. data = `${data}`;
  732. // "Remove all ASCII whitespace from data."
  733. data = data.replace(/[ \t\n\f\r]/g, "");
  734. // "If data's length divides by 4 leaving no remainder, then: if data ends
  735. // with one or two U+003D (=) code points, then remove them from data."
  736. if (data.length % 4 === 0) {
  737. data = data.replace(/==?$/, "");
  738. }
  739. // "If data's length divides by 4 leaving a remainder of 1, then return
  740. // failure."
  741. //
  742. // "If data contains a code point that is not one of
  743. //
  744. // U+002B (+)
  745. // U+002F (/)
  746. // ASCII alphanumeric
  747. //
  748. // then return failure."
  749. if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) {
  750. return null;
  751. }
  752. // "Let output be an empty byte sequence."
  753. let output = "";
  754. // "Let buffer be an empty buffer that can have bits appended to it."
  755. //
  756. // We append bits via left-shift and or. accumulatedBits is used to track
  757. // when we've gotten to 24 bits.
  758. let buffer = 0;
  759. let accumulatedBits = 0;
  760. // "Let position be a position variable for data, initially pointing at the
  761. // start of data."
  762. //
  763. // "While position does not point past the end of data:"
  764. for (let i = 0; i < data.length; i++) {
  765. // "Find the code point pointed to by position in the second column of
  766. // Table 1: The Base 64 Alphabet of RFC 4648. Let n be the number given in
  767. // the first cell of the same row.
  768. //
  769. // "Append to buffer the six bits corresponding to n, most significant bit
  770. // first."
  771. //
  772. // atobLookup() implements the table from RFC 4648.
  773. buffer <<= 6;
  774. buffer |= atobLookup(data[i]);
  775. accumulatedBits += 6;
  776. // "If buffer has accumulated 24 bits, interpret them as three 8-bit
  777. // big-endian numbers. Append three bytes with values equal to those
  778. // numbers to output, in the same order, and then empty buffer."
  779. if (accumulatedBits === 24) {
  780. output += String.fromCharCode((buffer & 0xff0000) >> 16);
  781. output += String.fromCharCode((buffer & 0xff00) >> 8);
  782. output += String.fromCharCode(buffer & 0xff);
  783. buffer = accumulatedBits = 0;
  784. }
  785. // "Advance position by 1."
  786. }
  787. // "If buffer is not empty, it contains either 12 or 18 bits. If it contains
  788. // 12 bits, then discard the last four and interpret the remaining eight as
  789. // an 8-bit big-endian number. If it contains 18 bits, then discard the last
  790. // two and interpret the remaining 16 as two 8-bit big-endian numbers. Append
  791. // the one or two bytes with values equal to those one or two numbers to
  792. // output, in the same order."
  793. if (accumulatedBits === 12) {
  794. buffer >>= 4;
  795. output += String.fromCharCode(buffer);
  796. } else if (accumulatedBits === 18) {
  797. buffer >>= 2;
  798. output += String.fromCharCode((buffer & 0xff00) >> 8);
  799. output += String.fromCharCode(buffer & 0xff);
  800. }
  801. // "Return output."
  802. return output;
  803. }
  804. /**
  805. * A lookup table for atob(), which converts an ASCII character to the
  806. * corresponding six-bit number.
  807. */
  808. const keystr =
  809. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  810. function atobLookup(chr) {
  811. const index = keystr.indexOf(chr);
  812. // Throw exception if character is not in the lookup string; should not be hit in tests
  813. return index < 0 ? undefined : index;
  814. }
  815. module.exports = atob;
  816. /***/ }),
  817. /***/ 4817:
  818. /***/ ((module) => {
  819. "use strict";
  820. /**
  821. * btoa() as defined by the HTML and Infra specs, which mostly just references
  822. * RFC 4648.
  823. */
  824. function btoa(s) {
  825. let i;
  826. // String conversion as required by Web IDL.
  827. s = `${s}`;
  828. // "The btoa() method must throw an "InvalidCharacterError" DOMException if
  829. // data contains any character whose code point is greater than U+00FF."
  830. for (i = 0; i < s.length; i++) {
  831. if (s.charCodeAt(i) > 255) {
  832. return null;
  833. }
  834. }
  835. let out = "";
  836. for (i = 0; i < s.length; i += 3) {
  837. const groupsOfSix = [undefined, undefined, undefined, undefined];
  838. groupsOfSix[0] = s.charCodeAt(i) >> 2;
  839. groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4;
  840. if (s.length > i + 1) {
  841. groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4;
  842. groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2;
  843. }
  844. if (s.length > i + 2) {
  845. groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6;
  846. groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f;
  847. }
  848. for (let j = 0; j < groupsOfSix.length; j++) {
  849. if (typeof groupsOfSix[j] === "undefined") {
  850. out += "=";
  851. } else {
  852. out += btoaLookup(groupsOfSix[j]);
  853. }
  854. }
  855. }
  856. return out;
  857. }
  858. /**
  859. * Lookup table for btoa(), which converts a six-bit number into the
  860. * corresponding ASCII character.
  861. */
  862. const keystr =
  863. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  864. function btoaLookup(index) {
  865. if (index >= 0 && index < 64) {
  866. return keystr[index];
  867. }
  868. // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests.
  869. return undefined;
  870. }
  871. module.exports = btoa;
  872. /***/ }),
  873. /***/ 4223:
  874. /***/ ((module, exports, __webpack_require__) => {
  875. var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */
  876. !function () {
  877. 'use strict';
  878. var re = {
  879. not_string: /[^s]/,
  880. not_bool: /[^t]/,
  881. not_type: /[^T]/,
  882. not_primitive: /[^v]/,
  883. number: /[diefg]/,
  884. numeric_arg: /[bcdiefguxX]/,
  885. json: /[j]/,
  886. not_json: /[^j]/,
  887. text: /^[^\x25]+/,
  888. modulo: /^\x25{2}/,
  889. placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
  890. key: /^([a-z_][a-z_\d]*)/i,
  891. key_access: /^\.([a-z_][a-z_\d]*)/i,
  892. index_access: /^\[(\d+)\]/,
  893. sign: /^[+-]/
  894. };
  895. function sprintf(key) {
  896. // `arguments` is not an array, but should be fine for this call
  897. return sprintf_format(sprintf_parse(key), arguments);
  898. }
  899. function vsprintf(fmt, argv) {
  900. return sprintf.apply(null, [fmt].concat(argv || []));
  901. }
  902. function sprintf_format(parse_tree, argv) {
  903. var cursor = 1,
  904. tree_length = parse_tree.length,
  905. arg,
  906. output = '',
  907. i,
  908. k,
  909. ph,
  910. pad,
  911. pad_character,
  912. pad_length,
  913. is_positive,
  914. sign;
  915. for (i = 0; i < tree_length; i++) {
  916. if (typeof parse_tree[i] === 'string') {
  917. output += parse_tree[i];
  918. } else if (typeof parse_tree[i] === 'object') {
  919. ph = parse_tree[i]; // convenience purposes only
  920. if (ph.keys) {
  921. // keyword argument
  922. arg = argv[cursor];
  923. for (k = 0; k < ph.keys.length; k++) {
  924. if (arg == undefined) {
  925. throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k - 1]));
  926. }
  927. arg = arg[ph.keys[k]];
  928. }
  929. } else if (ph.param_no) {
  930. // positional argument (explicit)
  931. arg = argv[ph.param_no];
  932. } else {
  933. // positional argument (implicit)
  934. arg = argv[cursor++];
  935. }
  936. if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
  937. arg = arg();
  938. }
  939. if (re.numeric_arg.test(ph.type) && typeof arg !== 'number' && isNaN(arg)) {
  940. throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg));
  941. }
  942. if (re.number.test(ph.type)) {
  943. is_positive = arg >= 0;
  944. }
  945. switch (ph.type) {
  946. case 'b':
  947. arg = parseInt(arg, 10).toString(2);
  948. break;
  949. case 'c':
  950. arg = String.fromCharCode(parseInt(arg, 10));
  951. break;
  952. case 'd':
  953. case 'i':
  954. arg = parseInt(arg, 10);
  955. break;
  956. case 'j':
  957. arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0);
  958. break;
  959. case 'e':
  960. arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential();
  961. break;
  962. case 'f':
  963. arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg);
  964. break;
  965. case 'g':
  966. arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg);
  967. break;
  968. case 'o':
  969. arg = (parseInt(arg, 10) >>> 0).toString(8);
  970. break;
  971. case 's':
  972. arg = String(arg);
  973. arg = ph.precision ? arg.substring(0, ph.precision) : arg;
  974. break;
  975. case 't':
  976. arg = String(!!arg);
  977. arg = ph.precision ? arg.substring(0, ph.precision) : arg;
  978. break;
  979. case 'T':
  980. arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase();
  981. arg = ph.precision ? arg.substring(0, ph.precision) : arg;
  982. break;
  983. case 'u':
  984. arg = parseInt(arg, 10) >>> 0;
  985. break;
  986. case 'v':
  987. arg = arg.valueOf();
  988. arg = ph.precision ? arg.substring(0, ph.precision) : arg;
  989. break;
  990. case 'x':
  991. arg = (parseInt(arg, 10) >>> 0).toString(16);
  992. break;
  993. case 'X':
  994. arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase();
  995. break;
  996. }
  997. if (re.json.test(ph.type)) {
  998. output += arg;
  999. } else {
  1000. if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
  1001. sign = is_positive ? '+' : '-';
  1002. arg = arg.toString().replace(re.sign, '');
  1003. } else {
  1004. sign = '';
  1005. }
  1006. pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ';
  1007. pad_length = ph.width - (sign + arg).length;
  1008. pad = ph.width ? pad_length > 0 ? pad_character.repeat(pad_length) : '' : '';
  1009. output += ph.align ? sign + arg + pad : pad_character === '0' ? sign + pad + arg : pad + sign + arg;
  1010. }
  1011. }
  1012. }
  1013. return output;
  1014. }
  1015. var sprintf_cache = Object.create(null);
  1016. function sprintf_parse(fmt) {
  1017. if (sprintf_cache[fmt]) {
  1018. return sprintf_cache[fmt];
  1019. }
  1020. var _fmt = fmt,
  1021. match,
  1022. parse_tree = [],
  1023. arg_names = 0;
  1024. while (_fmt) {
  1025. if ((match = re.text.exec(_fmt)) !== null) {
  1026. parse_tree.push(match[0]);
  1027. } else if ((match = re.modulo.exec(_fmt)) !== null) {
  1028. parse_tree.push('%');
  1029. } else if ((match = re.placeholder.exec(_fmt)) !== null) {
  1030. if (match[2]) {
  1031. arg_names |= 1;
  1032. var field_list = [],
  1033. replacement_field = match[2],
  1034. field_match = [];
  1035. if ((field_match = re.key.exec(replacement_field)) !== null) {
  1036. field_list.push(field_match[1]);
  1037. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  1038. if ((field_match = re.key_access.exec(replacement_field)) !== null) {
  1039. field_list.push(field_match[1]);
  1040. } else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
  1041. field_list.push(field_match[1]);
  1042. } else {
  1043. throw new SyntaxError('[sprintf] failed to parse named argument key');
  1044. }
  1045. }
  1046. } else {
  1047. throw new SyntaxError('[sprintf] failed to parse named argument key');
  1048. }
  1049. match[2] = field_list;
  1050. } else {
  1051. arg_names |= 2;
  1052. }
  1053. if (arg_names === 3) {
  1054. throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported');
  1055. }
  1056. parse_tree.push({
  1057. placeholder: match[0],
  1058. param_no: match[1],
  1059. keys: match[2],
  1060. sign: match[3],
  1061. pad_char: match[4],
  1062. align: match[5],
  1063. width: match[6],
  1064. precision: match[7],
  1065. type: match[8]
  1066. });
  1067. } else {
  1068. throw new SyntaxError('[sprintf] unexpected placeholder');
  1069. }
  1070. _fmt = _fmt.substring(match[0].length);
  1071. }
  1072. return sprintf_cache[fmt] = parse_tree;
  1073. }
  1074. /**
  1075. * export to either browser or node.js
  1076. */
  1077. /* eslint-disable quote-props */
  1078. if (true) {
  1079. exports.sprintf = sprintf;
  1080. exports.vsprintf = vsprintf;
  1081. }
  1082. if (typeof window !== 'undefined') {
  1083. window['sprintf'] = sprintf;
  1084. window['vsprintf'] = vsprintf;
  1085. if (true) {
  1086. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  1087. return {
  1088. 'sprintf': sprintf,
  1089. 'vsprintf': vsprintf
  1090. };
  1091. }).call(exports, __webpack_require__, exports, module),
  1092. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1093. }
  1094. }
  1095. /* eslint-enable quote-props */
  1096. }(); // eslint-disable-line
  1097. /***/ }),
  1098. /***/ 8677:
  1099. /***/ (function(module, exports, __webpack_require__) {
  1100. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1101. * URI.js - Mutating URLs
  1102. * IPv6 Support
  1103. *
  1104. * Version: 1.19.11
  1105. *
  1106. * Author: Rodney Rehm
  1107. * Web: http://medialize.github.io/URI.js/
  1108. *
  1109. * Licensed under
  1110. * MIT License http://www.opensource.org/licenses/mit-license
  1111. *
  1112. */
  1113. (function (root, factory) {
  1114. 'use strict'; // https://github.com/umdjs/umd/blob/master/returnExports.js
  1115. if ( true && module.exports) {
  1116. // Node
  1117. module.exports = factory();
  1118. } else if (true) {
  1119. // AMD. Register as an anonymous module.
  1120. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1121. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1122. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  1123. __WEBPACK_AMD_DEFINE_FACTORY__),
  1124. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1125. } else {}
  1126. })(this, function (root) {
  1127. 'use strict';
  1128. /*
  1129. var _in = "fe80:0000:0000:0000:0204:61ff:fe9d:f156";
  1130. var _out = IPv6.best(_in);
  1131. var _expected = "fe80::204:61ff:fe9d:f156";
  1132. console.log(_in, _out, _expected, _out === _expected);
  1133. */
  1134. // save current IPv6 variable, if any
  1135. var _IPv6 = root && root.IPv6;
  1136. function bestPresentation(address) {
  1137. // based on:
  1138. // Javascript to test an IPv6 address for proper format, and to
  1139. // present the "best text representation" according to IETF Draft RFC at
  1140. // http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
  1141. // 8 Feb 2010 Rich Brown, Dartware, LLC
  1142. // Please feel free to use this code as long as you provide a link to
  1143. // http://www.intermapper.com
  1144. // http://intermapper.com/support/tools/IPV6-Validator.aspx
  1145. // http://download.dartware.com/thirdparty/ipv6validator.js
  1146. var _address = address.toLowerCase();
  1147. var segments = _address.split(':');
  1148. var length = segments.length;
  1149. var total = 8; // trim colons (:: or ::a:b:c… or …a:b:c::)
  1150. if (segments[0] === '' && segments[1] === '' && segments[2] === '') {
  1151. // must have been ::
  1152. // remove first two items
  1153. segments.shift();
  1154. segments.shift();
  1155. } else if (segments[0] === '' && segments[1] === '') {
  1156. // must have been ::xxxx
  1157. // remove the first item
  1158. segments.shift();
  1159. } else if (segments[length - 1] === '' && segments[length - 2] === '') {
  1160. // must have been xxxx::
  1161. segments.pop();
  1162. }
  1163. length = segments.length; // adjust total segments for IPv4 trailer
  1164. if (segments[length - 1].indexOf('.') !== -1) {
  1165. // found a "." which means IPv4
  1166. total = 7;
  1167. } // fill empty segments them with "0000"
  1168. var pos;
  1169. for (pos = 0; pos < length; pos++) {
  1170. if (segments[pos] === '') {
  1171. break;
  1172. }
  1173. }
  1174. if (pos < total) {
  1175. segments.splice(pos, 1, '0000');
  1176. while (segments.length < total) {
  1177. segments.splice(pos, 0, '0000');
  1178. }
  1179. } // strip leading zeros
  1180. var _segments;
  1181. for (var i = 0; i < total; i++) {
  1182. _segments = segments[i].split('');
  1183. for (var j = 0; j < 3; j++) {
  1184. if (_segments[0] === '0' && _segments.length > 1) {
  1185. _segments.splice(0, 1);
  1186. } else {
  1187. break;
  1188. }
  1189. }
  1190. segments[i] = _segments.join('');
  1191. } // find longest sequence of zeroes and coalesce them into one segment
  1192. var best = -1;
  1193. var _best = 0;
  1194. var _current = 0;
  1195. var current = -1;
  1196. var inzeroes = false; // i; already declared
  1197. for (i = 0; i < total; i++) {
  1198. if (inzeroes) {
  1199. if (segments[i] === '0') {
  1200. _current += 1;
  1201. } else {
  1202. inzeroes = false;
  1203. if (_current > _best) {
  1204. best = current;
  1205. _best = _current;
  1206. }
  1207. }
  1208. } else {
  1209. if (segments[i] === '0') {
  1210. inzeroes = true;
  1211. current = i;
  1212. _current = 1;
  1213. }
  1214. }
  1215. }
  1216. if (_current > _best) {
  1217. best = current;
  1218. _best = _current;
  1219. }
  1220. if (_best > 1) {
  1221. segments.splice(best, _best, '');
  1222. }
  1223. length = segments.length; // assemble remaining segments
  1224. var result = '';
  1225. if (segments[0] === '') {
  1226. result = ':';
  1227. }
  1228. for (i = 0; i < length; i++) {
  1229. result += segments[i];
  1230. if (i === length - 1) {
  1231. break;
  1232. }
  1233. result += ':';
  1234. }
  1235. if (segments[length - 1] === '') {
  1236. result += ':';
  1237. }
  1238. return result;
  1239. }
  1240. function noConflict() {
  1241. /*jshint validthis: true */
  1242. if (root.IPv6 === this) {
  1243. root.IPv6 = _IPv6;
  1244. }
  1245. return this;
  1246. }
  1247. return {
  1248. best: bestPresentation,
  1249. noConflict: noConflict
  1250. };
  1251. });
  1252. /***/ }),
  1253. /***/ 9827:
  1254. /***/ (function(module, exports, __webpack_require__) {
  1255. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1256. * URI.js - Mutating URLs
  1257. * Second Level Domain (SLD) Support
  1258. *
  1259. * Version: 1.19.11
  1260. *
  1261. * Author: Rodney Rehm
  1262. * Web: http://medialize.github.io/URI.js/
  1263. *
  1264. * Licensed under
  1265. * MIT License http://www.opensource.org/licenses/mit-license
  1266. *
  1267. */
  1268. (function (root, factory) {
  1269. 'use strict'; // https://github.com/umdjs/umd/blob/master/returnExports.js
  1270. if ( true && module.exports) {
  1271. // Node
  1272. module.exports = factory();
  1273. } else if (true) {
  1274. // AMD. Register as an anonymous module.
  1275. !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1276. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1277. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  1278. __WEBPACK_AMD_DEFINE_FACTORY__),
  1279. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1280. } else {}
  1281. })(this, function (root) {
  1282. 'use strict'; // save current SecondLevelDomains variable, if any
  1283. var _SecondLevelDomains = root && root.SecondLevelDomains;
  1284. var SLD = {
  1285. // list of known Second Level Domains
  1286. // converted list of SLDs from https://github.com/gavingmiller/second-level-domains
  1287. // ----
  1288. // publicsuffix.org is more current and actually used by a couple of browsers internally.
  1289. // downside is it also contains domains like "dyndns.org" - which is fine for the security
  1290. // issues browser have to deal with (SOP for cookies, etc) - but is way overboard for URI.js
  1291. // ----
  1292. list: {
  1293. 'ac': ' com gov mil net org ',
  1294. 'ae': ' ac co gov mil name net org pro sch ',
  1295. 'af': ' com edu gov net org ',
  1296. 'al': ' com edu gov mil net org ',
  1297. 'ao': ' co ed gv it og pb ',
  1298. 'ar': ' com edu gob gov int mil net org tur ',
  1299. 'at': ' ac co gv or ',
  1300. 'au': ' asn com csiro edu gov id net org ',
  1301. 'ba': ' co com edu gov mil net org rs unbi unmo unsa untz unze ',
  1302. 'bb': ' biz co com edu gov info net org store tv ',
  1303. 'bh': ' biz cc com edu gov info net org ',
  1304. 'bn': ' com edu gov net org ',
  1305. 'bo': ' com edu gob gov int mil net org tv ',
  1306. 'br': ' adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ',
  1307. 'bs': ' com edu gov net org ',
  1308. 'bz': ' du et om ov rg ',
  1309. 'ca': ' ab bc mb nb nf nl ns nt nu on pe qc sk yk ',
  1310. 'ck': ' biz co edu gen gov info net org ',
  1311. 'cn': ' ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ',
  1312. 'co': ' com edu gov mil net nom org ',
  1313. 'cr': ' ac c co ed fi go or sa ',
  1314. 'cy': ' ac biz com ekloges gov ltd name net org parliament press pro tm ',
  1315. 'do': ' art com edu gob gov mil net org sld web ',
  1316. 'dz': ' art asso com edu gov net org pol ',
  1317. 'ec': ' com edu fin gov info med mil net org pro ',
  1318. 'eg': ' com edu eun gov mil name net org sci ',
  1319. 'er': ' com edu gov ind mil net org rochest w ',
  1320. 'es': ' com edu gob nom org ',
  1321. 'et': ' biz com edu gov info name net org ',
  1322. 'fj': ' ac biz com info mil name net org pro ',
  1323. 'fk': ' ac co gov net nom org ',
  1324. 'fr': ' asso com f gouv nom prd presse tm ',
  1325. 'gg': ' co net org ',
  1326. 'gh': ' com edu gov mil org ',
  1327. 'gn': ' ac com gov net org ',
  1328. 'gr': ' com edu gov mil net org ',
  1329. 'gt': ' com edu gob ind mil net org ',
  1330. 'gu': ' com edu gov net org ',
  1331. 'hk': ' com edu gov idv net org ',
  1332. 'hu': ' 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ',
  1333. 'id': ' ac co go mil net or sch web ',
  1334. 'il': ' ac co gov idf k12 muni net org ',
  1335. 'in': ' ac co edu ernet firm gen gov i ind mil net nic org res ',
  1336. 'iq': ' com edu gov i mil net org ',
  1337. 'ir': ' ac co dnssec gov i id net org sch ',
  1338. 'it': ' edu gov ',
  1339. 'je': ' co net org ',
  1340. 'jo': ' com edu gov mil name net org sch ',
  1341. 'jp': ' ac ad co ed go gr lg ne or ',
  1342. 'ke': ' ac co go info me mobi ne or sc ',
  1343. 'kh': ' com edu gov mil net org per ',
  1344. 'ki': ' biz com de edu gov info mob net org tel ',
  1345. 'km': ' asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ',
  1346. 'kn': ' edu gov net org ',
  1347. 'kr': ' ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ',
  1348. 'kw': ' com edu gov net org ',
  1349. 'ky': ' com edu gov net org ',
  1350. 'kz': ' com edu gov mil net org ',
  1351. 'lb': ' com edu gov net org ',
  1352. 'lk': ' assn com edu gov grp hotel int ltd net ngo org sch soc web ',
  1353. 'lr': ' com edu gov net org ',
  1354. 'lv': ' asn com conf edu gov id mil net org ',
  1355. 'ly': ' com edu gov id med net org plc sch ',
  1356. 'ma': ' ac co gov m net org press ',
  1357. 'mc': ' asso tm ',
  1358. 'me': ' ac co edu gov its net org priv ',
  1359. 'mg': ' com edu gov mil nom org prd tm ',
  1360. 'mk': ' com edu gov inf name net org pro ',
  1361. 'ml': ' com edu gov net org presse ',
  1362. 'mn': ' edu gov org ',
  1363. 'mo': ' com edu gov net org ',
  1364. 'mt': ' com edu gov net org ',
  1365. 'mv': ' aero biz com coop edu gov info int mil museum name net org pro ',
  1366. 'mw': ' ac co com coop edu gov int museum net org ',
  1367. 'mx': ' com edu gob net org ',
  1368. 'my': ' com edu gov mil name net org sch ',
  1369. 'nf': ' arts com firm info net other per rec store web ',
  1370. 'ng': ' biz com edu gov mil mobi name net org sch ',
  1371. 'ni': ' ac co com edu gob mil net nom org ',
  1372. 'np': ' com edu gov mil net org ',
  1373. 'nr': ' biz com edu gov info net org ',
  1374. 'om': ' ac biz co com edu gov med mil museum net org pro sch ',
  1375. 'pe': ' com edu gob mil net nom org sld ',
  1376. 'ph': ' com edu gov i mil net ngo org ',
  1377. 'pk': ' biz com edu fam gob gok gon gop gos gov net org web ',
  1378. 'pl': ' art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ',
  1379. 'pr': ' ac biz com edu est gov info isla name net org pro prof ',
  1380. 'ps': ' com edu gov net org plo sec ',
  1381. 'pw': ' belau co ed go ne or ',
  1382. 'ro': ' arts com firm info nom nt org rec store tm www ',
  1383. 'rs': ' ac co edu gov in org ',
  1384. 'sb': ' com edu gov net org ',
  1385. 'sc': ' com edu gov net org ',
  1386. 'sh': ' co com edu gov net nom org ',
  1387. 'sl': ' com edu gov net org ',
  1388. 'st': ' co com consulado edu embaixada gov mil net org principe saotome store ',
  1389. 'sv': ' com edu gob org red ',
  1390. 'sz': ' ac co org ',
  1391. 'tr': ' av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ',
  1392. 'tt': ' aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ',
  1393. 'tw': ' club com ebiz edu game gov idv mil net org ',
  1394. 'mu': ' ac co com gov net or org ',
  1395. 'mz': ' ac co edu gov org ',
  1396. 'na': ' co com ',
  1397. 'nz': ' ac co cri geek gen govt health iwi maori mil net org parliament school ',
  1398. 'pa': ' abo ac com edu gob ing med net nom org sld ',
  1399. 'pt': ' com edu gov int net nome org publ ',
  1400. 'py': ' com edu gov mil net org ',
  1401. 'qa': ' com edu gov mil net org ',
  1402. 're': ' asso com nom ',
  1403. 'ru': ' ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ',
  1404. 'rw': ' ac co com edu gouv gov int mil net ',
  1405. 'sa': ' com edu gov med net org pub sch ',
  1406. 'sd': ' com edu gov info med net org tv ',
  1407. 'se': ' a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ',
  1408. 'sg': ' com edu gov idn net org per ',
  1409. 'sn': ' art com edu gouv org perso univ ',
  1410. 'sy': ' com edu gov mil net news org ',
  1411. 'th': ' ac co go in mi net or ',
  1412. 'tj': ' ac biz co com edu go gov info int mil name net nic org test web ',
  1413. 'tn': ' agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ',
  1414. 'tz': ' ac co go ne or ',
  1415. 'ua': ' biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ',
  1416. 'ug': ' ac co go ne or org sc ',
  1417. 'uk': ' ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ',
  1418. 'us': ' dni fed isa kids nsn ',
  1419. 'uy': ' com edu gub mil net org ',
  1420. 've': ' co com edu gob info mil net org web ',
  1421. 'vi': ' co com k12 net org ',
  1422. 'vn': ' ac biz com edu gov health info int name net org pro ',
  1423. 'ye': ' co com gov ltd me net org plc ',
  1424. 'yu': ' ac co edu gov org ',
  1425. 'za': ' ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ',
  1426. 'zm': ' ac co com edu gov net org sch ',
  1427. // https://en.wikipedia.org/wiki/CentralNic#Second-level_domains
  1428. 'com': 'ar br cn de eu gb gr hu jpn kr no qc ru sa se uk us uy za ',
  1429. 'net': 'gb jp se uk ',
  1430. 'org': 'ae',
  1431. 'de': 'com '
  1432. },
  1433. // gorhill 2013-10-25: Using indexOf() instead Regexp(). Significant boost
  1434. // in both performance and memory footprint. No initialization required.
  1435. // http://jsperf.com/uri-js-sld-regex-vs-binary-search/4
  1436. // Following methods use lastIndexOf() rather than array.split() in order
  1437. // to avoid any memory allocations.
  1438. has: function (domain) {
  1439. var tldOffset = domain.lastIndexOf('.');
  1440. if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
  1441. return false;
  1442. }
  1443. var sldOffset = domain.lastIndexOf('.', tldOffset - 1);
  1444. if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
  1445. return false;
  1446. }
  1447. var sldList = SLD.list[domain.slice(tldOffset + 1)];
  1448. if (!sldList) {
  1449. return false;
  1450. }
  1451. return sldList.indexOf(' ' + domain.slice(sldOffset + 1, tldOffset) + ' ') >= 0;
  1452. },
  1453. is: function (domain) {
  1454. var tldOffset = domain.lastIndexOf('.');
  1455. if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
  1456. return false;
  1457. }
  1458. var sldOffset = domain.lastIndexOf('.', tldOffset - 1);
  1459. if (sldOffset >= 0) {
  1460. return false;
  1461. }
  1462. var sldList = SLD.list[domain.slice(tldOffset + 1)];
  1463. if (!sldList) {
  1464. return false;
  1465. }
  1466. return sldList.indexOf(' ' + domain.slice(0, tldOffset) + ' ') >= 0;
  1467. },
  1468. get: function (domain) {
  1469. var tldOffset = domain.lastIndexOf('.');
  1470. if (tldOffset <= 0 || tldOffset >= domain.length - 1) {
  1471. return null;
  1472. }
  1473. var sldOffset = domain.lastIndexOf('.', tldOffset - 1);
  1474. if (sldOffset <= 0 || sldOffset >= tldOffset - 1) {
  1475. return null;
  1476. }
  1477. var sldList = SLD.list[domain.slice(tldOffset + 1)];
  1478. if (!sldList) {
  1479. return null;
  1480. }
  1481. if (sldList.indexOf(' ' + domain.slice(sldOffset + 1, tldOffset) + ' ') < 0) {
  1482. return null;
  1483. }
  1484. return domain.slice(sldOffset + 1);
  1485. },
  1486. noConflict: function () {
  1487. if (root.SecondLevelDomains === this) {
  1488. root.SecondLevelDomains = _SecondLevelDomains;
  1489. }
  1490. return this;
  1491. }
  1492. };
  1493. return SLD;
  1494. });
  1495. /***/ }),
  1496. /***/ 5215:
  1497. /***/ (function(module, exports, __webpack_require__) {
  1498. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1499. * URI.js - Mutating URLs
  1500. *
  1501. * Version: 1.19.11
  1502. *
  1503. * Author: Rodney Rehm
  1504. * Web: http://medialize.github.io/URI.js/
  1505. *
  1506. * Licensed under
  1507. * MIT License http://www.opensource.org/licenses/mit-license
  1508. *
  1509. */
  1510. (function (root, factory) {
  1511. 'use strict'; // https://github.com/umdjs/umd/blob/master/returnExports.js
  1512. if ( true && module.exports) {
  1513. // Node
  1514. module.exports = factory(__webpack_require__(7819), __webpack_require__(8677), __webpack_require__(9827));
  1515. } else if (true) {
  1516. // AMD. Register as an anonymous module.
  1517. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(7819), __webpack_require__(8677), __webpack_require__(9827)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  1518. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  1519. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  1520. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1521. } else {}
  1522. })(this, function (punycode, IPv6, SLD, root) {
  1523. 'use strict';
  1524. /*global location, escape, unescape */
  1525. // FIXME: v2.0.0 renamce non-camelCase properties to uppercase
  1526. /*jshint camelcase: false */
  1527. // save current URI variable, if any
  1528. var _URI = root && root.URI;
  1529. function URI(url, base) {
  1530. var _urlSupplied = arguments.length >= 1;
  1531. var _baseSupplied = arguments.length >= 2; // Allow instantiation without the 'new' keyword
  1532. if (!(this instanceof URI)) {
  1533. if (_urlSupplied) {
  1534. if (_baseSupplied) {
  1535. return new URI(url, base);
  1536. }
  1537. return new URI(url);
  1538. }
  1539. return new URI();
  1540. }
  1541. if (url === undefined) {
  1542. if (_urlSupplied) {
  1543. throw new TypeError('undefined is not a valid argument for URI');
  1544. }
  1545. if (typeof location !== 'undefined') {
  1546. url = location.href + '';
  1547. } else {
  1548. url = '';
  1549. }
  1550. }
  1551. if (url === null) {
  1552. if (_urlSupplied) {
  1553. throw new TypeError('null is not a valid argument for URI');
  1554. }
  1555. }
  1556. this.href(url); // resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor
  1557. if (base !== undefined) {
  1558. return this.absoluteTo(base);
  1559. }
  1560. return this;
  1561. }
  1562. function isInteger(value) {
  1563. return /^[0-9]+$/.test(value);
  1564. }
  1565. URI.version = '1.19.11';
  1566. var p = URI.prototype;
  1567. var hasOwn = Object.prototype.hasOwnProperty;
  1568. function escapeRegEx(string) {
  1569. // https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963
  1570. return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  1571. }
  1572. function getType(value) {
  1573. // IE8 doesn't return [Object Undefined] but [Object Object] for undefined value
  1574. if (value === undefined) {
  1575. return 'Undefined';
  1576. }
  1577. return String(Object.prototype.toString.call(value)).slice(8, -1);
  1578. }
  1579. function isArray(obj) {
  1580. return getType(obj) === 'Array';
  1581. }
  1582. function filterArrayValues(data, value) {
  1583. var lookup = {};
  1584. var i, length;
  1585. if (getType(value) === 'RegExp') {
  1586. lookup = null;
  1587. } else if (isArray(value)) {
  1588. for (i = 0, length = value.length; i < length; i++) {
  1589. lookup[value[i]] = true;
  1590. }
  1591. } else {
  1592. lookup[value] = true;
  1593. }
  1594. for (i = 0, length = data.length; i < length; i++) {
  1595. /*jshint laxbreak: true */
  1596. var _match = lookup && lookup[data[i]] !== undefined || !lookup && value.test(data[i]);
  1597. /*jshint laxbreak: false */
  1598. if (_match) {
  1599. data.splice(i, 1);
  1600. length--;
  1601. i--;
  1602. }
  1603. }
  1604. return data;
  1605. }
  1606. function arrayContains(list, value) {
  1607. var i, length; // value may be string, number, array, regexp
  1608. if (isArray(value)) {
  1609. // Note: this can be optimized to O(n) (instead of current O(m * n))
  1610. for (i = 0, length = value.length; i < length; i++) {
  1611. if (!arrayContains(list, value[i])) {
  1612. return false;
  1613. }
  1614. }
  1615. return true;
  1616. }
  1617. var _type = getType(value);
  1618. for (i = 0, length = list.length; i < length; i++) {
  1619. if (_type === 'RegExp') {
  1620. if (typeof list[i] === 'string' && list[i].match(value)) {
  1621. return true;
  1622. }
  1623. } else if (list[i] === value) {
  1624. return true;
  1625. }
  1626. }
  1627. return false;
  1628. }
  1629. function arraysEqual(one, two) {
  1630. if (!isArray(one) || !isArray(two)) {
  1631. return false;
  1632. } // arrays can't be equal if they have different amount of content
  1633. if (one.length !== two.length) {
  1634. return false;
  1635. }
  1636. one.sort();
  1637. two.sort();
  1638. for (var i = 0, l = one.length; i < l; i++) {
  1639. if (one[i] !== two[i]) {
  1640. return false;
  1641. }
  1642. }
  1643. return true;
  1644. }
  1645. function trimSlashes(text) {
  1646. var trim_expression = /^\/+|\/+$/g;
  1647. return text.replace(trim_expression, '');
  1648. }
  1649. URI._parts = function () {
  1650. return {
  1651. protocol: null,
  1652. username: null,
  1653. password: null,
  1654. hostname: null,
  1655. urn: null,
  1656. port: null,
  1657. path: null,
  1658. query: null,
  1659. fragment: null,
  1660. // state
  1661. preventInvalidHostname: URI.preventInvalidHostname,
  1662. duplicateQueryParameters: URI.duplicateQueryParameters,
  1663. escapeQuerySpace: URI.escapeQuerySpace
  1664. };
  1665. }; // state: throw on invalid hostname
  1666. // see https://github.com/medialize/URI.js/pull/345
  1667. // and https://github.com/medialize/URI.js/issues/354
  1668. URI.preventInvalidHostname = false; // state: allow duplicate query parameters (a=1&a=1)
  1669. URI.duplicateQueryParameters = false; // state: replaces + with %20 (space in query strings)
  1670. URI.escapeQuerySpace = true; // static properties
  1671. URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
  1672. URI.idn_expression = /[^a-z0-9\._-]/i;
  1673. URI.punycode_expression = /(xn--)/i; // well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care?
  1674. URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; // credits to Rich Brown
  1675. // source: http://forums.intermapper.com/viewtopic.php?p=1096#1096
  1676. // specification: http://www.ietf.org/rfc/rfc4291.txt
  1677. URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; // expression used is "gruber revised" (@gruber v2) determined to be the
  1678. // best solution in a regex-golf we did a couple of ages ago at
  1679. // * http://mathiasbynens.be/demo/url-regex
  1680. // * http://rodneyrehm.de/t/url-regex.html
  1681. URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
  1682. URI.findUri = {
  1683. // valid "scheme://" or "www."
  1684. start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
  1685. // everything up to the next whitespace
  1686. end: /[\s\r\n]|$/,
  1687. // trim trailing punctuation captured by end RegExp
  1688. trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
  1689. // balanced parens inclusion (), [], {}, <>
  1690. parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g
  1691. };
  1692. URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/; // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1693. URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g; // http://www.iana.org/assignments/uri-schemes.html
  1694. // http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports
  1695. URI.defaultPorts = {
  1696. http: '80',
  1697. https: '443',
  1698. ftp: '21',
  1699. gopher: '70',
  1700. ws: '80',
  1701. wss: '443'
  1702. }; // list of protocols which always require a hostname
  1703. URI.hostProtocols = ['http', 'https']; // allowed hostname characters according to RFC 3986
  1704. // ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded
  1705. // I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - _
  1706. URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/; // map DOM Elements to their URI attribute
  1707. URI.domAttributes = {
  1708. 'a': 'href',
  1709. 'blockquote': 'cite',
  1710. 'link': 'href',
  1711. 'base': 'href',
  1712. 'script': 'src',
  1713. 'form': 'action',
  1714. 'img': 'src',
  1715. 'area': 'href',
  1716. 'iframe': 'src',
  1717. 'embed': 'src',
  1718. 'source': 'src',
  1719. 'track': 'src',
  1720. 'input': 'src',
  1721. // but only if type="image"
  1722. 'audio': 'src',
  1723. 'video': 'src'
  1724. };
  1725. URI.getDomAttribute = function (node) {
  1726. if (!node || !node.nodeName) {
  1727. return undefined;
  1728. }
  1729. var nodeName = node.nodeName.toLowerCase(); // <input> should only expose src for type="image"
  1730. if (nodeName === 'input' && node.type !== 'image') {
  1731. return undefined;
  1732. }
  1733. return URI.domAttributes[nodeName];
  1734. };
  1735. function escapeForDumbFirefox36(value) {
  1736. // https://github.com/medialize/URI.js/issues/91
  1737. return escape(value);
  1738. } // encoding / decoding according to RFC3986
  1739. function strictEncodeURIComponent(string) {
  1740. // see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent
  1741. return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, '%2A');
  1742. }
  1743. URI.encode = strictEncodeURIComponent;
  1744. URI.decode = decodeURIComponent;
  1745. URI.iso8859 = function () {
  1746. URI.encode = escape;
  1747. URI.decode = unescape;
  1748. };
  1749. URI.unicode = function () {
  1750. URI.encode = strictEncodeURIComponent;
  1751. URI.decode = decodeURIComponent;
  1752. };
  1753. URI.characters = {
  1754. pathname: {
  1755. encode: {
  1756. // RFC3986 2.1: For consistency, URI producers and normalizers should
  1757. // use uppercase hexadecimal digits for all percent-encodings.
  1758. expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
  1759. map: {
  1760. // -._~!'()*
  1761. '%24': '$',
  1762. '%26': '&',
  1763. '%2B': '+',
  1764. '%2C': ',',
  1765. '%3B': ';',
  1766. '%3D': '=',
  1767. '%3A': ':',
  1768. '%40': '@'
  1769. }
  1770. },
  1771. decode: {
  1772. expression: /[\/\?#]/g,
  1773. map: {
  1774. '/': '%2F',
  1775. '?': '%3F',
  1776. '#': '%23'
  1777. }
  1778. }
  1779. },
  1780. reserved: {
  1781. encode: {
  1782. // RFC3986 2.1: For consistency, URI producers and normalizers should
  1783. // use uppercase hexadecimal digits for all percent-encodings.
  1784. expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
  1785. map: {
  1786. // gen-delims
  1787. '%3A': ':',
  1788. '%2F': '/',
  1789. '%3F': '?',
  1790. '%23': '#',
  1791. '%5B': '[',
  1792. '%5D': ']',
  1793. '%40': '@',
  1794. // sub-delims
  1795. '%21': '!',
  1796. '%24': '$',
  1797. '%26': '&',
  1798. '%27': '\'',
  1799. '%28': '(',
  1800. '%29': ')',
  1801. '%2A': '*',
  1802. '%2B': '+',
  1803. '%2C': ',',
  1804. '%3B': ';',
  1805. '%3D': '='
  1806. }
  1807. }
  1808. },
  1809. urnpath: {
  1810. // The characters under `encode` are the characters called out by RFC 2141 as being acceptable
  1811. // for usage in a URN. RFC2141 also calls out "-", ".", and "_" as acceptable characters, but
  1812. // these aren't encoded by encodeURIComponent, so we don't have to call them out here. Also
  1813. // note that the colon character is not featured in the encoding map; this is because URI.js
  1814. // gives the colons in URNs semantic meaning as the delimiters of path segements, and so it
  1815. // should not appear unencoded in a segment itself.
  1816. // See also the note above about RFC3986 and capitalalized hex digits.
  1817. encode: {
  1818. expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
  1819. map: {
  1820. '%21': '!',
  1821. '%24': '$',
  1822. '%27': '\'',
  1823. '%28': '(',
  1824. '%29': ')',
  1825. '%2A': '*',
  1826. '%2B': '+',
  1827. '%2C': ',',
  1828. '%3B': ';',
  1829. '%3D': '=',
  1830. '%40': '@'
  1831. }
  1832. },
  1833. // These characters are the characters called out by RFC2141 as "reserved" characters that
  1834. // should never appear in a URN, plus the colon character (see note above).
  1835. decode: {
  1836. expression: /[\/\?#:]/g,
  1837. map: {
  1838. '/': '%2F',
  1839. '?': '%3F',
  1840. '#': '%23',
  1841. ':': '%3A'
  1842. }
  1843. }
  1844. }
  1845. };
  1846. URI.encodeQuery = function (string, escapeQuerySpace) {
  1847. var escaped = URI.encode(string + '');
  1848. if (escapeQuerySpace === undefined) {
  1849. escapeQuerySpace = URI.escapeQuerySpace;
  1850. }
  1851. return escapeQuerySpace ? escaped.replace(/%20/g, '+') : escaped;
  1852. };
  1853. URI.decodeQuery = function (string, escapeQuerySpace) {
  1854. string += '';
  1855. if (escapeQuerySpace === undefined) {
  1856. escapeQuerySpace = URI.escapeQuerySpace;
  1857. }
  1858. try {
  1859. return URI.decode(escapeQuerySpace ? string.replace(/\+/g, '%20') : string);
  1860. } catch (e) {
  1861. // we're not going to mess with weird encodings,
  1862. // give up and return the undecoded original string
  1863. // see https://github.com/medialize/URI.js/issues/87
  1864. // see https://github.com/medialize/URI.js/issues/92
  1865. return string;
  1866. }
  1867. }; // generate encode/decode path functions
  1868. var _parts = {
  1869. 'encode': 'encode',
  1870. 'decode': 'decode'
  1871. };
  1872. var _part;
  1873. var generateAccessor = function (_group, _part) {
  1874. return function (string) {
  1875. try {
  1876. return URI[_part](string + '').replace(URI.characters[_group][_part].expression, function (c) {
  1877. return URI.characters[_group][_part].map[c];
  1878. });
  1879. } catch (e) {
  1880. // we're not going to mess with weird encodings,
  1881. // give up and return the undecoded original string
  1882. // see https://github.com/medialize/URI.js/issues/87
  1883. // see https://github.com/medialize/URI.js/issues/92
  1884. return string;
  1885. }
  1886. };
  1887. };
  1888. for (_part in _parts) {
  1889. URI[_part + 'PathSegment'] = generateAccessor('pathname', _parts[_part]);
  1890. URI[_part + 'UrnPathSegment'] = generateAccessor('urnpath', _parts[_part]);
  1891. }
  1892. var generateSegmentedPathFunction = function (_sep, _codingFuncName, _innerCodingFuncName) {
  1893. return function (string) {
  1894. // Why pass in names of functions, rather than the function objects themselves? The
  1895. // definitions of some functions (but in particular, URI.decode) will occasionally change due
  1896. // to URI.js having ISO8859 and Unicode modes. Passing in the name and getting it will ensure
  1897. // that the functions we use here are "fresh".
  1898. var actualCodingFunc;
  1899. if (!_innerCodingFuncName) {
  1900. actualCodingFunc = URI[_codingFuncName];
  1901. } else {
  1902. actualCodingFunc = function (string) {
  1903. return URI[_codingFuncName](URI[_innerCodingFuncName](string));
  1904. };
  1905. }
  1906. var segments = (string + '').split(_sep);
  1907. for (var i = 0, length = segments.length; i < length; i++) {
  1908. segments[i] = actualCodingFunc(segments[i]);
  1909. }
  1910. return segments.join(_sep);
  1911. };
  1912. }; // This takes place outside the above loop because we don't want, e.g., encodeUrnPath functions.
  1913. URI.decodePath = generateSegmentedPathFunction('/', 'decodePathSegment');
  1914. URI.decodeUrnPath = generateSegmentedPathFunction(':', 'decodeUrnPathSegment');
  1915. URI.recodePath = generateSegmentedPathFunction('/', 'encodePathSegment', 'decode');
  1916. URI.recodeUrnPath = generateSegmentedPathFunction(':', 'encodeUrnPathSegment', 'decode');
  1917. URI.encodeReserved = generateAccessor('reserved', 'encode');
  1918. URI.parse = function (string, parts) {
  1919. var pos;
  1920. if (!parts) {
  1921. parts = {
  1922. preventInvalidHostname: URI.preventInvalidHostname
  1923. };
  1924. }
  1925. string = string.replace(URI.leading_whitespace_expression, ''); // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1926. string = string.replace(URI.ascii_tab_whitespace, ''); // [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment]
  1927. // extract fragment
  1928. pos = string.indexOf('#');
  1929. if (pos > -1) {
  1930. // escaping?
  1931. parts.fragment = string.substring(pos + 1) || null;
  1932. string = string.substring(0, pos);
  1933. } // extract query
  1934. pos = string.indexOf('?');
  1935. if (pos > -1) {
  1936. // escaping?
  1937. parts.query = string.substring(pos + 1) || null;
  1938. string = string.substring(0, pos);
  1939. } // slashes and backslashes have lost all meaning for the web protocols (https, http, wss, ws)
  1940. string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, '$1://'); // slashes and backslashes have lost all meaning for scheme relative URLs
  1941. string = string.replace(/^[/\\]{2,}/i, '//'); // extract protocol
  1942. if (string.substring(0, 2) === '//') {
  1943. // relative-scheme
  1944. parts.protocol = null;
  1945. string = string.substring(2); // extract "user:pass@host:port"
  1946. string = URI.parseAuthority(string, parts);
  1947. } else {
  1948. pos = string.indexOf(':');
  1949. if (pos > -1) {
  1950. parts.protocol = string.substring(0, pos) || null;
  1951. if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
  1952. // : may be within the path
  1953. parts.protocol = undefined;
  1954. } else if (string.substring(pos + 1, pos + 3).replace(/\\/g, '/') === '//') {
  1955. string = string.substring(pos + 3); // extract "user:pass@host:port"
  1956. string = URI.parseAuthority(string, parts);
  1957. } else {
  1958. string = string.substring(pos + 1);
  1959. parts.urn = true;
  1960. }
  1961. }
  1962. } // what's left must be the path
  1963. parts.path = string; // and we're done
  1964. return parts;
  1965. };
  1966. URI.parseHost = function (string, parts) {
  1967. if (!string) {
  1968. string = '';
  1969. } // Copy chrome, IE, opera backslash-handling behavior.
  1970. // Back slashes before the query string get converted to forward slashes
  1971. // See: https://github.com/joyent/node/blob/386fd24f49b0e9d1a8a076592a404168faeecc34/lib/url.js#L115-L124
  1972. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  1973. // https://github.com/medialize/URI.js/pull/233
  1974. string = string.replace(/\\/g, '/'); // extract host:port
  1975. var pos = string.indexOf('/');
  1976. var bracketPos;
  1977. var t;
  1978. if (pos === -1) {
  1979. pos = string.length;
  1980. }
  1981. if (string.charAt(0) === '[') {
  1982. // IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6
  1983. // I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts
  1984. // IPv6+port in the format [2001:db8::1]:80 (for the time being)
  1985. bracketPos = string.indexOf(']');
  1986. parts.hostname = string.substring(1, bracketPos) || null;
  1987. parts.port = string.substring(bracketPos + 2, pos) || null;
  1988. if (parts.port === '/') {
  1989. parts.port = null;
  1990. }
  1991. } else {
  1992. var firstColon = string.indexOf(':');
  1993. var firstSlash = string.indexOf('/');
  1994. var nextColon = string.indexOf(':', firstColon + 1);
  1995. if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
  1996. // IPv6 host contains multiple colons - but no port
  1997. // this notation is actually not allowed by RFC 3986, but we're a liberal parser
  1998. parts.hostname = string.substring(0, pos) || null;
  1999. parts.port = null;
  2000. } else {
  2001. t = string.substring(0, pos).split(':');
  2002. parts.hostname = t[0] || null;
  2003. parts.port = t[1] || null;
  2004. }
  2005. }
  2006. if (parts.hostname && string.substring(pos).charAt(0) !== '/') {
  2007. pos++;
  2008. string = '/' + string;
  2009. }
  2010. if (parts.preventInvalidHostname) {
  2011. URI.ensureValidHostname(parts.hostname, parts.protocol);
  2012. }
  2013. if (parts.port) {
  2014. URI.ensureValidPort(parts.port);
  2015. }
  2016. return string.substring(pos) || '/';
  2017. };
  2018. URI.parseAuthority = function (string, parts) {
  2019. string = URI.parseUserinfo(string, parts);
  2020. return URI.parseHost(string, parts);
  2021. };
  2022. URI.parseUserinfo = function (string, parts) {
  2023. // extract username:password
  2024. var _string = string;
  2025. var firstBackSlash = string.indexOf('\\');
  2026. if (firstBackSlash !== -1) {
  2027. string = string.replace(/\\/g, '/');
  2028. }
  2029. var firstSlash = string.indexOf('/');
  2030. var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1);
  2031. var t; // authority@ must come before /path or \path
  2032. if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
  2033. t = string.substring(0, pos).split(':');
  2034. parts.username = t[0] ? URI.decode(t[0]) : null;
  2035. t.shift();
  2036. parts.password = t[0] ? URI.decode(t.join(':')) : null;
  2037. string = _string.substring(pos + 1);
  2038. } else {
  2039. parts.username = null;
  2040. parts.password = null;
  2041. }
  2042. return string;
  2043. };
  2044. URI.parseQuery = function (string, escapeQuerySpace) {
  2045. if (!string) {
  2046. return {};
  2047. } // throw out the funky business - "?"[name"="value"&"]+
  2048. string = string.replace(/&+/g, '&').replace(/^\?*&*|&+$/g, '');
  2049. if (!string) {
  2050. return {};
  2051. }
  2052. var items = {};
  2053. var splits = string.split('&');
  2054. var length = splits.length;
  2055. var v, name, value;
  2056. for (var i = 0; i < length; i++) {
  2057. v = splits[i].split('=');
  2058. name = URI.decodeQuery(v.shift(), escapeQuerySpace); // no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters
  2059. value = v.length ? URI.decodeQuery(v.join('='), escapeQuerySpace) : null;
  2060. if (name === '__proto__') {
  2061. // ignore attempt at exploiting JavaScript internals
  2062. continue;
  2063. } else if (hasOwn.call(items, name)) {
  2064. if (typeof items[name] === 'string' || items[name] === null) {
  2065. items[name] = [items[name]];
  2066. }
  2067. items[name].push(value);
  2068. } else {
  2069. items[name] = value;
  2070. }
  2071. }
  2072. return items;
  2073. };
  2074. URI.build = function (parts) {
  2075. var t = '';
  2076. var requireAbsolutePath = false;
  2077. if (parts.protocol) {
  2078. t += parts.protocol + ':';
  2079. }
  2080. if (!parts.urn && (t || parts.hostname)) {
  2081. t += '//';
  2082. requireAbsolutePath = true;
  2083. }
  2084. t += URI.buildAuthority(parts) || '';
  2085. if (typeof parts.path === 'string') {
  2086. if (parts.path.charAt(0) !== '/' && requireAbsolutePath) {
  2087. t += '/';
  2088. }
  2089. t += parts.path;
  2090. }
  2091. if (typeof parts.query === 'string' && parts.query) {
  2092. t += '?' + parts.query;
  2093. }
  2094. if (typeof parts.fragment === 'string' && parts.fragment) {
  2095. t += '#' + parts.fragment;
  2096. }
  2097. return t;
  2098. };
  2099. URI.buildHost = function (parts) {
  2100. var t = '';
  2101. if (!parts.hostname) {
  2102. return '';
  2103. } else if (URI.ip6_expression.test(parts.hostname)) {
  2104. t += '[' + parts.hostname + ']';
  2105. } else {
  2106. t += parts.hostname;
  2107. }
  2108. if (parts.port) {
  2109. t += ':' + parts.port;
  2110. }
  2111. return t;
  2112. };
  2113. URI.buildAuthority = function (parts) {
  2114. return URI.buildUserinfo(parts) + URI.buildHost(parts);
  2115. };
  2116. URI.buildUserinfo = function (parts) {
  2117. var t = '';
  2118. if (parts.username) {
  2119. t += URI.encode(parts.username);
  2120. }
  2121. if (parts.password) {
  2122. t += ':' + URI.encode(parts.password);
  2123. }
  2124. if (t) {
  2125. t += '@';
  2126. }
  2127. return t;
  2128. };
  2129. URI.buildQuery = function (data, duplicateQueryParameters, escapeQuerySpace) {
  2130. // according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html
  2131. // being »-._~!$&'()*+,;=:@/?« %HEX and alnum are allowed
  2132. // the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax!
  2133. // URI.js treats the query string as being application/x-www-form-urlencoded
  2134. // see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type
  2135. var t = '';
  2136. var unique, key, i, length;
  2137. for (key in data) {
  2138. if (key === '__proto__') {
  2139. // ignore attempt at exploiting JavaScript internals
  2140. continue;
  2141. } else if (hasOwn.call(data, key)) {
  2142. if (isArray(data[key])) {
  2143. unique = {};
  2144. for (i = 0, length = data[key].length; i < length; i++) {
  2145. if (data[key][i] !== undefined && unique[data[key][i] + ''] === undefined) {
  2146. t += '&' + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
  2147. if (duplicateQueryParameters !== true) {
  2148. unique[data[key][i] + ''] = true;
  2149. }
  2150. }
  2151. }
  2152. } else if (data[key] !== undefined) {
  2153. t += '&' + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
  2154. }
  2155. }
  2156. }
  2157. return t.substring(1);
  2158. };
  2159. URI.buildQueryParameter = function (name, value, escapeQuerySpace) {
  2160. // http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded
  2161. // don't append "=" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization
  2162. return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? '=' + URI.encodeQuery(value, escapeQuerySpace) : '');
  2163. };
  2164. URI.addQuery = function (data, name, value) {
  2165. if (typeof name === 'object') {
  2166. for (var key in name) {
  2167. if (hasOwn.call(name, key)) {
  2168. URI.addQuery(data, key, name[key]);
  2169. }
  2170. }
  2171. } else if (typeof name === 'string') {
  2172. if (data[name] === undefined) {
  2173. data[name] = value;
  2174. return;
  2175. } else if (typeof data[name] === 'string') {
  2176. data[name] = [data[name]];
  2177. }
  2178. if (!isArray(value)) {
  2179. value = [value];
  2180. }
  2181. data[name] = (data[name] || []).concat(value);
  2182. } else {
  2183. throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
  2184. }
  2185. };
  2186. URI.setQuery = function (data, name, value) {
  2187. if (typeof name === 'object') {
  2188. for (var key in name) {
  2189. if (hasOwn.call(name, key)) {
  2190. URI.setQuery(data, key, name[key]);
  2191. }
  2192. }
  2193. } else if (typeof name === 'string') {
  2194. data[name] = value === undefined ? null : value;
  2195. } else {
  2196. throw new TypeError('URI.setQuery() accepts an object, string as the name parameter');
  2197. }
  2198. };
  2199. URI.removeQuery = function (data, name, value) {
  2200. var i, length, key;
  2201. if (isArray(name)) {
  2202. for (i = 0, length = name.length; i < length; i++) {
  2203. data[name[i]] = undefined;
  2204. }
  2205. } else if (getType(name) === 'RegExp') {
  2206. for (key in data) {
  2207. if (name.test(key)) {
  2208. data[key] = undefined;
  2209. }
  2210. }
  2211. } else if (typeof name === 'object') {
  2212. for (key in name) {
  2213. if (hasOwn.call(name, key)) {
  2214. URI.removeQuery(data, key, name[key]);
  2215. }
  2216. }
  2217. } else if (typeof name === 'string') {
  2218. if (value !== undefined) {
  2219. if (getType(value) === 'RegExp') {
  2220. if (!isArray(data[name]) && value.test(data[name])) {
  2221. data[name] = undefined;
  2222. } else {
  2223. data[name] = filterArrayValues(data[name], value);
  2224. }
  2225. } else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
  2226. data[name] = undefined;
  2227. } else if (isArray(data[name])) {
  2228. data[name] = filterArrayValues(data[name], value);
  2229. }
  2230. } else {
  2231. data[name] = undefined;
  2232. }
  2233. } else {
  2234. throw new TypeError('URI.removeQuery() accepts an object, string, RegExp as the first parameter');
  2235. }
  2236. };
  2237. URI.hasQuery = function (data, name, value, withinArray) {
  2238. switch (getType(name)) {
  2239. case 'String':
  2240. // Nothing to do here
  2241. break;
  2242. case 'RegExp':
  2243. for (var key in data) {
  2244. if (hasOwn.call(data, key)) {
  2245. if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {
  2246. return true;
  2247. }
  2248. }
  2249. }
  2250. return false;
  2251. case 'Object':
  2252. for (var _key in name) {
  2253. if (hasOwn.call(name, _key)) {
  2254. if (!URI.hasQuery(data, _key, name[_key])) {
  2255. return false;
  2256. }
  2257. }
  2258. }
  2259. return true;
  2260. default:
  2261. throw new TypeError('URI.hasQuery() accepts a string, regular expression or object as the name parameter');
  2262. }
  2263. switch (getType(value)) {
  2264. case 'Undefined':
  2265. // true if exists (but may be empty)
  2266. return name in data;
  2267. // data[name] !== undefined;
  2268. case 'Boolean':
  2269. // true if exists and non-empty
  2270. var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
  2271. return value === _booly;
  2272. case 'Function':
  2273. // allow complex comparison
  2274. return !!value(data[name], name, data);
  2275. case 'Array':
  2276. if (!isArray(data[name])) {
  2277. return false;
  2278. }
  2279. var op = withinArray ? arrayContains : arraysEqual;
  2280. return op(data[name], value);
  2281. case 'RegExp':
  2282. if (!isArray(data[name])) {
  2283. return Boolean(data[name] && data[name].match(value));
  2284. }
  2285. if (!withinArray) {
  2286. return false;
  2287. }
  2288. return arrayContains(data[name], value);
  2289. case 'Number':
  2290. value = String(value);
  2291. /* falls through */
  2292. case 'String':
  2293. if (!isArray(data[name])) {
  2294. return data[name] === value;
  2295. }
  2296. if (!withinArray) {
  2297. return false;
  2298. }
  2299. return arrayContains(data[name], value);
  2300. default:
  2301. throw new TypeError('URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter');
  2302. }
  2303. };
  2304. URI.joinPaths = function () {
  2305. var input = [];
  2306. var segments = [];
  2307. var nonEmptySegments = 0;
  2308. for (var i = 0; i < arguments.length; i++) {
  2309. var url = new URI(arguments[i]);
  2310. input.push(url);
  2311. var _segments = url.segment();
  2312. for (var s = 0; s < _segments.length; s++) {
  2313. if (typeof _segments[s] === 'string') {
  2314. segments.push(_segments[s]);
  2315. }
  2316. if (_segments[s]) {
  2317. nonEmptySegments++;
  2318. }
  2319. }
  2320. }
  2321. if (!segments.length || !nonEmptySegments) {
  2322. return new URI('');
  2323. }
  2324. var uri = new URI('').segment(segments);
  2325. if (input[0].path() === '' || input[0].path().slice(0, 1) === '/') {
  2326. uri.path('/' + uri.path());
  2327. }
  2328. return uri.normalize();
  2329. };
  2330. URI.commonPath = function (one, two) {
  2331. var length = Math.min(one.length, two.length);
  2332. var pos; // find first non-matching character
  2333. for (pos = 0; pos < length; pos++) {
  2334. if (one.charAt(pos) !== two.charAt(pos)) {
  2335. pos--;
  2336. break;
  2337. }
  2338. }
  2339. if (pos < 1) {
  2340. return one.charAt(0) === two.charAt(0) && one.charAt(0) === '/' ? '/' : '';
  2341. } // revert to last /
  2342. if (one.charAt(pos) !== '/' || two.charAt(pos) !== '/') {
  2343. pos = one.substring(0, pos).lastIndexOf('/');
  2344. }
  2345. return one.substring(0, pos + 1);
  2346. };
  2347. URI.withinString = function (string, callback, options) {
  2348. options || (options = {});
  2349. var _start = options.start || URI.findUri.start;
  2350. var _end = options.end || URI.findUri.end;
  2351. var _trim = options.trim || URI.findUri.trim;
  2352. var _parens = options.parens || URI.findUri.parens;
  2353. var _attributeOpen = /[a-z0-9-]=["']?$/i;
  2354. _start.lastIndex = 0;
  2355. while (true) {
  2356. var match = _start.exec(string);
  2357. if (!match) {
  2358. break;
  2359. }
  2360. var start = match.index;
  2361. if (options.ignoreHtml) {
  2362. // attribut(e=["']?$)
  2363. var attributeOpen = string.slice(Math.max(start - 3, 0), start);
  2364. if (attributeOpen && _attributeOpen.test(attributeOpen)) {
  2365. continue;
  2366. }
  2367. }
  2368. var end = start + string.slice(start).search(_end);
  2369. var slice = string.slice(start, end); // make sure we include well balanced parens
  2370. var parensEnd = -1;
  2371. while (true) {
  2372. var parensMatch = _parens.exec(slice);
  2373. if (!parensMatch) {
  2374. break;
  2375. }
  2376. var parensMatchEnd = parensMatch.index + parensMatch[0].length;
  2377. parensEnd = Math.max(parensEnd, parensMatchEnd);
  2378. }
  2379. if (parensEnd > -1) {
  2380. slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, '');
  2381. } else {
  2382. slice = slice.replace(_trim, '');
  2383. }
  2384. if (slice.length <= match[0].length) {
  2385. // the extract only contains the starting marker of a URI,
  2386. // e.g. "www" or "http://"
  2387. continue;
  2388. }
  2389. if (options.ignore && options.ignore.test(slice)) {
  2390. continue;
  2391. }
  2392. end = start + slice.length;
  2393. var result = callback(slice, start, end, string);
  2394. if (result === undefined) {
  2395. _start.lastIndex = end;
  2396. continue;
  2397. }
  2398. result = String(result);
  2399. string = string.slice(0, start) + result + string.slice(end);
  2400. _start.lastIndex = start + result.length;
  2401. }
  2402. _start.lastIndex = 0;
  2403. return string;
  2404. };
  2405. URI.ensureValidHostname = function (v, protocol) {
  2406. // Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986)
  2407. // they are not part of DNS and therefore ignored by URI.js
  2408. var hasHostname = !!v; // not null and not an empty string
  2409. var hasProtocol = !!protocol;
  2410. var rejectEmptyHostname = false;
  2411. if (hasProtocol) {
  2412. rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
  2413. }
  2414. if (rejectEmptyHostname && !hasHostname) {
  2415. throw new TypeError('Hostname cannot be empty, if protocol is ' + protocol);
  2416. } else if (v && v.match(URI.invalid_hostname_characters)) {
  2417. // test punycode
  2418. if (!punycode) {
  2419. throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');
  2420. }
  2421. if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
  2422. throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-:_]');
  2423. }
  2424. }
  2425. };
  2426. URI.ensureValidPort = function (v) {
  2427. if (!v) {
  2428. return;
  2429. }
  2430. var port = Number(v);
  2431. if (isInteger(port) && port > 0 && port < 65536) {
  2432. return;
  2433. }
  2434. throw new TypeError('Port "' + v + '" is not a valid port');
  2435. }; // noConflict
  2436. URI.noConflict = function (removeAll) {
  2437. if (removeAll) {
  2438. var unconflicted = {
  2439. URI: this.noConflict()
  2440. };
  2441. if (root.URITemplate && typeof root.URITemplate.noConflict === 'function') {
  2442. unconflicted.URITemplate = root.URITemplate.noConflict();
  2443. }
  2444. if (root.IPv6 && typeof root.IPv6.noConflict === 'function') {
  2445. unconflicted.IPv6 = root.IPv6.noConflict();
  2446. }
  2447. if (root.SecondLevelDomains && typeof root.SecondLevelDomains.noConflict === 'function') {
  2448. unconflicted.SecondLevelDomains = root.SecondLevelDomains.noConflict();
  2449. }
  2450. return unconflicted;
  2451. } else if (root.URI === this) {
  2452. root.URI = _URI;
  2453. }
  2454. return this;
  2455. };
  2456. p.build = function (deferBuild) {
  2457. if (deferBuild === true) {
  2458. this._deferred_build = true;
  2459. } else if (deferBuild === undefined || this._deferred_build) {
  2460. this._string = URI.build(this._parts);
  2461. this._deferred_build = false;
  2462. }
  2463. return this;
  2464. };
  2465. p.clone = function () {
  2466. return new URI(this);
  2467. };
  2468. p.valueOf = p.toString = function () {
  2469. return this.build(false)._string;
  2470. };
  2471. function generateSimpleAccessor(_part) {
  2472. return function (v, build) {
  2473. if (v === undefined) {
  2474. return this._parts[_part] || '';
  2475. } else {
  2476. this._parts[_part] = v || null;
  2477. this.build(!build);
  2478. return this;
  2479. }
  2480. };
  2481. }
  2482. function generatePrefixAccessor(_part, _key) {
  2483. return function (v, build) {
  2484. if (v === undefined) {
  2485. return this._parts[_part] || '';
  2486. } else {
  2487. if (v !== null) {
  2488. v = v + '';
  2489. if (v.charAt(0) === _key) {
  2490. v = v.substring(1);
  2491. }
  2492. }
  2493. this._parts[_part] = v;
  2494. this.build(!build);
  2495. return this;
  2496. }
  2497. };
  2498. }
  2499. p.protocol = generateSimpleAccessor('protocol');
  2500. p.username = generateSimpleAccessor('username');
  2501. p.password = generateSimpleAccessor('password');
  2502. p.hostname = generateSimpleAccessor('hostname');
  2503. p.port = generateSimpleAccessor('port');
  2504. p.query = generatePrefixAccessor('query', '?');
  2505. p.fragment = generatePrefixAccessor('fragment', '#');
  2506. p.search = function (v, build) {
  2507. var t = this.query(v, build);
  2508. return typeof t === 'string' && t.length ? '?' + t : t;
  2509. };
  2510. p.hash = function (v, build) {
  2511. var t = this.fragment(v, build);
  2512. return typeof t === 'string' && t.length ? '#' + t : t;
  2513. };
  2514. p.pathname = function (v, build) {
  2515. if (v === undefined || v === true) {
  2516. var res = this._parts.path || (this._parts.hostname ? '/' : '');
  2517. return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
  2518. } else {
  2519. if (this._parts.urn) {
  2520. this._parts.path = v ? URI.recodeUrnPath(v) : '';
  2521. } else {
  2522. this._parts.path = v ? URI.recodePath(v) : '/';
  2523. }
  2524. this.build(!build);
  2525. return this;
  2526. }
  2527. };
  2528. p.path = p.pathname;
  2529. p.href = function (href, build) {
  2530. var key;
  2531. if (href === undefined) {
  2532. return this.toString();
  2533. }
  2534. this._string = '';
  2535. this._parts = URI._parts();
  2536. var _URI = href instanceof URI;
  2537. var _object = typeof href === 'object' && (href.hostname || href.path || href.pathname);
  2538. if (href.nodeName) {
  2539. var attribute = URI.getDomAttribute(href);
  2540. href = href[attribute] || '';
  2541. _object = false;
  2542. } // window.location is reported to be an object, but it's not the sort
  2543. // of object we're looking for:
  2544. // * location.protocol ends with a colon
  2545. // * location.query != object.search
  2546. // * location.hash != object.fragment
  2547. // simply serializing the unknown object should do the trick
  2548. // (for location, not for everything...)
  2549. if (!_URI && _object && href.pathname !== undefined) {
  2550. href = href.toString();
  2551. }
  2552. if (typeof href === 'string' || href instanceof String) {
  2553. this._parts = URI.parse(String(href), this._parts);
  2554. } else if (_URI || _object) {
  2555. var src = _URI ? href._parts : href;
  2556. for (key in src) {
  2557. if (key === 'query') {
  2558. continue;
  2559. }
  2560. if (hasOwn.call(this._parts, key)) {
  2561. this._parts[key] = src[key];
  2562. }
  2563. }
  2564. if (src.query) {
  2565. this.query(src.query, false);
  2566. }
  2567. } else {
  2568. throw new TypeError('invalid input');
  2569. }
  2570. this.build(!build);
  2571. return this;
  2572. }; // identification accessors
  2573. p.is = function (what) {
  2574. var ip = false;
  2575. var ip4 = false;
  2576. var ip6 = false;
  2577. var name = false;
  2578. var sld = false;
  2579. var idn = false;
  2580. var punycode = false;
  2581. var relative = !this._parts.urn;
  2582. if (this._parts.hostname) {
  2583. relative = false;
  2584. ip4 = URI.ip4_expression.test(this._parts.hostname);
  2585. ip6 = URI.ip6_expression.test(this._parts.hostname);
  2586. ip = ip4 || ip6;
  2587. name = !ip;
  2588. sld = name && SLD && SLD.has(this._parts.hostname);
  2589. idn = name && URI.idn_expression.test(this._parts.hostname);
  2590. punycode = name && URI.punycode_expression.test(this._parts.hostname);
  2591. }
  2592. switch (what.toLowerCase()) {
  2593. case 'relative':
  2594. return relative;
  2595. case 'absolute':
  2596. return !relative;
  2597. // hostname identification
  2598. case 'domain':
  2599. case 'name':
  2600. return name;
  2601. case 'sld':
  2602. return sld;
  2603. case 'ip':
  2604. return ip;
  2605. case 'ip4':
  2606. case 'ipv4':
  2607. case 'inet4':
  2608. return ip4;
  2609. case 'ip6':
  2610. case 'ipv6':
  2611. case 'inet6':
  2612. return ip6;
  2613. case 'idn':
  2614. return idn;
  2615. case 'url':
  2616. return !this._parts.urn;
  2617. case 'urn':
  2618. return !!this._parts.urn;
  2619. case 'punycode':
  2620. return punycode;
  2621. }
  2622. return null;
  2623. }; // component specific input validation
  2624. var _protocol = p.protocol;
  2625. var _port = p.port;
  2626. var _hostname = p.hostname;
  2627. p.protocol = function (v, build) {
  2628. if (v) {
  2629. // accept trailing ://
  2630. v = v.replace(/:(\/\/)?$/, '');
  2631. if (!v.match(URI.protocol_expression)) {
  2632. throw new TypeError('Protocol "' + v + '" contains characters other than [A-Z0-9.+-] or doesn\'t start with [A-Z]');
  2633. }
  2634. }
  2635. return _protocol.call(this, v, build);
  2636. };
  2637. p.scheme = p.protocol;
  2638. p.port = function (v, build) {
  2639. if (this._parts.urn) {
  2640. return v === undefined ? '' : this;
  2641. }
  2642. if (v !== undefined) {
  2643. if (v === 0) {
  2644. v = null;
  2645. }
  2646. if (v) {
  2647. v += '';
  2648. if (v.charAt(0) === ':') {
  2649. v = v.substring(1);
  2650. }
  2651. URI.ensureValidPort(v);
  2652. }
  2653. }
  2654. return _port.call(this, v, build);
  2655. };
  2656. p.hostname = function (v, build) {
  2657. if (this._parts.urn) {
  2658. return v === undefined ? '' : this;
  2659. }
  2660. if (v !== undefined) {
  2661. var x = {
  2662. preventInvalidHostname: this._parts.preventInvalidHostname
  2663. };
  2664. var res = URI.parseHost(v, x);
  2665. if (res !== '/') {
  2666. throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
  2667. }
  2668. v = x.hostname;
  2669. if (this._parts.preventInvalidHostname) {
  2670. URI.ensureValidHostname(v, this._parts.protocol);
  2671. }
  2672. }
  2673. return _hostname.call(this, v, build);
  2674. }; // compound accessors
  2675. p.origin = function (v, build) {
  2676. if (this._parts.urn) {
  2677. return v === undefined ? '' : this;
  2678. }
  2679. if (v === undefined) {
  2680. var protocol = this.protocol();
  2681. var authority = this.authority();
  2682. if (!authority) {
  2683. return '';
  2684. }
  2685. return (protocol ? protocol + '://' : '') + this.authority();
  2686. } else {
  2687. var origin = URI(v);
  2688. this.protocol(origin.protocol()).authority(origin.authority()).build(!build);
  2689. return this;
  2690. }
  2691. };
  2692. p.host = function (v, build) {
  2693. if (this._parts.urn) {
  2694. return v === undefined ? '' : this;
  2695. }
  2696. if (v === undefined) {
  2697. return this._parts.hostname ? URI.buildHost(this._parts) : '';
  2698. } else {
  2699. var res = URI.parseHost(v, this._parts);
  2700. if (res !== '/') {
  2701. throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
  2702. }
  2703. this.build(!build);
  2704. return this;
  2705. }
  2706. };
  2707. p.authority = function (v, build) {
  2708. if (this._parts.urn) {
  2709. return v === undefined ? '' : this;
  2710. }
  2711. if (v === undefined) {
  2712. return this._parts.hostname ? URI.buildAuthority(this._parts) : '';
  2713. } else {
  2714. var res = URI.parseAuthority(v, this._parts);
  2715. if (res !== '/') {
  2716. throw new TypeError('Hostname "' + v + '" contains characters other than [A-Z0-9.-]');
  2717. }
  2718. this.build(!build);
  2719. return this;
  2720. }
  2721. };
  2722. p.userinfo = function (v, build) {
  2723. if (this._parts.urn) {
  2724. return v === undefined ? '' : this;
  2725. }
  2726. if (v === undefined) {
  2727. var t = URI.buildUserinfo(this._parts);
  2728. return t ? t.substring(0, t.length - 1) : t;
  2729. } else {
  2730. if (v[v.length - 1] !== '@') {
  2731. v += '@';
  2732. }
  2733. URI.parseUserinfo(v, this._parts);
  2734. this.build(!build);
  2735. return this;
  2736. }
  2737. };
  2738. p.resource = function (v, build) {
  2739. var parts;
  2740. if (v === undefined) {
  2741. return this.path() + this.search() + this.hash();
  2742. }
  2743. parts = URI.parse(v);
  2744. this._parts.path = parts.path;
  2745. this._parts.query = parts.query;
  2746. this._parts.fragment = parts.fragment;
  2747. this.build(!build);
  2748. return this;
  2749. }; // fraction accessors
  2750. p.subdomain = function (v, build) {
  2751. if (this._parts.urn) {
  2752. return v === undefined ? '' : this;
  2753. } // convenience, return "www" from "www.example.org"
  2754. if (v === undefined) {
  2755. if (!this._parts.hostname || this.is('IP')) {
  2756. return '';
  2757. } // grab domain and add another segment
  2758. var end = this._parts.hostname.length - this.domain().length - 1;
  2759. return this._parts.hostname.substring(0, end) || '';
  2760. } else {
  2761. var e = this._parts.hostname.length - this.domain().length;
  2762. var sub = this._parts.hostname.substring(0, e);
  2763. var replace = new RegExp('^' + escapeRegEx(sub));
  2764. if (v && v.charAt(v.length - 1) !== '.') {
  2765. v += '.';
  2766. }
  2767. if (v.indexOf(':') !== -1) {
  2768. throw new TypeError('Domains cannot contain colons');
  2769. }
  2770. if (v) {
  2771. URI.ensureValidHostname(v, this._parts.protocol);
  2772. }
  2773. this._parts.hostname = this._parts.hostname.replace(replace, v);
  2774. this.build(!build);
  2775. return this;
  2776. }
  2777. };
  2778. p.domain = function (v, build) {
  2779. if (this._parts.urn) {
  2780. return v === undefined ? '' : this;
  2781. }
  2782. if (typeof v === 'boolean') {
  2783. build = v;
  2784. v = undefined;
  2785. } // convenience, return "example.org" from "www.example.org"
  2786. if (v === undefined) {
  2787. if (!this._parts.hostname || this.is('IP')) {
  2788. return '';
  2789. } // if hostname consists of 1 or 2 segments, it must be the domain
  2790. var t = this._parts.hostname.match(/\./g);
  2791. if (t && t.length < 2) {
  2792. return this._parts.hostname;
  2793. } // grab tld and add another segment
  2794. var end = this._parts.hostname.length - this.tld(build).length - 1;
  2795. end = this._parts.hostname.lastIndexOf('.', end - 1) + 1;
  2796. return this._parts.hostname.substring(end) || '';
  2797. } else {
  2798. if (!v) {
  2799. throw new TypeError('cannot set domain empty');
  2800. }
  2801. if (v.indexOf(':') !== -1) {
  2802. throw new TypeError('Domains cannot contain colons');
  2803. }
  2804. URI.ensureValidHostname(v, this._parts.protocol);
  2805. if (!this._parts.hostname || this.is('IP')) {
  2806. this._parts.hostname = v;
  2807. } else {
  2808. var replace = new RegExp(escapeRegEx(this.domain()) + '$');
  2809. this._parts.hostname = this._parts.hostname.replace(replace, v);
  2810. }
  2811. this.build(!build);
  2812. return this;
  2813. }
  2814. };
  2815. p.tld = function (v, build) {
  2816. if (this._parts.urn) {
  2817. return v === undefined ? '' : this;
  2818. }
  2819. if (typeof v === 'boolean') {
  2820. build = v;
  2821. v = undefined;
  2822. } // return "org" from "www.example.org"
  2823. if (v === undefined) {
  2824. if (!this._parts.hostname || this.is('IP')) {
  2825. return '';
  2826. }
  2827. var pos = this._parts.hostname.lastIndexOf('.');
  2828. var tld = this._parts.hostname.substring(pos + 1);
  2829. if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
  2830. return SLD.get(this._parts.hostname) || tld;
  2831. }
  2832. return tld;
  2833. } else {
  2834. var replace;
  2835. if (!v) {
  2836. throw new TypeError('cannot set TLD empty');
  2837. } else if (v.match(/[^a-zA-Z0-9-]/)) {
  2838. if (SLD && SLD.is(v)) {
  2839. replace = new RegExp(escapeRegEx(this.tld()) + '$');
  2840. this._parts.hostname = this._parts.hostname.replace(replace, v);
  2841. } else {
  2842. throw new TypeError('TLD "' + v + '" contains characters other than [A-Z0-9]');
  2843. }
  2844. } else if (!this._parts.hostname || this.is('IP')) {
  2845. throw new ReferenceError('cannot set TLD on non-domain host');
  2846. } else {
  2847. replace = new RegExp(escapeRegEx(this.tld()) + '$');
  2848. this._parts.hostname = this._parts.hostname.replace(replace, v);
  2849. }
  2850. this.build(!build);
  2851. return this;
  2852. }
  2853. };
  2854. p.directory = function (v, build) {
  2855. if (this._parts.urn) {
  2856. return v === undefined ? '' : this;
  2857. }
  2858. if (v === undefined || v === true) {
  2859. if (!this._parts.path && !this._parts.hostname) {
  2860. return '';
  2861. }
  2862. if (this._parts.path === '/') {
  2863. return '/';
  2864. }
  2865. var end = this._parts.path.length - this.filename().length - 1;
  2866. var res = this._parts.path.substring(0, end) || (this._parts.hostname ? '/' : '');
  2867. return v ? URI.decodePath(res) : res;
  2868. } else {
  2869. var e = this._parts.path.length - this.filename().length;
  2870. var directory = this._parts.path.substring(0, e);
  2871. var replace = new RegExp('^' + escapeRegEx(directory)); // fully qualifier directories begin with a slash
  2872. if (!this.is('relative')) {
  2873. if (!v) {
  2874. v = '/';
  2875. }
  2876. if (v.charAt(0) !== '/') {
  2877. v = '/' + v;
  2878. }
  2879. } // directories always end with a slash
  2880. if (v && v.charAt(v.length - 1) !== '/') {
  2881. v += '/';
  2882. }
  2883. v = URI.recodePath(v);
  2884. this._parts.path = this._parts.path.replace(replace, v);
  2885. this.build(!build);
  2886. return this;
  2887. }
  2888. };
  2889. p.filename = function (v, build) {
  2890. if (this._parts.urn) {
  2891. return v === undefined ? '' : this;
  2892. }
  2893. if (typeof v !== 'string') {
  2894. if (!this._parts.path || this._parts.path === '/') {
  2895. return '';
  2896. }
  2897. var pos = this._parts.path.lastIndexOf('/');
  2898. var res = this._parts.path.substring(pos + 1);
  2899. return v ? URI.decodePathSegment(res) : res;
  2900. } else {
  2901. var mutatedDirectory = false;
  2902. if (v.charAt(0) === '/') {
  2903. v = v.substring(1);
  2904. }
  2905. if (v.match(/\.?\//)) {
  2906. mutatedDirectory = true;
  2907. }
  2908. var replace = new RegExp(escapeRegEx(this.filename()) + '$');
  2909. v = URI.recodePath(v);
  2910. this._parts.path = this._parts.path.replace(replace, v);
  2911. if (mutatedDirectory) {
  2912. this.normalizePath(build);
  2913. } else {
  2914. this.build(!build);
  2915. }
  2916. return this;
  2917. }
  2918. };
  2919. p.suffix = function (v, build) {
  2920. if (this._parts.urn) {
  2921. return v === undefined ? '' : this;
  2922. }
  2923. if (v === undefined || v === true) {
  2924. if (!this._parts.path || this._parts.path === '/') {
  2925. return '';
  2926. }
  2927. var filename = this.filename();
  2928. var pos = filename.lastIndexOf('.');
  2929. var s, res;
  2930. if (pos === -1) {
  2931. return '';
  2932. } // suffix may only contain alnum characters (yup, I made this up.)
  2933. s = filename.substring(pos + 1);
  2934. res = /^[a-z0-9%]+$/i.test(s) ? s : '';
  2935. return v ? URI.decodePathSegment(res) : res;
  2936. } else {
  2937. if (v.charAt(0) === '.') {
  2938. v = v.substring(1);
  2939. }
  2940. var suffix = this.suffix();
  2941. var replace;
  2942. if (!suffix) {
  2943. if (!v) {
  2944. return this;
  2945. }
  2946. this._parts.path += '.' + URI.recodePath(v);
  2947. } else if (!v) {
  2948. replace = new RegExp(escapeRegEx('.' + suffix) + '$');
  2949. } else {
  2950. replace = new RegExp(escapeRegEx(suffix) + '$');
  2951. }
  2952. if (replace) {
  2953. v = URI.recodePath(v);
  2954. this._parts.path = this._parts.path.replace(replace, v);
  2955. }
  2956. this.build(!build);
  2957. return this;
  2958. }
  2959. };
  2960. p.segment = function (segment, v, build) {
  2961. var separator = this._parts.urn ? ':' : '/';
  2962. var path = this.path();
  2963. var absolute = path.substring(0, 1) === '/';
  2964. var segments = path.split(separator);
  2965. if (segment !== undefined && typeof segment !== 'number') {
  2966. build = v;
  2967. v = segment;
  2968. segment = undefined;
  2969. }
  2970. if (segment !== undefined && typeof segment !== 'number') {
  2971. throw new Error('Bad segment "' + segment + '", must be 0-based integer');
  2972. }
  2973. if (absolute) {
  2974. segments.shift();
  2975. }
  2976. if (segment < 0) {
  2977. // allow negative indexes to address from the end
  2978. segment = Math.max(segments.length + segment, 0);
  2979. }
  2980. if (v === undefined) {
  2981. /*jshint laxbreak: true */
  2982. return segment === undefined ? segments : segments[segment];
  2983. /*jshint laxbreak: false */
  2984. } else if (segment === null || segments[segment] === undefined) {
  2985. if (isArray(v)) {
  2986. segments = []; // collapse empty elements within array
  2987. for (var i = 0, l = v.length; i < l; i++) {
  2988. if (!v[i].length && (!segments.length || !segments[segments.length - 1].length)) {
  2989. continue;
  2990. }
  2991. if (segments.length && !segments[segments.length - 1].length) {
  2992. segments.pop();
  2993. }
  2994. segments.push(trimSlashes(v[i]));
  2995. }
  2996. } else if (v || typeof v === 'string') {
  2997. v = trimSlashes(v);
  2998. if (segments[segments.length - 1] === '') {
  2999. // empty trailing elements have to be overwritten
  3000. // to prevent results such as /foo//bar
  3001. segments[segments.length - 1] = v;
  3002. } else {
  3003. segments.push(v);
  3004. }
  3005. }
  3006. } else {
  3007. if (v) {
  3008. segments[segment] = trimSlashes(v);
  3009. } else {
  3010. segments.splice(segment, 1);
  3011. }
  3012. }
  3013. if (absolute) {
  3014. segments.unshift('');
  3015. }
  3016. return this.path(segments.join(separator), build);
  3017. };
  3018. p.segmentCoded = function (segment, v, build) {
  3019. var segments, i, l;
  3020. if (typeof segment !== 'number') {
  3021. build = v;
  3022. v = segment;
  3023. segment = undefined;
  3024. }
  3025. if (v === undefined) {
  3026. segments = this.segment(segment, v, build);
  3027. if (!isArray(segments)) {
  3028. segments = segments !== undefined ? URI.decode(segments) : undefined;
  3029. } else {
  3030. for (i = 0, l = segments.length; i < l; i++) {
  3031. segments[i] = URI.decode(segments[i]);
  3032. }
  3033. }
  3034. return segments;
  3035. }
  3036. if (!isArray(v)) {
  3037. v = typeof v === 'string' || v instanceof String ? URI.encode(v) : v;
  3038. } else {
  3039. for (i = 0, l = v.length; i < l; i++) {
  3040. v[i] = URI.encode(v[i]);
  3041. }
  3042. }
  3043. return this.segment(segment, v, build);
  3044. }; // mutating query string
  3045. var q = p.query;
  3046. p.query = function (v, build) {
  3047. if (v === true) {
  3048. return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3049. } else if (typeof v === 'function') {
  3050. var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3051. var result = v.call(this, data);
  3052. this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
  3053. this.build(!build);
  3054. return this;
  3055. } else if (v !== undefined && typeof v !== 'string') {
  3056. this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
  3057. this.build(!build);
  3058. return this;
  3059. } else {
  3060. return q.call(this, v, build);
  3061. }
  3062. };
  3063. p.setQuery = function (name, value, build) {
  3064. var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3065. if (typeof name === 'string' || name instanceof String) {
  3066. data[name] = value !== undefined ? value : null;
  3067. } else if (typeof name === 'object') {
  3068. for (var key in name) {
  3069. if (hasOwn.call(name, key)) {
  3070. data[key] = name[key];
  3071. }
  3072. }
  3073. } else {
  3074. throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
  3075. }
  3076. this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
  3077. if (typeof name !== 'string') {
  3078. build = value;
  3079. }
  3080. this.build(!build);
  3081. return this;
  3082. };
  3083. p.addQuery = function (name, value, build) {
  3084. var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3085. URI.addQuery(data, name, value === undefined ? null : value);
  3086. this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
  3087. if (typeof name !== 'string') {
  3088. build = value;
  3089. }
  3090. this.build(!build);
  3091. return this;
  3092. };
  3093. p.removeQuery = function (name, value, build) {
  3094. var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3095. URI.removeQuery(data, name, value);
  3096. this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
  3097. if (typeof name !== 'string') {
  3098. build = value;
  3099. }
  3100. this.build(!build);
  3101. return this;
  3102. };
  3103. p.hasQuery = function (name, value, withinArray) {
  3104. var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
  3105. return URI.hasQuery(data, name, value, withinArray);
  3106. };
  3107. p.setSearch = p.setQuery;
  3108. p.addSearch = p.addQuery;
  3109. p.removeSearch = p.removeQuery;
  3110. p.hasSearch = p.hasQuery; // sanitizing URLs
  3111. p.normalize = function () {
  3112. if (this._parts.urn) {
  3113. return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
  3114. }
  3115. return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
  3116. };
  3117. p.normalizeProtocol = function (build) {
  3118. if (typeof this._parts.protocol === 'string') {
  3119. this._parts.protocol = this._parts.protocol.toLowerCase();
  3120. this.build(!build);
  3121. }
  3122. return this;
  3123. };
  3124. p.normalizeHostname = function (build) {
  3125. if (this._parts.hostname) {
  3126. if (this.is('IDN') && punycode) {
  3127. this._parts.hostname = punycode.toASCII(this._parts.hostname);
  3128. } else if (this.is('IPv6') && IPv6) {
  3129. this._parts.hostname = IPv6.best(this._parts.hostname);
  3130. }
  3131. this._parts.hostname = this._parts.hostname.toLowerCase();
  3132. this.build(!build);
  3133. }
  3134. return this;
  3135. };
  3136. p.normalizePort = function (build) {
  3137. // remove port of it's the protocol's default
  3138. if (typeof this._parts.protocol === 'string' && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
  3139. this._parts.port = null;
  3140. this.build(!build);
  3141. }
  3142. return this;
  3143. };
  3144. p.normalizePath = function (build) {
  3145. var _path = this._parts.path;
  3146. if (!_path) {
  3147. return this;
  3148. }
  3149. if (this._parts.urn) {
  3150. this._parts.path = URI.recodeUrnPath(this._parts.path);
  3151. this.build(!build);
  3152. return this;
  3153. }
  3154. if (this._parts.path === '/') {
  3155. return this;
  3156. }
  3157. _path = URI.recodePath(_path);
  3158. var _was_relative;
  3159. var _leadingParents = '';
  3160. var _parent, _pos; // handle relative paths
  3161. if (_path.charAt(0) !== '/') {
  3162. _was_relative = true;
  3163. _path = '/' + _path;
  3164. } // handle relative files (as opposed to directories)
  3165. if (_path.slice(-3) === '/..' || _path.slice(-2) === '/.') {
  3166. _path += '/';
  3167. } // resolve simples
  3168. _path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, '/').replace(/\/{2,}/g, '/'); // remember leading parents
  3169. if (_was_relative) {
  3170. _leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || '';
  3171. if (_leadingParents) {
  3172. _leadingParents = _leadingParents[0];
  3173. }
  3174. } // resolve parents
  3175. while (true) {
  3176. _parent = _path.search(/\/\.\.(\/|$)/);
  3177. if (_parent === -1) {
  3178. // no more ../ to resolve
  3179. break;
  3180. } else if (_parent === 0) {
  3181. // top level cannot be relative, skip it
  3182. _path = _path.substring(3);
  3183. continue;
  3184. }
  3185. _pos = _path.substring(0, _parent).lastIndexOf('/');
  3186. if (_pos === -1) {
  3187. _pos = _parent;
  3188. }
  3189. _path = _path.substring(0, _pos) + _path.substring(_parent + 3);
  3190. } // revert to relative
  3191. if (_was_relative && this.is('relative')) {
  3192. _path = _leadingParents + _path.substring(1);
  3193. }
  3194. this._parts.path = _path;
  3195. this.build(!build);
  3196. return this;
  3197. };
  3198. p.normalizePathname = p.normalizePath;
  3199. p.normalizeQuery = function (build) {
  3200. if (typeof this._parts.query === 'string') {
  3201. if (!this._parts.query.length) {
  3202. this._parts.query = null;
  3203. } else {
  3204. this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
  3205. }
  3206. this.build(!build);
  3207. }
  3208. return this;
  3209. };
  3210. p.normalizeFragment = function (build) {
  3211. if (!this._parts.fragment) {
  3212. this._parts.fragment = null;
  3213. this.build(!build);
  3214. }
  3215. return this;
  3216. };
  3217. p.normalizeSearch = p.normalizeQuery;
  3218. p.normalizeHash = p.normalizeFragment;
  3219. p.iso8859 = function () {
  3220. // expect unicode input, iso8859 output
  3221. var e = URI.encode;
  3222. var d = URI.decode;
  3223. URI.encode = escape;
  3224. URI.decode = decodeURIComponent;
  3225. try {
  3226. this.normalize();
  3227. } finally {
  3228. URI.encode = e;
  3229. URI.decode = d;
  3230. }
  3231. return this;
  3232. };
  3233. p.unicode = function () {
  3234. // expect iso8859 input, unicode output
  3235. var e = URI.encode;
  3236. var d = URI.decode;
  3237. URI.encode = strictEncodeURIComponent;
  3238. URI.decode = unescape;
  3239. try {
  3240. this.normalize();
  3241. } finally {
  3242. URI.encode = e;
  3243. URI.decode = d;
  3244. }
  3245. return this;
  3246. };
  3247. p.readable = function () {
  3248. var uri = this.clone(); // removing username, password, because they shouldn't be displayed according to RFC 3986
  3249. uri.username('').password('').normalize();
  3250. var t = '';
  3251. if (uri._parts.protocol) {
  3252. t += uri._parts.protocol + '://';
  3253. }
  3254. if (uri._parts.hostname) {
  3255. if (uri.is('punycode') && punycode) {
  3256. t += punycode.toUnicode(uri._parts.hostname);
  3257. if (uri._parts.port) {
  3258. t += ':' + uri._parts.port;
  3259. }
  3260. } else {
  3261. t += uri.host();
  3262. }
  3263. }
  3264. if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== '/') {
  3265. t += '/';
  3266. }
  3267. t += uri.path(true);
  3268. if (uri._parts.query) {
  3269. var q = '';
  3270. for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) {
  3271. var kv = (qp[i] || '').split('=');
  3272. q += '&' + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, '%26');
  3273. if (kv[1] !== undefined) {
  3274. q += '=' + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, '%26');
  3275. }
  3276. }
  3277. t += '?' + q.substring(1);
  3278. }
  3279. t += URI.decodeQuery(uri.hash(), true);
  3280. return t;
  3281. }; // resolving relative and absolute URLs
  3282. p.absoluteTo = function (base) {
  3283. var resolved = this.clone();
  3284. var properties = ['protocol', 'username', 'password', 'hostname', 'port'];
  3285. var basedir, i, p;
  3286. if (this._parts.urn) {
  3287. throw new Error('URNs do not have any generally defined hierarchical components');
  3288. }
  3289. if (!(base instanceof URI)) {
  3290. base = new URI(base);
  3291. }
  3292. if (resolved._parts.protocol) {
  3293. // Directly returns even if this._parts.hostname is empty.
  3294. return resolved;
  3295. } else {
  3296. resolved._parts.protocol = base._parts.protocol;
  3297. }
  3298. if (this._parts.hostname) {
  3299. return resolved;
  3300. }
  3301. for (i = 0; p = properties[i]; i++) {
  3302. resolved._parts[p] = base._parts[p];
  3303. }
  3304. if (!resolved._parts.path) {
  3305. resolved._parts.path = base._parts.path;
  3306. if (!resolved._parts.query) {
  3307. resolved._parts.query = base._parts.query;
  3308. }
  3309. } else {
  3310. if (resolved._parts.path.substring(-2) === '..') {
  3311. resolved._parts.path += '/';
  3312. }
  3313. if (resolved.path().charAt(0) !== '/') {
  3314. basedir = base.directory();
  3315. basedir = basedir ? basedir : base.path().indexOf('/') === 0 ? '/' : '';
  3316. resolved._parts.path = (basedir ? basedir + '/' : '') + resolved._parts.path;
  3317. resolved.normalizePath();
  3318. }
  3319. }
  3320. resolved.build();
  3321. return resolved;
  3322. };
  3323. p.relativeTo = function (base) {
  3324. var relative = this.clone().normalize();
  3325. var relativeParts, baseParts, common, relativePath, basePath;
  3326. if (relative._parts.urn) {
  3327. throw new Error('URNs do not have any generally defined hierarchical components');
  3328. }
  3329. base = new URI(base).normalize();
  3330. relativeParts = relative._parts;
  3331. baseParts = base._parts;
  3332. relativePath = relative.path();
  3333. basePath = base.path();
  3334. if (relativePath.charAt(0) !== '/') {
  3335. throw new Error('URI is already relative');
  3336. }
  3337. if (basePath.charAt(0) !== '/') {
  3338. throw new Error('Cannot calculate a URI relative to another relative URI');
  3339. }
  3340. if (relativeParts.protocol === baseParts.protocol) {
  3341. relativeParts.protocol = null;
  3342. }
  3343. if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
  3344. return relative.build();
  3345. }
  3346. if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
  3347. return relative.build();
  3348. }
  3349. if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
  3350. relativeParts.hostname = null;
  3351. relativeParts.port = null;
  3352. } else {
  3353. return relative.build();
  3354. }
  3355. if (relativePath === basePath) {
  3356. relativeParts.path = '';
  3357. return relative.build();
  3358. } // determine common sub path
  3359. common = URI.commonPath(relativePath, basePath); // If the paths have nothing in common, return a relative URL with the absolute path.
  3360. if (!common) {
  3361. return relative.build();
  3362. }
  3363. var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, '').replace(/.*?\//g, '../');
  3364. relativeParts.path = parents + relativeParts.path.substring(common.length) || './';
  3365. return relative.build();
  3366. }; // comparing URIs
  3367. p.equals = function (uri) {
  3368. var one = this.clone();
  3369. var two = new URI(uri);
  3370. var one_map = {};
  3371. var two_map = {};
  3372. var checked = {};
  3373. var one_query, two_query, key;
  3374. one.normalize();
  3375. two.normalize(); // exact match
  3376. if (one.toString() === two.toString()) {
  3377. return true;
  3378. } // extract query string
  3379. one_query = one.query();
  3380. two_query = two.query();
  3381. one.query('');
  3382. two.query(''); // definitely not equal if not even non-query parts match
  3383. if (one.toString() !== two.toString()) {
  3384. return false;
  3385. } // query parameters have the same length, even if they're permuted
  3386. if (one_query.length !== two_query.length) {
  3387. return false;
  3388. }
  3389. one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
  3390. two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
  3391. for (key in one_map) {
  3392. if (hasOwn.call(one_map, key)) {
  3393. if (!isArray(one_map[key])) {
  3394. if (one_map[key] !== two_map[key]) {
  3395. return false;
  3396. }
  3397. } else if (!arraysEqual(one_map[key], two_map[key])) {
  3398. return false;
  3399. }
  3400. checked[key] = true;
  3401. }
  3402. }
  3403. for (key in two_map) {
  3404. if (hasOwn.call(two_map, key)) {
  3405. if (!checked[key]) {
  3406. // two contains a parameter not present in one
  3407. return false;
  3408. }
  3409. }
  3410. }
  3411. return true;
  3412. }; // state
  3413. p.preventInvalidHostname = function (v) {
  3414. this._parts.preventInvalidHostname = !!v;
  3415. return this;
  3416. };
  3417. p.duplicateQueryParameters = function (v) {
  3418. this._parts.duplicateQueryParameters = !!v;
  3419. return this;
  3420. };
  3421. p.escapeQuerySpace = function (v) {
  3422. this._parts.escapeQuerySpace = !!v;
  3423. return this;
  3424. };
  3425. return URI;
  3426. });
  3427. /***/ }),
  3428. /***/ 7819:
  3429. /***/ (function(module, exports, __webpack_require__) {
  3430. /* module decorator */ module = __webpack_require__.nmd(module);
  3431. var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.0 by @mathias */
  3432. ;
  3433. (function (root) {
  3434. /** Detect free variables */
  3435. var freeExports = true && exports && !exports.nodeType && exports;
  3436. var freeModule = true && module && !module.nodeType && module;
  3437. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g;
  3438. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
  3439. root = freeGlobal;
  3440. }
  3441. /**
  3442. * The `punycode` object.
  3443. * @name punycode
  3444. * @type Object
  3445. */
  3446. var punycode,
  3447. /** Highest positive signed 32-bit float value */
  3448. maxInt = 2147483647,
  3449. // aka. 0x7FFFFFFF or 2^31-1
  3450. /** Bootstring parameters */
  3451. base = 36,
  3452. tMin = 1,
  3453. tMax = 26,
  3454. skew = 38,
  3455. damp = 700,
  3456. initialBias = 72,
  3457. initialN = 128,
  3458. // 0x80
  3459. delimiter = '-',
  3460. // '\x2D'
  3461. /** Regular expressions */
  3462. regexPunycode = /^xn--/,
  3463. regexNonASCII = /[^\x20-\x7E]/,
  3464. // unprintable ASCII chars + non-ASCII chars
  3465. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g,
  3466. // RFC 3490 separators
  3467. /** Error messages */
  3468. errors = {
  3469. 'overflow': 'Overflow: input needs wider integers to process',
  3470. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  3471. 'invalid-input': 'Invalid input'
  3472. },
  3473. /** Convenience shortcuts */
  3474. baseMinusTMin = base - tMin,
  3475. floor = Math.floor,
  3476. stringFromCharCode = String.fromCharCode,
  3477. /** Temporary variable */
  3478. key;
  3479. /*--------------------------------------------------------------------------*/
  3480. /**
  3481. * A generic error utility function.
  3482. * @private
  3483. * @param {String} type The error type.
  3484. * @returns {Error} Throws a `RangeError` with the applicable error message.
  3485. */
  3486. function error(type) {
  3487. throw new RangeError(errors[type]);
  3488. }
  3489. /**
  3490. * A generic `Array#map` utility function.
  3491. * @private
  3492. * @param {Array} array The array to iterate over.
  3493. * @param {Function} callback The function that gets called for every array
  3494. * item.
  3495. * @returns {Array} A new array of values returned by the callback function.
  3496. */
  3497. function map(array, fn) {
  3498. var length = array.length;
  3499. var result = [];
  3500. while (length--) {
  3501. result[length] = fn(array[length]);
  3502. }
  3503. return result;
  3504. }
  3505. /**
  3506. * A simple `Array#map`-like wrapper to work with domain name strings or email
  3507. * addresses.
  3508. * @private
  3509. * @param {String} domain The domain name or email address.
  3510. * @param {Function} callback The function that gets called for every
  3511. * character.
  3512. * @returns {Array} A new string of characters returned by the callback
  3513. * function.
  3514. */
  3515. function mapDomain(string, fn) {
  3516. var parts = string.split('@');
  3517. var result = '';
  3518. if (parts.length > 1) {
  3519. // In email addresses, only the domain name should be punycoded. Leave
  3520. // the local part (i.e. everything up to `@`) intact.
  3521. result = parts[0] + '@';
  3522. string = parts[1];
  3523. } // Avoid `split(regex)` for IE8 compatibility. See #17.
  3524. string = string.replace(regexSeparators, '\x2E');
  3525. var labels = string.split('.');
  3526. var encoded = map(labels, fn).join('.');
  3527. return result + encoded;
  3528. }
  3529. /**
  3530. * Creates an array containing the numeric code points of each Unicode
  3531. * character in the string. While JavaScript uses UCS-2 internally,
  3532. * this function will convert a pair of surrogate halves (each of which
  3533. * UCS-2 exposes as separate characters) into a single code point,
  3534. * matching UTF-16.
  3535. * @see `punycode.ucs2.encode`
  3536. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  3537. * @memberOf punycode.ucs2
  3538. * @name decode
  3539. * @param {String} string The Unicode input string (UCS-2).
  3540. * @returns {Array} The new array of code points.
  3541. */
  3542. function ucs2decode(string) {
  3543. var output = [],
  3544. counter = 0,
  3545. length = string.length,
  3546. value,
  3547. extra;
  3548. while (counter < length) {
  3549. value = string.charCodeAt(counter++);
  3550. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  3551. // high surrogate, and there is a next character
  3552. extra = string.charCodeAt(counter++);
  3553. if ((extra & 0xFC00) == 0xDC00) {
  3554. // low surrogate
  3555. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  3556. } else {
  3557. // unmatched surrogate; only append this code unit, in case the next
  3558. // code unit is the high surrogate of a surrogate pair
  3559. output.push(value);
  3560. counter--;
  3561. }
  3562. } else {
  3563. output.push(value);
  3564. }
  3565. }
  3566. return output;
  3567. }
  3568. /**
  3569. * Creates a string based on an array of numeric code points.
  3570. * @see `punycode.ucs2.decode`
  3571. * @memberOf punycode.ucs2
  3572. * @name encode
  3573. * @param {Array} codePoints The array of numeric code points.
  3574. * @returns {String} The new Unicode string (UCS-2).
  3575. */
  3576. function ucs2encode(array) {
  3577. return map(array, function (value) {
  3578. var output = '';
  3579. if (value > 0xFFFF) {
  3580. value -= 0x10000;
  3581. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  3582. value = 0xDC00 | value & 0x3FF;
  3583. }
  3584. output += stringFromCharCode(value);
  3585. return output;
  3586. }).join('');
  3587. }
  3588. /**
  3589. * Converts a basic code point into a digit/integer.
  3590. * @see `digitToBasic()`
  3591. * @private
  3592. * @param {Number} codePoint The basic numeric code point value.
  3593. * @returns {Number} The numeric value of a basic code point (for use in
  3594. * representing integers) in the range `0` to `base - 1`, or `base` if
  3595. * the code point does not represent a value.
  3596. */
  3597. function basicToDigit(codePoint) {
  3598. if (codePoint - 48 < 10) {
  3599. return codePoint - 22;
  3600. }
  3601. if (codePoint - 65 < 26) {
  3602. return codePoint - 65;
  3603. }
  3604. if (codePoint - 97 < 26) {
  3605. return codePoint - 97;
  3606. }
  3607. return base;
  3608. }
  3609. /**
  3610. * Converts a digit/integer into a basic code point.
  3611. * @see `basicToDigit()`
  3612. * @private
  3613. * @param {Number} digit The numeric value of a basic code point.
  3614. * @returns {Number} The basic code point whose value (when used for
  3615. * representing integers) is `digit`, which needs to be in the range
  3616. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  3617. * used; else, the lowercase form is used. The behavior is undefined
  3618. * if `flag` is non-zero and `digit` has no uppercase form.
  3619. */
  3620. function digitToBasic(digit, flag) {
  3621. // 0..25 map to ASCII a..z or A..Z
  3622. // 26..35 map to ASCII 0..9
  3623. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  3624. }
  3625. /**
  3626. * Bias adaptation function as per section 3.4 of RFC 3492.
  3627. * https://tools.ietf.org/html/rfc3492#section-3.4
  3628. * @private
  3629. */
  3630. function adapt(delta, numPoints, firstTime) {
  3631. var k = 0;
  3632. delta = firstTime ? floor(delta / damp) : delta >> 1;
  3633. delta += floor(delta / numPoints);
  3634. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  3635. delta = floor(delta / baseMinusTMin);
  3636. }
  3637. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  3638. }
  3639. /**
  3640. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  3641. * symbols.
  3642. * @memberOf punycode
  3643. * @param {String} input The Punycode string of ASCII-only symbols.
  3644. * @returns {String} The resulting string of Unicode symbols.
  3645. */
  3646. function decode(input) {
  3647. // Don't use UCS-2
  3648. var output = [],
  3649. inputLength = input.length,
  3650. out,
  3651. i = 0,
  3652. n = initialN,
  3653. bias = initialBias,
  3654. basic,
  3655. j,
  3656. index,
  3657. oldi,
  3658. w,
  3659. k,
  3660. digit,
  3661. t,
  3662. /** Cached calculation results */
  3663. baseMinusT; // Handle the basic code points: let `basic` be the number of input code
  3664. // points before the last delimiter, or `0` if there is none, then copy
  3665. // the first basic code points to the output.
  3666. basic = input.lastIndexOf(delimiter);
  3667. if (basic < 0) {
  3668. basic = 0;
  3669. }
  3670. for (j = 0; j < basic; ++j) {
  3671. // if it's not a basic code point
  3672. if (input.charCodeAt(j) >= 0x80) {
  3673. error('not-basic');
  3674. }
  3675. output.push(input.charCodeAt(j));
  3676. } // Main decoding loop: start just after the last delimiter if any basic code
  3677. // points were copied; start at the beginning otherwise.
  3678. for (index = basic > 0 ? basic + 1 : 0; index < inputLength;) {
  3679. // `index` is the index of the next character to be consumed.
  3680. // Decode a generalized variable-length integer into `delta`,
  3681. // which gets added to `i`. The overflow checking is easier
  3682. // if we increase `i` as we go, then subtract off its starting
  3683. // value at the end to obtain `delta`.
  3684. for (oldi = i, w = 1, k = base;; k += base) {
  3685. if (index >= inputLength) {
  3686. error('invalid-input');
  3687. }
  3688. digit = basicToDigit(input.charCodeAt(index++));
  3689. if (digit >= base || digit > floor((maxInt - i) / w)) {
  3690. error('overflow');
  3691. }
  3692. i += digit * w;
  3693. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  3694. if (digit < t) {
  3695. break;
  3696. }
  3697. baseMinusT = base - t;
  3698. if (w > floor(maxInt / baseMinusT)) {
  3699. error('overflow');
  3700. }
  3701. w *= baseMinusT;
  3702. }
  3703. out = output.length + 1;
  3704. bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,
  3705. // incrementing `n` each time, so we'll fix that now:
  3706. if (floor(i / out) > maxInt - n) {
  3707. error('overflow');
  3708. }
  3709. n += floor(i / out);
  3710. i %= out; // Insert `n` at position `i` of the output
  3711. output.splice(i++, 0, n);
  3712. }
  3713. return ucs2encode(output);
  3714. }
  3715. /**
  3716. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  3717. * Punycode string of ASCII-only symbols.
  3718. * @memberOf punycode
  3719. * @param {String} input The string of Unicode symbols.
  3720. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  3721. */
  3722. function encode(input) {
  3723. var n,
  3724. delta,
  3725. handledCPCount,
  3726. basicLength,
  3727. bias,
  3728. j,
  3729. m,
  3730. q,
  3731. k,
  3732. t,
  3733. currentValue,
  3734. output = [],
  3735. /** `inputLength` will hold the number of code points in `input`. */
  3736. inputLength,
  3737. /** Cached calculation results */
  3738. handledCPCountPlusOne,
  3739. baseMinusT,
  3740. qMinusT; // Convert the input in UCS-2 to Unicode
  3741. input = ucs2decode(input); // Cache the length
  3742. inputLength = input.length; // Initialize the state
  3743. n = initialN;
  3744. delta = 0;
  3745. bias = initialBias; // Handle the basic code points
  3746. for (j = 0; j < inputLength; ++j) {
  3747. currentValue = input[j];
  3748. if (currentValue < 0x80) {
  3749. output.push(stringFromCharCode(currentValue));
  3750. }
  3751. }
  3752. handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;
  3753. // `basicLength` is the number of basic code points.
  3754. // Finish the basic string - if it is not empty - with a delimiter
  3755. if (basicLength) {
  3756. output.push(delimiter);
  3757. } // Main encoding loop:
  3758. while (handledCPCount < inputLength) {
  3759. // All non-basic code points < n have been handled already. Find the next
  3760. // larger one:
  3761. for (m = maxInt, j = 0; j < inputLength; ++j) {
  3762. currentValue = input[j];
  3763. if (currentValue >= n && currentValue < m) {
  3764. m = currentValue;
  3765. }
  3766. } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  3767. // but guard against overflow
  3768. handledCPCountPlusOne = handledCPCount + 1;
  3769. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  3770. error('overflow');
  3771. }
  3772. delta += (m - n) * handledCPCountPlusOne;
  3773. n = m;
  3774. for (j = 0; j < inputLength; ++j) {
  3775. currentValue = input[j];
  3776. if (currentValue < n && ++delta > maxInt) {
  3777. error('overflow');
  3778. }
  3779. if (currentValue == n) {
  3780. // Represent delta as a generalized variable-length integer
  3781. for (q = delta, k = base;; k += base) {
  3782. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  3783. if (q < t) {
  3784. break;
  3785. }
  3786. qMinusT = q - t;
  3787. baseMinusT = base - t;
  3788. output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
  3789. q = floor(qMinusT / baseMinusT);
  3790. }
  3791. output.push(stringFromCharCode(digitToBasic(q, 0)));
  3792. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  3793. delta = 0;
  3794. ++handledCPCount;
  3795. }
  3796. }
  3797. ++delta;
  3798. ++n;
  3799. }
  3800. return output.join('');
  3801. }
  3802. /**
  3803. * Converts a Punycode string representing a domain name or an email address
  3804. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  3805. * it doesn't matter if you call it on a string that has already been
  3806. * converted to Unicode.
  3807. * @memberOf punycode
  3808. * @param {String} input The Punycoded domain name or email address to
  3809. * convert to Unicode.
  3810. * @returns {String} The Unicode representation of the given Punycode
  3811. * string.
  3812. */
  3813. function toUnicode(input) {
  3814. return mapDomain(input, function (string) {
  3815. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  3816. });
  3817. }
  3818. /**
  3819. * Converts a Unicode string representing a domain name or an email address to
  3820. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  3821. * i.e. it doesn't matter if you call it with a domain that's already in
  3822. * ASCII.
  3823. * @memberOf punycode
  3824. * @param {String} input The domain name or email address to convert, as a
  3825. * Unicode string.
  3826. * @returns {String} The Punycode representation of the given domain name or
  3827. * email address.
  3828. */
  3829. function toASCII(input) {
  3830. return mapDomain(input, function (string) {
  3831. return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
  3832. });
  3833. }
  3834. /*--------------------------------------------------------------------------*/
  3835. /** Define the public API */
  3836. punycode = {
  3837. /**
  3838. * A string representing the current Punycode.js version number.
  3839. * @memberOf punycode
  3840. * @type String
  3841. */
  3842. 'version': '1.3.2',
  3843. /**
  3844. * An object of methods to convert from JavaScript's internal character
  3845. * representation (UCS-2) to Unicode code points, and back.
  3846. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  3847. * @memberOf punycode
  3848. * @type Object
  3849. */
  3850. 'ucs2': {
  3851. 'decode': ucs2decode,
  3852. 'encode': ucs2encode
  3853. },
  3854. 'decode': decode,
  3855. 'encode': encode,
  3856. 'toASCII': toASCII,
  3857. 'toUnicode': toUnicode
  3858. };
  3859. /** Expose `punycode` */
  3860. // Some AMD build optimizers, like r.js, check for specific condition patterns
  3861. // like the following:
  3862. if (true) {
  3863. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  3864. return punycode;
  3865. }).call(exports, __webpack_require__, exports, module),
  3866. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  3867. } else {}
  3868. })(this);
  3869. /***/ }),
  3870. /***/ 517:
  3871. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3872. "use strict";
  3873. // ESM COMPAT FLAG
  3874. __webpack_require__.r(__webpack_exports__);
  3875. // EXPORTS
  3876. __webpack_require__.d(__webpack_exports__, {
  3877. "default": () => (/* binding */ src_converse)
  3878. });
  3879. // EXTERNAL MODULE: ./node_modules/urijs/src/URI.js
  3880. var URI = __webpack_require__(5215);
  3881. var URI_default = /*#__PURE__*/__webpack_require__.n(URI);
  3882. // EXTERNAL MODULE: ./node_modules/sprintf-js/src/sprintf.js
  3883. var sprintf = __webpack_require__(4223);
  3884. ;// CONCATENATED MODULE: ./src/headless/shared/i18n.js
  3885. /**
  3886. * @namespace i18n
  3887. */
  3888. /* harmony default export */ const i18n = ({
  3889. initialize() {},
  3890. /**
  3891. * Overridable string wrapper method which can be used to provide i18n
  3892. * support.
  3893. *
  3894. * The default implementation in @converse/headless simply calls sprintf
  3895. * with the passed in arguments.
  3896. *
  3897. * If you install the full version of Converse, then this method gets
  3898. * overwritten in src/i18n/index.js to return a translated string.
  3899. * @method __
  3900. * @private
  3901. * @memberOf i18n
  3902. * @param { String } str
  3903. */
  3904. __() {
  3905. return (0,sprintf.sprintf)(...arguments);
  3906. }
  3907. });
  3908. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isObjectLike.js
  3909. /**
  3910. * Checks if `value` is object-like. A value is object-like if it's not `null`
  3911. * and has a `typeof` result of "object".
  3912. *
  3913. * @static
  3914. * @memberOf _
  3915. * @since 4.0.0
  3916. * @category Lang
  3917. * @param {*} value The value to check.
  3918. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3919. * @example
  3920. *
  3921. * _.isObjectLike({});
  3922. * // => true
  3923. *
  3924. * _.isObjectLike([1, 2, 3]);
  3925. * // => true
  3926. *
  3927. * _.isObjectLike(_.noop);
  3928. * // => false
  3929. *
  3930. * _.isObjectLike(null);
  3931. * // => false
  3932. */
  3933. function isObjectLike(value) {
  3934. return value != null && typeof value == 'object';
  3935. }
  3936. /* harmony default export */ const lodash_es_isObjectLike = (isObjectLike);
  3937. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_freeGlobal.js
  3938. /** Detect free variable `global` from Node.js. */
  3939. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  3940. /* harmony default export */ const _freeGlobal = (freeGlobal);
  3941. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_root.js
  3942. /** Detect free variable `self`. */
  3943. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  3944. /** Used as a reference to the global object. */
  3945. var root = _freeGlobal || freeSelf || Function('return this')();
  3946. /* harmony default export */ const _root = (root);
  3947. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Symbol.js
  3948. /** Built-in value references. */
  3949. var _Symbol_Symbol = _root.Symbol;
  3950. /* harmony default export */ const _Symbol = (_Symbol_Symbol);
  3951. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getRawTag.js
  3952. /** Used for built-in method references. */
  3953. var objectProto = Object.prototype;
  3954. /** Used to check objects for own properties. */
  3955. var _getRawTag_hasOwnProperty = objectProto.hasOwnProperty;
  3956. /**
  3957. * Used to resolve the
  3958. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  3959. * of values.
  3960. */
  3961. var nativeObjectToString = objectProto.toString;
  3962. /** Built-in value references. */
  3963. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  3964. /**
  3965. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  3966. *
  3967. * @private
  3968. * @param {*} value The value to query.
  3969. * @returns {string} Returns the raw `toStringTag`.
  3970. */
  3971. function getRawTag(value) {
  3972. var isOwn = _getRawTag_hasOwnProperty.call(value, symToStringTag),
  3973. tag = value[symToStringTag];
  3974. try {
  3975. value[symToStringTag] = undefined;
  3976. var unmasked = true;
  3977. } catch (e) {}
  3978. var result = nativeObjectToString.call(value);
  3979. if (unmasked) {
  3980. if (isOwn) {
  3981. value[symToStringTag] = tag;
  3982. } else {
  3983. delete value[symToStringTag];
  3984. }
  3985. }
  3986. return result;
  3987. }
  3988. /* harmony default export */ const _getRawTag = (getRawTag);
  3989. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_objectToString.js
  3990. /** Used for built-in method references. */
  3991. var _objectToString_objectProto = Object.prototype;
  3992. /**
  3993. * Used to resolve the
  3994. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  3995. * of values.
  3996. */
  3997. var _objectToString_nativeObjectToString = _objectToString_objectProto.toString;
  3998. /**
  3999. * Converts `value` to a string using `Object.prototype.toString`.
  4000. *
  4001. * @private
  4002. * @param {*} value The value to convert.
  4003. * @returns {string} Returns the converted string.
  4004. */
  4005. function objectToString(value) {
  4006. return _objectToString_nativeObjectToString.call(value);
  4007. }
  4008. /* harmony default export */ const _objectToString = (objectToString);
  4009. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseGetTag.js
  4010. /** `Object#toString` result references. */
  4011. var nullTag = '[object Null]',
  4012. undefinedTag = '[object Undefined]';
  4013. /** Built-in value references. */
  4014. var _baseGetTag_symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  4015. /**
  4016. * The base implementation of `getTag` without fallbacks for buggy environments.
  4017. *
  4018. * @private
  4019. * @param {*} value The value to query.
  4020. * @returns {string} Returns the `toStringTag`.
  4021. */
  4022. function baseGetTag(value) {
  4023. if (value == null) {
  4024. return value === undefined ? undefinedTag : nullTag;
  4025. }
  4026. return (_baseGetTag_symToStringTag && _baseGetTag_symToStringTag in Object(value))
  4027. ? _getRawTag(value)
  4028. : _objectToString(value);
  4029. }
  4030. /* harmony default export */ const _baseGetTag = (baseGetTag);
  4031. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_overArg.js
  4032. /**
  4033. * Creates a unary function that invokes `func` with its argument transformed.
  4034. *
  4035. * @private
  4036. * @param {Function} func The function to wrap.
  4037. * @param {Function} transform The argument transform.
  4038. * @returns {Function} Returns the new function.
  4039. */
  4040. function overArg(func, transform) {
  4041. return function(arg) {
  4042. return func(transform(arg));
  4043. };
  4044. }
  4045. /* harmony default export */ const _overArg = (overArg);
  4046. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getPrototype.js
  4047. /** Built-in value references. */
  4048. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  4049. /* harmony default export */ const _getPrototype = (getPrototype);
  4050. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isPlainObject.js
  4051. /** `Object#toString` result references. */
  4052. var objectTag = '[object Object]';
  4053. /** Used for built-in method references. */
  4054. var funcProto = Function.prototype,
  4055. isPlainObject_objectProto = Object.prototype;
  4056. /** Used to resolve the decompiled source of functions. */
  4057. var funcToString = funcProto.toString;
  4058. /** Used to check objects for own properties. */
  4059. var isPlainObject_hasOwnProperty = isPlainObject_objectProto.hasOwnProperty;
  4060. /** Used to infer the `Object` constructor. */
  4061. var objectCtorString = funcToString.call(Object);
  4062. /**
  4063. * Checks if `value` is a plain object, that is, an object created by the
  4064. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  4065. *
  4066. * @static
  4067. * @memberOf _
  4068. * @since 0.8.0
  4069. * @category Lang
  4070. * @param {*} value The value to check.
  4071. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  4072. * @example
  4073. *
  4074. * function Foo() {
  4075. * this.a = 1;
  4076. * }
  4077. *
  4078. * _.isPlainObject(new Foo);
  4079. * // => false
  4080. *
  4081. * _.isPlainObject([1, 2, 3]);
  4082. * // => false
  4083. *
  4084. * _.isPlainObject({ 'x': 0, 'y': 0 });
  4085. * // => true
  4086. *
  4087. * _.isPlainObject(Object.create(null));
  4088. * // => true
  4089. */
  4090. function isPlainObject(value) {
  4091. if (!lodash_es_isObjectLike(value) || _baseGetTag(value) != objectTag) {
  4092. return false;
  4093. }
  4094. var proto = _getPrototype(value);
  4095. if (proto === null) {
  4096. return true;
  4097. }
  4098. var Ctor = isPlainObject_hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  4099. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  4100. funcToString.call(Ctor) == objectCtorString;
  4101. }
  4102. /* harmony default export */ const lodash_es_isPlainObject = (isPlainObject);
  4103. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isElement.js
  4104. /**
  4105. * Checks if `value` is likely a DOM element.
  4106. *
  4107. * @static
  4108. * @memberOf _
  4109. * @since 0.1.0
  4110. * @category Lang
  4111. * @param {*} value The value to check.
  4112. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  4113. * @example
  4114. *
  4115. * _.isElement(document.body);
  4116. * // => true
  4117. *
  4118. * _.isElement('<body>');
  4119. * // => false
  4120. */
  4121. function isElement(value) {
  4122. return lodash_es_isObjectLike(value) && value.nodeType === 1 && !lodash_es_isPlainObject(value);
  4123. }
  4124. /* harmony default export */ const lodash_es_isElement = (isElement);
  4125. ;// CONCATENATED MODULE: ./src/headless/log.js
  4126. var _console, _console2, _console3, _console4;
  4127. const LEVELS = {
  4128. 'debug': 0,
  4129. 'info': 1,
  4130. 'warn': 2,
  4131. 'error': 3,
  4132. 'fatal': 4
  4133. };
  4134. const logger = Object.assign({
  4135. 'debug': (_console = console) !== null && _console !== void 0 && _console.log ? console.log.bind(console) : function noop() {},
  4136. 'error': (_console2 = console) !== null && _console2 !== void 0 && _console2.log ? console.log.bind(console) : function noop() {},
  4137. 'info': (_console3 = console) !== null && _console3 !== void 0 && _console3.log ? console.log.bind(console) : function noop() {},
  4138. 'warn': (_console4 = console) !== null && _console4 !== void 0 && _console4.log ? console.log.bind(console) : function noop() {}
  4139. }, console);
  4140. /**
  4141. * The log namespace
  4142. * @namespace log
  4143. */
  4144. const log = {
  4145. /**
  4146. * The the log-level, which determines how verbose the logging is.
  4147. * @method log#setLogLevel
  4148. * @param { integer } level - The loglevel which allows for filtering of log messages
  4149. */
  4150. setLogLevel(level) {
  4151. if (!['debug', 'info', 'warn', 'error', 'fatal'].includes(level)) {
  4152. throw new Error(`Invalid loglevel: ${level}`);
  4153. }
  4154. this.loglevel = level;
  4155. },
  4156. /**
  4157. * Logs messages to the browser's developer console.
  4158. * Available loglevels are 0 for 'debug', 1 for 'info', 2 for 'warn',
  4159. * 3 for 'error' and 4 for 'fatal'.
  4160. * When using the 'error' or 'warn' loglevels, a full stacktrace will be
  4161. * logged as well.
  4162. * @method log#log
  4163. * @param { string | Error } message - The message to be logged
  4164. * @param { integer } level - The loglevel which allows for filtering of log messages
  4165. */
  4166. log(message, level) {
  4167. let style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  4168. if (LEVELS[level] < LEVELS[this.loglevel]) {
  4169. return;
  4170. }
  4171. if (level === 'error' || level === 'fatal') {
  4172. style = style || 'color: maroon';
  4173. } else if (level === 'debug') {
  4174. style = style || 'color: green';
  4175. }
  4176. if (message instanceof Error) {
  4177. message = message.stack;
  4178. } else if (lodash_es_isElement(message)) {
  4179. message = message.outerHTML;
  4180. }
  4181. const prefix = style ? '%c' : '';
  4182. if (level === 'error') {
  4183. logger.error(`${prefix} ERROR: ${message}`, style);
  4184. } else if (level === 'warn') {
  4185. logger.warn(`${prefix} ${new Date().toISOString()} WARNING: ${message}`, style);
  4186. } else if (level === 'fatal') {
  4187. logger.error(`${prefix} FATAL: ${message}`, style);
  4188. } else if (level === 'debug') {
  4189. logger.debug(`${prefix} ${new Date().toISOString()} DEBUG: ${message}`, style);
  4190. } else {
  4191. logger.info(`${prefix} ${new Date().toISOString()} INFO: ${message}`, style);
  4192. }
  4193. },
  4194. debug(message, style) {
  4195. this.log(message, 'debug', style);
  4196. },
  4197. error(message, style) {
  4198. this.log(message, 'error', style);
  4199. },
  4200. info(message, style) {
  4201. this.log(message, 'info', style);
  4202. },
  4203. warn(message, style) {
  4204. this.log(message, 'warn', style);
  4205. },
  4206. fatal(message, style) {
  4207. this.log(message, 'fatal', style);
  4208. }
  4209. };
  4210. /* harmony default export */ const headless_log = (log);
  4211. ;// CONCATENATED MODULE: ./src/strophe-shims.js
  4212. const WebSocket = window.WebSocket;
  4213. const strophe_shims_DOMParser = window.DOMParser;
  4214. function getDummyXMLDOMDocument() {
  4215. return document.implementation.createDocument('jabber:client', 'strophe', null);
  4216. }
  4217. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/md5.js
  4218. /*
  4219. * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  4220. * Digest Algorithm, as defined in RFC 1321.
  4221. * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
  4222. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  4223. * Distributed under the BSD License
  4224. * See http://pajhome.org.uk/crypt/md5 for more info.
  4225. */
  4226. /*
  4227. * Everything that isn't used by Strophe has been stripped here!
  4228. */
  4229. /*
  4230. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  4231. * to work around bugs in some JS interpreters.
  4232. */
  4233. const safe_add = function (x, y) {
  4234. const lsw = (x & 0xFFFF) + (y & 0xFFFF);
  4235. const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  4236. return msw << 16 | lsw & 0xFFFF;
  4237. };
  4238. /*
  4239. * Bitwise rotate a 32-bit number to the left.
  4240. */
  4241. const bit_rol = function (num, cnt) {
  4242. return num << cnt | num >>> 32 - cnt;
  4243. };
  4244. /*
  4245. * Convert a string to an array of little-endian words
  4246. */
  4247. const str2binl = function (str) {
  4248. if (typeof str !== "string") {
  4249. throw new Error("str2binl was passed a non-string");
  4250. }
  4251. const bin = [];
  4252. for (let i = 0; i < str.length * 8; i += 8) {
  4253. bin[i >> 5] |= (str.charCodeAt(i / 8) & 255) << i % 32;
  4254. }
  4255. return bin;
  4256. };
  4257. /*
  4258. * Convert an array of little-endian words to a string
  4259. */
  4260. const binl2str = function (bin) {
  4261. let str = "";
  4262. for (let i = 0; i < bin.length * 32; i += 8) {
  4263. str += String.fromCharCode(bin[i >> 5] >>> i % 32 & 255);
  4264. }
  4265. return str;
  4266. };
  4267. /*
  4268. * Convert an array of little-endian words to a hex string.
  4269. */
  4270. const binl2hex = function (binarray) {
  4271. const hex_tab = "0123456789abcdef";
  4272. let str = "";
  4273. for (let i = 0; i < binarray.length * 4; i++) {
  4274. str += hex_tab.charAt(binarray[i >> 2] >> i % 4 * 8 + 4 & 0xF) + hex_tab.charAt(binarray[i >> 2] >> i % 4 * 8 & 0xF);
  4275. }
  4276. return str;
  4277. };
  4278. /*
  4279. * These functions implement the four basic operations the algorithm uses.
  4280. */
  4281. const md5_cmn = function (q, a, b, x, s, t) {
  4282. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  4283. };
  4284. const md5_ff = function (a, b, c, d, x, s, t) {
  4285. return md5_cmn(b & c | ~b & d, a, b, x, s, t);
  4286. };
  4287. const md5_gg = function (a, b, c, d, x, s, t) {
  4288. return md5_cmn(b & d | c & ~d, a, b, x, s, t);
  4289. };
  4290. const md5_hh = function (a, b, c, d, x, s, t) {
  4291. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  4292. };
  4293. const md5_ii = function (a, b, c, d, x, s, t) {
  4294. return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
  4295. };
  4296. /*
  4297. * Calculate the MD5 of an array of little-endian words, and a bit length
  4298. */
  4299. const core_md5 = function (x, len) {
  4300. /* append padding */
  4301. x[len >> 5] |= 0x80 << len % 32;
  4302. x[(len + 64 >>> 9 << 4) + 14] = len;
  4303. let a = 1732584193;
  4304. let b = -271733879;
  4305. let c = -1732584194;
  4306. let d = 271733878;
  4307. let olda, oldb, oldc, oldd;
  4308. for (let i = 0; i < x.length; i += 16) {
  4309. olda = a;
  4310. oldb = b;
  4311. oldc = c;
  4312. oldd = d;
  4313. a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
  4314. d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
  4315. c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
  4316. b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
  4317. a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
  4318. d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
  4319. c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
  4320. b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
  4321. a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
  4322. d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
  4323. c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
  4324. b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
  4325. a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
  4326. d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
  4327. c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
  4328. b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
  4329. a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
  4330. d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
  4331. c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
  4332. b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
  4333. a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
  4334. d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
  4335. c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
  4336. b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
  4337. a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
  4338. d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
  4339. c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
  4340. b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
  4341. a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
  4342. d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
  4343. c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
  4344. b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
  4345. a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
  4346. d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
  4347. c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
  4348. b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
  4349. a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
  4350. d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
  4351. c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
  4352. b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
  4353. a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
  4354. d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
  4355. c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
  4356. b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
  4357. a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
  4358. d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
  4359. c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
  4360. b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
  4361. a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
  4362. d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
  4363. c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
  4364. b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
  4365. a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
  4366. d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
  4367. c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
  4368. b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
  4369. a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
  4370. d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
  4371. c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
  4372. b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
  4373. a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
  4374. d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
  4375. c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
  4376. b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
  4377. a = safe_add(a, olda);
  4378. b = safe_add(b, oldb);
  4379. c = safe_add(c, oldc);
  4380. d = safe_add(d, oldd);
  4381. }
  4382. return [a, b, c, d];
  4383. };
  4384. /*
  4385. * These are the functions you'll usually want to call.
  4386. * They take string arguments and return either hex or base-64 encoded
  4387. * strings.
  4388. */
  4389. const MD5 = {
  4390. hexdigest: function (s) {
  4391. return binl2hex(core_md5(str2binl(s), s.length * 8));
  4392. },
  4393. hash: function (s) {
  4394. return binl2str(core_md5(str2binl(s), s.length * 8));
  4395. }
  4396. };
  4397. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl.js
  4398. /** Class: Strophe.SASLMechanism
  4399. *
  4400. * Encapsulates an SASL authentication mechanism.
  4401. *
  4402. * User code may override the priority for each mechanism or disable it completely.
  4403. * See <priority> for information about changing priority and <test> for informatian on
  4404. * how to disable a mechanism.
  4405. *
  4406. * By default, all mechanisms are enabled and the priorities are
  4407. *
  4408. * SCRAM-SHA-1 - 60
  4409. * PLAIN - 50
  4410. * OAUTHBEARER - 40
  4411. * X-OAUTH2 - 30
  4412. * ANONYMOUS - 20
  4413. * EXTERNAL - 10
  4414. *
  4415. * See: Strophe.Connection.addSupportedSASLMechanisms
  4416. */
  4417. class SASLMechanism {
  4418. /**
  4419. * PrivateConstructor: Strophe.SASLMechanism
  4420. * SASL auth mechanism abstraction.
  4421. *
  4422. * Parameters:
  4423. * (String) name - SASL Mechanism name.
  4424. * (Boolean) isClientFirst - If client should send response first without challenge.
  4425. * (Number) priority - Priority.
  4426. *
  4427. * Returns:
  4428. * A new Strophe.SASLMechanism object.
  4429. */
  4430. constructor(name, isClientFirst, priority) {
  4431. /** PrivateVariable: mechname
  4432. * Mechanism name.
  4433. */
  4434. this.mechname = name;
  4435. /** PrivateVariable: isClientFirst
  4436. * If client sends response without initial server challenge.
  4437. */
  4438. this.isClientFirst = isClientFirst;
  4439. /** Variable: priority
  4440. * Determines which <SASLMechanism> is chosen for authentication (Higher is better).
  4441. * Users may override this to prioritize mechanisms differently.
  4442. *
  4443. * Example: (This will cause Strophe to choose the mechanism that the server sent first)
  4444. *
  4445. * > Strophe.SASLPlain.priority = Strophe.SASLSHA1.priority;
  4446. *
  4447. * See <SASL mechanisms> for a list of available mechanisms.
  4448. *
  4449. */
  4450. this.priority = priority;
  4451. }
  4452. /**
  4453. * Function: test
  4454. * Checks if mechanism able to run.
  4455. * To disable a mechanism, make this return false;
  4456. *
  4457. * To disable plain authentication run
  4458. * > Strophe.SASLPlain.test = function() {
  4459. * > return false;
  4460. * > }
  4461. *
  4462. * See <SASL mechanisms> for a list of available mechanisms.
  4463. *
  4464. * Parameters:
  4465. * (Strophe.Connection) connection - Target Connection.
  4466. *
  4467. * Returns:
  4468. * (Boolean) If mechanism was able to run.
  4469. */
  4470. test() {
  4471. // eslint-disable-line class-methods-use-this
  4472. return true;
  4473. }
  4474. /** PrivateFunction: onStart
  4475. * Called before starting mechanism on some connection.
  4476. *
  4477. * Parameters:
  4478. * (Strophe.Connection) connection - Target Connection.
  4479. */
  4480. onStart(connection) {
  4481. this._connection = connection;
  4482. }
  4483. /** PrivateFunction: onChallenge
  4484. * Called by protocol implementation on incoming challenge.
  4485. *
  4486. * By deafult, if the client is expected to send data first (isClientFirst === true),
  4487. * this method is called with `challenge` as null on the first call,
  4488. * unless `clientChallenge` is overridden in the relevant subclass.
  4489. *
  4490. * Parameters:
  4491. * (Strophe.Connection) connection - Target Connection.
  4492. * (String) challenge - current challenge to handle.
  4493. *
  4494. * Returns:
  4495. * (String) Mechanism response.
  4496. */
  4497. onChallenge(connection, challenge) {
  4498. // eslint-disable-line
  4499. throw new Error("You should implement challenge handling!");
  4500. }
  4501. /** PrivateFunction: clientChallenge
  4502. * Called by the protocol implementation if the client is expected to send
  4503. * data first in the authentication exchange (i.e. isClientFirst === true).
  4504. *
  4505. * Parameters:
  4506. * (Strophe.Connection) connection - Target Connection.
  4507. *
  4508. * Returns:
  4509. * (String) Mechanism response.
  4510. */
  4511. clientChallenge(connection) {
  4512. if (!this.isClientFirst) {
  4513. throw new Error("clientChallenge should not be called if isClientFirst is false!");
  4514. }
  4515. return this.onChallenge(connection);
  4516. }
  4517. /** PrivateFunction: onFailure
  4518. * Protocol informs mechanism implementation about SASL failure.
  4519. */
  4520. onFailure() {
  4521. this._connection = null;
  4522. }
  4523. /** PrivateFunction: onSuccess
  4524. * Protocol informs mechanism implementation about SASL success.
  4525. */
  4526. onSuccess() {
  4527. this._connection = null;
  4528. }
  4529. }
  4530. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-anon.js
  4531. // Building SASL callbacks
  4532. class SASLAnonymous extends SASLMechanism {
  4533. /** PrivateConstructor: SASLAnonymous
  4534. * SASL ANONYMOUS authentication.
  4535. */
  4536. constructor() {
  4537. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ANONYMOUS';
  4538. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4539. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 20;
  4540. super(mechname, isClientFirst, priority);
  4541. }
  4542. test(connection) {
  4543. // eslint-disable-line class-methods-use-this
  4544. return connection.authcid === null;
  4545. }
  4546. }
  4547. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-external.js
  4548. class SASLExternal extends SASLMechanism {
  4549. /** PrivateConstructor: SASLExternal
  4550. * SASL EXTERNAL authentication.
  4551. *
  4552. * The EXTERNAL mechanism allows a client to request the server to use
  4553. * credentials established by means external to the mechanism to
  4554. * authenticate the client. The external means may be, for instance,
  4555. * TLS services.
  4556. */
  4557. constructor() {
  4558. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'EXTERNAL';
  4559. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4560. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  4561. super(mechname, isClientFirst, priority);
  4562. }
  4563. onChallenge(connection) {
  4564. // eslint-disable-line class-methods-use-this
  4565. /** According to XEP-178, an authzid SHOULD NOT be presented when the
  4566. * authcid contained or implied in the client certificate is the JID (i.e.
  4567. * authzid) with which the user wants to log in as.
  4568. *
  4569. * To NOT send the authzid, the user should therefore set the authcid equal
  4570. * to the JID when instantiating a new Strophe.Connection object.
  4571. */
  4572. return connection.authcid === connection.authzid ? '' : connection.authzid;
  4573. }
  4574. }
  4575. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/utils.js
  4576. const utils = {
  4577. utf16to8: function (str) {
  4578. var i, c;
  4579. var out = "";
  4580. var len = str.length;
  4581. for (i = 0; i < len; i++) {
  4582. c = str.charCodeAt(i);
  4583. if (c >= 0x0000 && c <= 0x007F) {
  4584. out += str.charAt(i);
  4585. } else if (c > 0x07FF) {
  4586. out += String.fromCharCode(0xE0 | c >> 12 & 0x0F);
  4587. out += String.fromCharCode(0x80 | c >> 6 & 0x3F);
  4588. out += String.fromCharCode(0x80 | c >> 0 & 0x3F);
  4589. } else {
  4590. out += String.fromCharCode(0xC0 | c >> 6 & 0x1F);
  4591. out += String.fromCharCode(0x80 | c >> 0 & 0x3F);
  4592. }
  4593. }
  4594. return out;
  4595. },
  4596. addCookies: function (cookies) {
  4597. /* Parameters:
  4598. * (Object) cookies - either a map of cookie names
  4599. * to string values or to maps of cookie values.
  4600. *
  4601. * For example:
  4602. * { "myCookie": "1234" }
  4603. *
  4604. * or:
  4605. * { "myCookie": {
  4606. * "value": "1234",
  4607. * "domain": ".example.org",
  4608. * "path": "/",
  4609. * "expires": expirationDate
  4610. * }
  4611. * }
  4612. *
  4613. * These values get passed to Strophe.Connection via
  4614. * options.cookies
  4615. */
  4616. cookies = cookies || {};
  4617. for (const cookieName in cookies) {
  4618. if (Object.prototype.hasOwnProperty.call(cookies, cookieName)) {
  4619. let expires = '';
  4620. let domain = '';
  4621. let path = '';
  4622. const cookieObj = cookies[cookieName];
  4623. const isObj = typeof cookieObj === "object";
  4624. const cookieValue = escape(unescape(isObj ? cookieObj.value : cookieObj));
  4625. if (isObj) {
  4626. expires = cookieObj.expires ? ";expires=" + cookieObj.expires : '';
  4627. domain = cookieObj.domain ? ";domain=" + cookieObj.domain : '';
  4628. path = cookieObj.path ? ";path=" + cookieObj.path : '';
  4629. }
  4630. document.cookie = cookieName + '=' + cookieValue + expires + domain + path;
  4631. }
  4632. }
  4633. }
  4634. };
  4635. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-oauthbearer.js
  4636. class SASLOAuthBearer extends SASLMechanism {
  4637. /** PrivateConstructor: SASLOAuthBearer
  4638. * SASL OAuth Bearer authentication.
  4639. */
  4640. constructor() {
  4641. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'OAUTHBEARER';
  4642. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4643. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 40;
  4644. super(mechname, isClientFirst, priority);
  4645. }
  4646. test(connection) {
  4647. // eslint-disable-line class-methods-use-this
  4648. return connection.pass !== null;
  4649. }
  4650. onChallenge(connection) {
  4651. // eslint-disable-line class-methods-use-this
  4652. let auth_str = 'n,';
  4653. if (connection.authcid !== null) {
  4654. auth_str = auth_str + 'a=' + connection.authzid;
  4655. }
  4656. auth_str = auth_str + ',';
  4657. auth_str = auth_str + "\u0001";
  4658. auth_str = auth_str + 'auth=Bearer ';
  4659. auth_str = auth_str + connection.pass;
  4660. auth_str = auth_str + "\u0001";
  4661. auth_str = auth_str + "\u0001";
  4662. return utils.utf16to8(auth_str);
  4663. }
  4664. }
  4665. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-plain.js
  4666. class SASLPlain extends SASLMechanism {
  4667. /** PrivateConstructor: SASLPlain
  4668. * SASL PLAIN authentication.
  4669. */
  4670. constructor() {
  4671. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'PLAIN';
  4672. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4673. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
  4674. super(mechname, isClientFirst, priority);
  4675. }
  4676. test(connection) {
  4677. // eslint-disable-line class-methods-use-this
  4678. return connection.authcid !== null;
  4679. }
  4680. onChallenge(connection) {
  4681. // eslint-disable-line class-methods-use-this
  4682. const {
  4683. authcid,
  4684. authzid,
  4685. domain,
  4686. pass
  4687. } = connection;
  4688. if (!domain) {
  4689. throw new Error("SASLPlain onChallenge: domain is not defined!");
  4690. } // Only include authzid if it differs from authcid.
  4691. // See: https://tools.ietf.org/html/rfc6120#section-6.3.8
  4692. let auth_str = authzid !== `${authcid}@${domain}` ? authzid : '';
  4693. auth_str = auth_str + "\u0000";
  4694. auth_str = auth_str + authcid;
  4695. auth_str = auth_str + "\u0000";
  4696. auth_str = auth_str + pass;
  4697. return utils.utf16to8(auth_str);
  4698. }
  4699. }
  4700. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sha1.js
  4701. /*
  4702. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  4703. * in FIPS PUB 180-1
  4704. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  4705. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  4706. * Distributed under the BSD License
  4707. * See http://pajhome.org.uk/crypt/md5 for details.
  4708. */
  4709. /* global define */
  4710. /* Some functions and variables have been stripped for use with Strophe */
  4711. /*
  4712. * Calculate the SHA-1 of an array of big-endian words, and a bit length
  4713. */
  4714. function core_sha1(x, len) {
  4715. /* append padding */
  4716. x[len >> 5] |= 0x80 << 24 - len % 32;
  4717. x[(len + 64 >> 9 << 4) + 15] = len;
  4718. var w = new Array(80);
  4719. var a = 1732584193;
  4720. var b = -271733879;
  4721. var c = -1732584194;
  4722. var d = 271733878;
  4723. var e = -1009589776;
  4724. var i, j, t, olda, oldb, oldc, oldd, olde;
  4725. for (i = 0; i < x.length; i += 16) {
  4726. olda = a;
  4727. oldb = b;
  4728. oldc = c;
  4729. oldd = d;
  4730. olde = e;
  4731. for (j = 0; j < 80; j++) {
  4732. if (j < 16) {
  4733. w[j] = x[i + j];
  4734. } else {
  4735. w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
  4736. }
  4737. t = sha1_safe_add(sha1_safe_add(rol(a, 5), sha1_ft(j, b, c, d)), sha1_safe_add(sha1_safe_add(e, w[j]), sha1_kt(j)));
  4738. e = d;
  4739. d = c;
  4740. c = rol(b, 30);
  4741. b = a;
  4742. a = t;
  4743. }
  4744. a = sha1_safe_add(a, olda);
  4745. b = sha1_safe_add(b, oldb);
  4746. c = sha1_safe_add(c, oldc);
  4747. d = sha1_safe_add(d, oldd);
  4748. e = sha1_safe_add(e, olde);
  4749. }
  4750. return [a, b, c, d, e];
  4751. }
  4752. /*
  4753. * Perform the appropriate triplet combination function for the current
  4754. * iteration
  4755. */
  4756. function sha1_ft(t, b, c, d) {
  4757. if (t < 20) {
  4758. return b & c | ~b & d;
  4759. }
  4760. if (t < 40) {
  4761. return b ^ c ^ d;
  4762. }
  4763. if (t < 60) {
  4764. return b & c | b & d | c & d;
  4765. }
  4766. return b ^ c ^ d;
  4767. }
  4768. /*
  4769. * Determine the appropriate additive constant for the current iteration
  4770. */
  4771. function sha1_kt(t) {
  4772. return t < 20 ? 1518500249 : t < 40 ? 1859775393 : t < 60 ? -1894007588 : -899497514;
  4773. }
  4774. /*
  4775. * Calculate the HMAC-SHA1 of a key and some data
  4776. */
  4777. function core_hmac_sha1(key, data) {
  4778. var bkey = str2binb(key);
  4779. if (bkey.length > 16) {
  4780. bkey = core_sha1(bkey, key.length * 8);
  4781. }
  4782. var ipad = new Array(16),
  4783. opad = new Array(16);
  4784. for (var i = 0; i < 16; i++) {
  4785. ipad[i] = bkey[i] ^ 0x36363636;
  4786. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  4787. }
  4788. var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * 8);
  4789. return core_sha1(opad.concat(hash), 512 + 160);
  4790. }
  4791. /*
  4792. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  4793. * to work around bugs in some JS interpreters.
  4794. */
  4795. function sha1_safe_add(x, y) {
  4796. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  4797. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  4798. return msw << 16 | lsw & 0xFFFF;
  4799. }
  4800. /*
  4801. * Bitwise rotate a 32-bit number to the left.
  4802. */
  4803. function rol(num, cnt) {
  4804. return num << cnt | num >>> 32 - cnt;
  4805. }
  4806. /*
  4807. * Convert an 8-bit or 16-bit string to an array of big-endian words
  4808. * In 8-bit function, characters >255 have their hi-byte silently ignored.
  4809. */
  4810. function str2binb(str) {
  4811. var bin = [];
  4812. var mask = 255;
  4813. for (var i = 0; i < str.length * 8; i += 8) {
  4814. bin[i >> 5] |= (str.charCodeAt(i / 8) & mask) << 24 - i % 32;
  4815. }
  4816. return bin;
  4817. }
  4818. /*
  4819. * Convert an array of big-endian words to a base-64 string
  4820. */
  4821. function binb2b64(binarray) {
  4822. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  4823. var str = "";
  4824. var triplet, j;
  4825. for (var i = 0; i < binarray.length * 4; i += 3) {
  4826. triplet = (binarray[i >> 2] >> 8 * (3 - i % 4) & 0xFF) << 16 | (binarray[i + 1 >> 2] >> 8 * (3 - (i + 1) % 4) & 0xFF) << 8 | binarray[i + 2 >> 2] >> 8 * (3 - (i + 2) % 4) & 0xFF;
  4827. for (j = 0; j < 4; j++) {
  4828. if (i * 8 + j * 6 > binarray.length * 32) {
  4829. str += "=";
  4830. } else {
  4831. str += tab.charAt(triplet >> 6 * (3 - j) & 0x3F);
  4832. }
  4833. }
  4834. }
  4835. return str;
  4836. }
  4837. /*
  4838. * Convert an array of big-endian words to a string
  4839. */
  4840. function binb2str(bin) {
  4841. var str = "";
  4842. var mask = 255;
  4843. for (var i = 0; i < bin.length * 32; i += 8) {
  4844. str += String.fromCharCode(bin[i >> 5] >>> 24 - i % 32 & mask);
  4845. }
  4846. return str;
  4847. }
  4848. /*
  4849. * These are the functions you'll usually want to call
  4850. * They take string arguments and return either hex or base-64 encoded strings
  4851. */
  4852. const SHA1 = {
  4853. b64_hmac_sha1: function (key, data) {
  4854. return binb2b64(core_hmac_sha1(key, data));
  4855. },
  4856. b64_sha1: function (s) {
  4857. return binb2b64(core_sha1(str2binb(s), s.length * 8));
  4858. },
  4859. binb2str: binb2str,
  4860. core_hmac_sha1: core_hmac_sha1,
  4861. str_hmac_sha1: function (key, data) {
  4862. return binb2str(core_hmac_sha1(key, data));
  4863. },
  4864. str_sha1: function (s) {
  4865. return binb2str(core_sha1(str2binb(s), s.length * 8));
  4866. }
  4867. };
  4868. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-sha1.js
  4869. class SASLSHA1 extends SASLMechanism {
  4870. /** PrivateConstructor: SASLSHA1
  4871. * SASL SCRAM SHA 1 authentication.
  4872. */
  4873. constructor() {
  4874. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'SCRAM-SHA-1';
  4875. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4876. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 60;
  4877. super(mechname, isClientFirst, priority);
  4878. }
  4879. test(connection) {
  4880. // eslint-disable-line class-methods-use-this
  4881. return connection.authcid !== null;
  4882. }
  4883. onChallenge(connection, challenge) {
  4884. // eslint-disable-line class-methods-use-this
  4885. let nonce, salt, iter, Hi, U, U_old, i, k;
  4886. let responseText = "c=biws,";
  4887. let authMessage = `${connection._sasl_data["client-first-message-bare"]},${challenge},`;
  4888. const cnonce = connection._sasl_data.cnonce;
  4889. const attribMatch = /([a-z]+)=([^,]+)(,|$)/;
  4890. while (challenge.match(attribMatch)) {
  4891. const matches = challenge.match(attribMatch);
  4892. challenge = challenge.replace(matches[0], "");
  4893. switch (matches[1]) {
  4894. case "r":
  4895. nonce = matches[2];
  4896. break;
  4897. case "s":
  4898. salt = matches[2];
  4899. break;
  4900. case "i":
  4901. iter = matches[2];
  4902. break;
  4903. }
  4904. }
  4905. if (nonce.slice(0, cnonce.length) !== cnonce) {
  4906. connection._sasl_data = {};
  4907. return connection._sasl_failure_cb();
  4908. }
  4909. responseText += "r=" + nonce;
  4910. authMessage += responseText;
  4911. salt = atob(salt);
  4912. salt += "\x00\x00\x00\x01";
  4913. const pass = utils.utf16to8(connection.pass);
  4914. Hi = U_old = SHA1.core_hmac_sha1(pass, salt);
  4915. for (i = 1; i < iter; i++) {
  4916. U = SHA1.core_hmac_sha1(pass, SHA1.binb2str(U_old));
  4917. for (k = 0; k < 5; k++) {
  4918. Hi[k] ^= U[k];
  4919. }
  4920. U_old = U;
  4921. }
  4922. Hi = SHA1.binb2str(Hi);
  4923. const clientKey = SHA1.core_hmac_sha1(Hi, "Client Key");
  4924. const serverKey = SHA1.str_hmac_sha1(Hi, "Server Key");
  4925. const clientSignature = SHA1.core_hmac_sha1(SHA1.str_sha1(SHA1.binb2str(clientKey)), authMessage);
  4926. connection._sasl_data["server-signature"] = SHA1.b64_hmac_sha1(serverKey, authMessage);
  4927. for (k = 0; k < 5; k++) {
  4928. clientKey[k] ^= clientSignature[k];
  4929. }
  4930. responseText += ",p=" + btoa(SHA1.binb2str(clientKey));
  4931. return responseText;
  4932. }
  4933. clientChallenge(connection, test_cnonce) {
  4934. // eslint-disable-line class-methods-use-this
  4935. const cnonce = test_cnonce || MD5.hexdigest("" + Math.random() * 1234567890);
  4936. let auth_str = "n=" + utils.utf16to8(connection.authcid);
  4937. auth_str += ",r=";
  4938. auth_str += cnonce;
  4939. connection._sasl_data.cnonce = cnonce;
  4940. connection._sasl_data["client-first-message-bare"] = auth_str;
  4941. auth_str = "n,," + auth_str;
  4942. return auth_str;
  4943. }
  4944. }
  4945. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/sasl-xoauth2.js
  4946. class SASLXOAuth2 extends SASLMechanism {
  4947. /** PrivateConstructor: SASLXOAuth2
  4948. * SASL X-OAuth2 authentication.
  4949. */
  4950. constructor() {
  4951. let mechname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'X-OAUTH2';
  4952. let isClientFirst = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  4953. let priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 30;
  4954. super(mechname, isClientFirst, priority);
  4955. }
  4956. test(connection) {
  4957. // eslint-disable-line class-methods-use-this
  4958. return connection.pass !== null;
  4959. }
  4960. onChallenge(connection) {
  4961. // eslint-disable-line class-methods-use-this
  4962. let auth_str = '\u0000';
  4963. if (connection.authcid !== null) {
  4964. auth_str = auth_str + connection.authzid;
  4965. }
  4966. auth_str = auth_str + "\u0000";
  4967. auth_str = auth_str + connection.pass;
  4968. return utils.utf16to8(auth_str);
  4969. }
  4970. }
  4971. // EXTERNAL MODULE: ./node_modules/abab/index.js
  4972. var abab = __webpack_require__(9494);
  4973. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/core.js
  4974. /*
  4975. This program is distributed under the terms of the MIT license.
  4976. Please see the LICENSE file for details.
  4977. Copyright 2006-2018, OGG, LLC
  4978. */
  4979. /*global define, document, sessionStorage, setTimeout, clearTimeout, ActiveXObject, DOMParser, btoa, atob */
  4980. /** Function: $build
  4981. * Create a Strophe.Builder.
  4982. * This is an alias for 'new Strophe.Builder(name, attrs)'.
  4983. *
  4984. * Parameters:
  4985. * (String) name - The root element name.
  4986. * (Object) attrs - The attributes for the root element in object notation.
  4987. *
  4988. * Returns:
  4989. * A new Strophe.Builder object.
  4990. */
  4991. function $build(name, attrs) {
  4992. return new Strophe.Builder(name, attrs);
  4993. }
  4994. /** Function: $msg
  4995. * Create a Strophe.Builder with a <message/> element as the root.
  4996. *
  4997. * Parameters:
  4998. * (Object) attrs - The <message/> element attributes in object notation.
  4999. *
  5000. * Returns:
  5001. * A new Strophe.Builder object.
  5002. */
  5003. function $msg(attrs) {
  5004. return new Strophe.Builder("message", attrs);
  5005. }
  5006. /** Function: $iq
  5007. * Create a Strophe.Builder with an <iq/> element as the root.
  5008. *
  5009. * Parameters:
  5010. * (Object) attrs - The <iq/> element attributes in object notation.
  5011. *
  5012. * Returns:
  5013. * A new Strophe.Builder object.
  5014. */
  5015. function $iq(attrs) {
  5016. return new Strophe.Builder("iq", attrs);
  5017. }
  5018. /** Function: $pres
  5019. * Create a Strophe.Builder with a <presence/> element as the root.
  5020. *
  5021. * Parameters:
  5022. * (Object) attrs - The <presence/> element attributes in object notation.
  5023. *
  5024. * Returns:
  5025. * A new Strophe.Builder object.
  5026. */
  5027. function $pres(attrs) {
  5028. return new Strophe.Builder("presence", attrs);
  5029. }
  5030. /** Class: Strophe
  5031. * An object container for all Strophe library functions.
  5032. *
  5033. * This class is just a container for all the objects and constants
  5034. * used in the library. It is not meant to be instantiated, but to
  5035. * provide a namespace for library objects, constants, and functions.
  5036. */
  5037. const Strophe = {
  5038. /** Constant: VERSION */
  5039. VERSION: "1.5.0",
  5040. /** Constants: XMPP Namespace Constants
  5041. * Common namespace constants from the XMPP RFCs and XEPs.
  5042. *
  5043. * NS.HTTPBIND - HTTP BIND namespace from XEP 124.
  5044. * NS.BOSH - BOSH namespace from XEP 206.
  5045. * NS.CLIENT - Main XMPP client namespace.
  5046. * NS.AUTH - Legacy authentication namespace.
  5047. * NS.ROSTER - Roster operations namespace.
  5048. * NS.PROFILE - Profile namespace.
  5049. * NS.DISCO_INFO - Service discovery info namespace from XEP 30.
  5050. * NS.DISCO_ITEMS - Service discovery items namespace from XEP 30.
  5051. * NS.MUC - Multi-User Chat namespace from XEP 45.
  5052. * NS.SASL - XMPP SASL namespace from RFC 3920.
  5053. * NS.STREAM - XMPP Streams namespace from RFC 3920.
  5054. * NS.BIND - XMPP Binding namespace from RFC 3920 and RFC 6120.
  5055. * NS.SESSION - XMPP Session namespace from RFC 3920.
  5056. * NS.XHTML_IM - XHTML-IM namespace from XEP 71.
  5057. * NS.XHTML - XHTML body namespace from XEP 71.
  5058. */
  5059. NS: {
  5060. HTTPBIND: "http://jabber.org/protocol/httpbind",
  5061. BOSH: "urn:xmpp:xbosh",
  5062. CLIENT: "jabber:client",
  5063. AUTH: "jabber:iq:auth",
  5064. ROSTER: "jabber:iq:roster",
  5065. PROFILE: "jabber:iq:profile",
  5066. DISCO_INFO: "http://jabber.org/protocol/disco#info",
  5067. DISCO_ITEMS: "http://jabber.org/protocol/disco#items",
  5068. MUC: "http://jabber.org/protocol/muc",
  5069. SASL: "urn:ietf:params:xml:ns:xmpp-sasl",
  5070. STREAM: "http://etherx.jabber.org/streams",
  5071. FRAMING: "urn:ietf:params:xml:ns:xmpp-framing",
  5072. BIND: "urn:ietf:params:xml:ns:xmpp-bind",
  5073. SESSION: "urn:ietf:params:xml:ns:xmpp-session",
  5074. VERSION: "jabber:iq:version",
  5075. STANZAS: "urn:ietf:params:xml:ns:xmpp-stanzas",
  5076. XHTML_IM: "http://jabber.org/protocol/xhtml-im",
  5077. XHTML: "http://www.w3.org/1999/xhtml"
  5078. },
  5079. /** Constants: XHTML_IM Namespace
  5080. * contains allowed tags, tag attributes, and css properties.
  5081. * Used in the createHtml function to filter incoming html into the allowed XHTML-IM subset.
  5082. * See http://xmpp.org/extensions/xep-0071.html#profile-summary for the list of recommended
  5083. * allowed tags and their attributes.
  5084. */
  5085. XHTML: {
  5086. tags: ['a', 'blockquote', 'br', 'cite', 'em', 'img', 'li', 'ol', 'p', 'span', 'strong', 'ul', 'body'],
  5087. attributes: {
  5088. 'a': ['href'],
  5089. 'blockquote': ['style'],
  5090. 'br': [],
  5091. 'cite': ['style'],
  5092. 'em': [],
  5093. 'img': ['src', 'alt', 'style', 'height', 'width'],
  5094. 'li': ['style'],
  5095. 'ol': ['style'],
  5096. 'p': ['style'],
  5097. 'span': ['style'],
  5098. 'strong': [],
  5099. 'ul': ['style'],
  5100. 'body': []
  5101. },
  5102. css: ['background-color', 'color', 'font-family', 'font-size', 'font-style', 'font-weight', 'margin-left', 'margin-right', 'text-align', 'text-decoration'],
  5103. /** Function: XHTML.validTag
  5104. *
  5105. * Utility method to determine whether a tag is allowed
  5106. * in the XHTML_IM namespace.
  5107. *
  5108. * XHTML tag names are case sensitive and must be lower case.
  5109. */
  5110. validTag(tag) {
  5111. for (let i = 0; i < Strophe.XHTML.tags.length; i++) {
  5112. if (tag === Strophe.XHTML.tags[i]) {
  5113. return true;
  5114. }
  5115. }
  5116. return false;
  5117. },
  5118. /** Function: XHTML.validAttribute
  5119. *
  5120. * Utility method to determine whether an attribute is allowed
  5121. * as recommended per XEP-0071
  5122. *
  5123. * XHTML attribute names are case sensitive and must be lower case.
  5124. */
  5125. validAttribute(tag, attribute) {
  5126. if (typeof Strophe.XHTML.attributes[tag] !== 'undefined' && Strophe.XHTML.attributes[tag].length > 0) {
  5127. for (let i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
  5128. if (attribute === Strophe.XHTML.attributes[tag][i]) {
  5129. return true;
  5130. }
  5131. }
  5132. }
  5133. return false;
  5134. },
  5135. validCSS(style) {
  5136. for (let i = 0; i < Strophe.XHTML.css.length; i++) {
  5137. if (style === Strophe.XHTML.css[i]) {
  5138. return true;
  5139. }
  5140. }
  5141. return false;
  5142. }
  5143. },
  5144. /** Constants: Connection Status Constants
  5145. * Connection status constants for use by the connection handler
  5146. * callback.
  5147. *
  5148. * Status.ERROR - An error has occurred
  5149. * Status.CONNECTING - The connection is currently being made
  5150. * Status.CONNFAIL - The connection attempt failed
  5151. * Status.AUTHENTICATING - The connection is authenticating
  5152. * Status.AUTHFAIL - The authentication attempt failed
  5153. * Status.CONNECTED - The connection has succeeded
  5154. * Status.DISCONNECTED - The connection has been terminated
  5155. * Status.DISCONNECTING - The connection is currently being terminated
  5156. * Status.ATTACHED - The connection has been attached
  5157. * Status.REDIRECT - The connection has been redirected
  5158. * Status.CONNTIMEOUT - The connection has timed out
  5159. */
  5160. Status: {
  5161. ERROR: 0,
  5162. CONNECTING: 1,
  5163. CONNFAIL: 2,
  5164. AUTHENTICATING: 3,
  5165. AUTHFAIL: 4,
  5166. CONNECTED: 5,
  5167. DISCONNECTED: 6,
  5168. DISCONNECTING: 7,
  5169. ATTACHED: 8,
  5170. REDIRECT: 9,
  5171. CONNTIMEOUT: 10,
  5172. BINDREQUIRED: 11,
  5173. ATTACHFAIL: 12
  5174. },
  5175. ErrorCondition: {
  5176. BAD_FORMAT: "bad-format",
  5177. CONFLICT: "conflict",
  5178. MISSING_JID_NODE: "x-strophe-bad-non-anon-jid",
  5179. NO_AUTH_MECH: "no-auth-mech",
  5180. UNKNOWN_REASON: "unknown"
  5181. },
  5182. /** Constants: Log Level Constants
  5183. * Logging level indicators.
  5184. *
  5185. * LogLevel.DEBUG - Debug output
  5186. * LogLevel.INFO - Informational output
  5187. * LogLevel.WARN - Warnings
  5188. * LogLevel.ERROR - Errors
  5189. * LogLevel.FATAL - Fatal errors
  5190. */
  5191. LogLevel: {
  5192. DEBUG: 0,
  5193. INFO: 1,
  5194. WARN: 2,
  5195. ERROR: 3,
  5196. FATAL: 4
  5197. },
  5198. /** PrivateConstants: DOM Element Type Constants
  5199. * DOM element types.
  5200. *
  5201. * ElementType.NORMAL - Normal element.
  5202. * ElementType.TEXT - Text data element.
  5203. * ElementType.FRAGMENT - XHTML fragment element.
  5204. */
  5205. ElementType: {
  5206. NORMAL: 1,
  5207. TEXT: 3,
  5208. CDATA: 4,
  5209. FRAGMENT: 11
  5210. },
  5211. /** PrivateConstants: Timeout Values
  5212. * Timeout values for error states. These values are in seconds.
  5213. * These should not be changed unless you know exactly what you are
  5214. * doing.
  5215. *
  5216. * TIMEOUT - Timeout multiplier. A waiting request will be considered
  5217. * failed after Math.floor(TIMEOUT * wait) seconds have elapsed.
  5218. * This defaults to 1.1, and with default wait, 66 seconds.
  5219. * SECONDARY_TIMEOUT - Secondary timeout multiplier. In cases where
  5220. * Strophe can detect early failure, it will consider the request
  5221. * failed if it doesn't return after
  5222. * Math.floor(SECONDARY_TIMEOUT * wait) seconds have elapsed.
  5223. * This defaults to 0.1, and with default wait, 6 seconds.
  5224. */
  5225. TIMEOUT: 1.1,
  5226. SECONDARY_TIMEOUT: 0.1,
  5227. /** Function: addNamespace
  5228. * This function is used to extend the current namespaces in
  5229. * Strophe.NS. It takes a key and a value with the key being the
  5230. * name of the new namespace, with its actual value.
  5231. * For example:
  5232. * Strophe.addNamespace('PUBSUB', "http://jabber.org/protocol/pubsub");
  5233. *
  5234. * Parameters:
  5235. * (String) name - The name under which the namespace will be
  5236. * referenced under Strophe.NS
  5237. * (String) value - The actual namespace.
  5238. */
  5239. addNamespace(name, value) {
  5240. Strophe.NS[name] = value;
  5241. },
  5242. /** Function: forEachChild
  5243. * Map a function over some or all child elements of a given element.
  5244. *
  5245. * This is a small convenience function for mapping a function over
  5246. * some or all of the children of an element. If elemName is null, all
  5247. * children will be passed to the function, otherwise only children
  5248. * whose tag names match elemName will be passed.
  5249. *
  5250. * Parameters:
  5251. * (XMLElement) elem - The element to operate on.
  5252. * (String) elemName - The child element tag name filter.
  5253. * (Function) func - The function to apply to each child. This
  5254. * function should take a single argument, a DOM element.
  5255. */
  5256. forEachChild(elem, elemName, func) {
  5257. for (let i = 0; i < elem.childNodes.length; i++) {
  5258. const childNode = elem.childNodes[i];
  5259. if (childNode.nodeType === Strophe.ElementType.NORMAL && (!elemName || this.isTagEqual(childNode, elemName))) {
  5260. func(childNode);
  5261. }
  5262. }
  5263. },
  5264. /** Function: isTagEqual
  5265. * Compare an element's tag name with a string.
  5266. *
  5267. * This function is case sensitive.
  5268. *
  5269. * Parameters:
  5270. * (XMLElement) el - A DOM element.
  5271. * (String) name - The element name.
  5272. *
  5273. * Returns:
  5274. * true if the element's tag name matches _el_, and false
  5275. * otherwise.
  5276. */
  5277. isTagEqual(el, name) {
  5278. return el.tagName === name;
  5279. },
  5280. /** PrivateVariable: _xmlGenerator
  5281. * _Private_ variable that caches a DOM document to
  5282. * generate elements.
  5283. */
  5284. _xmlGenerator: null,
  5285. /** Function: xmlGenerator
  5286. * Get the DOM document to generate elements.
  5287. *
  5288. * Returns:
  5289. * The currently used DOM document.
  5290. */
  5291. xmlGenerator() {
  5292. if (!Strophe._xmlGenerator) {
  5293. Strophe._xmlGenerator = getDummyXMLDOMDocument();
  5294. }
  5295. return Strophe._xmlGenerator;
  5296. },
  5297. /** Function: xmlElement
  5298. * Create an XML DOM element.
  5299. *
  5300. * This function creates an XML DOM element correctly across all
  5301. * implementations. Note that these are not HTML DOM elements, which
  5302. * aren't appropriate for XMPP stanzas.
  5303. *
  5304. * Parameters:
  5305. * (String) name - The name for the element.
  5306. * (Array|Object) attrs - An optional array or object containing
  5307. * key/value pairs to use as element attributes. The object should
  5308. * be in the format {'key': 'value'} or {key: 'value'}. The array
  5309. * should have the format [['key1', 'value1'], ['key2', 'value2']].
  5310. * (String) text - The text child data for the element.
  5311. *
  5312. * Returns:
  5313. * A new XML DOM element.
  5314. */
  5315. xmlElement(name) {
  5316. if (!name) {
  5317. return null;
  5318. }
  5319. const node = Strophe.xmlGenerator().createElement(name); // FIXME: this should throw errors if args are the wrong type or
  5320. // there are more than two optional args
  5321. for (let a = 1; a < arguments.length; a++) {
  5322. const arg = arguments[a];
  5323. if (!arg) {
  5324. continue;
  5325. }
  5326. if (typeof arg === "string" || typeof arg === "number") {
  5327. node.appendChild(Strophe.xmlTextNode(arg));
  5328. } else if (typeof arg === "object" && typeof arg.sort === "function") {
  5329. for (let i = 0; i < arg.length; i++) {
  5330. const attr = arg[i];
  5331. if (typeof attr === "object" && typeof attr.sort === "function" && attr[1] !== undefined && attr[1] !== null) {
  5332. node.setAttribute(attr[0], attr[1]);
  5333. }
  5334. }
  5335. } else if (typeof arg === "object") {
  5336. for (const k in arg) {
  5337. if (Object.prototype.hasOwnProperty.call(arg, k) && arg[k] !== undefined && arg[k] !== null) {
  5338. node.setAttribute(k, arg[k]);
  5339. }
  5340. }
  5341. }
  5342. }
  5343. return node;
  5344. },
  5345. /* Function: xmlescape
  5346. * Excapes invalid xml characters.
  5347. *
  5348. * Parameters:
  5349. * (String) text - text to escape.
  5350. *
  5351. * Returns:
  5352. * Escaped text.
  5353. */
  5354. xmlescape(text) {
  5355. text = text.replace(/\&/g, "&amp;");
  5356. text = text.replace(/</g, "&lt;");
  5357. text = text.replace(/>/g, "&gt;");
  5358. text = text.replace(/'/g, "&apos;");
  5359. text = text.replace(/"/g, "&quot;");
  5360. return text;
  5361. },
  5362. /* Function: xmlunescape
  5363. * Unexcapes invalid xml characters.
  5364. *
  5365. * Parameters:
  5366. * (String) text - text to unescape.
  5367. *
  5368. * Returns:
  5369. * Unescaped text.
  5370. */
  5371. xmlunescape(text) {
  5372. text = text.replace(/\&amp;/g, "&");
  5373. text = text.replace(/&lt;/g, "<");
  5374. text = text.replace(/&gt;/g, ">");
  5375. text = text.replace(/&apos;/g, "'");
  5376. text = text.replace(/&quot;/g, "\"");
  5377. return text;
  5378. },
  5379. /** Function: xmlTextNode
  5380. * Creates an XML DOM text node.
  5381. *
  5382. * Provides a cross implementation version of document.createTextNode.
  5383. *
  5384. * Parameters:
  5385. * (String) text - The content of the text node.
  5386. *
  5387. * Returns:
  5388. * A new XML DOM text node.
  5389. */
  5390. xmlTextNode(text) {
  5391. return Strophe.xmlGenerator().createTextNode(text);
  5392. },
  5393. /** Function: xmlHtmlNode
  5394. * Creates an XML DOM html node.
  5395. *
  5396. * Parameters:
  5397. * (String) html - The content of the html node.
  5398. *
  5399. * Returns:
  5400. * A new XML DOM text node.
  5401. */
  5402. xmlHtmlNode(html) {
  5403. let node; //ensure text is escaped
  5404. if (strophe_shims_DOMParser) {
  5405. const parser = new strophe_shims_DOMParser();
  5406. node = parser.parseFromString(html, "text/xml");
  5407. } else {
  5408. node = new ActiveXObject("Microsoft.XMLDOM");
  5409. node.async = "false";
  5410. node.loadXML(html);
  5411. }
  5412. return node;
  5413. },
  5414. /** Function: getText
  5415. * Get the concatenation of all text children of an element.
  5416. *
  5417. * Parameters:
  5418. * (XMLElement) elem - A DOM element.
  5419. *
  5420. * Returns:
  5421. * A String with the concatenated text of all text element children.
  5422. */
  5423. getText(elem) {
  5424. if (!elem) {
  5425. return null;
  5426. }
  5427. let str = "";
  5428. if (elem.childNodes.length === 0 && elem.nodeType === Strophe.ElementType.TEXT) {
  5429. str += elem.nodeValue;
  5430. }
  5431. for (let i = 0; i < elem.childNodes.length; i++) {
  5432. if (elem.childNodes[i].nodeType === Strophe.ElementType.TEXT) {
  5433. str += elem.childNodes[i].nodeValue;
  5434. }
  5435. }
  5436. return Strophe.xmlescape(str);
  5437. },
  5438. /** Function: copyElement
  5439. * Copy an XML DOM element.
  5440. *
  5441. * This function copies a DOM element and all its descendants and returns
  5442. * the new copy.
  5443. *
  5444. * Parameters:
  5445. * (XMLElement) elem - A DOM element.
  5446. *
  5447. * Returns:
  5448. * A new, copied DOM element tree.
  5449. */
  5450. copyElement(elem) {
  5451. let el;
  5452. if (elem.nodeType === Strophe.ElementType.NORMAL) {
  5453. el = Strophe.xmlElement(elem.tagName);
  5454. for (let i = 0; i < elem.attributes.length; i++) {
  5455. el.setAttribute(elem.attributes[i].nodeName, elem.attributes[i].value);
  5456. }
  5457. for (let i = 0; i < elem.childNodes.length; i++) {
  5458. el.appendChild(Strophe.copyElement(elem.childNodes[i]));
  5459. }
  5460. } else if (elem.nodeType === Strophe.ElementType.TEXT) {
  5461. el = Strophe.xmlGenerator().createTextNode(elem.nodeValue);
  5462. }
  5463. return el;
  5464. },
  5465. /** Function: createHtml
  5466. * Copy an HTML DOM element into an XML DOM.
  5467. *
  5468. * This function copies a DOM element and all its descendants and returns
  5469. * the new copy.
  5470. *
  5471. * Parameters:
  5472. * (HTMLElement) elem - A DOM element.
  5473. *
  5474. * Returns:
  5475. * A new, copied DOM element tree.
  5476. */
  5477. createHtml(elem) {
  5478. let el;
  5479. if (elem.nodeType === Strophe.ElementType.NORMAL) {
  5480. const tag = elem.nodeName.toLowerCase(); // XHTML tags must be lower case.
  5481. if (Strophe.XHTML.validTag(tag)) {
  5482. try {
  5483. el = Strophe.xmlElement(tag);
  5484. for (let i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
  5485. const attribute = Strophe.XHTML.attributes[tag][i];
  5486. let value = elem.getAttribute(attribute);
  5487. if (typeof value === 'undefined' || value === null || value === '' || value === false || value === 0) {
  5488. continue;
  5489. }
  5490. if (attribute === 'style' && typeof value === 'object' && typeof value.cssText !== 'undefined') {
  5491. value = value.cssText; // we're dealing with IE, need to get CSS out
  5492. } // filter out invalid css styles
  5493. if (attribute === 'style') {
  5494. const css = [];
  5495. const cssAttrs = value.split(';');
  5496. for (let j = 0; j < cssAttrs.length; j++) {
  5497. const attr = cssAttrs[j].split(':');
  5498. const cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
  5499. if (Strophe.XHTML.validCSS(cssName)) {
  5500. const cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
  5501. css.push(cssName + ': ' + cssValue);
  5502. }
  5503. }
  5504. if (css.length > 0) {
  5505. value = css.join('; ');
  5506. el.setAttribute(attribute, value);
  5507. }
  5508. } else {
  5509. el.setAttribute(attribute, value);
  5510. }
  5511. }
  5512. for (let i = 0; i < elem.childNodes.length; i++) {
  5513. el.appendChild(Strophe.createHtml(elem.childNodes[i]));
  5514. }
  5515. } catch (e) {
  5516. // invalid elements
  5517. el = Strophe.xmlTextNode('');
  5518. }
  5519. } else {
  5520. el = Strophe.xmlGenerator().createDocumentFragment();
  5521. for (let i = 0; i < elem.childNodes.length; i++) {
  5522. el.appendChild(Strophe.createHtml(elem.childNodes[i]));
  5523. }
  5524. }
  5525. } else if (elem.nodeType === Strophe.ElementType.FRAGMENT) {
  5526. el = Strophe.xmlGenerator().createDocumentFragment();
  5527. for (let i = 0; i < elem.childNodes.length; i++) {
  5528. el.appendChild(Strophe.createHtml(elem.childNodes[i]));
  5529. }
  5530. } else if (elem.nodeType === Strophe.ElementType.TEXT) {
  5531. el = Strophe.xmlTextNode(elem.nodeValue);
  5532. }
  5533. return el;
  5534. },
  5535. /** Function: escapeNode
  5536. * Escape the node part (also called local part) of a JID.
  5537. *
  5538. * Parameters:
  5539. * (String) node - A node (or local part).
  5540. *
  5541. * Returns:
  5542. * An escaped node (or local part).
  5543. */
  5544. escapeNode(node) {
  5545. if (typeof node !== "string") {
  5546. return node;
  5547. }
  5548. return node.replace(/^\s+|\s+$/g, '').replace(/\\/g, "\\5c").replace(/ /g, "\\20").replace(/\"/g, "\\22").replace(/\&/g, "\\26").replace(/\'/g, "\\27").replace(/\//g, "\\2f").replace(/:/g, "\\3a").replace(/</g, "\\3c").replace(/>/g, "\\3e").replace(/@/g, "\\40");
  5549. },
  5550. /** Function: unescapeNode
  5551. * Unescape a node part (also called local part) of a JID.
  5552. *
  5553. * Parameters:
  5554. * (String) node - A node (or local part).
  5555. *
  5556. * Returns:
  5557. * An unescaped node (or local part).
  5558. */
  5559. unescapeNode(node) {
  5560. if (typeof node !== "string") {
  5561. return node;
  5562. }
  5563. return node.replace(/\\20/g, " ").replace(/\\22/g, '"').replace(/\\26/g, "&").replace(/\\27/g, "'").replace(/\\2f/g, "/").replace(/\\3a/g, ":").replace(/\\3c/g, "<").replace(/\\3e/g, ">").replace(/\\40/g, "@").replace(/\\5c/g, "\\");
  5564. },
  5565. /** Function: getNodeFromJid
  5566. * Get the node portion of a JID String.
  5567. *
  5568. * Parameters:
  5569. * (String) jid - A JID.
  5570. *
  5571. * Returns:
  5572. * A String containing the node.
  5573. */
  5574. getNodeFromJid(jid) {
  5575. if (jid.indexOf("@") < 0) {
  5576. return null;
  5577. }
  5578. return jid.split("@")[0];
  5579. },
  5580. /** Function: getDomainFromJid
  5581. * Get the domain portion of a JID String.
  5582. *
  5583. * Parameters:
  5584. * (String) jid - A JID.
  5585. *
  5586. * Returns:
  5587. * A String containing the domain.
  5588. */
  5589. getDomainFromJid(jid) {
  5590. const bare = Strophe.getBareJidFromJid(jid);
  5591. if (bare.indexOf("@") < 0) {
  5592. return bare;
  5593. } else {
  5594. const parts = bare.split("@");
  5595. parts.splice(0, 1);
  5596. return parts.join('@');
  5597. }
  5598. },
  5599. /** Function: getResourceFromJid
  5600. * Get the resource portion of a JID String.
  5601. *
  5602. * Parameters:
  5603. * (String) jid - A JID.
  5604. *
  5605. * Returns:
  5606. * A String containing the resource.
  5607. */
  5608. getResourceFromJid(jid) {
  5609. if (!jid) {
  5610. return null;
  5611. }
  5612. const s = jid.split("/");
  5613. if (s.length < 2) {
  5614. return null;
  5615. }
  5616. s.splice(0, 1);
  5617. return s.join('/');
  5618. },
  5619. /** Function: getBareJidFromJid
  5620. * Get the bare JID from a JID String.
  5621. *
  5622. * Parameters:
  5623. * (String) jid - A JID.
  5624. *
  5625. * Returns:
  5626. * A String containing the bare JID.
  5627. */
  5628. getBareJidFromJid(jid) {
  5629. return jid ? jid.split("/")[0] : null;
  5630. },
  5631. /** PrivateFunction: _handleError
  5632. * _Private_ function that properly logs an error to the console
  5633. */
  5634. _handleError(e) {
  5635. if (typeof e.stack !== "undefined") {
  5636. Strophe.fatal(e.stack);
  5637. }
  5638. if (e.sourceURL) {
  5639. Strophe.fatal("error: " + this.handler + " " + e.sourceURL + ":" + e.line + " - " + e.name + ": " + e.message);
  5640. } else if (e.fileName) {
  5641. Strophe.fatal("error: " + this.handler + " " + e.fileName + ":" + e.lineNumber + " - " + e.name + ": " + e.message);
  5642. } else {
  5643. Strophe.fatal("error: " + e.message);
  5644. }
  5645. },
  5646. /** Function: log
  5647. * User overrideable logging function.
  5648. *
  5649. * This function is called whenever the Strophe library calls any
  5650. * of the logging functions. The default implementation of this
  5651. * function logs only fatal errors. If client code wishes to handle the logging
  5652. * messages, it should override this with
  5653. * > Strophe.log = function (level, msg) {
  5654. * > (user code here)
  5655. * > };
  5656. *
  5657. * Please note that data sent and received over the wire is logged
  5658. * via Strophe.Connection.rawInput() and Strophe.Connection.rawOutput().
  5659. *
  5660. * The different levels and their meanings are
  5661. *
  5662. * DEBUG - Messages useful for debugging purposes.
  5663. * INFO - Informational messages. This is mostly information like
  5664. * 'disconnect was called' or 'SASL auth succeeded'.
  5665. * WARN - Warnings about potential problems. This is mostly used
  5666. * to report transient connection errors like request timeouts.
  5667. * ERROR - Some error occurred.
  5668. * FATAL - A non-recoverable fatal error occurred.
  5669. *
  5670. * Parameters:
  5671. * (Integer) level - The log level of the log message. This will
  5672. * be one of the values in Strophe.LogLevel.
  5673. * (String) msg - The log message.
  5674. */
  5675. log(level, msg) {
  5676. if (level === this.LogLevel.FATAL) {
  5677. var _console;
  5678. (_console = console) === null || _console === void 0 ? void 0 : _console.error(msg);
  5679. }
  5680. },
  5681. /** Function: debug
  5682. * Log a message at the Strophe.LogLevel.DEBUG level.
  5683. *
  5684. * Parameters:
  5685. * (String) msg - The log message.
  5686. */
  5687. debug(msg) {
  5688. this.log(this.LogLevel.DEBUG, msg);
  5689. },
  5690. /** Function: info
  5691. * Log a message at the Strophe.LogLevel.INFO level.
  5692. *
  5693. * Parameters:
  5694. * (String) msg - The log message.
  5695. */
  5696. info(msg) {
  5697. this.log(this.LogLevel.INFO, msg);
  5698. },
  5699. /** Function: warn
  5700. * Log a message at the Strophe.LogLevel.WARN level.
  5701. *
  5702. * Parameters:
  5703. * (String) msg - The log message.
  5704. */
  5705. warn(msg) {
  5706. this.log(this.LogLevel.WARN, msg);
  5707. },
  5708. /** Function: error
  5709. * Log a message at the Strophe.LogLevel.ERROR level.
  5710. *
  5711. * Parameters:
  5712. * (String) msg - The log message.
  5713. */
  5714. error(msg) {
  5715. this.log(this.LogLevel.ERROR, msg);
  5716. },
  5717. /** Function: fatal
  5718. * Log a message at the Strophe.LogLevel.FATAL level.
  5719. *
  5720. * Parameters:
  5721. * (String) msg - The log message.
  5722. */
  5723. fatal(msg) {
  5724. this.log(this.LogLevel.FATAL, msg);
  5725. },
  5726. /** Function: serialize
  5727. * Render a DOM element and all descendants to a String.
  5728. *
  5729. * Parameters:
  5730. * (XMLElement) elem - A DOM element.
  5731. *
  5732. * Returns:
  5733. * The serialized element tree as a String.
  5734. */
  5735. serialize(elem) {
  5736. if (!elem) {
  5737. return null;
  5738. }
  5739. if (typeof elem.tree === "function") {
  5740. elem = elem.tree();
  5741. }
  5742. const names = [...Array(elem.attributes.length).keys()].map(i => elem.attributes[i].nodeName);
  5743. names.sort();
  5744. let result = names.reduce((a, n) => `${a} ${n}="${Strophe.xmlescape(elem.attributes.getNamedItem(n).value)}"`, `<${elem.nodeName}`);
  5745. if (elem.childNodes.length > 0) {
  5746. result += ">";
  5747. for (let i = 0; i < elem.childNodes.length; i++) {
  5748. const child = elem.childNodes[i];
  5749. switch (child.nodeType) {
  5750. case Strophe.ElementType.NORMAL:
  5751. // normal element, so recurse
  5752. result += Strophe.serialize(child);
  5753. break;
  5754. case Strophe.ElementType.TEXT:
  5755. // text element to escape values
  5756. result += Strophe.xmlescape(child.nodeValue);
  5757. break;
  5758. case Strophe.ElementType.CDATA:
  5759. // cdata section so don't escape values
  5760. result += "<![CDATA[" + child.nodeValue + "]]>";
  5761. }
  5762. }
  5763. result += "</" + elem.nodeName + ">";
  5764. } else {
  5765. result += "/>";
  5766. }
  5767. return result;
  5768. },
  5769. /** PrivateVariable: _requestId
  5770. * _Private_ variable that keeps track of the request ids for
  5771. * connections.
  5772. */
  5773. _requestId: 0,
  5774. /** PrivateVariable: Strophe.connectionPlugins
  5775. * _Private_ variable Used to store plugin names that need
  5776. * initialization on Strophe.Connection construction.
  5777. */
  5778. _connectionPlugins: {},
  5779. /** Function: addConnectionPlugin
  5780. * Extends the Strophe.Connection object with the given plugin.
  5781. *
  5782. * Parameters:
  5783. * (String) name - The name of the extension.
  5784. * (Object) ptype - The plugin's prototype.
  5785. */
  5786. addConnectionPlugin(name, ptype) {
  5787. Strophe._connectionPlugins[name] = ptype;
  5788. }
  5789. };
  5790. /** Class: Strophe.Builder
  5791. * XML DOM builder.
  5792. *
  5793. * This object provides an interface similar to JQuery but for building
  5794. * DOM elements easily and rapidly. All the functions except for toString()
  5795. * and tree() return the object, so calls can be chained. Here's an
  5796. * example using the $iq() builder helper.
  5797. * > $iq({to: 'you', from: 'me', type: 'get', id: '1'})
  5798. * > .c('query', {xmlns: 'strophe:example'})
  5799. * > .c('example')
  5800. * > .toString()
  5801. *
  5802. * The above generates this XML fragment
  5803. * > <iq to='you' from='me' type='get' id='1'>
  5804. * > <query xmlns='strophe:example'>
  5805. * > <example/>
  5806. * > </query>
  5807. * > </iq>
  5808. * The corresponding DOM manipulations to get a similar fragment would be
  5809. * a lot more tedious and probably involve several helper variables.
  5810. *
  5811. * Since adding children makes new operations operate on the child, up()
  5812. * is provided to traverse up the tree. To add two children, do
  5813. * > builder.c('child1', ...).up().c('child2', ...)
  5814. * The next operation on the Builder will be relative to the second child.
  5815. */
  5816. /** Constructor: Strophe.Builder
  5817. * Create a Strophe.Builder object.
  5818. *
  5819. * The attributes should be passed in object notation. For example
  5820. * > let b = new Builder('message', {to: 'you', from: 'me'});
  5821. * or
  5822. * > let b = new Builder('messsage', {'xml:lang': 'en'});
  5823. *
  5824. * Parameters:
  5825. * (String) name - The name of the root element.
  5826. * (Object) attrs - The attributes for the root element in object notation.
  5827. *
  5828. * Returns:
  5829. * A new Strophe.Builder.
  5830. */
  5831. Strophe.Builder = class Builder {
  5832. constructor(name, attrs) {
  5833. // Set correct namespace for jabber:client elements
  5834. if (name === "presence" || name === "message" || name === "iq") {
  5835. if (attrs && !attrs.xmlns) {
  5836. attrs.xmlns = Strophe.NS.CLIENT;
  5837. } else if (!attrs) {
  5838. attrs = {
  5839. xmlns: Strophe.NS.CLIENT
  5840. };
  5841. }
  5842. } // Holds the tree being built.
  5843. this.nodeTree = Strophe.xmlElement(name, attrs); // Points to the current operation node.
  5844. this.node = this.nodeTree;
  5845. }
  5846. /** Function: tree
  5847. * Return the DOM tree.
  5848. *
  5849. * This function returns the current DOM tree as an element object. This
  5850. * is suitable for passing to functions like Strophe.Connection.send().
  5851. *
  5852. * Returns:
  5853. * The DOM tree as a element object.
  5854. */
  5855. tree() {
  5856. return this.nodeTree;
  5857. }
  5858. /** Function: toString
  5859. * Serialize the DOM tree to a String.
  5860. *
  5861. * This function returns a string serialization of the current DOM
  5862. * tree. It is often used internally to pass data to a
  5863. * Strophe.Request object.
  5864. *
  5865. * Returns:
  5866. * The serialized DOM tree in a String.
  5867. */
  5868. toString() {
  5869. return Strophe.serialize(this.nodeTree);
  5870. }
  5871. /** Function: up
  5872. * Make the current parent element the new current element.
  5873. *
  5874. * This function is often used after c() to traverse back up the tree.
  5875. * For example, to add two children to the same element
  5876. * > builder.c('child1', {}).up().c('child2', {});
  5877. *
  5878. * Returns:
  5879. * The Stophe.Builder object.
  5880. */
  5881. up() {
  5882. this.node = this.node.parentNode;
  5883. return this;
  5884. }
  5885. /** Function: root
  5886. * Make the root element the new current element.
  5887. *
  5888. * When at a deeply nested element in the tree, this function can be used
  5889. * to jump back to the root of the tree, instead of having to repeatedly
  5890. * call up().
  5891. *
  5892. * Returns:
  5893. * The Stophe.Builder object.
  5894. */
  5895. root() {
  5896. this.node = this.nodeTree;
  5897. return this;
  5898. }
  5899. /** Function: attrs
  5900. * Add or modify attributes of the current element.
  5901. *
  5902. * The attributes should be passed in object notation. This function
  5903. * does not move the current element pointer.
  5904. *
  5905. * Parameters:
  5906. * (Object) moreattrs - The attributes to add/modify in object notation.
  5907. *
  5908. * Returns:
  5909. * The Strophe.Builder object.
  5910. */
  5911. attrs(moreattrs) {
  5912. for (const k in moreattrs) {
  5913. if (Object.prototype.hasOwnProperty.call(moreattrs, k)) {
  5914. if (moreattrs[k] === undefined) {
  5915. this.node.removeAttribute(k);
  5916. } else {
  5917. this.node.setAttribute(k, moreattrs[k]);
  5918. }
  5919. }
  5920. }
  5921. return this;
  5922. }
  5923. /** Function: c
  5924. * Add a child to the current element and make it the new current
  5925. * element.
  5926. *
  5927. * This function moves the current element pointer to the child,
  5928. * unless text is provided. If you need to add another child, it
  5929. * is necessary to use up() to go back to the parent in the tree.
  5930. *
  5931. * Parameters:
  5932. * (String) name - The name of the child.
  5933. * (Object) attrs - The attributes of the child in object notation.
  5934. * (String) text - The text to add to the child.
  5935. *
  5936. * Returns:
  5937. * The Strophe.Builder object.
  5938. */
  5939. c(name, attrs, text) {
  5940. const child = Strophe.xmlElement(name, attrs, text);
  5941. this.node.appendChild(child);
  5942. if (typeof text !== "string" && typeof text !== "number") {
  5943. this.node = child;
  5944. }
  5945. return this;
  5946. }
  5947. /** Function: cnode
  5948. * Add a child to the current element and make it the new current
  5949. * element.
  5950. *
  5951. * This function is the same as c() except that instead of using a
  5952. * name and an attributes object to create the child it uses an
  5953. * existing DOM element object.
  5954. *
  5955. * Parameters:
  5956. * (XMLElement) elem - A DOM element.
  5957. *
  5958. * Returns:
  5959. * The Strophe.Builder object.
  5960. */
  5961. cnode(elem) {
  5962. let impNode;
  5963. const xmlGen = Strophe.xmlGenerator();
  5964. try {
  5965. impNode = xmlGen.importNode !== undefined;
  5966. } catch (e) {
  5967. impNode = false;
  5968. }
  5969. const newElem = impNode ? xmlGen.importNode(elem, true) : Strophe.copyElement(elem);
  5970. this.node.appendChild(newElem);
  5971. this.node = newElem;
  5972. return this;
  5973. }
  5974. /** Function: t
  5975. * Add a child text element.
  5976. *
  5977. * This *does not* make the child the new current element since there
  5978. * are no children of text elements.
  5979. *
  5980. * Parameters:
  5981. * (String) text - The text data to append to the current element.
  5982. *
  5983. * Returns:
  5984. * The Strophe.Builder object.
  5985. */
  5986. t(text) {
  5987. const child = Strophe.xmlTextNode(text);
  5988. this.node.appendChild(child);
  5989. return this;
  5990. }
  5991. /** Function: h
  5992. * Replace current element contents with the HTML passed in.
  5993. *
  5994. * This *does not* make the child the new current element
  5995. *
  5996. * Parameters:
  5997. * (String) html - The html to insert as contents of current element.
  5998. *
  5999. * Returns:
  6000. * The Strophe.Builder object.
  6001. */
  6002. h(html) {
  6003. const fragment = Strophe.xmlGenerator().createElement('body'); // force the browser to try and fix any invalid HTML tags
  6004. fragment.innerHTML = html; // copy cleaned html into an xml dom
  6005. const xhtml = Strophe.createHtml(fragment);
  6006. while (xhtml.childNodes.length > 0) {
  6007. this.node.appendChild(xhtml.childNodes[0]);
  6008. }
  6009. return this;
  6010. }
  6011. };
  6012. /** PrivateClass: Strophe.Handler
  6013. * _Private_ helper class for managing stanza handlers.
  6014. *
  6015. * A Strophe.Handler encapsulates a user provided callback function to be
  6016. * executed when matching stanzas are received by the connection.
  6017. * Handlers can be either one-off or persistant depending on their
  6018. * return value. Returning true will cause a Handler to remain active, and
  6019. * returning false will remove the Handler.
  6020. *
  6021. * Users will not use Strophe.Handler objects directly, but instead they
  6022. * will use Strophe.Connection.addHandler() and
  6023. * Strophe.Connection.deleteHandler().
  6024. */
  6025. /** PrivateConstructor: Strophe.Handler
  6026. * Create and initialize a new Strophe.Handler.
  6027. *
  6028. * Parameters:
  6029. * (Function) handler - A function to be executed when the handler is run.
  6030. * (String) ns - The namespace to match.
  6031. * (String) name - The element name to match.
  6032. * (String) type - The element type to match.
  6033. * (String) id - The element id attribute to match.
  6034. * (String) from - The element from attribute to match.
  6035. * (Object) options - Handler options
  6036. *
  6037. * Returns:
  6038. * A new Strophe.Handler object.
  6039. */
  6040. Strophe.Handler = function (handler, ns, name, type, id, from, options) {
  6041. this.handler = handler;
  6042. this.ns = ns;
  6043. this.name = name;
  6044. this.type = type;
  6045. this.id = id;
  6046. this.options = options || {
  6047. 'matchBareFromJid': false,
  6048. 'ignoreNamespaceFragment': false
  6049. }; // BBB: Maintain backward compatibility with old `matchBare` option
  6050. if (this.options.matchBare) {
  6051. Strophe.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.');
  6052. this.options.matchBareFromJid = this.options.matchBare;
  6053. delete this.options.matchBare;
  6054. }
  6055. if (this.options.matchBareFromJid) {
  6056. this.from = from ? Strophe.getBareJidFromJid(from) : null;
  6057. } else {
  6058. this.from = from;
  6059. } // whether the handler is a user handler or a system handler
  6060. this.user = true;
  6061. };
  6062. Strophe.Handler.prototype = {
  6063. /** PrivateFunction: getNamespace
  6064. * Returns the XML namespace attribute on an element.
  6065. * If `ignoreNamespaceFragment` was passed in for this handler, then the
  6066. * URL fragment will be stripped.
  6067. *
  6068. * Parameters:
  6069. * (XMLElement) elem - The XML element with the namespace.
  6070. *
  6071. * Returns:
  6072. * The namespace, with optionally the fragment stripped.
  6073. */
  6074. getNamespace(elem) {
  6075. let elNamespace = elem.getAttribute("xmlns");
  6076. if (elNamespace && this.options.ignoreNamespaceFragment) {
  6077. elNamespace = elNamespace.split('#')[0];
  6078. }
  6079. return elNamespace;
  6080. },
  6081. /** PrivateFunction: namespaceMatch
  6082. * Tests if a stanza matches the namespace set for this Strophe.Handler.
  6083. *
  6084. * Parameters:
  6085. * (XMLElement) elem - The XML element to test.
  6086. *
  6087. * Returns:
  6088. * true if the stanza matches and false otherwise.
  6089. */
  6090. namespaceMatch(elem) {
  6091. let nsMatch = false;
  6092. if (!this.ns) {
  6093. return true;
  6094. } else {
  6095. Strophe.forEachChild(elem, null, elem => {
  6096. if (this.getNamespace(elem) === this.ns) {
  6097. nsMatch = true;
  6098. }
  6099. });
  6100. return nsMatch || this.getNamespace(elem) === this.ns;
  6101. }
  6102. },
  6103. /** PrivateFunction: isMatch
  6104. * Tests if a stanza matches the Strophe.Handler.
  6105. *
  6106. * Parameters:
  6107. * (XMLElement) elem - The XML element to test.
  6108. *
  6109. * Returns:
  6110. * true if the stanza matches and false otherwise.
  6111. */
  6112. isMatch(elem) {
  6113. let from = elem.getAttribute('from');
  6114. if (this.options.matchBareFromJid) {
  6115. from = Strophe.getBareJidFromJid(from);
  6116. }
  6117. const elem_type = elem.getAttribute("type");
  6118. if (this.namespaceMatch(elem) && (!this.name || Strophe.isTagEqual(elem, this.name)) && (!this.type || (Array.isArray(this.type) ? this.type.indexOf(elem_type) !== -1 : elem_type === this.type)) && (!this.id || elem.getAttribute("id") === this.id) && (!this.from || from === this.from)) {
  6119. return true;
  6120. }
  6121. return false;
  6122. },
  6123. /** PrivateFunction: run
  6124. * Run the callback on a matching stanza.
  6125. *
  6126. * Parameters:
  6127. * (XMLElement) elem - The DOM element that triggered the
  6128. * Strophe.Handler.
  6129. *
  6130. * Returns:
  6131. * A boolean indicating if the handler should remain active.
  6132. */
  6133. run(elem) {
  6134. let result = null;
  6135. try {
  6136. result = this.handler(elem);
  6137. } catch (e) {
  6138. Strophe._handleError(e);
  6139. throw e;
  6140. }
  6141. return result;
  6142. },
  6143. /** PrivateFunction: toString
  6144. * Get a String representation of the Strophe.Handler object.
  6145. *
  6146. * Returns:
  6147. * A String.
  6148. */
  6149. toString() {
  6150. return "{Handler: " + this.handler + "(" + this.name + "," + this.id + "," + this.ns + ")}";
  6151. }
  6152. };
  6153. /** PrivateClass: Strophe.TimedHandler
  6154. * _Private_ helper class for managing timed handlers.
  6155. *
  6156. * A Strophe.TimedHandler encapsulates a user provided callback that
  6157. * should be called after a certain period of time or at regular
  6158. * intervals. The return value of the callback determines whether the
  6159. * Strophe.TimedHandler will continue to fire.
  6160. *
  6161. * Users will not use Strophe.TimedHandler objects directly, but instead
  6162. * they will use Strophe.Connection.addTimedHandler() and
  6163. * Strophe.Connection.deleteTimedHandler().
  6164. */
  6165. Strophe.TimedHandler = class TimedHandler {
  6166. /** PrivateConstructor: Strophe.TimedHandler
  6167. * Create and initialize a new Strophe.TimedHandler object.
  6168. *
  6169. * Parameters:
  6170. * (Integer) period - The number of milliseconds to wait before the
  6171. * handler is called.
  6172. * (Function) handler - The callback to run when the handler fires. This
  6173. * function should take no arguments.
  6174. *
  6175. * Returns:
  6176. * A new Strophe.TimedHandler object.
  6177. */
  6178. constructor(period, handler) {
  6179. this.period = period;
  6180. this.handler = handler;
  6181. this.lastCalled = new Date().getTime();
  6182. this.user = true;
  6183. }
  6184. /** PrivateFunction: run
  6185. * Run the callback for the Strophe.TimedHandler.
  6186. *
  6187. * Returns:
  6188. * true if the Strophe.TimedHandler should be called again, and false
  6189. * otherwise.
  6190. */
  6191. run() {
  6192. this.lastCalled = new Date().getTime();
  6193. return this.handler();
  6194. }
  6195. /** PrivateFunction: reset
  6196. * Reset the last called time for the Strophe.TimedHandler.
  6197. */
  6198. reset() {
  6199. this.lastCalled = new Date().getTime();
  6200. }
  6201. /** PrivateFunction: toString
  6202. * Get a string representation of the Strophe.TimedHandler object.
  6203. *
  6204. * Returns:
  6205. * The string representation.
  6206. */
  6207. toString() {
  6208. return "{TimedHandler: " + this.handler + "(" + this.period + ")}";
  6209. }
  6210. };
  6211. /** Class: Strophe.Connection
  6212. * XMPP Connection manager.
  6213. *
  6214. * This class is the main part of Strophe. It manages a BOSH or websocket
  6215. * connection to an XMPP server and dispatches events to the user callbacks
  6216. * as data arrives. It supports SASL PLAIN, SASL SCRAM-SHA-1
  6217. * and legacy authentication.
  6218. *
  6219. * After creating a Strophe.Connection object, the user will typically
  6220. * call connect() with a user supplied callback to handle connection level
  6221. * events like authentication failure, disconnection, or connection
  6222. * complete.
  6223. *
  6224. * The user will also have several event handlers defined by using
  6225. * addHandler() and addTimedHandler(). These will allow the user code to
  6226. * respond to interesting stanzas or do something periodically with the
  6227. * connection. These handlers will be active once authentication is
  6228. * finished.
  6229. *
  6230. * To send data to the connection, use send().
  6231. */
  6232. /** Constructor: Strophe.Connection
  6233. * Create and initialize a Strophe.Connection object.
  6234. *
  6235. * The transport-protocol for this connection will be chosen automatically
  6236. * based on the given service parameter. URLs starting with "ws://" or
  6237. * "wss://" will use WebSockets, URLs starting with "http://", "https://"
  6238. * or without a protocol will use BOSH.
  6239. *
  6240. * To make Strophe connect to the current host you can leave out the protocol
  6241. * and host part and just pass the path, e.g.
  6242. *
  6243. * > let conn = new Strophe.Connection("/http-bind/");
  6244. *
  6245. * Options common to both Websocket and BOSH:
  6246. * ------------------------------------------
  6247. *
  6248. * cookies:
  6249. *
  6250. * The *cookies* option allows you to pass in cookies to be added to the
  6251. * document. These cookies will then be included in the BOSH XMLHttpRequest
  6252. * or in the websocket connection.
  6253. *
  6254. * The passed in value must be a map of cookie names and string values.
  6255. *
  6256. * > { "myCookie": {
  6257. * > "value": "1234",
  6258. * > "domain": ".example.org",
  6259. * > "path": "/",
  6260. * > "expires": expirationDate
  6261. * > }
  6262. * > }
  6263. *
  6264. * Note that cookies can't be set in this way for other domains (i.e. cross-domain).
  6265. * Those cookies need to be set under those domains, for example they can be
  6266. * set server-side by making a XHR call to that domain to ask it to set any
  6267. * necessary cookies.
  6268. *
  6269. * mechanisms:
  6270. *
  6271. * The *mechanisms* option allows you to specify the SASL mechanisms that this
  6272. * instance of Strophe.Connection (and therefore your XMPP client) will
  6273. * support.
  6274. *
  6275. * The value must be an array of objects with Strophe.SASLMechanism
  6276. * prototypes.
  6277. *
  6278. * If nothing is specified, then the following mechanisms (and their
  6279. * priorities) are registered:
  6280. *
  6281. * SCRAM-SHA-1 - 60
  6282. * PLAIN - 50
  6283. * OAUTHBEARER - 40
  6284. * X-OAUTH2 - 30
  6285. * ANONYMOUS - 20
  6286. * EXTERNAL - 10
  6287. *
  6288. * explicitResourceBinding:
  6289. *
  6290. * If `explicitResourceBinding` is set to a truthy value, then the XMPP client
  6291. * needs to explicitly call `Strophe.Connection.prototype.bind` once the XMPP
  6292. * server has advertised the "urn:ietf:params:xml:ns:xmpp-bind" feature.
  6293. *
  6294. * Making this step explicit allows client authors to first finish other
  6295. * stream related tasks, such as setting up an XEP-0198 Stream Management
  6296. * session, before binding the JID resource for this session.
  6297. *
  6298. * WebSocket options:
  6299. * ------------------
  6300. *
  6301. * protocol:
  6302. *
  6303. * If you want to connect to the current host with a WebSocket connection you
  6304. * can tell Strophe to use WebSockets through a "protocol" attribute in the
  6305. * optional options parameter. Valid values are "ws" for WebSocket and "wss"
  6306. * for Secure WebSocket.
  6307. * So to connect to "wss://CURRENT_HOSTNAME/xmpp-websocket" you would call
  6308. *
  6309. * > let conn = new Strophe.Connection("/xmpp-websocket/", {protocol: "wss"});
  6310. *
  6311. * Note that relative URLs _NOT_ starting with a "/" will also include the path
  6312. * of the current site.
  6313. *
  6314. * Also because downgrading security is not permitted by browsers, when using
  6315. * relative URLs both BOSH and WebSocket connections will use their secure
  6316. * variants if the current connection to the site is also secure (https).
  6317. *
  6318. * worker:
  6319. *
  6320. * Set this option to URL from where the shared worker script should be loaded.
  6321. *
  6322. * To run the websocket connection inside a shared worker.
  6323. * This allows you to share a single websocket-based connection between
  6324. * multiple Strophe.Connection instances, for example one per browser tab.
  6325. *
  6326. * The script to use is the one in `src/shared-connection-worker.js`.
  6327. *
  6328. * BOSH options:
  6329. * -------------
  6330. *
  6331. * By adding "sync" to the options, you can control if requests will
  6332. * be made synchronously or not. The default behaviour is asynchronous.
  6333. * If you want to make requests synchronous, make "sync" evaluate to true.
  6334. * > let conn = new Strophe.Connection("/http-bind/", {sync: true});
  6335. *
  6336. * You can also toggle this on an already established connection.
  6337. * > conn.options.sync = true;
  6338. *
  6339. * The *customHeaders* option can be used to provide custom HTTP headers to be
  6340. * included in the XMLHttpRequests made.
  6341. *
  6342. * The *keepalive* option can be used to instruct Strophe to maintain the
  6343. * current BOSH session across interruptions such as webpage reloads.
  6344. *
  6345. * It will do this by caching the sessions tokens in sessionStorage, and when
  6346. * "restore" is called it will check whether there are cached tokens with
  6347. * which it can resume an existing session.
  6348. *
  6349. * The *withCredentials* option should receive a Boolean value and is used to
  6350. * indicate wether cookies should be included in ajax requests (by default
  6351. * they're not).
  6352. * Set this value to true if you are connecting to a BOSH service
  6353. * and for some reason need to send cookies to it.
  6354. * In order for this to work cross-domain, the server must also enable
  6355. * credentials by setting the Access-Control-Allow-Credentials response header
  6356. * to "true". For most usecases however this setting should be false (which
  6357. * is the default).
  6358. * Additionally, when using Access-Control-Allow-Credentials, the
  6359. * Access-Control-Allow-Origin header can't be set to the wildcard "*", but
  6360. * instead must be restricted to actual domains.
  6361. *
  6362. * The *contentType* option can be set to change the default Content-Type
  6363. * of "text/xml; charset=utf-8", which can be useful to reduce the amount of
  6364. * CORS preflight requests that are sent to the server.
  6365. *
  6366. * Parameters:
  6367. * (String) service - The BOSH or WebSocket service URL.
  6368. * (Object) options - A hash of configuration options
  6369. *
  6370. * Returns:
  6371. * A new Strophe.Connection object.
  6372. */
  6373. Strophe.Connection = class Connection {
  6374. constructor(service, options) {
  6375. // The service URL
  6376. this.service = service; // Configuration options
  6377. this.options = options || {};
  6378. this.setProtocol();
  6379. /* The connected JID. */
  6380. this.jid = "";
  6381. /* the JIDs domain */
  6382. this.domain = null;
  6383. /* stream:features */
  6384. this.features = null; // SASL
  6385. this._sasl_data = {};
  6386. this.do_bind = false;
  6387. this.do_session = false;
  6388. this.mechanisms = {}; // handler lists
  6389. this.timedHandlers = [];
  6390. this.handlers = [];
  6391. this.removeTimeds = [];
  6392. this.removeHandlers = [];
  6393. this.addTimeds = [];
  6394. this.addHandlers = [];
  6395. this.protocolErrorHandlers = {
  6396. 'HTTP': {},
  6397. 'websocket': {}
  6398. };
  6399. this._idleTimeout = null;
  6400. this._disconnectTimeout = null;
  6401. this.authenticated = false;
  6402. this.connected = false;
  6403. this.disconnecting = false;
  6404. this.do_authentication = true;
  6405. this.paused = false;
  6406. this.restored = false;
  6407. this._data = [];
  6408. this._uniqueId = 0;
  6409. this._sasl_success_handler = null;
  6410. this._sasl_failure_handler = null;
  6411. this._sasl_challenge_handler = null; // Max retries before disconnecting
  6412. this.maxRetries = 5; // Call onIdle callback every 1/10th of a second
  6413. this._idleTimeout = setTimeout(() => this._onIdle(), 100);
  6414. utils.addCookies(this.options.cookies);
  6415. this.registerSASLMechanisms(this.options.mechanisms); // A client must always respond to incoming IQ "set" and "get" stanzas.
  6416. // See https://datatracker.ietf.org/doc/html/rfc6120#section-8.2.3
  6417. //
  6418. // This is a fallback handler which gets called when no other handler
  6419. // was called for a received IQ "set" or "get".
  6420. this.iqFallbackHandler = new Strophe.Handler(iq => this.send($iq({
  6421. type: 'error',
  6422. id: iq.getAttribute('id')
  6423. }).c('error', {
  6424. 'type': 'cancel'
  6425. }).c('service-unavailable', {
  6426. 'xmlns': Strophe.NS.STANZAS
  6427. })), null, 'iq', ['get', 'set']); // initialize plugins
  6428. for (const k in Strophe._connectionPlugins) {
  6429. if (Object.prototype.hasOwnProperty.call(Strophe._connectionPlugins, k)) {
  6430. const F = function () {};
  6431. F.prototype = Strophe._connectionPlugins[k];
  6432. this[k] = new F();
  6433. this[k].init(this);
  6434. }
  6435. }
  6436. }
  6437. /** Function: setProtocol
  6438. * Select protocal based on this.options or this.service
  6439. */
  6440. setProtocol() {
  6441. const proto = this.options.protocol || "";
  6442. if (this.options.worker) {
  6443. this._proto = new Strophe.WorkerWebsocket(this);
  6444. } else if (this.service.indexOf("ws:") === 0 || this.service.indexOf("wss:") === 0 || proto.indexOf("ws") === 0) {
  6445. this._proto = new Strophe.Websocket(this);
  6446. } else {
  6447. this._proto = new Strophe.Bosh(this);
  6448. }
  6449. }
  6450. /** Function: reset
  6451. * Reset the connection.
  6452. *
  6453. * This function should be called after a connection is disconnected
  6454. * before that connection is reused.
  6455. */
  6456. reset() {
  6457. this._proto._reset(); // SASL
  6458. this.do_session = false;
  6459. this.do_bind = false; // handler lists
  6460. this.timedHandlers = [];
  6461. this.handlers = [];
  6462. this.removeTimeds = [];
  6463. this.removeHandlers = [];
  6464. this.addTimeds = [];
  6465. this.addHandlers = [];
  6466. this.authenticated = false;
  6467. this.connected = false;
  6468. this.disconnecting = false;
  6469. this.restored = false;
  6470. this._data = [];
  6471. this._requests = [];
  6472. this._uniqueId = 0;
  6473. }
  6474. /** Function: pause
  6475. * Pause the request manager.
  6476. *
  6477. * This will prevent Strophe from sending any more requests to the
  6478. * server. This is very useful for temporarily pausing
  6479. * BOSH-Connections while a lot of send() calls are happening quickly.
  6480. * This causes Strophe to send the data in a single request, saving
  6481. * many request trips.
  6482. */
  6483. pause() {
  6484. this.paused = true;
  6485. }
  6486. /** Function: resume
  6487. * Resume the request manager.
  6488. *
  6489. * This resumes after pause() has been called.
  6490. */
  6491. resume() {
  6492. this.paused = false;
  6493. }
  6494. /** Function: getUniqueId
  6495. * Generate a unique ID for use in <iq/> elements.
  6496. *
  6497. * All <iq/> stanzas are required to have unique id attributes. This
  6498. * function makes creating these easy. Each connection instance has
  6499. * a counter which starts from zero, and the value of this counter
  6500. * plus a colon followed by the suffix becomes the unique id. If no
  6501. * suffix is supplied, the counter is used as the unique id.
  6502. *
  6503. * Suffixes are used to make debugging easier when reading the stream
  6504. * data, and their use is recommended. The counter resets to 0 for
  6505. * every new connection for the same reason. For connections to the
  6506. * same server that authenticate the same way, all the ids should be
  6507. * the same, which makes it easy to see changes. This is useful for
  6508. * automated testing as well.
  6509. *
  6510. * Parameters:
  6511. * (String) suffix - A optional suffix to append to the id.
  6512. *
  6513. * Returns:
  6514. * A unique string to be used for the id attribute.
  6515. */
  6516. getUniqueId(suffix) {
  6517. // eslint-disable-line class-methods-use-this
  6518. const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  6519. const r = Math.random() * 16 | 0,
  6520. v = c === 'x' ? r : r & 0x3 | 0x8;
  6521. return v.toString(16);
  6522. });
  6523. if (typeof suffix === "string" || typeof suffix === "number") {
  6524. return uuid + ":" + suffix;
  6525. } else {
  6526. return uuid + "";
  6527. }
  6528. }
  6529. /** Function: addProtocolErrorHandler
  6530. * Register a handler function for when a protocol (websocker or HTTP)
  6531. * error occurs.
  6532. *
  6533. * NOTE: Currently only HTTP errors for BOSH requests are handled.
  6534. * Patches that handle websocket errors would be very welcome.
  6535. *
  6536. * Parameters:
  6537. * (String) protocol - 'HTTP' or 'websocket'
  6538. * (Integer) status_code - Error status code (e.g 500, 400 or 404)
  6539. * (Function) callback - Function that will fire on Http error
  6540. *
  6541. * Example:
  6542. * function onError(err_code){
  6543. * //do stuff
  6544. * }
  6545. *
  6546. * let conn = Strophe.connect('http://example.com/http-bind');
  6547. * conn.addProtocolErrorHandler('HTTP', 500, onError);
  6548. * // Triggers HTTP 500 error and onError handler will be called
  6549. * conn.connect('user_jid@incorrect_jabber_host', 'secret', onConnect);
  6550. */
  6551. addProtocolErrorHandler(protocol, status_code, callback) {
  6552. this.protocolErrorHandlers[protocol][status_code] = callback;
  6553. }
  6554. /** Function: connect
  6555. * Starts the connection process.
  6556. *
  6557. * As the connection process proceeds, the user supplied callback will
  6558. * be triggered multiple times with status updates. The callback
  6559. * should take two arguments - the status code and the error condition.
  6560. *
  6561. * The status code will be one of the values in the Strophe.Status
  6562. * constants. The error condition will be one of the conditions
  6563. * defined in RFC 3920 or the condition 'strophe-parsererror'.
  6564. *
  6565. * The Parameters _wait_, _hold_ and _route_ are optional and only relevant
  6566. * for BOSH connections. Please see XEP 124 for a more detailed explanation
  6567. * of the optional parameters.
  6568. *
  6569. * Parameters:
  6570. * (String) jid - The user's JID. This may be a bare JID,
  6571. * or a full JID. If a node is not supplied, SASL OAUTHBEARER or
  6572. * SASL ANONYMOUS authentication will be attempted (OAUTHBEARER will
  6573. * process the provided password value as an access token).
  6574. * (String) pass - The user's password.
  6575. * (Function) callback - The connect callback function.
  6576. * (Integer) wait - The optional HTTPBIND wait value. This is the
  6577. * time the server will wait before returning an empty result for
  6578. * a request. The default setting of 60 seconds is recommended.
  6579. * (Integer) hold - The optional HTTPBIND hold value. This is the
  6580. * number of connections the server will hold at one time. This
  6581. * should almost always be set to 1 (the default).
  6582. * (String) route - The optional route value.
  6583. * (String) authcid - The optional alternative authentication identity
  6584. * (username) if intending to impersonate another user.
  6585. * When using the SASL-EXTERNAL authentication mechanism, for example
  6586. * with client certificates, then the authcid value is used to
  6587. * determine whether an authorization JID (authzid) should be sent to
  6588. * the server. The authzid should NOT be sent to the server if the
  6589. * authzid and authcid are the same. So to prevent it from being sent
  6590. * (for example when the JID is already contained in the client
  6591. * certificate), set authcid to that same JID. See XEP-178 for more
  6592. * details.
  6593. * (Integer) disconnection_timeout - The optional disconnection timeout
  6594. * in milliseconds before _doDisconnect will be called.
  6595. */
  6596. connect(jid, pass, callback, wait, hold, route, authcid) {
  6597. let disconnection_timeout = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 3000;
  6598. this.jid = jid;
  6599. /** Variable: authzid
  6600. * Authorization identity.
  6601. */
  6602. this.authzid = Strophe.getBareJidFromJid(this.jid);
  6603. /** Variable: authcid
  6604. * Authentication identity (User name).
  6605. */
  6606. this.authcid = authcid || Strophe.getNodeFromJid(this.jid);
  6607. /** Variable: pass
  6608. * Authentication identity (User password).
  6609. */
  6610. this.pass = pass;
  6611. this.connect_callback = callback;
  6612. this.disconnecting = false;
  6613. this.connected = false;
  6614. this.authenticated = false;
  6615. this.restored = false;
  6616. this.disconnection_timeout = disconnection_timeout; // parse jid for domain
  6617. this.domain = Strophe.getDomainFromJid(this.jid);
  6618. this._changeConnectStatus(Strophe.Status.CONNECTING, null);
  6619. this._proto._connect(wait, hold, route);
  6620. }
  6621. /** Function: attach
  6622. * Attach to an already created and authenticated BOSH session.
  6623. *
  6624. * This function is provided to allow Strophe to attach to BOSH
  6625. * sessions which have been created externally, perhaps by a Web
  6626. * application. This is often used to support auto-login type features
  6627. * without putting user credentials into the page.
  6628. *
  6629. * Parameters:
  6630. * (String) jid - The full JID that is bound by the session.
  6631. * (String) sid - The SID of the BOSH session.
  6632. * (String) rid - The current RID of the BOSH session. This RID
  6633. * will be used by the next request.
  6634. * (Function) callback The connect callback function.
  6635. * (Integer) wait - The optional HTTPBIND wait value. This is the
  6636. * time the server will wait before returning an empty result for
  6637. * a request. The default setting of 60 seconds is recommended.
  6638. * Other settings will require tweaks to the Strophe.TIMEOUT value.
  6639. * (Integer) hold - The optional HTTPBIND hold value. This is the
  6640. * number of connections the server will hold at one time. This
  6641. * should almost always be set to 1 (the default).
  6642. * (Integer) wind - The optional HTTBIND window value. This is the
  6643. * allowed range of request ids that are valid. The default is 5.
  6644. */
  6645. attach(jid, sid, rid, callback, wait, hold, wind) {
  6646. if (this._proto._attach) {
  6647. return this._proto._attach(jid, sid, rid, callback, wait, hold, wind);
  6648. } else {
  6649. const error = new Error('The "attach" method is not available for your connection protocol');
  6650. error.name = 'StropheSessionError';
  6651. throw error;
  6652. }
  6653. }
  6654. /** Function: restore
  6655. * Attempt to restore a cached BOSH session.
  6656. *
  6657. * This function is only useful in conjunction with providing the
  6658. * "keepalive":true option when instantiating a new Strophe.Connection.
  6659. *
  6660. * When "keepalive" is set to true, Strophe will cache the BOSH tokens
  6661. * RID (Request ID) and SID (Session ID) and then when this function is
  6662. * called, it will attempt to restore the session from those cached
  6663. * tokens.
  6664. *
  6665. * This function must therefore be called instead of connect or attach.
  6666. *
  6667. * For an example on how to use it, please see examples/restore.js
  6668. *
  6669. * Parameters:
  6670. * (String) jid - The user's JID. This may be a bare JID or a full JID.
  6671. * (Function) callback - The connect callback function.
  6672. * (Integer) wait - The optional HTTPBIND wait value. This is the
  6673. * time the server will wait before returning an empty result for
  6674. * a request. The default setting of 60 seconds is recommended.
  6675. * (Integer) hold - The optional HTTPBIND hold value. This is the
  6676. * number of connections the server will hold at one time. This
  6677. * should almost always be set to 1 (the default).
  6678. * (Integer) wind - The optional HTTBIND window value. This is the
  6679. * allowed range of request ids that are valid. The default is 5.
  6680. */
  6681. restore(jid, callback, wait, hold, wind) {
  6682. if (this._sessionCachingSupported()) {
  6683. this._proto._restore(jid, callback, wait, hold, wind);
  6684. } else {
  6685. const error = new Error('The "restore" method can only be used with a BOSH connection.');
  6686. error.name = 'StropheSessionError';
  6687. throw error;
  6688. }
  6689. }
  6690. /** PrivateFunction: _sessionCachingSupported
  6691. * Checks whether sessionStorage and JSON are supported and whether we're
  6692. * using BOSH.
  6693. */
  6694. _sessionCachingSupported() {
  6695. if (this._proto instanceof Strophe.Bosh) {
  6696. if (!JSON) {
  6697. return false;
  6698. }
  6699. try {
  6700. sessionStorage.setItem('_strophe_', '_strophe_');
  6701. sessionStorage.removeItem('_strophe_');
  6702. } catch (e) {
  6703. return false;
  6704. }
  6705. return true;
  6706. }
  6707. return false;
  6708. }
  6709. /** Function: xmlInput
  6710. * User overrideable function that receives XML data coming into the
  6711. * connection.
  6712. *
  6713. * The default function does nothing. User code can override this with
  6714. * > Strophe.Connection.xmlInput = function (elem) {
  6715. * > (user code)
  6716. * > };
  6717. *
  6718. * Due to limitations of current Browsers' XML-Parsers the opening and closing
  6719. * <stream> tag for WebSocket-Connoctions will be passed as selfclosing here.
  6720. *
  6721. * BOSH-Connections will have all stanzas wrapped in a <body> tag. See
  6722. * <Strophe.Bosh.strip> if you want to strip this tag.
  6723. *
  6724. * Parameters:
  6725. * (XMLElement) elem - The XML data received by the connection.
  6726. */
  6727. xmlInput(elem) {
  6728. // eslint-disable-line
  6729. return;
  6730. }
  6731. /** Function: xmlOutput
  6732. * User overrideable function that receives XML data sent to the
  6733. * connection.
  6734. *
  6735. * The default function does nothing. User code can override this with
  6736. * > Strophe.Connection.xmlOutput = function (elem) {
  6737. * > (user code)
  6738. * > };
  6739. *
  6740. * Due to limitations of current Browsers' XML-Parsers the opening and closing
  6741. * <stream> tag for WebSocket-Connoctions will be passed as selfclosing here.
  6742. *
  6743. * BOSH-Connections will have all stanzas wrapped in a <body> tag. See
  6744. * <Strophe.Bosh.strip> if you want to strip this tag.
  6745. *
  6746. * Parameters:
  6747. * (XMLElement) elem - The XMLdata sent by the connection.
  6748. */
  6749. xmlOutput(elem) {
  6750. // eslint-disable-line
  6751. return;
  6752. }
  6753. /** Function: rawInput
  6754. * User overrideable function that receives raw data coming into the
  6755. * connection.
  6756. *
  6757. * The default function does nothing. User code can override this with
  6758. * > Strophe.Connection.rawInput = function (data) {
  6759. * > (user code)
  6760. * > };
  6761. *
  6762. * Parameters:
  6763. * (String) data - The data received by the connection.
  6764. */
  6765. rawInput(data) {
  6766. // eslint-disable-line
  6767. return;
  6768. }
  6769. /** Function: rawOutput
  6770. * User overrideable function that receives raw data sent to the
  6771. * connection.
  6772. *
  6773. * The default function does nothing. User code can override this with
  6774. * > Strophe.Connection.rawOutput = function (data) {
  6775. * > (user code)
  6776. * > };
  6777. *
  6778. * Parameters:
  6779. * (String) data - The data sent by the connection.
  6780. */
  6781. rawOutput(data) {
  6782. // eslint-disable-line
  6783. return;
  6784. }
  6785. /** Function: nextValidRid
  6786. * User overrideable function that receives the new valid rid.
  6787. *
  6788. * The default function does nothing. User code can override this with
  6789. * > Strophe.Connection.nextValidRid = function (rid) {
  6790. * > (user code)
  6791. * > };
  6792. *
  6793. * Parameters:
  6794. * (Number) rid - The next valid rid
  6795. */
  6796. nextValidRid(rid) {
  6797. // eslint-disable-line
  6798. return;
  6799. }
  6800. /** Function: send
  6801. * Send a stanza.
  6802. *
  6803. * This function is called to push data onto the send queue to
  6804. * go out over the wire. Whenever a request is sent to the BOSH
  6805. * server, all pending data is sent and the queue is flushed.
  6806. *
  6807. * Parameters:
  6808. * (XMLElement |
  6809. * [XMLElement] |
  6810. * Strophe.Builder) elem - The stanza to send.
  6811. */
  6812. send(elem) {
  6813. if (elem === null) {
  6814. return;
  6815. }
  6816. if (typeof elem.sort === "function") {
  6817. for (let i = 0; i < elem.length; i++) {
  6818. this._queueData(elem[i]);
  6819. }
  6820. } else if (typeof elem.tree === "function") {
  6821. this._queueData(elem.tree());
  6822. } else {
  6823. this._queueData(elem);
  6824. }
  6825. this._proto._send();
  6826. }
  6827. /** Function: flush
  6828. * Immediately send any pending outgoing data.
  6829. *
  6830. * Normally send() queues outgoing data until the next idle period
  6831. * (100ms), which optimizes network use in the common cases when
  6832. * several send()s are called in succession. flush() can be used to
  6833. * immediately send all pending data.
  6834. */
  6835. flush() {
  6836. // cancel the pending idle period and run the idle function
  6837. // immediately
  6838. clearTimeout(this._idleTimeout);
  6839. this._onIdle();
  6840. }
  6841. /** Function: sendPresence
  6842. * Helper function to send presence stanzas. The main benefit is for
  6843. * sending presence stanzas for which you expect a responding presence
  6844. * stanza with the same id (for example when leaving a chat room).
  6845. *
  6846. * Parameters:
  6847. * (XMLElement) elem - The stanza to send.
  6848. * (Function) callback - The callback function for a successful request.
  6849. * (Function) errback - The callback function for a failed or timed
  6850. * out request. On timeout, the stanza will be null.
  6851. * (Integer) timeout - The time specified in milliseconds for a
  6852. * timeout to occur.
  6853. *
  6854. * Returns:
  6855. * The id used to send the presence.
  6856. */
  6857. sendPresence(elem, callback, errback, timeout) {
  6858. let timeoutHandler = null;
  6859. if (typeof elem.tree === "function") {
  6860. elem = elem.tree();
  6861. }
  6862. let id = elem.getAttribute('id');
  6863. if (!id) {
  6864. // inject id if not found
  6865. id = this.getUniqueId("sendPresence");
  6866. elem.setAttribute("id", id);
  6867. }
  6868. if (typeof callback === "function" || typeof errback === "function") {
  6869. const handler = this.addHandler(stanza => {
  6870. // remove timeout handler if there is one
  6871. if (timeoutHandler) {
  6872. this.deleteTimedHandler(timeoutHandler);
  6873. }
  6874. if (stanza.getAttribute('type') === 'error') {
  6875. if (errback) {
  6876. errback(stanza);
  6877. }
  6878. } else if (callback) {
  6879. callback(stanza);
  6880. }
  6881. }, null, 'presence', null, id); // if timeout specified, set up a timeout handler.
  6882. if (timeout) {
  6883. timeoutHandler = this.addTimedHandler(timeout, () => {
  6884. // get rid of normal handler
  6885. this.deleteHandler(handler); // call errback on timeout with null stanza
  6886. if (errback) {
  6887. errback(null);
  6888. }
  6889. return false;
  6890. });
  6891. }
  6892. }
  6893. this.send(elem);
  6894. return id;
  6895. }
  6896. /** Function: sendIQ
  6897. * Helper function to send IQ stanzas.
  6898. *
  6899. * Parameters:
  6900. * (XMLElement) elem - The stanza to send.
  6901. * (Function) callback - The callback function for a successful request.
  6902. * (Function) errback - The callback function for a failed or timed
  6903. * out request. On timeout, the stanza will be null.
  6904. * (Integer) timeout - The time specified in milliseconds for a
  6905. * timeout to occur.
  6906. *
  6907. * Returns:
  6908. * The id used to send the IQ.
  6909. */
  6910. sendIQ(elem, callback, errback, timeout) {
  6911. let timeoutHandler = null;
  6912. if (typeof elem.tree === "function") {
  6913. elem = elem.tree();
  6914. }
  6915. let id = elem.getAttribute('id');
  6916. if (!id) {
  6917. // inject id if not found
  6918. id = this.getUniqueId("sendIQ");
  6919. elem.setAttribute("id", id);
  6920. }
  6921. if (typeof callback === "function" || typeof errback === "function") {
  6922. const handler = this.addHandler(stanza => {
  6923. // remove timeout handler if there is one
  6924. if (timeoutHandler) {
  6925. this.deleteTimedHandler(timeoutHandler);
  6926. }
  6927. const iqtype = stanza.getAttribute('type');
  6928. if (iqtype === 'result') {
  6929. if (callback) {
  6930. callback(stanza);
  6931. }
  6932. } else if (iqtype === 'error') {
  6933. if (errback) {
  6934. errback(stanza);
  6935. }
  6936. } else {
  6937. const error = new Error(`Got bad IQ type of ${iqtype}`);
  6938. error.name = "StropheError";
  6939. throw error;
  6940. }
  6941. }, null, 'iq', ['error', 'result'], id); // if timeout specified, set up a timeout handler.
  6942. if (timeout) {
  6943. timeoutHandler = this.addTimedHandler(timeout, () => {
  6944. // get rid of normal handler
  6945. this.deleteHandler(handler); // call errback on timeout with null stanza
  6946. if (errback) {
  6947. errback(null);
  6948. }
  6949. return false;
  6950. });
  6951. }
  6952. }
  6953. this.send(elem);
  6954. return id;
  6955. }
  6956. /** PrivateFunction: _queueData
  6957. * Queue outgoing data for later sending. Also ensures that the data
  6958. * is a DOMElement.
  6959. */
  6960. _queueData(element) {
  6961. if (element === null || !element.tagName || !element.childNodes) {
  6962. const error = new Error("Cannot queue non-DOMElement.");
  6963. error.name = "StropheError";
  6964. throw error;
  6965. }
  6966. this._data.push(element);
  6967. }
  6968. /** PrivateFunction: _sendRestart
  6969. * Send an xmpp:restart stanza.
  6970. */
  6971. _sendRestart() {
  6972. this._data.push("restart");
  6973. this._proto._sendRestart();
  6974. this._idleTimeout = setTimeout(() => this._onIdle(), 100);
  6975. }
  6976. /** Function: addTimedHandler
  6977. * Add a timed handler to the connection.
  6978. *
  6979. * This function adds a timed handler. The provided handler will
  6980. * be called every period milliseconds until it returns false,
  6981. * the connection is terminated, or the handler is removed. Handlers
  6982. * that wish to continue being invoked should return true.
  6983. *
  6984. * Because of method binding it is necessary to save the result of
  6985. * this function if you wish to remove a handler with
  6986. * deleteTimedHandler().
  6987. *
  6988. * Note that user handlers are not active until authentication is
  6989. * successful.
  6990. *
  6991. * Parameters:
  6992. * (Integer) period - The period of the handler.
  6993. * (Function) handler - The callback function.
  6994. *
  6995. * Returns:
  6996. * A reference to the handler that can be used to remove it.
  6997. */
  6998. addTimedHandler(period, handler) {
  6999. const thand = new Strophe.TimedHandler(period, handler);
  7000. this.addTimeds.push(thand);
  7001. return thand;
  7002. }
  7003. /** Function: deleteTimedHandler
  7004. * Delete a timed handler for a connection.
  7005. *
  7006. * This function removes a timed handler from the connection. The
  7007. * handRef parameter is *not* the function passed to addTimedHandler(),
  7008. * but is the reference returned from addTimedHandler().
  7009. *
  7010. * Parameters:
  7011. * (Strophe.TimedHandler) handRef - The handler reference.
  7012. */
  7013. deleteTimedHandler(handRef) {
  7014. // this must be done in the Idle loop so that we don't change
  7015. // the handlers during iteration
  7016. this.removeTimeds.push(handRef);
  7017. }
  7018. /** Function: addHandler
  7019. * Add a stanza handler for the connection.
  7020. *
  7021. * This function adds a stanza handler to the connection. The
  7022. * handler callback will be called for any stanza that matches
  7023. * the parameters. Note that if multiple parameters are supplied,
  7024. * they must all match for the handler to be invoked.
  7025. *
  7026. * The handler will receive the stanza that triggered it as its argument.
  7027. * *The handler should return true if it is to be invoked again;
  7028. * returning false will remove the handler after it returns.*
  7029. *
  7030. * As a convenience, the ns parameters applies to the top level element
  7031. * and also any of its immediate children. This is primarily to make
  7032. * matching /iq/query elements easy.
  7033. *
  7034. * Options
  7035. * ~~~~~~~
  7036. * With the options argument, you can specify boolean flags that affect how
  7037. * matches are being done.
  7038. *
  7039. * Currently two flags exist:
  7040. *
  7041. * - matchBareFromJid:
  7042. * When set to true, the from parameter and the
  7043. * from attribute on the stanza will be matched as bare JIDs instead
  7044. * of full JIDs. To use this, pass {matchBareFromJid: true} as the
  7045. * value of options. The default value for matchBareFromJid is false.
  7046. *
  7047. * - ignoreNamespaceFragment:
  7048. * When set to true, a fragment specified on the stanza's namespace
  7049. * URL will be ignored when it's matched with the one configured for
  7050. * the handler.
  7051. *
  7052. * This means that if you register like this:
  7053. * > connection.addHandler(
  7054. * > handler,
  7055. * > 'http://jabber.org/protocol/muc',
  7056. * > null, null, null, null,
  7057. * > {'ignoreNamespaceFragment': true}
  7058. * > );
  7059. *
  7060. * Then a stanza with XML namespace of
  7061. * 'http://jabber.org/protocol/muc#user' will also be matched. If
  7062. * 'ignoreNamespaceFragment' is false, then only stanzas with
  7063. * 'http://jabber.org/protocol/muc' will be matched.
  7064. *
  7065. * Deleting the handler
  7066. * ~~~~~~~~~~~~~~~~~~~~
  7067. * The return value should be saved if you wish to remove the handler
  7068. * with deleteHandler().
  7069. *
  7070. * Parameters:
  7071. * (Function) handler - The user callback.
  7072. * (String) ns - The namespace to match.
  7073. * (String) name - The stanza name to match.
  7074. * (String|Array) type - The stanza type (or types if an array) to match.
  7075. * (String) id - The stanza id attribute to match.
  7076. * (String) from - The stanza from attribute to match.
  7077. * (String) options - The handler options
  7078. *
  7079. * Returns:
  7080. * A reference to the handler that can be used to remove it.
  7081. */
  7082. addHandler(handler, ns, name, type, id, from, options) {
  7083. const hand = new Strophe.Handler(handler, ns, name, type, id, from, options);
  7084. this.addHandlers.push(hand);
  7085. return hand;
  7086. }
  7087. /** Function: deleteHandler
  7088. * Delete a stanza handler for a connection.
  7089. *
  7090. * This function removes a stanza handler from the connection. The
  7091. * handRef parameter is *not* the function passed to addHandler(),
  7092. * but is the reference returned from addHandler().
  7093. *
  7094. * Parameters:
  7095. * (Strophe.Handler) handRef - The handler reference.
  7096. */
  7097. deleteHandler(handRef) {
  7098. // this must be done in the Idle loop so that we don't change
  7099. // the handlers during iteration
  7100. this.removeHandlers.push(handRef); // If a handler is being deleted while it is being added,
  7101. // prevent it from getting added
  7102. const i = this.addHandlers.indexOf(handRef);
  7103. if (i >= 0) {
  7104. this.addHandlers.splice(i, 1);
  7105. }
  7106. }
  7107. /** Function: registerSASLMechanisms
  7108. *
  7109. * Register the SASL mechanisms which will be supported by this instance of
  7110. * Strophe.Connection (i.e. which this XMPP client will support).
  7111. *
  7112. * Parameters:
  7113. * (Array) mechanisms - Array of objects with Strophe.SASLMechanism prototypes
  7114. *
  7115. */
  7116. registerSASLMechanisms(mechanisms) {
  7117. this.mechanisms = {};
  7118. mechanisms = mechanisms || [Strophe.SASLAnonymous, Strophe.SASLExternal, Strophe.SASLOAuthBearer, Strophe.SASLXOAuth2, Strophe.SASLPlain, Strophe.SASLSHA1];
  7119. mechanisms.forEach(m => this.registerSASLMechanism(m));
  7120. }
  7121. /** Function: registerSASLMechanism
  7122. *
  7123. * Register a single SASL mechanism, to be supported by this client.
  7124. *
  7125. * Parameters:
  7126. * (Object) mechanism - Object with a Strophe.SASLMechanism prototype
  7127. *
  7128. */
  7129. registerSASLMechanism(Mechanism) {
  7130. const mechanism = new Mechanism();
  7131. this.mechanisms[mechanism.mechname] = mechanism;
  7132. }
  7133. /** Function: disconnect
  7134. * Start the graceful disconnection process.
  7135. *
  7136. * This function starts the disconnection process. This process starts
  7137. * by sending unavailable presence and sending BOSH body of type
  7138. * terminate. A timeout handler makes sure that disconnection happens
  7139. * even if the BOSH server does not respond.
  7140. * If the Connection object isn't connected, at least tries to abort all pending requests
  7141. * so the connection object won't generate successful requests (which were already opened).
  7142. *
  7143. * The user supplied connection callback will be notified of the
  7144. * progress as this process happens.
  7145. *
  7146. * Parameters:
  7147. * (String) reason - The reason the disconnect is occuring.
  7148. */
  7149. disconnect(reason) {
  7150. this._changeConnectStatus(Strophe.Status.DISCONNECTING, reason);
  7151. if (reason) {
  7152. Strophe.warn("Disconnect was called because: " + reason);
  7153. } else {
  7154. Strophe.info("Disconnect was called");
  7155. }
  7156. if (this.connected) {
  7157. let pres = false;
  7158. this.disconnecting = true;
  7159. if (this.authenticated) {
  7160. pres = $pres({
  7161. 'xmlns': Strophe.NS.CLIENT,
  7162. 'type': 'unavailable'
  7163. });
  7164. } // setup timeout handler
  7165. this._disconnectTimeout = this._addSysTimedHandler(this.disconnection_timeout, this._onDisconnectTimeout.bind(this));
  7166. this._proto._disconnect(pres);
  7167. } else {
  7168. Strophe.warn("Disconnect was called before Strophe connected to the server");
  7169. this._proto._abortAllRequests();
  7170. this._doDisconnect();
  7171. }
  7172. }
  7173. /** PrivateFunction: _changeConnectStatus
  7174. * _Private_ helper function that makes sure plugins and the user's
  7175. * callback are notified of connection status changes.
  7176. *
  7177. * Parameters:
  7178. * (Integer) status - the new connection status, one of the values
  7179. * in Strophe.Status
  7180. * (String) condition - the error condition or null
  7181. * (XMLElement) elem - The triggering stanza.
  7182. */
  7183. _changeConnectStatus(status, condition, elem) {
  7184. // notify all plugins listening for status changes
  7185. for (const k in Strophe._connectionPlugins) {
  7186. if (Object.prototype.hasOwnProperty.call(Strophe._connectionPlugins, k)) {
  7187. const plugin = this[k];
  7188. if (plugin.statusChanged) {
  7189. try {
  7190. plugin.statusChanged(status, condition);
  7191. } catch (err) {
  7192. Strophe.error(`${k} plugin caused an exception changing status: ${err}`);
  7193. }
  7194. }
  7195. }
  7196. } // notify the user's callback
  7197. if (this.connect_callback) {
  7198. try {
  7199. this.connect_callback(status, condition, elem);
  7200. } catch (e) {
  7201. Strophe._handleError(e);
  7202. Strophe.error(`User connection callback caused an exception: ${e}`);
  7203. }
  7204. }
  7205. }
  7206. /** PrivateFunction: _doDisconnect
  7207. * _Private_ function to disconnect.
  7208. *
  7209. * This is the last piece of the disconnection logic. This resets the
  7210. * connection and alerts the user's connection callback.
  7211. */
  7212. _doDisconnect(condition) {
  7213. if (typeof this._idleTimeout === "number") {
  7214. clearTimeout(this._idleTimeout);
  7215. } // Cancel Disconnect Timeout
  7216. if (this._disconnectTimeout !== null) {
  7217. this.deleteTimedHandler(this._disconnectTimeout);
  7218. this._disconnectTimeout = null;
  7219. }
  7220. Strophe.debug("_doDisconnect was called");
  7221. this._proto._doDisconnect();
  7222. this.authenticated = false;
  7223. this.disconnecting = false;
  7224. this.restored = false; // delete handlers
  7225. this.handlers = [];
  7226. this.timedHandlers = [];
  7227. this.removeTimeds = [];
  7228. this.removeHandlers = [];
  7229. this.addTimeds = [];
  7230. this.addHandlers = []; // tell the parent we disconnected
  7231. this._changeConnectStatus(Strophe.Status.DISCONNECTED, condition);
  7232. this.connected = false;
  7233. }
  7234. /** PrivateFunction: _dataRecv
  7235. * _Private_ handler to processes incoming data from the the connection.
  7236. *
  7237. * Except for _connect_cb handling the initial connection request,
  7238. * this function handles the incoming data for all requests. This
  7239. * function also fires stanza handlers that match each incoming
  7240. * stanza.
  7241. *
  7242. * Parameters:
  7243. * (Strophe.Request) req - The request that has data ready.
  7244. * (string) req - The stanza a raw string (optiona).
  7245. */
  7246. _dataRecv(req, raw) {
  7247. const elem = this._proto._reqToData(req);
  7248. if (elem === null) {
  7249. return;
  7250. }
  7251. if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
  7252. if (elem.nodeName === this._proto.strip && elem.childNodes.length) {
  7253. this.xmlInput(elem.childNodes[0]);
  7254. } else {
  7255. this.xmlInput(elem);
  7256. }
  7257. }
  7258. if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
  7259. if (raw) {
  7260. this.rawInput(raw);
  7261. } else {
  7262. this.rawInput(Strophe.serialize(elem));
  7263. }
  7264. } // remove handlers scheduled for deletion
  7265. while (this.removeHandlers.length > 0) {
  7266. const hand = this.removeHandlers.pop();
  7267. const i = this.handlers.indexOf(hand);
  7268. if (i >= 0) {
  7269. this.handlers.splice(i, 1);
  7270. }
  7271. } // add handlers scheduled for addition
  7272. while (this.addHandlers.length > 0) {
  7273. this.handlers.push(this.addHandlers.pop());
  7274. } // handle graceful disconnect
  7275. if (this.disconnecting && this._proto._emptyQueue()) {
  7276. this._doDisconnect();
  7277. return;
  7278. }
  7279. const type = elem.getAttribute("type");
  7280. if (type !== null && type === "terminate") {
  7281. // Don't process stanzas that come in after disconnect
  7282. if (this.disconnecting) {
  7283. return;
  7284. } // an error occurred
  7285. let cond = elem.getAttribute("condition");
  7286. const conflict = elem.getElementsByTagName("conflict");
  7287. if (cond !== null) {
  7288. if (cond === "remote-stream-error" && conflict.length > 0) {
  7289. cond = "conflict";
  7290. }
  7291. this._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
  7292. } else {
  7293. this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.UNKOWN_REASON);
  7294. }
  7295. this._doDisconnect(cond);
  7296. return;
  7297. } // send each incoming stanza through the handler chain
  7298. Strophe.forEachChild(elem, null, child => {
  7299. const matches = [];
  7300. this.handlers = this.handlers.reduce((handlers, handler) => {
  7301. try {
  7302. if (handler.isMatch(child) && (this.authenticated || !handler.user)) {
  7303. if (handler.run(child)) {
  7304. handlers.push(handler);
  7305. }
  7306. matches.push(handler);
  7307. } else {
  7308. handlers.push(handler);
  7309. }
  7310. } catch (e) {
  7311. // if the handler throws an exception, we consider it as false
  7312. Strophe.warn('Removing Strophe handlers due to uncaught exception: ' + e.message);
  7313. }
  7314. return handlers;
  7315. }, []); // If no handler was fired for an incoming IQ with type="set",
  7316. // then we return an IQ error stanza with service-unavailable.
  7317. if (!matches.length && this.iqFallbackHandler.isMatch(child)) {
  7318. this.iqFallbackHandler.run(child);
  7319. }
  7320. });
  7321. }
  7322. /** PrivateFunction: _connect_cb
  7323. * _Private_ handler for initial connection request.
  7324. *
  7325. * This handler is used to process the initial connection request
  7326. * response from the BOSH server. It is used to set up authentication
  7327. * handlers and start the authentication process.
  7328. *
  7329. * SASL authentication will be attempted if available, otherwise
  7330. * the code will fall back to legacy authentication.
  7331. *
  7332. * Parameters:
  7333. * (Strophe.Request) req - The current request.
  7334. * (Function) _callback - low level (xmpp) connect callback function.
  7335. * Useful for plugins with their own xmpp connect callback (when they
  7336. * want to do something special).
  7337. */
  7338. _connect_cb(req, _callback, raw) {
  7339. Strophe.debug("_connect_cb was called");
  7340. this.connected = true;
  7341. let bodyWrap;
  7342. try {
  7343. bodyWrap = this._proto._reqToData(req);
  7344. } catch (e) {
  7345. if (e.name !== Strophe.ErrorCondition.BAD_FORMAT) {
  7346. throw e;
  7347. }
  7348. this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.BAD_FORMAT);
  7349. this._doDisconnect(Strophe.ErrorCondition.BAD_FORMAT);
  7350. }
  7351. if (!bodyWrap) {
  7352. return;
  7353. }
  7354. if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
  7355. if (bodyWrap.nodeName === this._proto.strip && bodyWrap.childNodes.length) {
  7356. this.xmlInput(bodyWrap.childNodes[0]);
  7357. } else {
  7358. this.xmlInput(bodyWrap);
  7359. }
  7360. }
  7361. if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
  7362. if (raw) {
  7363. this.rawInput(raw);
  7364. } else {
  7365. this.rawInput(Strophe.serialize(bodyWrap));
  7366. }
  7367. }
  7368. const conncheck = this._proto._connect_cb(bodyWrap);
  7369. if (conncheck === Strophe.Status.CONNFAIL) {
  7370. return;
  7371. } // Check for the stream:features tag
  7372. let hasFeatures;
  7373. if (bodyWrap.getElementsByTagNameNS) {
  7374. hasFeatures = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "features").length > 0;
  7375. } else {
  7376. hasFeatures = bodyWrap.getElementsByTagName("stream:features").length > 0 || bodyWrap.getElementsByTagName("features").length > 0;
  7377. }
  7378. if (!hasFeatures) {
  7379. this._proto._no_auth_received(_callback);
  7380. return;
  7381. }
  7382. const matched = Array.from(bodyWrap.getElementsByTagName("mechanism")).map(m => this.mechanisms[m.textContent]).filter(m => m);
  7383. if (matched.length === 0) {
  7384. if (bodyWrap.getElementsByTagName("auth").length === 0) {
  7385. // There are no matching SASL mechanisms and also no legacy
  7386. // auth available.
  7387. this._proto._no_auth_received(_callback);
  7388. return;
  7389. }
  7390. }
  7391. if (this.do_authentication !== false) {
  7392. this.authenticate(matched);
  7393. }
  7394. }
  7395. /** Function: sortMechanismsByPriority
  7396. *
  7397. * Sorts an array of objects with prototype SASLMechanism according to
  7398. * their priorities.
  7399. *
  7400. * Parameters:
  7401. * (Array) mechanisms - Array of SASL mechanisms.
  7402. *
  7403. */
  7404. sortMechanismsByPriority(mechanisms) {
  7405. // eslint-disable-line class-methods-use-this
  7406. // Sorting mechanisms according to priority.
  7407. for (let i = 0; i < mechanisms.length - 1; ++i) {
  7408. let higher = i;
  7409. for (let j = i + 1; j < mechanisms.length; ++j) {
  7410. if (mechanisms[j].priority > mechanisms[higher].priority) {
  7411. higher = j;
  7412. }
  7413. }
  7414. if (higher !== i) {
  7415. const swap = mechanisms[i];
  7416. mechanisms[i] = mechanisms[higher];
  7417. mechanisms[higher] = swap;
  7418. }
  7419. }
  7420. return mechanisms;
  7421. }
  7422. /** Function: authenticate
  7423. * Set up authentication
  7424. *
  7425. * Continues the initial connection request by setting up authentication
  7426. * handlers and starting the authentication process.
  7427. *
  7428. * SASL authentication will be attempted if available, otherwise
  7429. * the code will fall back to legacy authentication.
  7430. *
  7431. * Parameters:
  7432. * (Array) matched - Array of SASL mechanisms supported.
  7433. *
  7434. */
  7435. authenticate(matched) {
  7436. if (!this._attemptSASLAuth(matched)) {
  7437. this._attemptLegacyAuth();
  7438. }
  7439. }
  7440. /** PrivateFunction: _attemptSASLAuth
  7441. *
  7442. * Iterate through an array of SASL mechanisms and attempt authentication
  7443. * with the highest priority (enabled) mechanism.
  7444. *
  7445. * Parameters:
  7446. * (Array) mechanisms - Array of SASL mechanisms.
  7447. *
  7448. * Returns:
  7449. * (Boolean) mechanism_found - true or false, depending on whether a
  7450. * valid SASL mechanism was found with which authentication could be
  7451. * started.
  7452. */
  7453. _attemptSASLAuth(mechanisms) {
  7454. mechanisms = this.sortMechanismsByPriority(mechanisms || []);
  7455. let mechanism_found = false;
  7456. for (let i = 0; i < mechanisms.length; ++i) {
  7457. if (!mechanisms[i].test(this)) {
  7458. continue;
  7459. }
  7460. this._sasl_success_handler = this._addSysHandler(this._sasl_success_cb.bind(this), null, "success", null, null);
  7461. this._sasl_failure_handler = this._addSysHandler(this._sasl_failure_cb.bind(this), null, "failure", null, null);
  7462. this._sasl_challenge_handler = this._addSysHandler(this._sasl_challenge_cb.bind(this), null, "challenge", null, null);
  7463. this._sasl_mechanism = mechanisms[i];
  7464. this._sasl_mechanism.onStart(this);
  7465. const request_auth_exchange = $build("auth", {
  7466. 'xmlns': Strophe.NS.SASL,
  7467. 'mechanism': this._sasl_mechanism.mechname
  7468. });
  7469. if (this._sasl_mechanism.isClientFirst) {
  7470. const response = this._sasl_mechanism.clientChallenge(this);
  7471. request_auth_exchange.t((0,abab.btoa)(response));
  7472. }
  7473. this.send(request_auth_exchange.tree());
  7474. mechanism_found = true;
  7475. break;
  7476. }
  7477. return mechanism_found;
  7478. }
  7479. /** PrivateFunction: _sasl_challenge_cb
  7480. * _Private_ handler for the SASL challenge
  7481. *
  7482. */
  7483. _sasl_challenge_cb(elem) {
  7484. const challenge = (0,abab.atob)(Strophe.getText(elem));
  7485. const response = this._sasl_mechanism.onChallenge(this, challenge);
  7486. const stanza = $build('response', {
  7487. 'xmlns': Strophe.NS.SASL
  7488. });
  7489. if (response !== "") {
  7490. stanza.t((0,abab.btoa)(response));
  7491. }
  7492. this.send(stanza.tree());
  7493. return true;
  7494. }
  7495. /** PrivateFunction: _attemptLegacyAuth
  7496. *
  7497. * Attempt legacy (i.e. non-SASL) authentication.
  7498. */
  7499. _attemptLegacyAuth() {
  7500. if (Strophe.getNodeFromJid(this.jid) === null) {
  7501. // we don't have a node, which is required for non-anonymous
  7502. // client connections
  7503. this._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.MISSING_JID_NODE);
  7504. this.disconnect(Strophe.ErrorCondition.MISSING_JID_NODE);
  7505. } else {
  7506. // Fall back to legacy authentication
  7507. this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null);
  7508. this._addSysHandler(this._onLegacyAuthIQResult.bind(this), null, null, null, "_auth_1");
  7509. this.send($iq({
  7510. 'type': "get",
  7511. 'to': this.domain,
  7512. 'id': "_auth_1"
  7513. }).c("query", {
  7514. xmlns: Strophe.NS.AUTH
  7515. }).c("username", {}).t(Strophe.getNodeFromJid(this.jid)).tree());
  7516. }
  7517. }
  7518. /** PrivateFunction: _onLegacyAuthIQResult
  7519. * _Private_ handler for legacy authentication.
  7520. *
  7521. * This handler is called in response to the initial <iq type='get'/>
  7522. * for legacy authentication. It builds an authentication <iq/> and
  7523. * sends it, creating a handler (calling back to _auth2_cb()) to
  7524. * handle the result
  7525. *
  7526. * Parameters:
  7527. * (XMLElement) elem - The stanza that triggered the callback.
  7528. *
  7529. * Returns:
  7530. * false to remove the handler.
  7531. */
  7532. _onLegacyAuthIQResult(elem) {
  7533. // eslint-disable-line no-unused-vars
  7534. // build plaintext auth iq
  7535. const iq = $iq({
  7536. type: "set",
  7537. id: "_auth_2"
  7538. }).c('query', {
  7539. xmlns: Strophe.NS.AUTH
  7540. }).c('username', {}).t(Strophe.getNodeFromJid(this.jid)).up().c('password').t(this.pass);
  7541. if (!Strophe.getResourceFromJid(this.jid)) {
  7542. // since the user has not supplied a resource, we pick
  7543. // a default one here. unlike other auth methods, the server
  7544. // cannot do this for us.
  7545. this.jid = Strophe.getBareJidFromJid(this.jid) + '/strophe';
  7546. }
  7547. iq.up().c('resource', {}).t(Strophe.getResourceFromJid(this.jid));
  7548. this._addSysHandler(this._auth2_cb.bind(this), null, null, null, "_auth_2");
  7549. this.send(iq.tree());
  7550. return false;
  7551. }
  7552. /** PrivateFunction: _sasl_success_cb
  7553. * _Private_ handler for succesful SASL authentication.
  7554. *
  7555. * Parameters:
  7556. * (XMLElement) elem - The matching stanza.
  7557. *
  7558. * Returns:
  7559. * false to remove the handler.
  7560. */
  7561. _sasl_success_cb(elem) {
  7562. if (this._sasl_data["server-signature"]) {
  7563. let serverSignature;
  7564. const success = (0,abab.atob)(Strophe.getText(elem));
  7565. const attribMatch = /([a-z]+)=([^,]+)(,|$)/;
  7566. const matches = success.match(attribMatch);
  7567. if (matches[1] === "v") {
  7568. serverSignature = matches[2];
  7569. }
  7570. if (serverSignature !== this._sasl_data["server-signature"]) {
  7571. // remove old handlers
  7572. this.deleteHandler(this._sasl_failure_handler);
  7573. this._sasl_failure_handler = null;
  7574. if (this._sasl_challenge_handler) {
  7575. this.deleteHandler(this._sasl_challenge_handler);
  7576. this._sasl_challenge_handler = null;
  7577. }
  7578. this._sasl_data = {};
  7579. return this._sasl_failure_cb(null);
  7580. }
  7581. }
  7582. Strophe.info("SASL authentication succeeded.");
  7583. if (this._sasl_mechanism) {
  7584. this._sasl_mechanism.onSuccess();
  7585. } // remove old handlers
  7586. this.deleteHandler(this._sasl_failure_handler);
  7587. this._sasl_failure_handler = null;
  7588. if (this._sasl_challenge_handler) {
  7589. this.deleteHandler(this._sasl_challenge_handler);
  7590. this._sasl_challenge_handler = null;
  7591. }
  7592. const streamfeature_handlers = [];
  7593. const wrapper = (handlers, elem) => {
  7594. while (handlers.length) {
  7595. this.deleteHandler(handlers.pop());
  7596. }
  7597. this._onStreamFeaturesAfterSASL(elem);
  7598. return false;
  7599. };
  7600. streamfeature_handlers.push(this._addSysHandler(elem => wrapper(streamfeature_handlers, elem), null, "stream:features", null, null));
  7601. streamfeature_handlers.push(this._addSysHandler(elem => wrapper(streamfeature_handlers, elem), Strophe.NS.STREAM, "features", null, null)); // we must send an xmpp:restart now
  7602. this._sendRestart();
  7603. return false;
  7604. }
  7605. /** PrivateFunction: _onStreamFeaturesAfterSASL
  7606. * Parameters:
  7607. * (XMLElement) elem - The matching stanza.
  7608. *
  7609. * Returns:
  7610. * false to remove the handler.
  7611. */
  7612. _onStreamFeaturesAfterSASL(elem) {
  7613. // save stream:features for future usage
  7614. this.features = elem;
  7615. for (let i = 0; i < elem.childNodes.length; i++) {
  7616. const child = elem.childNodes[i];
  7617. if (child.nodeName === 'bind') {
  7618. this.do_bind = true;
  7619. }
  7620. if (child.nodeName === 'session') {
  7621. this.do_session = true;
  7622. }
  7623. }
  7624. if (!this.do_bind) {
  7625. this._changeConnectStatus(Strophe.Status.AUTHFAIL, null);
  7626. return false;
  7627. } else if (!this.options.explicitResourceBinding) {
  7628. this.bind();
  7629. } else {
  7630. this._changeConnectStatus(Strophe.Status.BINDREQUIRED, null);
  7631. }
  7632. return false;
  7633. }
  7634. /** Function: bind
  7635. *
  7636. * Sends an IQ to the XMPP server to bind a JID resource for this session.
  7637. *
  7638. * https://tools.ietf.org/html/rfc6120#section-7.5
  7639. *
  7640. * If `explicitResourceBinding` was set to a truthy value in the options
  7641. * passed to the Strophe.Connection constructor, then this function needs
  7642. * to be called explicitly by the client author.
  7643. *
  7644. * Otherwise it'll be called automatically as soon as the XMPP server
  7645. * advertises the "urn:ietf:params:xml:ns:xmpp-bind" stream feature.
  7646. */
  7647. bind() {
  7648. if (!this.do_bind) {
  7649. Strophe.log(Strophe.LogLevel.INFO, `Strophe.Connection.prototype.bind called but "do_bind" is false`);
  7650. return;
  7651. }
  7652. this._addSysHandler(this._onResourceBindResultIQ.bind(this), null, null, null, "_bind_auth_2");
  7653. const resource = Strophe.getResourceFromJid(this.jid);
  7654. if (resource) {
  7655. this.send($iq({
  7656. type: "set",
  7657. id: "_bind_auth_2"
  7658. }).c('bind', {
  7659. xmlns: Strophe.NS.BIND
  7660. }).c('resource', {}).t(resource).tree());
  7661. } else {
  7662. this.send($iq({
  7663. type: "set",
  7664. id: "_bind_auth_2"
  7665. }).c('bind', {
  7666. xmlns: Strophe.NS.BIND
  7667. }).tree());
  7668. }
  7669. }
  7670. /** PrivateFunction: _onResourceBindIQ
  7671. * _Private_ handler for binding result and session start.
  7672. *
  7673. * Parameters:
  7674. * (XMLElement) elem - The matching stanza.
  7675. *
  7676. * Returns:
  7677. * false to remove the handler.
  7678. */
  7679. _onResourceBindResultIQ(elem) {
  7680. if (elem.getAttribute("type") === "error") {
  7681. Strophe.warn("Resource binding failed.");
  7682. const conflict = elem.getElementsByTagName("conflict");
  7683. let condition;
  7684. if (conflict.length > 0) {
  7685. condition = Strophe.ErrorCondition.CONFLICT;
  7686. }
  7687. this._changeConnectStatus(Strophe.Status.AUTHFAIL, condition, elem);
  7688. return false;
  7689. } // TODO - need to grab errors
  7690. const bind = elem.getElementsByTagName("bind");
  7691. if (bind.length > 0) {
  7692. const jidNode = bind[0].getElementsByTagName("jid");
  7693. if (jidNode.length > 0) {
  7694. this.authenticated = true;
  7695. this.jid = Strophe.getText(jidNode[0]);
  7696. if (this.do_session) {
  7697. this._establishSession();
  7698. } else {
  7699. this._changeConnectStatus(Strophe.Status.CONNECTED, null);
  7700. }
  7701. }
  7702. } else {
  7703. Strophe.warn("Resource binding failed.");
  7704. this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
  7705. return false;
  7706. }
  7707. }
  7708. /** PrivateFunction: _establishSession
  7709. * Send IQ request to establish a session with the XMPP server.
  7710. *
  7711. * See https://xmpp.org/rfcs/rfc3921.html#session
  7712. *
  7713. * Note: The protocol for session establishment has been determined as
  7714. * unnecessary and removed in RFC-6121.
  7715. */
  7716. _establishSession() {
  7717. if (!this.do_session) {
  7718. throw new Error(`Strophe.Connection.prototype._establishSession ` + `called but apparently ${Strophe.NS.SESSION} wasn't advertised by the server`);
  7719. }
  7720. this._addSysHandler(this._onSessionResultIQ.bind(this), null, null, null, "_session_auth_2");
  7721. this.send($iq({
  7722. type: "set",
  7723. id: "_session_auth_2"
  7724. }).c('session', {
  7725. xmlns: Strophe.NS.SESSION
  7726. }).tree());
  7727. }
  7728. /** PrivateFunction: _onSessionResultIQ
  7729. * _Private_ handler for the server's IQ response to a client's session
  7730. * request.
  7731. *
  7732. * This sets Connection.authenticated to true on success, which
  7733. * starts the processing of user handlers.
  7734. *
  7735. * See https://xmpp.org/rfcs/rfc3921.html#session
  7736. *
  7737. * Note: The protocol for session establishment has been determined as
  7738. * unnecessary and removed in RFC-6121.
  7739. *
  7740. * Parameters:
  7741. * (XMLElement) elem - The matching stanza.
  7742. *
  7743. * Returns:
  7744. * false to remove the handler.
  7745. */
  7746. _onSessionResultIQ(elem) {
  7747. if (elem.getAttribute("type") === "result") {
  7748. this.authenticated = true;
  7749. this._changeConnectStatus(Strophe.Status.CONNECTED, null);
  7750. } else if (elem.getAttribute("type") === "error") {
  7751. this.authenticated = false;
  7752. Strophe.warn("Session creation failed.");
  7753. this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
  7754. return false;
  7755. }
  7756. return false;
  7757. }
  7758. /** PrivateFunction: _sasl_failure_cb
  7759. * _Private_ handler for SASL authentication failure.
  7760. *
  7761. * Parameters:
  7762. * (XMLElement) elem - The matching stanza.
  7763. *
  7764. * Returns:
  7765. * false to remove the handler.
  7766. */
  7767. _sasl_failure_cb(elem) {
  7768. // delete unneeded handlers
  7769. if (this._sasl_success_handler) {
  7770. this.deleteHandler(this._sasl_success_handler);
  7771. this._sasl_success_handler = null;
  7772. }
  7773. if (this._sasl_challenge_handler) {
  7774. this.deleteHandler(this._sasl_challenge_handler);
  7775. this._sasl_challenge_handler = null;
  7776. }
  7777. if (this._sasl_mechanism) this._sasl_mechanism.onFailure();
  7778. this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
  7779. return false;
  7780. }
  7781. /** PrivateFunction: _auth2_cb
  7782. * _Private_ handler to finish legacy authentication.
  7783. *
  7784. * This handler is called when the result from the jabber:iq:auth
  7785. * <iq/> stanza is returned.
  7786. *
  7787. * Parameters:
  7788. * (XMLElement) elem - The stanza that triggered the callback.
  7789. *
  7790. * Returns:
  7791. * false to remove the handler.
  7792. */
  7793. _auth2_cb(elem) {
  7794. if (elem.getAttribute("type") === "result") {
  7795. this.authenticated = true;
  7796. this._changeConnectStatus(Strophe.Status.CONNECTED, null);
  7797. } else if (elem.getAttribute("type") === "error") {
  7798. this._changeConnectStatus(Strophe.Status.AUTHFAIL, null, elem);
  7799. this.disconnect('authentication failed');
  7800. }
  7801. return false;
  7802. }
  7803. /** PrivateFunction: _addSysTimedHandler
  7804. * _Private_ function to add a system level timed handler.
  7805. *
  7806. * This function is used to add a Strophe.TimedHandler for the
  7807. * library code. System timed handlers are allowed to run before
  7808. * authentication is complete.
  7809. *
  7810. * Parameters:
  7811. * (Integer) period - The period of the handler.
  7812. * (Function) handler - The callback function.
  7813. */
  7814. _addSysTimedHandler(period, handler) {
  7815. const thand = new Strophe.TimedHandler(period, handler);
  7816. thand.user = false;
  7817. this.addTimeds.push(thand);
  7818. return thand;
  7819. }
  7820. /** PrivateFunction: _addSysHandler
  7821. * _Private_ function to add a system level stanza handler.
  7822. *
  7823. * This function is used to add a Strophe.Handler for the
  7824. * library code. System stanza handlers are allowed to run before
  7825. * authentication is complete.
  7826. *
  7827. * Parameters:
  7828. * (Function) handler - The callback function.
  7829. * (String) ns - The namespace to match.
  7830. * (String) name - The stanza name to match.
  7831. * (String) type - The stanza type attribute to match.
  7832. * (String) id - The stanza id attribute to match.
  7833. */
  7834. _addSysHandler(handler, ns, name, type, id) {
  7835. const hand = new Strophe.Handler(handler, ns, name, type, id);
  7836. hand.user = false;
  7837. this.addHandlers.push(hand);
  7838. return hand;
  7839. }
  7840. /** PrivateFunction: _onDisconnectTimeout
  7841. * _Private_ timeout handler for handling non-graceful disconnection.
  7842. *
  7843. * If the graceful disconnect process does not complete within the
  7844. * time allotted, this handler finishes the disconnect anyway.
  7845. *
  7846. * Returns:
  7847. * false to remove the handler.
  7848. */
  7849. _onDisconnectTimeout() {
  7850. Strophe.debug("_onDisconnectTimeout was called");
  7851. this._changeConnectStatus(Strophe.Status.CONNTIMEOUT, null);
  7852. this._proto._onDisconnectTimeout(); // actually disconnect
  7853. this._doDisconnect();
  7854. return false;
  7855. }
  7856. /** PrivateFunction: _onIdle
  7857. * _Private_ handler to process events during idle cycle.
  7858. *
  7859. * This handler is called every 100ms to fire timed handlers that
  7860. * are ready and keep poll requests going.
  7861. */
  7862. _onIdle() {
  7863. // add timed handlers scheduled for addition
  7864. // NOTE: we add before remove in the case a timed handler is
  7865. // added and then deleted before the next _onIdle() call.
  7866. while (this.addTimeds.length > 0) {
  7867. this.timedHandlers.push(this.addTimeds.pop());
  7868. } // remove timed handlers that have been scheduled for deletion
  7869. while (this.removeTimeds.length > 0) {
  7870. const thand = this.removeTimeds.pop();
  7871. const i = this.timedHandlers.indexOf(thand);
  7872. if (i >= 0) {
  7873. this.timedHandlers.splice(i, 1);
  7874. }
  7875. } // call ready timed handlers
  7876. const now = new Date().getTime();
  7877. const newList = [];
  7878. for (let i = 0; i < this.timedHandlers.length; i++) {
  7879. const thand = this.timedHandlers[i];
  7880. if (this.authenticated || !thand.user) {
  7881. const since = thand.lastCalled + thand.period;
  7882. if (since - now <= 0) {
  7883. if (thand.run()) {
  7884. newList.push(thand);
  7885. }
  7886. } else {
  7887. newList.push(thand);
  7888. }
  7889. }
  7890. }
  7891. this.timedHandlers = newList;
  7892. clearTimeout(this._idleTimeout);
  7893. this._proto._onIdle(); // reactivate the timer only if connected
  7894. if (this.connected) {
  7895. this._idleTimeout = setTimeout(() => this._onIdle(), 100);
  7896. }
  7897. }
  7898. };
  7899. Strophe.SASLMechanism = SASLMechanism;
  7900. /** Constants: SASL mechanisms
  7901. * Available authentication mechanisms
  7902. *
  7903. * Strophe.SASLAnonymous - SASL ANONYMOUS authentication.
  7904. * Strophe.SASLPlain - SASL PLAIN authentication.
  7905. * Strophe.SASLSHA1 - SASL SCRAM-SHA-1 authentication
  7906. * Strophe.SASLOAuthBearer - SASL OAuth Bearer authentication
  7907. * Strophe.SASLExternal - SASL EXTERNAL authentication
  7908. * Strophe.SASLXOAuth2 - SASL X-OAuth2 authentication
  7909. */
  7910. Strophe.SASLAnonymous = SASLAnonymous;
  7911. Strophe.SASLPlain = SASLPlain;
  7912. Strophe.SASLSHA1 = SASLSHA1;
  7913. Strophe.SASLOAuthBearer = SASLOAuthBearer;
  7914. Strophe.SASLExternal = SASLExternal;
  7915. Strophe.SASLXOAuth2 = SASLXOAuth2;
  7916. /* harmony default export */ const core = ({
  7917. 'Strophe': Strophe,
  7918. '$build': $build,
  7919. '$iq': $iq,
  7920. '$msg': $msg,
  7921. '$pres': $pres,
  7922. 'SHA1': SHA1,
  7923. 'MD5': MD5,
  7924. 'b64_hmac_sha1': SHA1.b64_hmac_sha1,
  7925. 'b64_sha1': SHA1.b64_sha1,
  7926. 'str_hmac_sha1': SHA1.str_hmac_sha1,
  7927. 'str_sha1': SHA1.str_sha1
  7928. });
  7929. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/bosh.js
  7930. /*
  7931. This program is distributed under the terms of the MIT license.
  7932. Please see the LICENSE file for details.
  7933. Copyright 2006-2008, OGG, LLC
  7934. */
  7935. /* global ActiveXObject */
  7936. /** PrivateClass: Strophe.Request
  7937. * _Private_ helper class that provides a cross implementation abstraction
  7938. * for a BOSH related XMLHttpRequest.
  7939. *
  7940. * The Strophe.Request class is used internally to encapsulate BOSH request
  7941. * information. It is not meant to be used from user's code.
  7942. */
  7943. Strophe.Request = class Request {
  7944. /** PrivateConstructor: Strophe.Request
  7945. * Create and initialize a new Strophe.Request object.
  7946. *
  7947. * Parameters:
  7948. * (XMLElement) elem - The XML data to be sent in the request.
  7949. * (Function) func - The function that will be called when the
  7950. * XMLHttpRequest readyState changes.
  7951. * (Integer) rid - The BOSH rid attribute associated with this request.
  7952. * (Integer) sends - The number of times this same request has been sent.
  7953. */
  7954. constructor(elem, func, rid, sends) {
  7955. this.id = ++Strophe._requestId;
  7956. this.xmlData = elem;
  7957. this.data = Strophe.serialize(elem); // save original function in case we need to make a new request
  7958. // from this one.
  7959. this.origFunc = func;
  7960. this.func = func;
  7961. this.rid = rid;
  7962. this.date = NaN;
  7963. this.sends = sends || 0;
  7964. this.abort = false;
  7965. this.dead = null;
  7966. this.age = function () {
  7967. if (!this.date) {
  7968. return 0;
  7969. }
  7970. const now = new Date();
  7971. return (now - this.date) / 1000;
  7972. };
  7973. this.timeDead = function () {
  7974. if (!this.dead) {
  7975. return 0;
  7976. }
  7977. const now = new Date();
  7978. return (now - this.dead) / 1000;
  7979. };
  7980. this.xhr = this._newXHR();
  7981. }
  7982. /** PrivateFunction: getResponse
  7983. * Get a response from the underlying XMLHttpRequest.
  7984. *
  7985. * This function attempts to get a response from the request and checks
  7986. * for errors.
  7987. *
  7988. * Throws:
  7989. * "parsererror" - A parser error occured.
  7990. * "bad-format" - The entity has sent XML that cannot be processed.
  7991. *
  7992. * Returns:
  7993. * The DOM element tree of the response.
  7994. */
  7995. getResponse() {
  7996. let node = null;
  7997. if (this.xhr.responseXML && this.xhr.responseXML.documentElement) {
  7998. node = this.xhr.responseXML.documentElement;
  7999. if (node.tagName === "parsererror") {
  8000. Strophe.error("invalid response received");
  8001. Strophe.error("responseText: " + this.xhr.responseText);
  8002. Strophe.error("responseXML: " + Strophe.serialize(this.xhr.responseXML));
  8003. throw new Error("parsererror");
  8004. }
  8005. } else if (this.xhr.responseText) {
  8006. // In React Native, we may get responseText but no responseXML. We can try to parse it manually.
  8007. Strophe.debug("Got responseText but no responseXML; attempting to parse it with DOMParser...");
  8008. node = new strophe_shims_DOMParser().parseFromString(this.xhr.responseText, 'application/xml').documentElement;
  8009. if (!node) {
  8010. throw new Error('Parsing produced null node');
  8011. } else if (node.querySelector('parsererror')) {
  8012. Strophe.error("invalid response received: " + node.querySelector('parsererror').textContent);
  8013. Strophe.error("responseText: " + this.xhr.responseText);
  8014. const error = new Error();
  8015. error.name = Strophe.ErrorCondition.BAD_FORMAT;
  8016. throw error;
  8017. }
  8018. }
  8019. return node;
  8020. }
  8021. /** PrivateFunction: _newXHR
  8022. * _Private_ helper function to create XMLHttpRequests.
  8023. *
  8024. * This function creates XMLHttpRequests across all implementations.
  8025. *
  8026. * Returns:
  8027. * A new XMLHttpRequest.
  8028. */
  8029. _newXHR() {
  8030. let xhr = null;
  8031. if (window.XMLHttpRequest) {
  8032. xhr = new XMLHttpRequest();
  8033. if (xhr.overrideMimeType) {
  8034. xhr.overrideMimeType("text/xml; charset=utf-8");
  8035. }
  8036. } else if (window.ActiveXObject) {
  8037. xhr = new ActiveXObject("Microsoft.XMLHTTP");
  8038. } // use Function.bind() to prepend ourselves as an argument
  8039. xhr.onreadystatechange = this.func.bind(null, this);
  8040. return xhr;
  8041. }
  8042. };
  8043. /** Class: Strophe.Bosh
  8044. * _Private_ helper class that handles BOSH Connections
  8045. *
  8046. * The Strophe.Bosh class is used internally by Strophe.Connection
  8047. * to encapsulate BOSH sessions. It is not meant to be used from user's code.
  8048. */
  8049. /** File: bosh.js
  8050. * A JavaScript library to enable BOSH in Strophejs.
  8051. *
  8052. * this library uses Bidirectional-streams Over Synchronous HTTP (BOSH)
  8053. * to emulate a persistent, stateful, two-way connection to an XMPP server.
  8054. * More information on BOSH can be found in XEP 124.
  8055. */
  8056. /** PrivateConstructor: Strophe.Bosh
  8057. * Create and initialize a Strophe.Bosh object.
  8058. *
  8059. * Parameters:
  8060. * (Strophe.Connection) connection - The Strophe.Connection that will use BOSH.
  8061. *
  8062. * Returns:
  8063. * A new Strophe.Bosh object.
  8064. */
  8065. Strophe.Bosh = class Bosh {
  8066. constructor(connection) {
  8067. this._conn = connection;
  8068. /* request id for body tags */
  8069. this.rid = Math.floor(Math.random() * 4294967295);
  8070. /* The current session ID. */
  8071. this.sid = null; // default BOSH values
  8072. this.hold = 1;
  8073. this.wait = 60;
  8074. this.window = 5;
  8075. this.errors = 0;
  8076. this.inactivity = null;
  8077. this.lastResponseHeaders = null;
  8078. this._requests = [];
  8079. }
  8080. /** PrivateFunction: _buildBody
  8081. * _Private_ helper function to generate the <body/> wrapper for BOSH.
  8082. *
  8083. * Returns:
  8084. * A Strophe.Builder with a <body/> element.
  8085. */
  8086. _buildBody() {
  8087. const bodyWrap = $build('body', {
  8088. 'rid': this.rid++,
  8089. 'xmlns': Strophe.NS.HTTPBIND
  8090. });
  8091. if (this.sid !== null) {
  8092. bodyWrap.attrs({
  8093. 'sid': this.sid
  8094. });
  8095. }
  8096. if (this._conn.options.keepalive && this._conn._sessionCachingSupported()) {
  8097. this._cacheSession();
  8098. }
  8099. return bodyWrap;
  8100. }
  8101. /** PrivateFunction: _reset
  8102. * Reset the connection.
  8103. *
  8104. * This function is called by the reset function of the Strophe Connection
  8105. */
  8106. _reset() {
  8107. this.rid = Math.floor(Math.random() * 4294967295);
  8108. this.sid = null;
  8109. this.errors = 0;
  8110. if (this._conn._sessionCachingSupported()) {
  8111. window.sessionStorage.removeItem('strophe-bosh-session');
  8112. }
  8113. this._conn.nextValidRid(this.rid);
  8114. }
  8115. /** PrivateFunction: _connect
  8116. * _Private_ function that initializes the BOSH connection.
  8117. *
  8118. * Creates and sends the Request that initializes the BOSH connection.
  8119. */
  8120. _connect(wait, hold, route) {
  8121. this.wait = wait || this.wait;
  8122. this.hold = hold || this.hold;
  8123. this.errors = 0;
  8124. const body = this._buildBody().attrs({
  8125. "to": this._conn.domain,
  8126. "xml:lang": "en",
  8127. "wait": this.wait,
  8128. "hold": this.hold,
  8129. "content": "text/xml; charset=utf-8",
  8130. "ver": "1.6",
  8131. "xmpp:version": "1.0",
  8132. "xmlns:xmpp": Strophe.NS.BOSH
  8133. });
  8134. if (route) {
  8135. body.attrs({
  8136. 'route': route
  8137. });
  8138. }
  8139. const _connect_cb = this._conn._connect_cb;
  8140. this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, _connect_cb.bind(this._conn)), body.tree().getAttribute("rid")));
  8141. this._throttledRequestHandler();
  8142. }
  8143. /** PrivateFunction: _attach
  8144. * Attach to an already created and authenticated BOSH session.
  8145. *
  8146. * This function is provided to allow Strophe to attach to BOSH
  8147. * sessions which have been created externally, perhaps by a Web
  8148. * application. This is often used to support auto-login type features
  8149. * without putting user credentials into the page.
  8150. *
  8151. * Parameters:
  8152. * (String) jid - The full JID that is bound by the session.
  8153. * (String) sid - The SID of the BOSH session.
  8154. * (String) rid - The current RID of the BOSH session. This RID
  8155. * will be used by the next request.
  8156. * (Function) callback The connect callback function.
  8157. * (Integer) wait - The optional HTTPBIND wait value. This is the
  8158. * time the server will wait before returning an empty result for
  8159. * a request. The default setting of 60 seconds is recommended.
  8160. * Other settings will require tweaks to the Strophe.TIMEOUT value.
  8161. * (Integer) hold - The optional HTTPBIND hold value. This is the
  8162. * number of connections the server will hold at one time. This
  8163. * should almost always be set to 1 (the default).
  8164. * (Integer) wind - The optional HTTBIND window value. This is the
  8165. * allowed range of request ids that are valid. The default is 5.
  8166. */
  8167. _attach(jid, sid, rid, callback, wait, hold, wind) {
  8168. this._conn.jid = jid;
  8169. this.sid = sid;
  8170. this.rid = rid;
  8171. this._conn.connect_callback = callback;
  8172. this._conn.domain = Strophe.getDomainFromJid(this._conn.jid);
  8173. this._conn.authenticated = true;
  8174. this._conn.connected = true;
  8175. this.wait = wait || this.wait;
  8176. this.hold = hold || this.hold;
  8177. this.window = wind || this.window;
  8178. this._conn._changeConnectStatus(Strophe.Status.ATTACHED, null);
  8179. }
  8180. /** PrivateFunction: _restore
  8181. * Attempt to restore a cached BOSH session
  8182. *
  8183. * Parameters:
  8184. * (String) jid - The full JID that is bound by the session.
  8185. * This parameter is optional but recommended, specifically in cases
  8186. * where prebinded BOSH sessions are used where it's important to know
  8187. * that the right session is being restored.
  8188. * (Function) callback The connect callback function.
  8189. * (Integer) wait - The optional HTTPBIND wait value. This is the
  8190. * time the server will wait before returning an empty result for
  8191. * a request. The default setting of 60 seconds is recommended.
  8192. * Other settings will require tweaks to the Strophe.TIMEOUT value.
  8193. * (Integer) hold - The optional HTTPBIND hold value. This is the
  8194. * number of connections the server will hold at one time. This
  8195. * should almost always be set to 1 (the default).
  8196. * (Integer) wind - The optional HTTBIND window value. This is the
  8197. * allowed range of request ids that are valid. The default is 5.
  8198. */
  8199. _restore(jid, callback, wait, hold, wind) {
  8200. const session = JSON.parse(window.sessionStorage.getItem('strophe-bosh-session'));
  8201. if (typeof session !== "undefined" && session !== null && session.rid && session.sid && session.jid && (typeof jid === "undefined" || jid === null || Strophe.getBareJidFromJid(session.jid) === Strophe.getBareJidFromJid(jid) || // If authcid is null, then it's an anonymous login, so
  8202. // we compare only the domains:
  8203. Strophe.getNodeFromJid(jid) === null && Strophe.getDomainFromJid(session.jid) === jid)) {
  8204. this._conn.restored = true;
  8205. this._attach(session.jid, session.sid, session.rid, callback, wait, hold, wind);
  8206. } else {
  8207. const error = new Error("_restore: no restoreable session.");
  8208. error.name = "StropheSessionError";
  8209. throw error;
  8210. }
  8211. }
  8212. /** PrivateFunction: _cacheSession
  8213. * _Private_ handler for the beforeunload event.
  8214. *
  8215. * This handler is used to process the Bosh-part of the initial request.
  8216. * Parameters:
  8217. * (Strophe.Request) bodyWrap - The received stanza.
  8218. */
  8219. _cacheSession() {
  8220. if (this._conn.authenticated) {
  8221. if (this._conn.jid && this.rid && this.sid) {
  8222. window.sessionStorage.setItem('strophe-bosh-session', JSON.stringify({
  8223. 'jid': this._conn.jid,
  8224. 'rid': this.rid,
  8225. 'sid': this.sid
  8226. }));
  8227. }
  8228. } else {
  8229. window.sessionStorage.removeItem('strophe-bosh-session');
  8230. }
  8231. }
  8232. /** PrivateFunction: _connect_cb
  8233. * _Private_ handler for initial connection request.
  8234. *
  8235. * This handler is used to process the Bosh-part of the initial request.
  8236. * Parameters:
  8237. * (Strophe.Request) bodyWrap - The received stanza.
  8238. */
  8239. _connect_cb(bodyWrap) {
  8240. const typ = bodyWrap.getAttribute("type");
  8241. if (typ !== null && typ === "terminate") {
  8242. // an error occurred
  8243. let cond = bodyWrap.getAttribute("condition");
  8244. Strophe.error("BOSH-Connection failed: " + cond);
  8245. const conflict = bodyWrap.getElementsByTagName("conflict");
  8246. if (cond !== null) {
  8247. if (cond === "remote-stream-error" && conflict.length > 0) {
  8248. cond = "conflict";
  8249. }
  8250. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
  8251. } else {
  8252. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown");
  8253. }
  8254. this._conn._doDisconnect(cond);
  8255. return Strophe.Status.CONNFAIL;
  8256. } // check to make sure we don't overwrite these if _connect_cb is
  8257. // called multiple times in the case of missing stream:features
  8258. if (!this.sid) {
  8259. this.sid = bodyWrap.getAttribute("sid");
  8260. }
  8261. const wind = bodyWrap.getAttribute('requests');
  8262. if (wind) {
  8263. this.window = parseInt(wind, 10);
  8264. }
  8265. const hold = bodyWrap.getAttribute('hold');
  8266. if (hold) {
  8267. this.hold = parseInt(hold, 10);
  8268. }
  8269. const wait = bodyWrap.getAttribute('wait');
  8270. if (wait) {
  8271. this.wait = parseInt(wait, 10);
  8272. }
  8273. const inactivity = bodyWrap.getAttribute('inactivity');
  8274. if (inactivity) {
  8275. this.inactivity = parseInt(inactivity, 10);
  8276. }
  8277. }
  8278. /** PrivateFunction: _disconnect
  8279. * _Private_ part of Connection.disconnect for Bosh
  8280. *
  8281. * Parameters:
  8282. * (Request) pres - This stanza will be sent before disconnecting.
  8283. */
  8284. _disconnect(pres) {
  8285. this._sendTerminate(pres);
  8286. }
  8287. /** PrivateFunction: _doDisconnect
  8288. * _Private_ function to disconnect.
  8289. *
  8290. * Resets the SID and RID.
  8291. */
  8292. _doDisconnect() {
  8293. this.sid = null;
  8294. this.rid = Math.floor(Math.random() * 4294967295);
  8295. if (this._conn._sessionCachingSupported()) {
  8296. window.sessionStorage.removeItem('strophe-bosh-session');
  8297. }
  8298. this._conn.nextValidRid(this.rid);
  8299. }
  8300. /** PrivateFunction: _emptyQueue
  8301. * _Private_ function to check if the Request queue is empty.
  8302. *
  8303. * Returns:
  8304. * True, if there are no Requests queued, False otherwise.
  8305. */
  8306. _emptyQueue() {
  8307. return this._requests.length === 0;
  8308. }
  8309. /** PrivateFunction: _callProtocolErrorHandlers
  8310. * _Private_ function to call error handlers registered for HTTP errors.
  8311. *
  8312. * Parameters:
  8313. * (Strophe.Request) req - The request that is changing readyState.
  8314. */
  8315. _callProtocolErrorHandlers(req) {
  8316. const reqStatus = Bosh._getRequestStatus(req);
  8317. const err_callback = this._conn.protocolErrorHandlers.HTTP[reqStatus];
  8318. if (err_callback) {
  8319. err_callback.call(this, reqStatus);
  8320. }
  8321. }
  8322. /** PrivateFunction: _hitError
  8323. * _Private_ function to handle the error count.
  8324. *
  8325. * Requests are resent automatically until their error count reaches
  8326. * 5. Each time an error is encountered, this function is called to
  8327. * increment the count and disconnect if the count is too high.
  8328. *
  8329. * Parameters:
  8330. * (Integer) reqStatus - The request status.
  8331. */
  8332. _hitError(reqStatus) {
  8333. this.errors++;
  8334. Strophe.warn("request errored, status: " + reqStatus + ", number of errors: " + this.errors);
  8335. if (this.errors > 4) {
  8336. this._conn._onDisconnectTimeout();
  8337. }
  8338. }
  8339. /** PrivateFunction: _no_auth_received
  8340. *
  8341. * Called on stream start/restart when no stream:features
  8342. * has been received and sends a blank poll request.
  8343. */
  8344. _no_auth_received(callback) {
  8345. Strophe.warn("Server did not yet offer a supported authentication " + "mechanism. Sending a blank poll request.");
  8346. if (callback) {
  8347. callback = callback.bind(this._conn);
  8348. } else {
  8349. callback = this._conn._connect_cb.bind(this._conn);
  8350. }
  8351. const body = this._buildBody();
  8352. this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, callback), body.tree().getAttribute("rid")));
  8353. this._throttledRequestHandler();
  8354. }
  8355. /** PrivateFunction: _onDisconnectTimeout
  8356. * _Private_ timeout handler for handling non-graceful disconnection.
  8357. *
  8358. * Cancels all remaining Requests and clears the queue.
  8359. */
  8360. _onDisconnectTimeout() {
  8361. this._abortAllRequests();
  8362. }
  8363. /** PrivateFunction: _abortAllRequests
  8364. * _Private_ helper function that makes sure all pending requests are aborted.
  8365. */
  8366. _abortAllRequests() {
  8367. while (this._requests.length > 0) {
  8368. const req = this._requests.pop();
  8369. req.abort = true;
  8370. req.xhr.abort();
  8371. req.xhr.onreadystatechange = function () {};
  8372. }
  8373. }
  8374. /** PrivateFunction: _onIdle
  8375. * _Private_ handler called by Strophe.Connection._onIdle
  8376. *
  8377. * Sends all queued Requests or polls with empty Request if there are none.
  8378. */
  8379. _onIdle() {
  8380. const data = this._conn._data; // if no requests are in progress, poll
  8381. if (this._conn.authenticated && this._requests.length === 0 && data.length === 0 && !this._conn.disconnecting) {
  8382. Strophe.debug("no requests during idle cycle, sending blank request");
  8383. data.push(null);
  8384. }
  8385. if (this._conn.paused) {
  8386. return;
  8387. }
  8388. if (this._requests.length < 2 && data.length > 0) {
  8389. const body = this._buildBody();
  8390. for (let i = 0; i < data.length; i++) {
  8391. if (data[i] !== null) {
  8392. if (data[i] === "restart") {
  8393. body.attrs({
  8394. "to": this._conn.domain,
  8395. "xml:lang": "en",
  8396. "xmpp:restart": "true",
  8397. "xmlns:xmpp": Strophe.NS.BOSH
  8398. });
  8399. } else {
  8400. body.cnode(data[i]).up();
  8401. }
  8402. }
  8403. }
  8404. delete this._conn._data;
  8405. this._conn._data = [];
  8406. this._requests.push(new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, this._conn._dataRecv.bind(this._conn)), body.tree().getAttribute("rid")));
  8407. this._throttledRequestHandler();
  8408. }
  8409. if (this._requests.length > 0) {
  8410. const time_elapsed = this._requests[0].age();
  8411. if (this._requests[0].dead !== null) {
  8412. if (this._requests[0].timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
  8413. this._throttledRequestHandler();
  8414. }
  8415. }
  8416. if (time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)) {
  8417. Strophe.warn("Request " + this._requests[0].id + " timed out, over " + Math.floor(Strophe.TIMEOUT * this.wait) + " seconds since last activity");
  8418. this._throttledRequestHandler();
  8419. }
  8420. }
  8421. }
  8422. /** PrivateFunction: _getRequestStatus
  8423. *
  8424. * Returns the HTTP status code from a Strophe.Request
  8425. *
  8426. * Parameters:
  8427. * (Strophe.Request) req - The Strophe.Request instance.
  8428. * (Integer) def - The default value that should be returned if no
  8429. * status value was found.
  8430. */
  8431. static _getRequestStatus(req, def) {
  8432. let reqStatus;
  8433. if (req.xhr.readyState === 4) {
  8434. try {
  8435. reqStatus = req.xhr.status;
  8436. } catch (e) {
  8437. // ignore errors from undefined status attribute. Works
  8438. // around a browser bug
  8439. Strophe.error("Caught an error while retrieving a request's status, " + "reqStatus: " + reqStatus);
  8440. }
  8441. }
  8442. if (typeof reqStatus === "undefined") {
  8443. reqStatus = typeof def === 'number' ? def : 0;
  8444. }
  8445. return reqStatus;
  8446. }
  8447. /** PrivateFunction: _onRequestStateChange
  8448. * _Private_ handler for Strophe.Request state changes.
  8449. *
  8450. * This function is called when the XMLHttpRequest readyState changes.
  8451. * It contains a lot of error handling logic for the many ways that
  8452. * requests can fail, and calls the request callback when requests
  8453. * succeed.
  8454. *
  8455. * Parameters:
  8456. * (Function) func - The handler for the request.
  8457. * (Strophe.Request) req - The request that is changing readyState.
  8458. */
  8459. _onRequestStateChange(func, req) {
  8460. Strophe.debug("request id " + req.id + "." + req.sends + " state changed to " + req.xhr.readyState);
  8461. if (req.abort) {
  8462. req.abort = false;
  8463. return;
  8464. }
  8465. if (req.xhr.readyState !== 4) {
  8466. // The request is not yet complete
  8467. return;
  8468. }
  8469. const reqStatus = Bosh._getRequestStatus(req);
  8470. this.lastResponseHeaders = req.xhr.getAllResponseHeaders();
  8471. if (this._conn.disconnecting && reqStatus >= 400) {
  8472. this._hitError(reqStatus);
  8473. this._callProtocolErrorHandlers(req);
  8474. return;
  8475. }
  8476. const reqIs0 = this._requests[0] === req;
  8477. const reqIs1 = this._requests[1] === req;
  8478. const valid_request = reqStatus > 0 && reqStatus < 500;
  8479. const too_many_retries = req.sends > this._conn.maxRetries;
  8480. if (valid_request || too_many_retries) {
  8481. // remove from internal queue
  8482. this._removeRequest(req);
  8483. Strophe.debug("request id " + req.id + " should now be removed");
  8484. }
  8485. if (reqStatus === 200) {
  8486. // request succeeded
  8487. // if request 1 finished, or request 0 finished and request
  8488. // 1 is over Strophe.SECONDARY_TIMEOUT seconds old, we need to
  8489. // restart the other - both will be in the first spot, as the
  8490. // completed request has been removed from the queue already
  8491. if (reqIs1 || reqIs0 && this._requests.length > 0 && this._requests[0].age() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
  8492. this._restartRequest(0);
  8493. }
  8494. this._conn.nextValidRid(Number(req.rid) + 1);
  8495. Strophe.debug("request id " + req.id + "." + req.sends + " got 200");
  8496. func(req); // call handler
  8497. this.errors = 0;
  8498. } else if (reqStatus === 0 || reqStatus >= 400 && reqStatus < 600 || reqStatus >= 12000) {
  8499. // request failed
  8500. Strophe.error("request id " + req.id + "." + req.sends + " error " + reqStatus + " happened");
  8501. this._hitError(reqStatus);
  8502. this._callProtocolErrorHandlers(req);
  8503. if (reqStatus >= 400 && reqStatus < 500) {
  8504. this._conn._changeConnectStatus(Strophe.Status.DISCONNECTING, null);
  8505. this._conn._doDisconnect();
  8506. }
  8507. } else {
  8508. Strophe.error("request id " + req.id + "." + req.sends + " error " + reqStatus + " happened");
  8509. }
  8510. if (!valid_request && !too_many_retries) {
  8511. this._throttledRequestHandler();
  8512. } else if (too_many_retries && !this._conn.connected) {
  8513. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "giving-up");
  8514. }
  8515. }
  8516. /** PrivateFunction: _processRequest
  8517. * _Private_ function to process a request in the queue.
  8518. *
  8519. * This function takes requests off the queue and sends them and
  8520. * restarts dead requests.
  8521. *
  8522. * Parameters:
  8523. * (Integer) i - The index of the request in the queue.
  8524. */
  8525. _processRequest(i) {
  8526. let req = this._requests[i];
  8527. const reqStatus = Bosh._getRequestStatus(req, -1); // make sure we limit the number of retries
  8528. if (req.sends > this._conn.maxRetries) {
  8529. this._conn._onDisconnectTimeout();
  8530. return;
  8531. }
  8532. const time_elapsed = req.age();
  8533. const primary_timeout = !isNaN(time_elapsed) && time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait);
  8534. const secondary_timeout = req.dead !== null && req.timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait);
  8535. const server_error = req.xhr.readyState === 4 && (reqStatus < 1 || reqStatus >= 500);
  8536. if (primary_timeout || secondary_timeout || server_error) {
  8537. if (secondary_timeout) {
  8538. Strophe.error(`Request ${this._requests[i].id} timed out (secondary), restarting`);
  8539. }
  8540. req.abort = true;
  8541. req.xhr.abort(); // setting to null fails on IE6, so set to empty function
  8542. req.xhr.onreadystatechange = function () {};
  8543. this._requests[i] = new Strophe.Request(req.xmlData, req.origFunc, req.rid, req.sends);
  8544. req = this._requests[i];
  8545. }
  8546. if (req.xhr.readyState === 0) {
  8547. Strophe.debug("request id " + req.id + "." + req.sends + " posting");
  8548. try {
  8549. const content_type = this._conn.options.contentType || "text/xml; charset=utf-8";
  8550. req.xhr.open("POST", this._conn.service, this._conn.options.sync ? false : true);
  8551. if (typeof req.xhr.setRequestHeader !== 'undefined') {
  8552. // IE9 doesn't have setRequestHeader
  8553. req.xhr.setRequestHeader("Content-Type", content_type);
  8554. }
  8555. if (this._conn.options.withCredentials) {
  8556. req.xhr.withCredentials = true;
  8557. }
  8558. } catch (e2) {
  8559. Strophe.error("XHR open failed: " + e2.toString());
  8560. if (!this._conn.connected) {
  8561. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "bad-service");
  8562. }
  8563. this._conn.disconnect();
  8564. return;
  8565. } // Fires the XHR request -- may be invoked immediately
  8566. // or on a gradually expanding retry window for reconnects
  8567. const sendFunc = () => {
  8568. req.date = new Date();
  8569. if (this._conn.options.customHeaders) {
  8570. const headers = this._conn.options.customHeaders;
  8571. for (const header in headers) {
  8572. if (Object.prototype.hasOwnProperty.call(headers, header)) {
  8573. req.xhr.setRequestHeader(header, headers[header]);
  8574. }
  8575. }
  8576. }
  8577. req.xhr.send(req.data);
  8578. }; // Implement progressive backoff for reconnects --
  8579. // First retry (send === 1) should also be instantaneous
  8580. if (req.sends > 1) {
  8581. // Using a cube of the retry number creates a nicely
  8582. // expanding retry window
  8583. const backoff = Math.min(Math.floor(Strophe.TIMEOUT * this.wait), Math.pow(req.sends, 3)) * 1000;
  8584. setTimeout(function () {
  8585. // XXX: setTimeout should be called only with function expressions (23974bc1)
  8586. sendFunc();
  8587. }, backoff);
  8588. } else {
  8589. sendFunc();
  8590. }
  8591. req.sends++;
  8592. if (this._conn.xmlOutput !== Strophe.Connection.prototype.xmlOutput) {
  8593. if (req.xmlData.nodeName === this.strip && req.xmlData.childNodes.length) {
  8594. this._conn.xmlOutput(req.xmlData.childNodes[0]);
  8595. } else {
  8596. this._conn.xmlOutput(req.xmlData);
  8597. }
  8598. }
  8599. if (this._conn.rawOutput !== Strophe.Connection.prototype.rawOutput) {
  8600. this._conn.rawOutput(req.data);
  8601. }
  8602. } else {
  8603. Strophe.debug("_processRequest: " + (i === 0 ? "first" : "second") + " request has readyState of " + req.xhr.readyState);
  8604. }
  8605. }
  8606. /** PrivateFunction: _removeRequest
  8607. * _Private_ function to remove a request from the queue.
  8608. *
  8609. * Parameters:
  8610. * (Strophe.Request) req - The request to remove.
  8611. */
  8612. _removeRequest(req) {
  8613. Strophe.debug("removing request");
  8614. for (let i = this._requests.length - 1; i >= 0; i--) {
  8615. if (req === this._requests[i]) {
  8616. this._requests.splice(i, 1);
  8617. }
  8618. } // IE6 fails on setting to null, so set to empty function
  8619. req.xhr.onreadystatechange = function () {};
  8620. this._throttledRequestHandler();
  8621. }
  8622. /** PrivateFunction: _restartRequest
  8623. * _Private_ function to restart a request that is presumed dead.
  8624. *
  8625. * Parameters:
  8626. * (Integer) i - The index of the request in the queue.
  8627. */
  8628. _restartRequest(i) {
  8629. const req = this._requests[i];
  8630. if (req.dead === null) {
  8631. req.dead = new Date();
  8632. }
  8633. this._processRequest(i);
  8634. }
  8635. /** PrivateFunction: _reqToData
  8636. * _Private_ function to get a stanza out of a request.
  8637. *
  8638. * Tries to extract a stanza out of a Request Object.
  8639. * When this fails the current connection will be disconnected.
  8640. *
  8641. * Parameters:
  8642. * (Object) req - The Request.
  8643. *
  8644. * Returns:
  8645. * The stanza that was passed.
  8646. */
  8647. _reqToData(req) {
  8648. try {
  8649. return req.getResponse();
  8650. } catch (e) {
  8651. if (e.message !== "parsererror") {
  8652. throw e;
  8653. }
  8654. this._conn.disconnect("strophe-parsererror");
  8655. }
  8656. }
  8657. /** PrivateFunction: _sendTerminate
  8658. * _Private_ function to send initial disconnect sequence.
  8659. *
  8660. * This is the first step in a graceful disconnect. It sends
  8661. * the BOSH server a terminate body and includes an unavailable
  8662. * presence if authentication has completed.
  8663. */
  8664. _sendTerminate(pres) {
  8665. Strophe.debug("_sendTerminate was called");
  8666. const body = this._buildBody().attrs({
  8667. type: "terminate"
  8668. });
  8669. if (pres) {
  8670. body.cnode(pres.tree());
  8671. }
  8672. const req = new Strophe.Request(body.tree(), this._onRequestStateChange.bind(this, this._conn._dataRecv.bind(this._conn)), body.tree().getAttribute("rid"));
  8673. this._requests.push(req);
  8674. this._throttledRequestHandler();
  8675. }
  8676. /** PrivateFunction: _send
  8677. * _Private_ part of the Connection.send function for BOSH
  8678. *
  8679. * Just triggers the RequestHandler to send the messages that are in the queue
  8680. */
  8681. _send() {
  8682. clearTimeout(this._conn._idleTimeout);
  8683. this._throttledRequestHandler();
  8684. this._conn._idleTimeout = setTimeout(() => this._conn._onIdle(), 100);
  8685. }
  8686. /** PrivateFunction: _sendRestart
  8687. *
  8688. * Send an xmpp:restart stanza.
  8689. */
  8690. _sendRestart() {
  8691. this._throttledRequestHandler();
  8692. clearTimeout(this._conn._idleTimeout);
  8693. }
  8694. /** PrivateFunction: _throttledRequestHandler
  8695. * _Private_ function to throttle requests to the connection window.
  8696. *
  8697. * This function makes sure we don't send requests so fast that the
  8698. * request ids overflow the connection window in the case that one
  8699. * request died.
  8700. */
  8701. _throttledRequestHandler() {
  8702. if (!this._requests) {
  8703. Strophe.debug("_throttledRequestHandler called with " + "undefined requests");
  8704. } else {
  8705. Strophe.debug("_throttledRequestHandler called with " + this._requests.length + " requests");
  8706. }
  8707. if (!this._requests || this._requests.length === 0) {
  8708. return;
  8709. }
  8710. if (this._requests.length > 0) {
  8711. this._processRequest(0);
  8712. }
  8713. if (this._requests.length > 1 && Math.abs(this._requests[0].rid - this._requests[1].rid) < this.window) {
  8714. this._processRequest(1);
  8715. }
  8716. }
  8717. };
  8718. /** Variable: strip
  8719. *
  8720. * BOSH-Connections will have all stanzas wrapped in a <body> tag when
  8721. * passed to <Strophe.Connection.xmlInput> or <Strophe.Connection.xmlOutput>.
  8722. * To strip this tag, User code can set <Strophe.Bosh.strip> to "body":
  8723. *
  8724. * > Strophe.Bosh.prototype.strip = "body";
  8725. *
  8726. * This will enable stripping of the body tag in both
  8727. * <Strophe.Connection.xmlInput> and <Strophe.Connection.xmlOutput>.
  8728. */
  8729. Strophe.Bosh.prototype.strip = null;
  8730. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/websocket.js
  8731. /*
  8732. This program is distributed under the terms of the MIT license.
  8733. Please see the LICENSE file for details.
  8734. Copyright 2006-2008, OGG, LLC
  8735. */
  8736. /* global window, clearTimeout, WebSocket, DOMParser */
  8737. /** Class: Strophe.WebSocket
  8738. * _Private_ helper class that handles WebSocket Connections
  8739. *
  8740. * The Strophe.WebSocket class is used internally by Strophe.Connection
  8741. * to encapsulate WebSocket sessions. It is not meant to be used from user's code.
  8742. */
  8743. /** File: websocket.js
  8744. * A JavaScript library to enable XMPP over Websocket in Strophejs.
  8745. *
  8746. * This file implements XMPP over WebSockets for Strophejs.
  8747. * If a Connection is established with a Websocket url (ws://...)
  8748. * Strophe will use WebSockets.
  8749. * For more information on XMPP-over-WebSocket see RFC 7395:
  8750. * http://tools.ietf.org/html/rfc7395
  8751. *
  8752. * WebSocket support implemented by Andreas Guth (andreas.guth@rwth-aachen.de)
  8753. */
  8754. Strophe.Websocket = class Websocket {
  8755. /** PrivateConstructor: Strophe.Websocket
  8756. * Create and initialize a Strophe.WebSocket object.
  8757. * Currently only sets the connection Object.
  8758. *
  8759. * Parameters:
  8760. * (Strophe.Connection) connection - The Strophe.Connection that will use WebSockets.
  8761. *
  8762. * Returns:
  8763. * A new Strophe.WebSocket object.
  8764. */
  8765. constructor(connection) {
  8766. this._conn = connection;
  8767. this.strip = "wrapper";
  8768. const service = connection.service;
  8769. if (service.indexOf("ws:") !== 0 && service.indexOf("wss:") !== 0) {
  8770. // If the service is not an absolute URL, assume it is a path and put the absolute
  8771. // URL together from options, current URL and the path.
  8772. let new_service = "";
  8773. if (connection.options.protocol === "ws" && window.location.protocol !== "https:") {
  8774. new_service += "ws";
  8775. } else {
  8776. new_service += "wss";
  8777. }
  8778. new_service += "://" + window.location.host;
  8779. if (service.indexOf("/") !== 0) {
  8780. new_service += window.location.pathname + service;
  8781. } else {
  8782. new_service += service;
  8783. }
  8784. connection.service = new_service;
  8785. }
  8786. }
  8787. /** PrivateFunction: _buildStream
  8788. * _Private_ helper function to generate the <stream> start tag for WebSockets
  8789. *
  8790. * Returns:
  8791. * A Strophe.Builder with a <stream> element.
  8792. */
  8793. _buildStream() {
  8794. return $build("open", {
  8795. "xmlns": Strophe.NS.FRAMING,
  8796. "to": this._conn.domain,
  8797. "version": '1.0'
  8798. });
  8799. }
  8800. /** PrivateFunction: _checkStreamError
  8801. * _Private_ checks a message for stream:error
  8802. *
  8803. * Parameters:
  8804. * (Strophe.Request) bodyWrap - The received stanza.
  8805. * connectstatus - The ConnectStatus that will be set on error.
  8806. * Returns:
  8807. * true if there was a streamerror, false otherwise.
  8808. */
  8809. _checkStreamError(bodyWrap, connectstatus) {
  8810. let errors;
  8811. if (bodyWrap.getElementsByTagNameNS) {
  8812. errors = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "error");
  8813. } else {
  8814. errors = bodyWrap.getElementsByTagName("stream:error");
  8815. }
  8816. if (errors.length === 0) {
  8817. return false;
  8818. }
  8819. const error = errors[0];
  8820. let condition = "";
  8821. let text = "";
  8822. const ns = "urn:ietf:params:xml:ns:xmpp-streams";
  8823. for (let i = 0; i < error.childNodes.length; i++) {
  8824. const e = error.childNodes[i];
  8825. if (e.getAttribute("xmlns") !== ns) {
  8826. break;
  8827. }
  8828. if (e.nodeName === "text") {
  8829. text = e.textContent;
  8830. } else {
  8831. condition = e.nodeName;
  8832. }
  8833. }
  8834. let errorString = "WebSocket stream error: ";
  8835. if (condition) {
  8836. errorString += condition;
  8837. } else {
  8838. errorString += "unknown";
  8839. }
  8840. if (text) {
  8841. errorString += " - " + text;
  8842. }
  8843. Strophe.error(errorString); // close the connection on stream_error
  8844. this._conn._changeConnectStatus(connectstatus, condition);
  8845. this._conn._doDisconnect();
  8846. return true;
  8847. }
  8848. /** PrivateFunction: _reset
  8849. * Reset the connection.
  8850. *
  8851. * This function is called by the reset function of the Strophe Connection.
  8852. * Is not needed by WebSockets.
  8853. */
  8854. _reset() {
  8855. // eslint-disable-line class-methods-use-this
  8856. return;
  8857. }
  8858. /** PrivateFunction: _connect
  8859. * _Private_ function called by Strophe.Connection.connect
  8860. *
  8861. * Creates a WebSocket for a connection and assigns Callbacks to it.
  8862. * Does nothing if there already is a WebSocket.
  8863. */
  8864. _connect() {
  8865. // Ensure that there is no open WebSocket from a previous Connection.
  8866. this._closeSocket();
  8867. this.socket = new WebSocket(this._conn.service, "xmpp");
  8868. this.socket.onopen = () => this._onOpen();
  8869. this.socket.onerror = e => this._onError(e);
  8870. this.socket.onclose = e => this._onClose(e); // Gets replaced with this._onMessage once _onInitialMessage is called
  8871. this.socket.onmessage = message => this._onInitialMessage(message);
  8872. }
  8873. /** PrivateFunction: _connect_cb
  8874. * _Private_ function called by Strophe.Connection._connect_cb
  8875. *
  8876. * checks for stream:error
  8877. *
  8878. * Parameters:
  8879. * (Strophe.Request) bodyWrap - The received stanza.
  8880. */
  8881. _connect_cb(bodyWrap) {
  8882. const error = this._checkStreamError(bodyWrap, Strophe.Status.CONNFAIL);
  8883. if (error) {
  8884. return Strophe.Status.CONNFAIL;
  8885. }
  8886. }
  8887. /** PrivateFunction: _handleStreamStart
  8888. * _Private_ function that checks the opening <open /> tag for errors.
  8889. *
  8890. * Disconnects if there is an error and returns false, true otherwise.
  8891. *
  8892. * Parameters:
  8893. * (Node) message - Stanza containing the <open /> tag.
  8894. */
  8895. _handleStreamStart(message) {
  8896. let error = false; // Check for errors in the <open /> tag
  8897. const ns = message.getAttribute("xmlns");
  8898. if (typeof ns !== "string") {
  8899. error = "Missing xmlns in <open />";
  8900. } else if (ns !== Strophe.NS.FRAMING) {
  8901. error = "Wrong xmlns in <open />: " + ns;
  8902. }
  8903. const ver = message.getAttribute("version");
  8904. if (typeof ver !== "string") {
  8905. error = "Missing version in <open />";
  8906. } else if (ver !== "1.0") {
  8907. error = "Wrong version in <open />: " + ver;
  8908. }
  8909. if (error) {
  8910. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, error);
  8911. this._conn._doDisconnect();
  8912. return false;
  8913. }
  8914. return true;
  8915. }
  8916. /** PrivateFunction: _onInitialMessage
  8917. * _Private_ function that handles the first connection messages.
  8918. *
  8919. * On receiving an opening stream tag this callback replaces itself with the real
  8920. * message handler. On receiving a stream error the connection is terminated.
  8921. */
  8922. _onInitialMessage(message) {
  8923. if (message.data.indexOf("<open ") === 0 || message.data.indexOf("<?xml") === 0) {
  8924. // Strip the XML Declaration, if there is one
  8925. const data = message.data.replace(/^(<\?.*?\?>\s*)*/, "");
  8926. if (data === '') return;
  8927. const streamStart = new strophe_shims_DOMParser().parseFromString(data, "text/xml").documentElement;
  8928. this._conn.xmlInput(streamStart);
  8929. this._conn.rawInput(message.data); //_handleStreamSteart will check for XML errors and disconnect on error
  8930. if (this._handleStreamStart(streamStart)) {
  8931. //_connect_cb will check for stream:error and disconnect on error
  8932. this._connect_cb(streamStart);
  8933. }
  8934. } else if (message.data.indexOf("<close ") === 0) {
  8935. // <close xmlns="urn:ietf:params:xml:ns:xmpp-framing />
  8936. // Parse the raw string to an XML element
  8937. const parsedMessage = new strophe_shims_DOMParser().parseFromString(message.data, "text/xml").documentElement; // Report this input to the raw and xml handlers
  8938. this._conn.xmlInput(parsedMessage);
  8939. this._conn.rawInput(message.data);
  8940. const see_uri = parsedMessage.getAttribute("see-other-uri");
  8941. if (see_uri) {
  8942. const service = this._conn.service; // Valid scenarios: WSS->WSS, WS->ANY
  8943. const isSecureRedirect = service.indexOf("wss:") >= 0 && see_uri.indexOf("wss:") >= 0 || service.indexOf("ws:") >= 0;
  8944. if (isSecureRedirect) {
  8945. this._conn._changeConnectStatus(Strophe.Status.REDIRECT, "Received see-other-uri, resetting connection");
  8946. this._conn.reset();
  8947. this._conn.service = see_uri;
  8948. this._connect();
  8949. }
  8950. } else {
  8951. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "Received closing stream");
  8952. this._conn._doDisconnect();
  8953. }
  8954. } else {
  8955. this._replaceMessageHandler();
  8956. const string = this._streamWrap(message.data);
  8957. const elem = new strophe_shims_DOMParser().parseFromString(string, "text/xml").documentElement;
  8958. this._conn._connect_cb(elem, null, message.data);
  8959. }
  8960. }
  8961. /** PrivateFunction: _replaceMessageHandler
  8962. *
  8963. * Called by _onInitialMessage in order to replace itself with the general message handler.
  8964. * This method is overridden by Strophe.WorkerWebsocket, which manages a
  8965. * websocket connection via a service worker and doesn't have direct access
  8966. * to the socket.
  8967. */
  8968. _replaceMessageHandler() {
  8969. this.socket.onmessage = m => this._onMessage(m);
  8970. }
  8971. /** PrivateFunction: _disconnect
  8972. * _Private_ function called by Strophe.Connection.disconnect
  8973. *
  8974. * Disconnects and sends a last stanza if one is given
  8975. *
  8976. * Parameters:
  8977. * (Request) pres - This stanza will be sent before disconnecting.
  8978. */
  8979. _disconnect(pres) {
  8980. if (this.socket && this.socket.readyState !== WebSocket.CLOSED) {
  8981. if (pres) {
  8982. this._conn.send(pres);
  8983. }
  8984. const close = $build("close", {
  8985. "xmlns": Strophe.NS.FRAMING
  8986. });
  8987. this._conn.xmlOutput(close.tree());
  8988. const closeString = Strophe.serialize(close);
  8989. this._conn.rawOutput(closeString);
  8990. try {
  8991. this.socket.send(closeString);
  8992. } catch (e) {
  8993. Strophe.warn("Couldn't send <close /> tag.");
  8994. }
  8995. }
  8996. setTimeout(() => this._conn._doDisconnect, 0);
  8997. }
  8998. /** PrivateFunction: _doDisconnect
  8999. * _Private_ function to disconnect.
  9000. *
  9001. * Just closes the Socket for WebSockets
  9002. */
  9003. _doDisconnect() {
  9004. Strophe.debug("WebSockets _doDisconnect was called");
  9005. this._closeSocket();
  9006. }
  9007. /** PrivateFunction _streamWrap
  9008. * _Private_ helper function to wrap a stanza in a <stream> tag.
  9009. * This is used so Strophe can process stanzas from WebSockets like BOSH
  9010. */
  9011. _streamWrap(stanza) {
  9012. // eslint-disable-line class-methods-use-this
  9013. return "<wrapper>" + stanza + '</wrapper>';
  9014. }
  9015. /** PrivateFunction: _closeSocket
  9016. * _Private_ function to close the WebSocket.
  9017. *
  9018. * Closes the socket if it is still open and deletes it
  9019. */
  9020. _closeSocket() {
  9021. if (this.socket) {
  9022. try {
  9023. this.socket.onclose = null;
  9024. this.socket.onerror = null;
  9025. this.socket.onmessage = null;
  9026. this.socket.close();
  9027. } catch (e) {
  9028. Strophe.debug(e.message);
  9029. }
  9030. }
  9031. this.socket = null;
  9032. }
  9033. /** PrivateFunction: _emptyQueue
  9034. * _Private_ function to check if the message queue is empty.
  9035. *
  9036. * Returns:
  9037. * True, because WebSocket messages are send immediately after queueing.
  9038. */
  9039. _emptyQueue() {
  9040. // eslint-disable-line class-methods-use-this
  9041. return true;
  9042. }
  9043. /** PrivateFunction: _onClose
  9044. * _Private_ function to handle websockets closing.
  9045. */
  9046. _onClose(e) {
  9047. if (this._conn.connected && !this._conn.disconnecting) {
  9048. Strophe.error("Websocket closed unexpectedly");
  9049. this._conn._doDisconnect();
  9050. } else if (e && e.code === 1006 && !this._conn.connected && this.socket) {
  9051. // in case the onError callback was not called (Safari 10 does not
  9052. // call onerror when the initial connection fails) we need to
  9053. // dispatch a CONNFAIL status update to be consistent with the
  9054. // behavior on other browsers.
  9055. Strophe.error("Websocket closed unexcectedly");
  9056. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
  9057. this._conn._doDisconnect();
  9058. } else {
  9059. Strophe.debug("Websocket closed");
  9060. }
  9061. }
  9062. /** PrivateFunction: _no_auth_received
  9063. *
  9064. * Called on stream start/restart when no stream:features
  9065. * has been received.
  9066. */
  9067. _no_auth_received(callback) {
  9068. Strophe.error("Server did not offer a supported authentication mechanism");
  9069. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, Strophe.ErrorCondition.NO_AUTH_MECH);
  9070. if (callback) {
  9071. callback.call(this._conn);
  9072. }
  9073. this._conn._doDisconnect();
  9074. }
  9075. /** PrivateFunction: _onDisconnectTimeout
  9076. * _Private_ timeout handler for handling non-graceful disconnection.
  9077. *
  9078. * This does nothing for WebSockets
  9079. */
  9080. _onDisconnectTimeout() {} // eslint-disable-line class-methods-use-this
  9081. /** PrivateFunction: _abortAllRequests
  9082. * _Private_ helper function that makes sure all pending requests are aborted.
  9083. */
  9084. _abortAllRequests() {} // eslint-disable-line class-methods-use-this
  9085. /** PrivateFunction: _onError
  9086. * _Private_ function to handle websockets errors.
  9087. *
  9088. * Parameters:
  9089. * (Object) error - The websocket error.
  9090. */
  9091. _onError(error) {
  9092. Strophe.error("Websocket error " + JSON.stringify(error));
  9093. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
  9094. this._disconnect();
  9095. }
  9096. /** PrivateFunction: _onIdle
  9097. * _Private_ function called by Strophe.Connection._onIdle
  9098. *
  9099. * sends all queued stanzas
  9100. */
  9101. _onIdle() {
  9102. const data = this._conn._data;
  9103. if (data.length > 0 && !this._conn.paused) {
  9104. for (let i = 0; i < data.length; i++) {
  9105. if (data[i] !== null) {
  9106. let stanza;
  9107. if (data[i] === "restart") {
  9108. stanza = this._buildStream().tree();
  9109. } else {
  9110. stanza = data[i];
  9111. }
  9112. const rawStanza = Strophe.serialize(stanza);
  9113. this._conn.xmlOutput(stanza);
  9114. this._conn.rawOutput(rawStanza);
  9115. this.socket.send(rawStanza);
  9116. }
  9117. }
  9118. this._conn._data = [];
  9119. }
  9120. }
  9121. /** PrivateFunction: _onMessage
  9122. * _Private_ function to handle websockets messages.
  9123. *
  9124. * This function parses each of the messages as if they are full documents.
  9125. * [TODO : We may actually want to use a SAX Push parser].
  9126. *
  9127. * Since all XMPP traffic starts with
  9128. * <stream:stream version='1.0'
  9129. * xml:lang='en'
  9130. * xmlns='jabber:client'
  9131. * xmlns:stream='http://etherx.jabber.org/streams'
  9132. * id='3697395463'
  9133. * from='SERVER'>
  9134. *
  9135. * The first stanza will always fail to be parsed.
  9136. *
  9137. * Additionally, the seconds stanza will always be <stream:features> with
  9138. * the stream NS defined in the previous stanza, so we need to 'force'
  9139. * the inclusion of the NS in this stanza.
  9140. *
  9141. * Parameters:
  9142. * (string) message - The websocket message.
  9143. */
  9144. _onMessage(message) {
  9145. let elem; // check for closing stream
  9146. const close = '<close xmlns="urn:ietf:params:xml:ns:xmpp-framing" />';
  9147. if (message.data === close) {
  9148. this._conn.rawInput(close);
  9149. this._conn.xmlInput(message);
  9150. if (!this._conn.disconnecting) {
  9151. this._conn._doDisconnect();
  9152. }
  9153. return;
  9154. } else if (message.data.search("<open ") === 0) {
  9155. // This handles stream restarts
  9156. elem = new strophe_shims_DOMParser().parseFromString(message.data, "text/xml").documentElement;
  9157. if (!this._handleStreamStart(elem)) {
  9158. return;
  9159. }
  9160. } else {
  9161. const data = this._streamWrap(message.data);
  9162. elem = new strophe_shims_DOMParser().parseFromString(data, "text/xml").documentElement;
  9163. }
  9164. if (this._checkStreamError(elem, Strophe.Status.ERROR)) {
  9165. return;
  9166. } //handle unavailable presence stanza before disconnecting
  9167. if (this._conn.disconnecting && elem.firstChild.nodeName === "presence" && elem.firstChild.getAttribute("type") === "unavailable") {
  9168. this._conn.xmlInput(elem);
  9169. this._conn.rawInput(Strophe.serialize(elem)); // if we are already disconnecting we will ignore the unavailable stanza and
  9170. // wait for the </stream:stream> tag before we close the connection
  9171. return;
  9172. }
  9173. this._conn._dataRecv(elem, message.data);
  9174. }
  9175. /** PrivateFunction: _onOpen
  9176. * _Private_ function to handle websockets connection setup.
  9177. *
  9178. * The opening stream tag is sent here.
  9179. */
  9180. _onOpen() {
  9181. Strophe.debug("Websocket open");
  9182. const start = this._buildStream();
  9183. this._conn.xmlOutput(start.tree());
  9184. const startString = Strophe.serialize(start);
  9185. this._conn.rawOutput(startString);
  9186. this.socket.send(startString);
  9187. }
  9188. /** PrivateFunction: _reqToData
  9189. * _Private_ function to get a stanza out of a request.
  9190. *
  9191. * WebSockets don't use requests, so the passed argument is just returned.
  9192. *
  9193. * Parameters:
  9194. * (Object) stanza - The stanza.
  9195. *
  9196. * Returns:
  9197. * The stanza that was passed.
  9198. */
  9199. _reqToData(stanza) {
  9200. // eslint-disable-line class-methods-use-this
  9201. return stanza;
  9202. }
  9203. /** PrivateFunction: _send
  9204. * _Private_ part of the Connection.send function for WebSocket
  9205. *
  9206. * Just flushes the messages that are in the queue
  9207. */
  9208. _send() {
  9209. this._conn.flush();
  9210. }
  9211. /** PrivateFunction: _sendRestart
  9212. *
  9213. * Send an xmpp:restart stanza.
  9214. */
  9215. _sendRestart() {
  9216. clearTimeout(this._conn._idleTimeout);
  9217. this._conn._onIdle.bind(this._conn)();
  9218. }
  9219. };
  9220. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/worker-websocket.js
  9221. /*
  9222. This program is distributed under the terms of the MIT license.
  9223. Please see the LICENSE file for details.
  9224. Copyright 2020, JC Brand
  9225. */
  9226. const lmap = {};
  9227. lmap['debug'] = Strophe.LogLevel.DEBUG;
  9228. lmap['info'] = Strophe.LogLevel.INFO;
  9229. lmap['warn'] = Strophe.LogLevel.WARN;
  9230. lmap['error'] = Strophe.LogLevel.ERROR;
  9231. lmap['fatal'] = Strophe.LogLevel.FATAL;
  9232. /** Class: Strophe.WorkerWebsocket
  9233. * _Private_ helper class that handles a websocket connection inside a shared worker.
  9234. */
  9235. Strophe.WorkerWebsocket = class WorkerWebsocket extends Strophe.Websocket {
  9236. /** PrivateConstructor: Strophe.WorkerWebsocket
  9237. * Create and initialize a Strophe.WorkerWebsocket object.
  9238. *
  9239. * Parameters:
  9240. * (Strophe.Connection) connection - The Strophe.Connection
  9241. *
  9242. * Returns:
  9243. * A new Strophe.WorkerWebsocket object.
  9244. */
  9245. constructor(connection) {
  9246. super(connection);
  9247. this._conn = connection;
  9248. this.worker = new SharedWorker(this._conn.options.worker, 'Strophe XMPP Connection');
  9249. this.worker.onerror = e => {
  9250. var _console;
  9251. (_console = console) === null || _console === void 0 ? void 0 : _console.error(e);
  9252. Strophe.log(Strophe.LogLevel.ERROR, `Shared Worker Error: ${e}`);
  9253. };
  9254. }
  9255. get socket() {
  9256. return {
  9257. 'send': str => this.worker.port.postMessage(['send', str])
  9258. };
  9259. }
  9260. _connect() {
  9261. this._messageHandler = m => this._onInitialMessage(m);
  9262. this.worker.port.start();
  9263. this.worker.port.onmessage = ev => this._onWorkerMessage(ev);
  9264. this.worker.port.postMessage(['_connect', this._conn.service, this._conn.jid]);
  9265. }
  9266. _attach(callback) {
  9267. this._messageHandler = m => this._onMessage(m);
  9268. this._conn.connect_callback = callback;
  9269. this.worker.port.start();
  9270. this.worker.port.onmessage = ev => this._onWorkerMessage(ev);
  9271. this.worker.port.postMessage(['_attach', this._conn.service]);
  9272. }
  9273. _attachCallback(status, jid) {
  9274. if (status === Strophe.Status.ATTACHED) {
  9275. this._conn.jid = jid;
  9276. this._conn.authenticated = true;
  9277. this._conn.connected = true;
  9278. this._conn.restored = true;
  9279. this._conn._changeConnectStatus(Strophe.Status.ATTACHED);
  9280. } else if (status === Strophe.Status.ATTACHFAIL) {
  9281. this._conn.authenticated = false;
  9282. this._conn.connected = false;
  9283. this._conn.restored = false;
  9284. this._conn._changeConnectStatus(Strophe.Status.ATTACHFAIL);
  9285. }
  9286. }
  9287. _disconnect(readyState, pres) {
  9288. pres && this._conn.send(pres);
  9289. const close = $build("close", {
  9290. "xmlns": Strophe.NS.FRAMING
  9291. });
  9292. this._conn.xmlOutput(close.tree());
  9293. const closeString = Strophe.serialize(close);
  9294. this._conn.rawOutput(closeString);
  9295. this.worker.port.postMessage(['send', closeString]);
  9296. this._conn._doDisconnect();
  9297. }
  9298. _onClose(e) {
  9299. if (this._conn.connected && !this._conn.disconnecting) {
  9300. Strophe.error("Websocket closed unexpectedly");
  9301. this._conn._doDisconnect();
  9302. } else if (e && e.code === 1006 && !this._conn.connected) {
  9303. // in case the onError callback was not called (Safari 10 does not
  9304. // call onerror when the initial connection fails) we need to
  9305. // dispatch a CONNFAIL status update to be consistent with the
  9306. // behavior on other browsers.
  9307. Strophe.error("Websocket closed unexcectedly");
  9308. this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established or was disconnected.");
  9309. this._conn._doDisconnect();
  9310. } else {
  9311. Strophe.debug("Websocket closed");
  9312. }
  9313. }
  9314. _closeSocket() {
  9315. this.worker.port.postMessage(['_closeSocket']);
  9316. }
  9317. /** PrivateFunction: _replaceMessageHandler
  9318. *
  9319. * Called by _onInitialMessage in order to replace itself with the general message handler.
  9320. * This method is overridden by Strophe.WorkerWebsocket, which manages a
  9321. * websocket connection via a service worker and doesn't have direct access
  9322. * to the socket.
  9323. */
  9324. _replaceMessageHandler() {
  9325. this._messageHandler = m => this._onMessage(m);
  9326. }
  9327. /** PrivateFunction: _onWorkerMessage
  9328. * _Private_ function that handles messages received from the service worker
  9329. */
  9330. _onWorkerMessage(ev) {
  9331. const {
  9332. data
  9333. } = ev;
  9334. const method_name = data[0];
  9335. if (method_name === '_onMessage') {
  9336. this._messageHandler(data[1]);
  9337. } else if (method_name in this) {
  9338. try {
  9339. this[method_name].apply(this, ev.data.slice(1));
  9340. } catch (e) {
  9341. Strophe.log(Strophe.LogLevel.ERROR, e);
  9342. }
  9343. } else if (method_name === 'log') {
  9344. const level = data[1];
  9345. const msg = data[2];
  9346. Strophe.log(lmap[level], msg);
  9347. } else {
  9348. Strophe.log(Strophe.LogLevel.ERROR, `Found unhandled service worker message: ${data}`);
  9349. }
  9350. }
  9351. };
  9352. ;// CONCATENATED MODULE: ./node_modules/strophe.js/src/strophe.js
  9353. /*global global*/
  9354. __webpack_require__.g.$build = core.$build;
  9355. __webpack_require__.g.$iq = core.$iq;
  9356. __webpack_require__.g.$msg = core.$msg;
  9357. __webpack_require__.g.$pres = core.$pres;
  9358. __webpack_require__.g.Strophe = core.Strophe;
  9359. const {
  9360. b64_sha1
  9361. } = SHA1;
  9362. ;// CONCATENATED MODULE: ./src/headless/shared/constants.js
  9363. const BOSH_WAIT = 59;
  9364. const CONNECTION_STATUS = {};
  9365. CONNECTION_STATUS[Strophe.Status.ATTACHED] = 'ATTACHED';
  9366. CONNECTION_STATUS[Strophe.Status.AUTHENTICATING] = 'AUTHENTICATING';
  9367. CONNECTION_STATUS[Strophe.Status.AUTHFAIL] = 'AUTHFAIL';
  9368. CONNECTION_STATUS[Strophe.Status.CONNECTED] = 'CONNECTED';
  9369. CONNECTION_STATUS[Strophe.Status.CONNECTING] = 'CONNECTING';
  9370. CONNECTION_STATUS[Strophe.Status.CONNFAIL] = 'CONNFAIL';
  9371. CONNECTION_STATUS[Strophe.Status.DISCONNECTED] = 'DISCONNECTED';
  9372. CONNECTION_STATUS[Strophe.Status.DISCONNECTING] = 'DISCONNECTING';
  9373. CONNECTION_STATUS[Strophe.Status.ERROR] = 'ERROR';
  9374. CONNECTION_STATUS[Strophe.Status.RECONNECTING] = 'RECONNECTING';
  9375. CONNECTION_STATUS[Strophe.Status.REDIRECT] = 'REDIRECT'; // Core plugins are whitelisted automatically
  9376. // These are just the @converse/headless plugins, for the full converse,
  9377. // the other plugins are whitelisted in src/consts.js
  9378. const CORE_PLUGINS = ['converse-adhoc', 'converse-bookmarks', 'converse-bosh', 'converse-caps', 'converse-carbons', 'converse-chat', 'converse-chatboxes', 'converse-disco', 'converse-emoji', 'converse-headlines', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-pubsub', 'converse-roster', 'converse-smacks', 'converse-status', 'converse-vcard'];
  9379. const URL_PARSE_OPTIONS = {
  9380. 'start': /(\b|_)(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi
  9381. };
  9382. const CHAT_STATES = ['active', 'composing', 'gone', 'inactive', 'paused'];
  9383. const KEYCODES = {
  9384. TAB: 9,
  9385. ENTER: 13,
  9386. SHIFT: 16,
  9387. CTRL: 17,
  9388. ALT: 18,
  9389. ESCAPE: 27,
  9390. LEFT_ARROW: 37,
  9391. UP_ARROW: 38,
  9392. RIGHT_ARROW: 39,
  9393. DOWN_ARROW: 40,
  9394. FORWARD_SLASH: 47,
  9395. AT: 50,
  9396. META: 91,
  9397. META_RIGHT: 93
  9398. };
  9399. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isObject.js
  9400. /**
  9401. * Checks if `value` is the
  9402. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  9403. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  9404. *
  9405. * @static
  9406. * @memberOf _
  9407. * @since 0.1.0
  9408. * @category Lang
  9409. * @param {*} value The value to check.
  9410. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  9411. * @example
  9412. *
  9413. * _.isObject({});
  9414. * // => true
  9415. *
  9416. * _.isObject([1, 2, 3]);
  9417. * // => true
  9418. *
  9419. * _.isObject(_.noop);
  9420. * // => true
  9421. *
  9422. * _.isObject(null);
  9423. * // => false
  9424. */
  9425. function isObject(value) {
  9426. var type = typeof value;
  9427. return value != null && (type == 'object' || type == 'function');
  9428. }
  9429. /* harmony default export */ const lodash_es_isObject = (isObject);
  9430. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isFunction.js
  9431. /** `Object#toString` result references. */
  9432. var asyncTag = '[object AsyncFunction]',
  9433. funcTag = '[object Function]',
  9434. genTag = '[object GeneratorFunction]',
  9435. proxyTag = '[object Proxy]';
  9436. /**
  9437. * Checks if `value` is classified as a `Function` object.
  9438. *
  9439. * @static
  9440. * @memberOf _
  9441. * @since 0.1.0
  9442. * @category Lang
  9443. * @param {*} value The value to check.
  9444. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  9445. * @example
  9446. *
  9447. * _.isFunction(_);
  9448. * // => true
  9449. *
  9450. * _.isFunction(/abc/);
  9451. * // => false
  9452. */
  9453. function isFunction(value) {
  9454. if (!lodash_es_isObject(value)) {
  9455. return false;
  9456. }
  9457. // The use of `Object#toString` avoids issues with the `typeof` operator
  9458. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  9459. var tag = _baseGetTag(value);
  9460. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  9461. }
  9462. /* harmony default export */ const lodash_es_isFunction = (isFunction);
  9463. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_coreJsData.js
  9464. /** Used to detect overreaching core-js shims. */
  9465. var coreJsData = _root["__core-js_shared__"];
  9466. /* harmony default export */ const _coreJsData = (coreJsData);
  9467. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isMasked.js
  9468. /** Used to detect methods masquerading as native. */
  9469. var maskSrcKey = (function() {
  9470. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  9471. return uid ? ('Symbol(src)_1.' + uid) : '';
  9472. }());
  9473. /**
  9474. * Checks if `func` has its source masked.
  9475. *
  9476. * @private
  9477. * @param {Function} func The function to check.
  9478. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  9479. */
  9480. function isMasked(func) {
  9481. return !!maskSrcKey && (maskSrcKey in func);
  9482. }
  9483. /* harmony default export */ const _isMasked = (isMasked);
  9484. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_toSource.js
  9485. /** Used for built-in method references. */
  9486. var _toSource_funcProto = Function.prototype;
  9487. /** Used to resolve the decompiled source of functions. */
  9488. var _toSource_funcToString = _toSource_funcProto.toString;
  9489. /**
  9490. * Converts `func` to its source code.
  9491. *
  9492. * @private
  9493. * @param {Function} func The function to convert.
  9494. * @returns {string} Returns the source code.
  9495. */
  9496. function toSource(func) {
  9497. if (func != null) {
  9498. try {
  9499. return _toSource_funcToString.call(func);
  9500. } catch (e) {}
  9501. try {
  9502. return (func + '');
  9503. } catch (e) {}
  9504. }
  9505. return '';
  9506. }
  9507. /* harmony default export */ const _toSource = (toSource);
  9508. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsNative.js
  9509. /**
  9510. * Used to match `RegExp`
  9511. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  9512. */
  9513. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  9514. /** Used to detect host constructors (Safari). */
  9515. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  9516. /** Used for built-in method references. */
  9517. var _baseIsNative_funcProto = Function.prototype,
  9518. _baseIsNative_objectProto = Object.prototype;
  9519. /** Used to resolve the decompiled source of functions. */
  9520. var _baseIsNative_funcToString = _baseIsNative_funcProto.toString;
  9521. /** Used to check objects for own properties. */
  9522. var _baseIsNative_hasOwnProperty = _baseIsNative_objectProto.hasOwnProperty;
  9523. /** Used to detect if a method is native. */
  9524. var reIsNative = RegExp('^' +
  9525. _baseIsNative_funcToString.call(_baseIsNative_hasOwnProperty).replace(reRegExpChar, '\\$&')
  9526. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  9527. );
  9528. /**
  9529. * The base implementation of `_.isNative` without bad shim checks.
  9530. *
  9531. * @private
  9532. * @param {*} value The value to check.
  9533. * @returns {boolean} Returns `true` if `value` is a native function,
  9534. * else `false`.
  9535. */
  9536. function baseIsNative(value) {
  9537. if (!lodash_es_isObject(value) || _isMasked(value)) {
  9538. return false;
  9539. }
  9540. var pattern = lodash_es_isFunction(value) ? reIsNative : reIsHostCtor;
  9541. return pattern.test(_toSource(value));
  9542. }
  9543. /* harmony default export */ const _baseIsNative = (baseIsNative);
  9544. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getValue.js
  9545. /**
  9546. * Gets the value at `key` of `object`.
  9547. *
  9548. * @private
  9549. * @param {Object} [object] The object to query.
  9550. * @param {string} key The key of the property to get.
  9551. * @returns {*} Returns the property value.
  9552. */
  9553. function getValue(object, key) {
  9554. return object == null ? undefined : object[key];
  9555. }
  9556. /* harmony default export */ const _getValue = (getValue);
  9557. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getNative.js
  9558. /**
  9559. * Gets the native function at `key` of `object`.
  9560. *
  9561. * @private
  9562. * @param {Object} object The object to query.
  9563. * @param {string} key The key of the method to get.
  9564. * @returns {*} Returns the function if it's native, else `undefined`.
  9565. */
  9566. function getNative(object, key) {
  9567. var value = _getValue(object, key);
  9568. return _baseIsNative(value) ? value : undefined;
  9569. }
  9570. /* harmony default export */ const _getNative = (getNative);
  9571. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_defineProperty.js
  9572. var defineProperty = (function() {
  9573. try {
  9574. var func = _getNative(Object, 'defineProperty');
  9575. func({}, '', {});
  9576. return func;
  9577. } catch (e) {}
  9578. }());
  9579. /* harmony default export */ const _defineProperty = (defineProperty);
  9580. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseAssignValue.js
  9581. /**
  9582. * The base implementation of `assignValue` and `assignMergeValue` without
  9583. * value checks.
  9584. *
  9585. * @private
  9586. * @param {Object} object The object to modify.
  9587. * @param {string} key The key of the property to assign.
  9588. * @param {*} value The value to assign.
  9589. */
  9590. function baseAssignValue(object, key, value) {
  9591. if (key == '__proto__' && _defineProperty) {
  9592. _defineProperty(object, key, {
  9593. 'configurable': true,
  9594. 'enumerable': true,
  9595. 'value': value,
  9596. 'writable': true
  9597. });
  9598. } else {
  9599. object[key] = value;
  9600. }
  9601. }
  9602. /* harmony default export */ const _baseAssignValue = (baseAssignValue);
  9603. ;// CONCATENATED MODULE: ./node_modules/lodash-es/eq.js
  9604. /**
  9605. * Performs a
  9606. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9607. * comparison between two values to determine if they are equivalent.
  9608. *
  9609. * @static
  9610. * @memberOf _
  9611. * @since 4.0.0
  9612. * @category Lang
  9613. * @param {*} value The value to compare.
  9614. * @param {*} other The other value to compare.
  9615. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  9616. * @example
  9617. *
  9618. * var object = { 'a': 1 };
  9619. * var other = { 'a': 1 };
  9620. *
  9621. * _.eq(object, object);
  9622. * // => true
  9623. *
  9624. * _.eq(object, other);
  9625. * // => false
  9626. *
  9627. * _.eq('a', 'a');
  9628. * // => true
  9629. *
  9630. * _.eq('a', Object('a'));
  9631. * // => false
  9632. *
  9633. * _.eq(NaN, NaN);
  9634. * // => true
  9635. */
  9636. function eq(value, other) {
  9637. return value === other || (value !== value && other !== other);
  9638. }
  9639. /* harmony default export */ const lodash_es_eq = (eq);
  9640. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_assignValue.js
  9641. /** Used for built-in method references. */
  9642. var _assignValue_objectProto = Object.prototype;
  9643. /** Used to check objects for own properties. */
  9644. var _assignValue_hasOwnProperty = _assignValue_objectProto.hasOwnProperty;
  9645. /**
  9646. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  9647. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9648. * for equality comparisons.
  9649. *
  9650. * @private
  9651. * @param {Object} object The object to modify.
  9652. * @param {string} key The key of the property to assign.
  9653. * @param {*} value The value to assign.
  9654. */
  9655. function assignValue(object, key, value) {
  9656. var objValue = object[key];
  9657. if (!(_assignValue_hasOwnProperty.call(object, key) && lodash_es_eq(objValue, value)) ||
  9658. (value === undefined && !(key in object))) {
  9659. _baseAssignValue(object, key, value);
  9660. }
  9661. }
  9662. /* harmony default export */ const _assignValue = (assignValue);
  9663. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_copyObject.js
  9664. /**
  9665. * Copies properties of `source` to `object`.
  9666. *
  9667. * @private
  9668. * @param {Object} source The object to copy properties from.
  9669. * @param {Array} props The property identifiers to copy.
  9670. * @param {Object} [object={}] The object to copy properties to.
  9671. * @param {Function} [customizer] The function to customize copied values.
  9672. * @returns {Object} Returns `object`.
  9673. */
  9674. function copyObject(source, props, object, customizer) {
  9675. var isNew = !object;
  9676. object || (object = {});
  9677. var index = -1,
  9678. length = props.length;
  9679. while (++index < length) {
  9680. var key = props[index];
  9681. var newValue = customizer
  9682. ? customizer(object[key], source[key], key, object, source)
  9683. : undefined;
  9684. if (newValue === undefined) {
  9685. newValue = source[key];
  9686. }
  9687. if (isNew) {
  9688. _baseAssignValue(object, key, newValue);
  9689. } else {
  9690. _assignValue(object, key, newValue);
  9691. }
  9692. }
  9693. return object;
  9694. }
  9695. /* harmony default export */ const _copyObject = (copyObject);
  9696. ;// CONCATENATED MODULE: ./node_modules/lodash-es/identity.js
  9697. /**
  9698. * This method returns the first argument it receives.
  9699. *
  9700. * @static
  9701. * @since 0.1.0
  9702. * @memberOf _
  9703. * @category Util
  9704. * @param {*} value Any value.
  9705. * @returns {*} Returns `value`.
  9706. * @example
  9707. *
  9708. * var object = { 'a': 1 };
  9709. *
  9710. * console.log(_.identity(object) === object);
  9711. * // => true
  9712. */
  9713. function identity(value) {
  9714. return value;
  9715. }
  9716. /* harmony default export */ const lodash_es_identity = (identity);
  9717. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_apply.js
  9718. /**
  9719. * A faster alternative to `Function#apply`, this function invokes `func`
  9720. * with the `this` binding of `thisArg` and the arguments of `args`.
  9721. *
  9722. * @private
  9723. * @param {Function} func The function to invoke.
  9724. * @param {*} thisArg The `this` binding of `func`.
  9725. * @param {Array} args The arguments to invoke `func` with.
  9726. * @returns {*} Returns the result of `func`.
  9727. */
  9728. function apply(func, thisArg, args) {
  9729. switch (args.length) {
  9730. case 0: return func.call(thisArg);
  9731. case 1: return func.call(thisArg, args[0]);
  9732. case 2: return func.call(thisArg, args[0], args[1]);
  9733. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  9734. }
  9735. return func.apply(thisArg, args);
  9736. }
  9737. /* harmony default export */ const _apply = (apply);
  9738. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_overRest.js
  9739. /* Built-in method references for those with the same name as other `lodash` methods. */
  9740. var nativeMax = Math.max;
  9741. /**
  9742. * A specialized version of `baseRest` which transforms the rest array.
  9743. *
  9744. * @private
  9745. * @param {Function} func The function to apply a rest parameter to.
  9746. * @param {number} [start=func.length-1] The start position of the rest parameter.
  9747. * @param {Function} transform The rest array transform.
  9748. * @returns {Function} Returns the new function.
  9749. */
  9750. function overRest(func, start, transform) {
  9751. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  9752. return function() {
  9753. var args = arguments,
  9754. index = -1,
  9755. length = nativeMax(args.length - start, 0),
  9756. array = Array(length);
  9757. while (++index < length) {
  9758. array[index] = args[start + index];
  9759. }
  9760. index = -1;
  9761. var otherArgs = Array(start + 1);
  9762. while (++index < start) {
  9763. otherArgs[index] = args[index];
  9764. }
  9765. otherArgs[start] = transform(array);
  9766. return _apply(func, this, otherArgs);
  9767. };
  9768. }
  9769. /* harmony default export */ const _overRest = (overRest);
  9770. ;// CONCATENATED MODULE: ./node_modules/lodash-es/constant.js
  9771. /**
  9772. * Creates a function that returns `value`.
  9773. *
  9774. * @static
  9775. * @memberOf _
  9776. * @since 2.4.0
  9777. * @category Util
  9778. * @param {*} value The value to return from the new function.
  9779. * @returns {Function} Returns the new constant function.
  9780. * @example
  9781. *
  9782. * var objects = _.times(2, _.constant({ 'a': 1 }));
  9783. *
  9784. * console.log(objects);
  9785. * // => [{ 'a': 1 }, { 'a': 1 }]
  9786. *
  9787. * console.log(objects[0] === objects[1]);
  9788. * // => true
  9789. */
  9790. function constant(value) {
  9791. return function() {
  9792. return value;
  9793. };
  9794. }
  9795. /* harmony default export */ const lodash_es_constant = (constant);
  9796. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSetToString.js
  9797. /**
  9798. * The base implementation of `setToString` without support for hot loop shorting.
  9799. *
  9800. * @private
  9801. * @param {Function} func The function to modify.
  9802. * @param {Function} string The `toString` result.
  9803. * @returns {Function} Returns `func`.
  9804. */
  9805. var baseSetToString = !_defineProperty ? lodash_es_identity : function(func, string) {
  9806. return _defineProperty(func, 'toString', {
  9807. 'configurable': true,
  9808. 'enumerable': false,
  9809. 'value': lodash_es_constant(string),
  9810. 'writable': true
  9811. });
  9812. };
  9813. /* harmony default export */ const _baseSetToString = (baseSetToString);
  9814. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_shortOut.js
  9815. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  9816. var HOT_COUNT = 800,
  9817. HOT_SPAN = 16;
  9818. /* Built-in method references for those with the same name as other `lodash` methods. */
  9819. var nativeNow = Date.now;
  9820. /**
  9821. * Creates a function that'll short out and invoke `identity` instead
  9822. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  9823. * milliseconds.
  9824. *
  9825. * @private
  9826. * @param {Function} func The function to restrict.
  9827. * @returns {Function} Returns the new shortable function.
  9828. */
  9829. function shortOut(func) {
  9830. var count = 0,
  9831. lastCalled = 0;
  9832. return function() {
  9833. var stamp = nativeNow(),
  9834. remaining = HOT_SPAN - (stamp - lastCalled);
  9835. lastCalled = stamp;
  9836. if (remaining > 0) {
  9837. if (++count >= HOT_COUNT) {
  9838. return arguments[0];
  9839. }
  9840. } else {
  9841. count = 0;
  9842. }
  9843. return func.apply(undefined, arguments);
  9844. };
  9845. }
  9846. /* harmony default export */ const _shortOut = (shortOut);
  9847. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_setToString.js
  9848. /**
  9849. * Sets the `toString` method of `func` to return `string`.
  9850. *
  9851. * @private
  9852. * @param {Function} func The function to modify.
  9853. * @param {Function} string The `toString` result.
  9854. * @returns {Function} Returns `func`.
  9855. */
  9856. var setToString = _shortOut(_baseSetToString);
  9857. /* harmony default export */ const _setToString = (setToString);
  9858. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseRest.js
  9859. /**
  9860. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  9861. *
  9862. * @private
  9863. * @param {Function} func The function to apply a rest parameter to.
  9864. * @param {number} [start=func.length-1] The start position of the rest parameter.
  9865. * @returns {Function} Returns the new function.
  9866. */
  9867. function baseRest(func, start) {
  9868. return _setToString(_overRest(func, start, lodash_es_identity), func + '');
  9869. }
  9870. /* harmony default export */ const _baseRest = (baseRest);
  9871. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isLength.js
  9872. /** Used as references for various `Number` constants. */
  9873. var MAX_SAFE_INTEGER = 9007199254740991;
  9874. /**
  9875. * Checks if `value` is a valid array-like length.
  9876. *
  9877. * **Note:** This method is loosely based on
  9878. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  9879. *
  9880. * @static
  9881. * @memberOf _
  9882. * @since 4.0.0
  9883. * @category Lang
  9884. * @param {*} value The value to check.
  9885. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  9886. * @example
  9887. *
  9888. * _.isLength(3);
  9889. * // => true
  9890. *
  9891. * _.isLength(Number.MIN_VALUE);
  9892. * // => false
  9893. *
  9894. * _.isLength(Infinity);
  9895. * // => false
  9896. *
  9897. * _.isLength('3');
  9898. * // => false
  9899. */
  9900. function isLength(value) {
  9901. return typeof value == 'number' &&
  9902. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  9903. }
  9904. /* harmony default export */ const lodash_es_isLength = (isLength);
  9905. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isArrayLike.js
  9906. /**
  9907. * Checks if `value` is array-like. A value is considered array-like if it's
  9908. * not a function and has a `value.length` that's an integer greater than or
  9909. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  9910. *
  9911. * @static
  9912. * @memberOf _
  9913. * @since 4.0.0
  9914. * @category Lang
  9915. * @param {*} value The value to check.
  9916. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  9917. * @example
  9918. *
  9919. * _.isArrayLike([1, 2, 3]);
  9920. * // => true
  9921. *
  9922. * _.isArrayLike(document.body.children);
  9923. * // => true
  9924. *
  9925. * _.isArrayLike('abc');
  9926. * // => true
  9927. *
  9928. * _.isArrayLike(_.noop);
  9929. * // => false
  9930. */
  9931. function isArrayLike(value) {
  9932. return value != null && lodash_es_isLength(value.length) && !lodash_es_isFunction(value);
  9933. }
  9934. /* harmony default export */ const lodash_es_isArrayLike = (isArrayLike);
  9935. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isIndex.js
  9936. /** Used as references for various `Number` constants. */
  9937. var _isIndex_MAX_SAFE_INTEGER = 9007199254740991;
  9938. /** Used to detect unsigned integer values. */
  9939. var reIsUint = /^(?:0|[1-9]\d*)$/;
  9940. /**
  9941. * Checks if `value` is a valid array-like index.
  9942. *
  9943. * @private
  9944. * @param {*} value The value to check.
  9945. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  9946. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  9947. */
  9948. function isIndex(value, length) {
  9949. var type = typeof value;
  9950. length = length == null ? _isIndex_MAX_SAFE_INTEGER : length;
  9951. return !!length &&
  9952. (type == 'number' ||
  9953. (type != 'symbol' && reIsUint.test(value))) &&
  9954. (value > -1 && value % 1 == 0 && value < length);
  9955. }
  9956. /* harmony default export */ const _isIndex = (isIndex);
  9957. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isIterateeCall.js
  9958. /**
  9959. * Checks if the given arguments are from an iteratee call.
  9960. *
  9961. * @private
  9962. * @param {*} value The potential iteratee value argument.
  9963. * @param {*} index The potential iteratee index or key argument.
  9964. * @param {*} object The potential iteratee object argument.
  9965. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  9966. * else `false`.
  9967. */
  9968. function isIterateeCall(value, index, object) {
  9969. if (!lodash_es_isObject(object)) {
  9970. return false;
  9971. }
  9972. var type = typeof index;
  9973. if (type == 'number'
  9974. ? (lodash_es_isArrayLike(object) && _isIndex(index, object.length))
  9975. : (type == 'string' && index in object)
  9976. ) {
  9977. return lodash_es_eq(object[index], value);
  9978. }
  9979. return false;
  9980. }
  9981. /* harmony default export */ const _isIterateeCall = (isIterateeCall);
  9982. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createAssigner.js
  9983. /**
  9984. * Creates a function like `_.assign`.
  9985. *
  9986. * @private
  9987. * @param {Function} assigner The function to assign values.
  9988. * @returns {Function} Returns the new assigner function.
  9989. */
  9990. function createAssigner(assigner) {
  9991. return _baseRest(function(object, sources) {
  9992. var index = -1,
  9993. length = sources.length,
  9994. customizer = length > 1 ? sources[length - 1] : undefined,
  9995. guard = length > 2 ? sources[2] : undefined;
  9996. customizer = (assigner.length > 3 && typeof customizer == 'function')
  9997. ? (length--, customizer)
  9998. : undefined;
  9999. if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
  10000. customizer = length < 3 ? undefined : customizer;
  10001. length = 1;
  10002. }
  10003. object = Object(object);
  10004. while (++index < length) {
  10005. var source = sources[index];
  10006. if (source) {
  10007. assigner(object, source, index, customizer);
  10008. }
  10009. }
  10010. return object;
  10011. });
  10012. }
  10013. /* harmony default export */ const _createAssigner = (createAssigner);
  10014. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseTimes.js
  10015. /**
  10016. * The base implementation of `_.times` without support for iteratee shorthands
  10017. * or max array length checks.
  10018. *
  10019. * @private
  10020. * @param {number} n The number of times to invoke `iteratee`.
  10021. * @param {Function} iteratee The function invoked per iteration.
  10022. * @returns {Array} Returns the array of results.
  10023. */
  10024. function baseTimes(n, iteratee) {
  10025. var index = -1,
  10026. result = Array(n);
  10027. while (++index < n) {
  10028. result[index] = iteratee(index);
  10029. }
  10030. return result;
  10031. }
  10032. /* harmony default export */ const _baseTimes = (baseTimes);
  10033. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsArguments.js
  10034. /** `Object#toString` result references. */
  10035. var argsTag = '[object Arguments]';
  10036. /**
  10037. * The base implementation of `_.isArguments`.
  10038. *
  10039. * @private
  10040. * @param {*} value The value to check.
  10041. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10042. */
  10043. function baseIsArguments(value) {
  10044. return lodash_es_isObjectLike(value) && _baseGetTag(value) == argsTag;
  10045. }
  10046. /* harmony default export */ const _baseIsArguments = (baseIsArguments);
  10047. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isArguments.js
  10048. /** Used for built-in method references. */
  10049. var isArguments_objectProto = Object.prototype;
  10050. /** Used to check objects for own properties. */
  10051. var isArguments_hasOwnProperty = isArguments_objectProto.hasOwnProperty;
  10052. /** Built-in value references. */
  10053. var propertyIsEnumerable = isArguments_objectProto.propertyIsEnumerable;
  10054. /**
  10055. * Checks if `value` is likely an `arguments` object.
  10056. *
  10057. * @static
  10058. * @memberOf _
  10059. * @since 0.1.0
  10060. * @category Lang
  10061. * @param {*} value The value to check.
  10062. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  10063. * else `false`.
  10064. * @example
  10065. *
  10066. * _.isArguments(function() { return arguments; }());
  10067. * // => true
  10068. *
  10069. * _.isArguments([1, 2, 3]);
  10070. * // => false
  10071. */
  10072. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  10073. return lodash_es_isObjectLike(value) && isArguments_hasOwnProperty.call(value, 'callee') &&
  10074. !propertyIsEnumerable.call(value, 'callee');
  10075. };
  10076. /* harmony default export */ const lodash_es_isArguments = (isArguments);
  10077. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isArray.js
  10078. /**
  10079. * Checks if `value` is classified as an `Array` object.
  10080. *
  10081. * @static
  10082. * @memberOf _
  10083. * @since 0.1.0
  10084. * @category Lang
  10085. * @param {*} value The value to check.
  10086. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  10087. * @example
  10088. *
  10089. * _.isArray([1, 2, 3]);
  10090. * // => true
  10091. *
  10092. * _.isArray(document.body.children);
  10093. * // => false
  10094. *
  10095. * _.isArray('abc');
  10096. * // => false
  10097. *
  10098. * _.isArray(_.noop);
  10099. * // => false
  10100. */
  10101. var isArray = Array.isArray;
  10102. /* harmony default export */ const lodash_es_isArray = (isArray);
  10103. ;// CONCATENATED MODULE: ./node_modules/lodash-es/stubFalse.js
  10104. /**
  10105. * This method returns `false`.
  10106. *
  10107. * @static
  10108. * @memberOf _
  10109. * @since 4.13.0
  10110. * @category Util
  10111. * @returns {boolean} Returns `false`.
  10112. * @example
  10113. *
  10114. * _.times(2, _.stubFalse);
  10115. * // => [false, false]
  10116. */
  10117. function stubFalse() {
  10118. return false;
  10119. }
  10120. /* harmony default export */ const lodash_es_stubFalse = (stubFalse);
  10121. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isBuffer.js
  10122. /** Detect free variable `exports`. */
  10123. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  10124. /** Detect free variable `module`. */
  10125. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  10126. /** Detect the popular CommonJS extension `module.exports`. */
  10127. var moduleExports = freeModule && freeModule.exports === freeExports;
  10128. /** Built-in value references. */
  10129. var Buffer = moduleExports ? _root.Buffer : undefined;
  10130. /* Built-in method references for those with the same name as other `lodash` methods. */
  10131. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  10132. /**
  10133. * Checks if `value` is a buffer.
  10134. *
  10135. * @static
  10136. * @memberOf _
  10137. * @since 4.3.0
  10138. * @category Lang
  10139. * @param {*} value The value to check.
  10140. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  10141. * @example
  10142. *
  10143. * _.isBuffer(new Buffer(2));
  10144. * // => true
  10145. *
  10146. * _.isBuffer(new Uint8Array(2));
  10147. * // => false
  10148. */
  10149. var isBuffer = nativeIsBuffer || lodash_es_stubFalse;
  10150. /* harmony default export */ const lodash_es_isBuffer = (isBuffer);
  10151. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsTypedArray.js
  10152. /** `Object#toString` result references. */
  10153. var _baseIsTypedArray_argsTag = '[object Arguments]',
  10154. arrayTag = '[object Array]',
  10155. boolTag = '[object Boolean]',
  10156. dateTag = '[object Date]',
  10157. errorTag = '[object Error]',
  10158. _baseIsTypedArray_funcTag = '[object Function]',
  10159. mapTag = '[object Map]',
  10160. numberTag = '[object Number]',
  10161. _baseIsTypedArray_objectTag = '[object Object]',
  10162. regexpTag = '[object RegExp]',
  10163. setTag = '[object Set]',
  10164. stringTag = '[object String]',
  10165. weakMapTag = '[object WeakMap]';
  10166. var arrayBufferTag = '[object ArrayBuffer]',
  10167. dataViewTag = '[object DataView]',
  10168. float32Tag = '[object Float32Array]',
  10169. float64Tag = '[object Float64Array]',
  10170. int8Tag = '[object Int8Array]',
  10171. int16Tag = '[object Int16Array]',
  10172. int32Tag = '[object Int32Array]',
  10173. uint8Tag = '[object Uint8Array]',
  10174. uint8ClampedTag = '[object Uint8ClampedArray]',
  10175. uint16Tag = '[object Uint16Array]',
  10176. uint32Tag = '[object Uint32Array]';
  10177. /** Used to identify `toStringTag` values of typed arrays. */
  10178. var typedArrayTags = {};
  10179. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  10180. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  10181. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  10182. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  10183. typedArrayTags[uint32Tag] = true;
  10184. typedArrayTags[_baseIsTypedArray_argsTag] = typedArrayTags[arrayTag] =
  10185. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  10186. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  10187. typedArrayTags[errorTag] = typedArrayTags[_baseIsTypedArray_funcTag] =
  10188. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  10189. typedArrayTags[_baseIsTypedArray_objectTag] = typedArrayTags[regexpTag] =
  10190. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  10191. typedArrayTags[weakMapTag] = false;
  10192. /**
  10193. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  10194. *
  10195. * @private
  10196. * @param {*} value The value to check.
  10197. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10198. */
  10199. function baseIsTypedArray(value) {
  10200. return lodash_es_isObjectLike(value) &&
  10201. lodash_es_isLength(value.length) && !!typedArrayTags[_baseGetTag(value)];
  10202. }
  10203. /* harmony default export */ const _baseIsTypedArray = (baseIsTypedArray);
  10204. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseUnary.js
  10205. /**
  10206. * The base implementation of `_.unary` without support for storing metadata.
  10207. *
  10208. * @private
  10209. * @param {Function} func The function to cap arguments for.
  10210. * @returns {Function} Returns the new capped function.
  10211. */
  10212. function baseUnary(func) {
  10213. return function(value) {
  10214. return func(value);
  10215. };
  10216. }
  10217. /* harmony default export */ const _baseUnary = (baseUnary);
  10218. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_nodeUtil.js
  10219. /** Detect free variable `exports`. */
  10220. var _nodeUtil_freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  10221. /** Detect free variable `module`. */
  10222. var _nodeUtil_freeModule = _nodeUtil_freeExports && typeof module == 'object' && module && !module.nodeType && module;
  10223. /** Detect the popular CommonJS extension `module.exports`. */
  10224. var _nodeUtil_moduleExports = _nodeUtil_freeModule && _nodeUtil_freeModule.exports === _nodeUtil_freeExports;
  10225. /** Detect free variable `process` from Node.js. */
  10226. var freeProcess = _nodeUtil_moduleExports && _freeGlobal.process;
  10227. /** Used to access faster Node.js helpers. */
  10228. var nodeUtil = (function() {
  10229. try {
  10230. // Use `util.types` for Node.js 10+.
  10231. var types = _nodeUtil_freeModule && _nodeUtil_freeModule.require && _nodeUtil_freeModule.require('util').types;
  10232. if (types) {
  10233. return types;
  10234. }
  10235. // Legacy `process.binding('util')` for Node.js < 10.
  10236. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  10237. } catch (e) {}
  10238. }());
  10239. /* harmony default export */ const _nodeUtil = (nodeUtil);
  10240. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isTypedArray.js
  10241. /* Node.js helper references. */
  10242. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  10243. /**
  10244. * Checks if `value` is classified as a typed array.
  10245. *
  10246. * @static
  10247. * @memberOf _
  10248. * @since 3.0.0
  10249. * @category Lang
  10250. * @param {*} value The value to check.
  10251. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  10252. * @example
  10253. *
  10254. * _.isTypedArray(new Uint8Array);
  10255. * // => true
  10256. *
  10257. * _.isTypedArray([]);
  10258. * // => false
  10259. */
  10260. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  10261. /* harmony default export */ const lodash_es_isTypedArray = (isTypedArray);
  10262. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayLikeKeys.js
  10263. /** Used for built-in method references. */
  10264. var _arrayLikeKeys_objectProto = Object.prototype;
  10265. /** Used to check objects for own properties. */
  10266. var _arrayLikeKeys_hasOwnProperty = _arrayLikeKeys_objectProto.hasOwnProperty;
  10267. /**
  10268. * Creates an array of the enumerable property names of the array-like `value`.
  10269. *
  10270. * @private
  10271. * @param {*} value The value to query.
  10272. * @param {boolean} inherited Specify returning inherited property names.
  10273. * @returns {Array} Returns the array of property names.
  10274. */
  10275. function arrayLikeKeys(value, inherited) {
  10276. var isArr = lodash_es_isArray(value),
  10277. isArg = !isArr && lodash_es_isArguments(value),
  10278. isBuff = !isArr && !isArg && lodash_es_isBuffer(value),
  10279. isType = !isArr && !isArg && !isBuff && lodash_es_isTypedArray(value),
  10280. skipIndexes = isArr || isArg || isBuff || isType,
  10281. result = skipIndexes ? _baseTimes(value.length, String) : [],
  10282. length = result.length;
  10283. for (var key in value) {
  10284. if ((inherited || _arrayLikeKeys_hasOwnProperty.call(value, key)) &&
  10285. !(skipIndexes && (
  10286. // Safari 9 has enumerable `arguments.length` in strict mode.
  10287. key == 'length' ||
  10288. // Node.js 0.10 has enumerable non-index properties on buffers.
  10289. (isBuff && (key == 'offset' || key == 'parent')) ||
  10290. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  10291. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  10292. // Skip index properties.
  10293. _isIndex(key, length)
  10294. ))) {
  10295. result.push(key);
  10296. }
  10297. }
  10298. return result;
  10299. }
  10300. /* harmony default export */ const _arrayLikeKeys = (arrayLikeKeys);
  10301. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isPrototype.js
  10302. /** Used for built-in method references. */
  10303. var _isPrototype_objectProto = Object.prototype;
  10304. /**
  10305. * Checks if `value` is likely a prototype object.
  10306. *
  10307. * @private
  10308. * @param {*} value The value to check.
  10309. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  10310. */
  10311. function isPrototype(value) {
  10312. var Ctor = value && value.constructor,
  10313. proto = (typeof Ctor == 'function' && Ctor.prototype) || _isPrototype_objectProto;
  10314. return value === proto;
  10315. }
  10316. /* harmony default export */ const _isPrototype = (isPrototype);
  10317. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_nativeKeysIn.js
  10318. /**
  10319. * This function is like
  10320. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  10321. * except that it includes inherited enumerable properties.
  10322. *
  10323. * @private
  10324. * @param {Object} object The object to query.
  10325. * @returns {Array} Returns the array of property names.
  10326. */
  10327. function nativeKeysIn(object) {
  10328. var result = [];
  10329. if (object != null) {
  10330. for (var key in Object(object)) {
  10331. result.push(key);
  10332. }
  10333. }
  10334. return result;
  10335. }
  10336. /* harmony default export */ const _nativeKeysIn = (nativeKeysIn);
  10337. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseKeysIn.js
  10338. /** Used for built-in method references. */
  10339. var _baseKeysIn_objectProto = Object.prototype;
  10340. /** Used to check objects for own properties. */
  10341. var _baseKeysIn_hasOwnProperty = _baseKeysIn_objectProto.hasOwnProperty;
  10342. /**
  10343. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  10344. *
  10345. * @private
  10346. * @param {Object} object The object to query.
  10347. * @returns {Array} Returns the array of property names.
  10348. */
  10349. function baseKeysIn(object) {
  10350. if (!lodash_es_isObject(object)) {
  10351. return _nativeKeysIn(object);
  10352. }
  10353. var isProto = _isPrototype(object),
  10354. result = [];
  10355. for (var key in object) {
  10356. if (!(key == 'constructor' && (isProto || !_baseKeysIn_hasOwnProperty.call(object, key)))) {
  10357. result.push(key);
  10358. }
  10359. }
  10360. return result;
  10361. }
  10362. /* harmony default export */ const _baseKeysIn = (baseKeysIn);
  10363. ;// CONCATENATED MODULE: ./node_modules/lodash-es/keysIn.js
  10364. /**
  10365. * Creates an array of the own and inherited enumerable property names of `object`.
  10366. *
  10367. * **Note:** Non-object values are coerced to objects.
  10368. *
  10369. * @static
  10370. * @memberOf _
  10371. * @since 3.0.0
  10372. * @category Object
  10373. * @param {Object} object The object to query.
  10374. * @returns {Array} Returns the array of property names.
  10375. * @example
  10376. *
  10377. * function Foo() {
  10378. * this.a = 1;
  10379. * this.b = 2;
  10380. * }
  10381. *
  10382. * Foo.prototype.c = 3;
  10383. *
  10384. * _.keysIn(new Foo);
  10385. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  10386. */
  10387. function keysIn(object) {
  10388. return lodash_es_isArrayLike(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  10389. }
  10390. /* harmony default export */ const lodash_es_keysIn = (keysIn);
  10391. ;// CONCATENATED MODULE: ./node_modules/lodash-es/assignIn.js
  10392. /**
  10393. * This method is like `_.assign` except that it iterates over own and
  10394. * inherited source properties.
  10395. *
  10396. * **Note:** This method mutates `object`.
  10397. *
  10398. * @static
  10399. * @memberOf _
  10400. * @since 4.0.0
  10401. * @alias extend
  10402. * @category Object
  10403. * @param {Object} object The destination object.
  10404. * @param {...Object} [sources] The source objects.
  10405. * @returns {Object} Returns `object`.
  10406. * @see _.assign
  10407. * @example
  10408. *
  10409. * function Foo() {
  10410. * this.a = 1;
  10411. * }
  10412. *
  10413. * function Bar() {
  10414. * this.c = 3;
  10415. * }
  10416. *
  10417. * Foo.prototype.b = 2;
  10418. * Bar.prototype.d = 4;
  10419. *
  10420. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  10421. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  10422. */
  10423. var assignIn = _createAssigner(function(object, source) {
  10424. _copyObject(source, lodash_es_keysIn(source), object);
  10425. });
  10426. /* harmony default export */ const lodash_es_assignIn = (assignIn);
  10427. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arraySome.js
  10428. /**
  10429. * A specialized version of `_.some` for arrays without support for iteratee
  10430. * shorthands.
  10431. *
  10432. * @private
  10433. * @param {Array} [array] The array to iterate over.
  10434. * @param {Function} predicate The function invoked per iteration.
  10435. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10436. * else `false`.
  10437. */
  10438. function arraySome(array, predicate) {
  10439. var index = -1,
  10440. length = array == null ? 0 : array.length;
  10441. while (++index < length) {
  10442. if (predicate(array[index], index, array)) {
  10443. return true;
  10444. }
  10445. }
  10446. return false;
  10447. }
  10448. /* harmony default export */ const _arraySome = (arraySome);
  10449. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_listCacheClear.js
  10450. /**
  10451. * Removes all key-value entries from the list cache.
  10452. *
  10453. * @private
  10454. * @name clear
  10455. * @memberOf ListCache
  10456. */
  10457. function listCacheClear() {
  10458. this.__data__ = [];
  10459. this.size = 0;
  10460. }
  10461. /* harmony default export */ const _listCacheClear = (listCacheClear);
  10462. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_assocIndexOf.js
  10463. /**
  10464. * Gets the index at which the `key` is found in `array` of key-value pairs.
  10465. *
  10466. * @private
  10467. * @param {Array} array The array to inspect.
  10468. * @param {*} key The key to search for.
  10469. * @returns {number} Returns the index of the matched value, else `-1`.
  10470. */
  10471. function assocIndexOf(array, key) {
  10472. var length = array.length;
  10473. while (length--) {
  10474. if (lodash_es_eq(array[length][0], key)) {
  10475. return length;
  10476. }
  10477. }
  10478. return -1;
  10479. }
  10480. /* harmony default export */ const _assocIndexOf = (assocIndexOf);
  10481. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_listCacheDelete.js
  10482. /** Used for built-in method references. */
  10483. var arrayProto = Array.prototype;
  10484. /** Built-in value references. */
  10485. var splice = arrayProto.splice;
  10486. /**
  10487. * Removes `key` and its value from the list cache.
  10488. *
  10489. * @private
  10490. * @name delete
  10491. * @memberOf ListCache
  10492. * @param {string} key The key of the value to remove.
  10493. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10494. */
  10495. function listCacheDelete(key) {
  10496. var data = this.__data__,
  10497. index = _assocIndexOf(data, key);
  10498. if (index < 0) {
  10499. return false;
  10500. }
  10501. var lastIndex = data.length - 1;
  10502. if (index == lastIndex) {
  10503. data.pop();
  10504. } else {
  10505. splice.call(data, index, 1);
  10506. }
  10507. --this.size;
  10508. return true;
  10509. }
  10510. /* harmony default export */ const _listCacheDelete = (listCacheDelete);
  10511. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_listCacheGet.js
  10512. /**
  10513. * Gets the list cache value for `key`.
  10514. *
  10515. * @private
  10516. * @name get
  10517. * @memberOf ListCache
  10518. * @param {string} key The key of the value to get.
  10519. * @returns {*} Returns the entry value.
  10520. */
  10521. function listCacheGet(key) {
  10522. var data = this.__data__,
  10523. index = _assocIndexOf(data, key);
  10524. return index < 0 ? undefined : data[index][1];
  10525. }
  10526. /* harmony default export */ const _listCacheGet = (listCacheGet);
  10527. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_listCacheHas.js
  10528. /**
  10529. * Checks if a list cache value for `key` exists.
  10530. *
  10531. * @private
  10532. * @name has
  10533. * @memberOf ListCache
  10534. * @param {string} key The key of the entry to check.
  10535. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10536. */
  10537. function listCacheHas(key) {
  10538. return _assocIndexOf(this.__data__, key) > -1;
  10539. }
  10540. /* harmony default export */ const _listCacheHas = (listCacheHas);
  10541. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_listCacheSet.js
  10542. /**
  10543. * Sets the list cache `key` to `value`.
  10544. *
  10545. * @private
  10546. * @name set
  10547. * @memberOf ListCache
  10548. * @param {string} key The key of the value to set.
  10549. * @param {*} value The value to set.
  10550. * @returns {Object} Returns the list cache instance.
  10551. */
  10552. function listCacheSet(key, value) {
  10553. var data = this.__data__,
  10554. index = _assocIndexOf(data, key);
  10555. if (index < 0) {
  10556. ++this.size;
  10557. data.push([key, value]);
  10558. } else {
  10559. data[index][1] = value;
  10560. }
  10561. return this;
  10562. }
  10563. /* harmony default export */ const _listCacheSet = (listCacheSet);
  10564. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_ListCache.js
  10565. /**
  10566. * Creates an list cache object.
  10567. *
  10568. * @private
  10569. * @constructor
  10570. * @param {Array} [entries] The key-value pairs to cache.
  10571. */
  10572. function ListCache(entries) {
  10573. var index = -1,
  10574. length = entries == null ? 0 : entries.length;
  10575. this.clear();
  10576. while (++index < length) {
  10577. var entry = entries[index];
  10578. this.set(entry[0], entry[1]);
  10579. }
  10580. }
  10581. // Add methods to `ListCache`.
  10582. ListCache.prototype.clear = _listCacheClear;
  10583. ListCache.prototype['delete'] = _listCacheDelete;
  10584. ListCache.prototype.get = _listCacheGet;
  10585. ListCache.prototype.has = _listCacheHas;
  10586. ListCache.prototype.set = _listCacheSet;
  10587. /* harmony default export */ const _ListCache = (ListCache);
  10588. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stackClear.js
  10589. /**
  10590. * Removes all key-value entries from the stack.
  10591. *
  10592. * @private
  10593. * @name clear
  10594. * @memberOf Stack
  10595. */
  10596. function stackClear() {
  10597. this.__data__ = new _ListCache;
  10598. this.size = 0;
  10599. }
  10600. /* harmony default export */ const _stackClear = (stackClear);
  10601. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stackDelete.js
  10602. /**
  10603. * Removes `key` and its value from the stack.
  10604. *
  10605. * @private
  10606. * @name delete
  10607. * @memberOf Stack
  10608. * @param {string} key The key of the value to remove.
  10609. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10610. */
  10611. function stackDelete(key) {
  10612. var data = this.__data__,
  10613. result = data['delete'](key);
  10614. this.size = data.size;
  10615. return result;
  10616. }
  10617. /* harmony default export */ const _stackDelete = (stackDelete);
  10618. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stackGet.js
  10619. /**
  10620. * Gets the stack value for `key`.
  10621. *
  10622. * @private
  10623. * @name get
  10624. * @memberOf Stack
  10625. * @param {string} key The key of the value to get.
  10626. * @returns {*} Returns the entry value.
  10627. */
  10628. function stackGet(key) {
  10629. return this.__data__.get(key);
  10630. }
  10631. /* harmony default export */ const _stackGet = (stackGet);
  10632. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stackHas.js
  10633. /**
  10634. * Checks if a stack value for `key` exists.
  10635. *
  10636. * @private
  10637. * @name has
  10638. * @memberOf Stack
  10639. * @param {string} key The key of the entry to check.
  10640. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10641. */
  10642. function stackHas(key) {
  10643. return this.__data__.has(key);
  10644. }
  10645. /* harmony default export */ const _stackHas = (stackHas);
  10646. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Map.js
  10647. /* Built-in method references that are verified to be native. */
  10648. var _Map_Map = _getNative(_root, 'Map');
  10649. /* harmony default export */ const _Map = (_Map_Map);
  10650. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_nativeCreate.js
  10651. /* Built-in method references that are verified to be native. */
  10652. var nativeCreate = _getNative(Object, 'create');
  10653. /* harmony default export */ const _nativeCreate = (nativeCreate);
  10654. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hashClear.js
  10655. /**
  10656. * Removes all key-value entries from the hash.
  10657. *
  10658. * @private
  10659. * @name clear
  10660. * @memberOf Hash
  10661. */
  10662. function hashClear() {
  10663. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  10664. this.size = 0;
  10665. }
  10666. /* harmony default export */ const _hashClear = (hashClear);
  10667. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hashDelete.js
  10668. /**
  10669. * Removes `key` and its value from the hash.
  10670. *
  10671. * @private
  10672. * @name delete
  10673. * @memberOf Hash
  10674. * @param {Object} hash The hash to modify.
  10675. * @param {string} key The key of the value to remove.
  10676. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10677. */
  10678. function hashDelete(key) {
  10679. var result = this.has(key) && delete this.__data__[key];
  10680. this.size -= result ? 1 : 0;
  10681. return result;
  10682. }
  10683. /* harmony default export */ const _hashDelete = (hashDelete);
  10684. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hashGet.js
  10685. /** Used to stand-in for `undefined` hash values. */
  10686. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10687. /** Used for built-in method references. */
  10688. var _hashGet_objectProto = Object.prototype;
  10689. /** Used to check objects for own properties. */
  10690. var _hashGet_hasOwnProperty = _hashGet_objectProto.hasOwnProperty;
  10691. /**
  10692. * Gets the hash value for `key`.
  10693. *
  10694. * @private
  10695. * @name get
  10696. * @memberOf Hash
  10697. * @param {string} key The key of the value to get.
  10698. * @returns {*} Returns the entry value.
  10699. */
  10700. function hashGet(key) {
  10701. var data = this.__data__;
  10702. if (_nativeCreate) {
  10703. var result = data[key];
  10704. return result === HASH_UNDEFINED ? undefined : result;
  10705. }
  10706. return _hashGet_hasOwnProperty.call(data, key) ? data[key] : undefined;
  10707. }
  10708. /* harmony default export */ const _hashGet = (hashGet);
  10709. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hashHas.js
  10710. /** Used for built-in method references. */
  10711. var _hashHas_objectProto = Object.prototype;
  10712. /** Used to check objects for own properties. */
  10713. var _hashHas_hasOwnProperty = _hashHas_objectProto.hasOwnProperty;
  10714. /**
  10715. * Checks if a hash value for `key` exists.
  10716. *
  10717. * @private
  10718. * @name has
  10719. * @memberOf Hash
  10720. * @param {string} key The key of the entry to check.
  10721. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10722. */
  10723. function hashHas(key) {
  10724. var data = this.__data__;
  10725. return _nativeCreate ? (data[key] !== undefined) : _hashHas_hasOwnProperty.call(data, key);
  10726. }
  10727. /* harmony default export */ const _hashHas = (hashHas);
  10728. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hashSet.js
  10729. /** Used to stand-in for `undefined` hash values. */
  10730. var _hashSet_HASH_UNDEFINED = '__lodash_hash_undefined__';
  10731. /**
  10732. * Sets the hash `key` to `value`.
  10733. *
  10734. * @private
  10735. * @name set
  10736. * @memberOf Hash
  10737. * @param {string} key The key of the value to set.
  10738. * @param {*} value The value to set.
  10739. * @returns {Object} Returns the hash instance.
  10740. */
  10741. function hashSet(key, value) {
  10742. var data = this.__data__;
  10743. this.size += this.has(key) ? 0 : 1;
  10744. data[key] = (_nativeCreate && value === undefined) ? _hashSet_HASH_UNDEFINED : value;
  10745. return this;
  10746. }
  10747. /* harmony default export */ const _hashSet = (hashSet);
  10748. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Hash.js
  10749. /**
  10750. * Creates a hash object.
  10751. *
  10752. * @private
  10753. * @constructor
  10754. * @param {Array} [entries] The key-value pairs to cache.
  10755. */
  10756. function Hash(entries) {
  10757. var index = -1,
  10758. length = entries == null ? 0 : entries.length;
  10759. this.clear();
  10760. while (++index < length) {
  10761. var entry = entries[index];
  10762. this.set(entry[0], entry[1]);
  10763. }
  10764. }
  10765. // Add methods to `Hash`.
  10766. Hash.prototype.clear = _hashClear;
  10767. Hash.prototype['delete'] = _hashDelete;
  10768. Hash.prototype.get = _hashGet;
  10769. Hash.prototype.has = _hashHas;
  10770. Hash.prototype.set = _hashSet;
  10771. /* harmony default export */ const _Hash = (Hash);
  10772. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapCacheClear.js
  10773. /**
  10774. * Removes all key-value entries from the map.
  10775. *
  10776. * @private
  10777. * @name clear
  10778. * @memberOf MapCache
  10779. */
  10780. function mapCacheClear() {
  10781. this.size = 0;
  10782. this.__data__ = {
  10783. 'hash': new _Hash,
  10784. 'map': new (_Map || _ListCache),
  10785. 'string': new _Hash
  10786. };
  10787. }
  10788. /* harmony default export */ const _mapCacheClear = (mapCacheClear);
  10789. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isKeyable.js
  10790. /**
  10791. * Checks if `value` is suitable for use as unique object key.
  10792. *
  10793. * @private
  10794. * @param {*} value The value to check.
  10795. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10796. */
  10797. function isKeyable(value) {
  10798. var type = typeof value;
  10799. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10800. ? (value !== '__proto__')
  10801. : (value === null);
  10802. }
  10803. /* harmony default export */ const _isKeyable = (isKeyable);
  10804. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getMapData.js
  10805. /**
  10806. * Gets the data for `map`.
  10807. *
  10808. * @private
  10809. * @param {Object} map The map to query.
  10810. * @param {string} key The reference key.
  10811. * @returns {*} Returns the map data.
  10812. */
  10813. function getMapData(map, key) {
  10814. var data = map.__data__;
  10815. return _isKeyable(key)
  10816. ? data[typeof key == 'string' ? 'string' : 'hash']
  10817. : data.map;
  10818. }
  10819. /* harmony default export */ const _getMapData = (getMapData);
  10820. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapCacheDelete.js
  10821. /**
  10822. * Removes `key` and its value from the map.
  10823. *
  10824. * @private
  10825. * @name delete
  10826. * @memberOf MapCache
  10827. * @param {string} key The key of the value to remove.
  10828. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  10829. */
  10830. function mapCacheDelete(key) {
  10831. var result = _getMapData(this, key)['delete'](key);
  10832. this.size -= result ? 1 : 0;
  10833. return result;
  10834. }
  10835. /* harmony default export */ const _mapCacheDelete = (mapCacheDelete);
  10836. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapCacheGet.js
  10837. /**
  10838. * Gets the map value for `key`.
  10839. *
  10840. * @private
  10841. * @name get
  10842. * @memberOf MapCache
  10843. * @param {string} key The key of the value to get.
  10844. * @returns {*} Returns the entry value.
  10845. */
  10846. function mapCacheGet(key) {
  10847. return _getMapData(this, key).get(key);
  10848. }
  10849. /* harmony default export */ const _mapCacheGet = (mapCacheGet);
  10850. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapCacheHas.js
  10851. /**
  10852. * Checks if a map value for `key` exists.
  10853. *
  10854. * @private
  10855. * @name has
  10856. * @memberOf MapCache
  10857. * @param {string} key The key of the entry to check.
  10858. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  10859. */
  10860. function mapCacheHas(key) {
  10861. return _getMapData(this, key).has(key);
  10862. }
  10863. /* harmony default export */ const _mapCacheHas = (mapCacheHas);
  10864. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapCacheSet.js
  10865. /**
  10866. * Sets the map `key` to `value`.
  10867. *
  10868. * @private
  10869. * @name set
  10870. * @memberOf MapCache
  10871. * @param {string} key The key of the value to set.
  10872. * @param {*} value The value to set.
  10873. * @returns {Object} Returns the map cache instance.
  10874. */
  10875. function mapCacheSet(key, value) {
  10876. var data = _getMapData(this, key),
  10877. size = data.size;
  10878. data.set(key, value);
  10879. this.size += data.size == size ? 0 : 1;
  10880. return this;
  10881. }
  10882. /* harmony default export */ const _mapCacheSet = (mapCacheSet);
  10883. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_MapCache.js
  10884. /**
  10885. * Creates a map cache object to store key-value pairs.
  10886. *
  10887. * @private
  10888. * @constructor
  10889. * @param {Array} [entries] The key-value pairs to cache.
  10890. */
  10891. function MapCache(entries) {
  10892. var index = -1,
  10893. length = entries == null ? 0 : entries.length;
  10894. this.clear();
  10895. while (++index < length) {
  10896. var entry = entries[index];
  10897. this.set(entry[0], entry[1]);
  10898. }
  10899. }
  10900. // Add methods to `MapCache`.
  10901. MapCache.prototype.clear = _mapCacheClear;
  10902. MapCache.prototype['delete'] = _mapCacheDelete;
  10903. MapCache.prototype.get = _mapCacheGet;
  10904. MapCache.prototype.has = _mapCacheHas;
  10905. MapCache.prototype.set = _mapCacheSet;
  10906. /* harmony default export */ const _MapCache = (MapCache);
  10907. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stackSet.js
  10908. /** Used as the size to enable large array optimizations. */
  10909. var LARGE_ARRAY_SIZE = 200;
  10910. /**
  10911. * Sets the stack `key` to `value`.
  10912. *
  10913. * @private
  10914. * @name set
  10915. * @memberOf Stack
  10916. * @param {string} key The key of the value to set.
  10917. * @param {*} value The value to set.
  10918. * @returns {Object} Returns the stack cache instance.
  10919. */
  10920. function stackSet(key, value) {
  10921. var data = this.__data__;
  10922. if (data instanceof _ListCache) {
  10923. var pairs = data.__data__;
  10924. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  10925. pairs.push([key, value]);
  10926. this.size = ++data.size;
  10927. return this;
  10928. }
  10929. data = this.__data__ = new _MapCache(pairs);
  10930. }
  10931. data.set(key, value);
  10932. this.size = data.size;
  10933. return this;
  10934. }
  10935. /* harmony default export */ const _stackSet = (stackSet);
  10936. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Stack.js
  10937. /**
  10938. * Creates a stack cache object to store key-value pairs.
  10939. *
  10940. * @private
  10941. * @constructor
  10942. * @param {Array} [entries] The key-value pairs to cache.
  10943. */
  10944. function Stack(entries) {
  10945. var data = this.__data__ = new _ListCache(entries);
  10946. this.size = data.size;
  10947. }
  10948. // Add methods to `Stack`.
  10949. Stack.prototype.clear = _stackClear;
  10950. Stack.prototype['delete'] = _stackDelete;
  10951. Stack.prototype.get = _stackGet;
  10952. Stack.prototype.has = _stackHas;
  10953. Stack.prototype.set = _stackSet;
  10954. /* harmony default export */ const _Stack = (Stack);
  10955. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_setCacheAdd.js
  10956. /** Used to stand-in for `undefined` hash values. */
  10957. var _setCacheAdd_HASH_UNDEFINED = '__lodash_hash_undefined__';
  10958. /**
  10959. * Adds `value` to the array cache.
  10960. *
  10961. * @private
  10962. * @name add
  10963. * @memberOf SetCache
  10964. * @alias push
  10965. * @param {*} value The value to cache.
  10966. * @returns {Object} Returns the cache instance.
  10967. */
  10968. function setCacheAdd(value) {
  10969. this.__data__.set(value, _setCacheAdd_HASH_UNDEFINED);
  10970. return this;
  10971. }
  10972. /* harmony default export */ const _setCacheAdd = (setCacheAdd);
  10973. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_setCacheHas.js
  10974. /**
  10975. * Checks if `value` is in the array cache.
  10976. *
  10977. * @private
  10978. * @name has
  10979. * @memberOf SetCache
  10980. * @param {*} value The value to search for.
  10981. * @returns {number} Returns `true` if `value` is found, else `false`.
  10982. */
  10983. function setCacheHas(value) {
  10984. return this.__data__.has(value);
  10985. }
  10986. /* harmony default export */ const _setCacheHas = (setCacheHas);
  10987. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_SetCache.js
  10988. /**
  10989. *
  10990. * Creates an array cache object to store unique values.
  10991. *
  10992. * @private
  10993. * @constructor
  10994. * @param {Array} [values] The values to cache.
  10995. */
  10996. function SetCache(values) {
  10997. var index = -1,
  10998. length = values == null ? 0 : values.length;
  10999. this.__data__ = new _MapCache;
  11000. while (++index < length) {
  11001. this.add(values[index]);
  11002. }
  11003. }
  11004. // Add methods to `SetCache`.
  11005. SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
  11006. SetCache.prototype.has = _setCacheHas;
  11007. /* harmony default export */ const _SetCache = (SetCache);
  11008. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cacheHas.js
  11009. /**
  11010. * Checks if a `cache` value for `key` exists.
  11011. *
  11012. * @private
  11013. * @param {Object} cache The cache to query.
  11014. * @param {string} key The key of the entry to check.
  11015. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  11016. */
  11017. function cacheHas(cache, key) {
  11018. return cache.has(key);
  11019. }
  11020. /* harmony default export */ const _cacheHas = (cacheHas);
  11021. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_equalArrays.js
  11022. /** Used to compose bitmasks for value comparisons. */
  11023. var COMPARE_PARTIAL_FLAG = 1,
  11024. COMPARE_UNORDERED_FLAG = 2;
  11025. /**
  11026. * A specialized version of `baseIsEqualDeep` for arrays with support for
  11027. * partial deep comparisons.
  11028. *
  11029. * @private
  11030. * @param {Array} array The array to compare.
  11031. * @param {Array} other The other array to compare.
  11032. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11033. * @param {Function} customizer The function to customize comparisons.
  11034. * @param {Function} equalFunc The function to determine equivalents of values.
  11035. * @param {Object} stack Tracks traversed `array` and `other` objects.
  11036. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  11037. */
  11038. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  11039. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  11040. arrLength = array.length,
  11041. othLength = other.length;
  11042. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  11043. return false;
  11044. }
  11045. // Check that cyclic values are equal.
  11046. var arrStacked = stack.get(array);
  11047. var othStacked = stack.get(other);
  11048. if (arrStacked && othStacked) {
  11049. return arrStacked == other && othStacked == array;
  11050. }
  11051. var index = -1,
  11052. result = true,
  11053. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new _SetCache : undefined;
  11054. stack.set(array, other);
  11055. stack.set(other, array);
  11056. // Ignore non-index properties.
  11057. while (++index < arrLength) {
  11058. var arrValue = array[index],
  11059. othValue = other[index];
  11060. if (customizer) {
  11061. var compared = isPartial
  11062. ? customizer(othValue, arrValue, index, other, array, stack)
  11063. : customizer(arrValue, othValue, index, array, other, stack);
  11064. }
  11065. if (compared !== undefined) {
  11066. if (compared) {
  11067. continue;
  11068. }
  11069. result = false;
  11070. break;
  11071. }
  11072. // Recursively compare arrays (susceptible to call stack limits).
  11073. if (seen) {
  11074. if (!_arraySome(other, function(othValue, othIndex) {
  11075. if (!_cacheHas(seen, othIndex) &&
  11076. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  11077. return seen.push(othIndex);
  11078. }
  11079. })) {
  11080. result = false;
  11081. break;
  11082. }
  11083. } else if (!(
  11084. arrValue === othValue ||
  11085. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  11086. )) {
  11087. result = false;
  11088. break;
  11089. }
  11090. }
  11091. stack['delete'](array);
  11092. stack['delete'](other);
  11093. return result;
  11094. }
  11095. /* harmony default export */ const _equalArrays = (equalArrays);
  11096. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Uint8Array.js
  11097. /** Built-in value references. */
  11098. var _Uint8Array_Uint8Array = _root.Uint8Array;
  11099. /* harmony default export */ const _Uint8Array = (_Uint8Array_Uint8Array);
  11100. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_mapToArray.js
  11101. /**
  11102. * Converts `map` to its key-value pairs.
  11103. *
  11104. * @private
  11105. * @param {Object} map The map to convert.
  11106. * @returns {Array} Returns the key-value pairs.
  11107. */
  11108. function mapToArray(map) {
  11109. var index = -1,
  11110. result = Array(map.size);
  11111. map.forEach(function(value, key) {
  11112. result[++index] = [key, value];
  11113. });
  11114. return result;
  11115. }
  11116. /* harmony default export */ const _mapToArray = (mapToArray);
  11117. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_setToArray.js
  11118. /**
  11119. * Converts `set` to an array of its values.
  11120. *
  11121. * @private
  11122. * @param {Object} set The set to convert.
  11123. * @returns {Array} Returns the values.
  11124. */
  11125. function setToArray(set) {
  11126. var index = -1,
  11127. result = Array(set.size);
  11128. set.forEach(function(value) {
  11129. result[++index] = value;
  11130. });
  11131. return result;
  11132. }
  11133. /* harmony default export */ const _setToArray = (setToArray);
  11134. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_equalByTag.js
  11135. /** Used to compose bitmasks for value comparisons. */
  11136. var _equalByTag_COMPARE_PARTIAL_FLAG = 1,
  11137. _equalByTag_COMPARE_UNORDERED_FLAG = 2;
  11138. /** `Object#toString` result references. */
  11139. var _equalByTag_boolTag = '[object Boolean]',
  11140. _equalByTag_dateTag = '[object Date]',
  11141. _equalByTag_errorTag = '[object Error]',
  11142. _equalByTag_mapTag = '[object Map]',
  11143. _equalByTag_numberTag = '[object Number]',
  11144. _equalByTag_regexpTag = '[object RegExp]',
  11145. _equalByTag_setTag = '[object Set]',
  11146. _equalByTag_stringTag = '[object String]',
  11147. symbolTag = '[object Symbol]';
  11148. var _equalByTag_arrayBufferTag = '[object ArrayBuffer]',
  11149. _equalByTag_dataViewTag = '[object DataView]';
  11150. /** Used to convert symbols to primitives and strings. */
  11151. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  11152. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  11153. /**
  11154. * A specialized version of `baseIsEqualDeep` for comparing objects of
  11155. * the same `toStringTag`.
  11156. *
  11157. * **Note:** This function only supports comparing values with tags of
  11158. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  11159. *
  11160. * @private
  11161. * @param {Object} object The object to compare.
  11162. * @param {Object} other The other object to compare.
  11163. * @param {string} tag The `toStringTag` of the objects to compare.
  11164. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11165. * @param {Function} customizer The function to customize comparisons.
  11166. * @param {Function} equalFunc The function to determine equivalents of values.
  11167. * @param {Object} stack Tracks traversed `object` and `other` objects.
  11168. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11169. */
  11170. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  11171. switch (tag) {
  11172. case _equalByTag_dataViewTag:
  11173. if ((object.byteLength != other.byteLength) ||
  11174. (object.byteOffset != other.byteOffset)) {
  11175. return false;
  11176. }
  11177. object = object.buffer;
  11178. other = other.buffer;
  11179. case _equalByTag_arrayBufferTag:
  11180. if ((object.byteLength != other.byteLength) ||
  11181. !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) {
  11182. return false;
  11183. }
  11184. return true;
  11185. case _equalByTag_boolTag:
  11186. case _equalByTag_dateTag:
  11187. case _equalByTag_numberTag:
  11188. // Coerce booleans to `1` or `0` and dates to milliseconds.
  11189. // Invalid dates are coerced to `NaN`.
  11190. return lodash_es_eq(+object, +other);
  11191. case _equalByTag_errorTag:
  11192. return object.name == other.name && object.message == other.message;
  11193. case _equalByTag_regexpTag:
  11194. case _equalByTag_stringTag:
  11195. // Coerce regexes to strings and treat strings, primitives and objects,
  11196. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  11197. // for more details.
  11198. return object == (other + '');
  11199. case _equalByTag_mapTag:
  11200. var convert = _mapToArray;
  11201. case _equalByTag_setTag:
  11202. var isPartial = bitmask & _equalByTag_COMPARE_PARTIAL_FLAG;
  11203. convert || (convert = _setToArray);
  11204. if (object.size != other.size && !isPartial) {
  11205. return false;
  11206. }
  11207. // Assume cyclic values are equal.
  11208. var stacked = stack.get(object);
  11209. if (stacked) {
  11210. return stacked == other;
  11211. }
  11212. bitmask |= _equalByTag_COMPARE_UNORDERED_FLAG;
  11213. // Recursively compare objects (susceptible to call stack limits).
  11214. stack.set(object, other);
  11215. var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  11216. stack['delete'](object);
  11217. return result;
  11218. case symbolTag:
  11219. if (symbolValueOf) {
  11220. return symbolValueOf.call(object) == symbolValueOf.call(other);
  11221. }
  11222. }
  11223. return false;
  11224. }
  11225. /* harmony default export */ const _equalByTag = (equalByTag);
  11226. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayPush.js
  11227. /**
  11228. * Appends the elements of `values` to `array`.
  11229. *
  11230. * @private
  11231. * @param {Array} array The array to modify.
  11232. * @param {Array} values The values to append.
  11233. * @returns {Array} Returns `array`.
  11234. */
  11235. function arrayPush(array, values) {
  11236. var index = -1,
  11237. length = values.length,
  11238. offset = array.length;
  11239. while (++index < length) {
  11240. array[offset + index] = values[index];
  11241. }
  11242. return array;
  11243. }
  11244. /* harmony default export */ const _arrayPush = (arrayPush);
  11245. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseGetAllKeys.js
  11246. /**
  11247. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  11248. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  11249. * symbols of `object`.
  11250. *
  11251. * @private
  11252. * @param {Object} object The object to query.
  11253. * @param {Function} keysFunc The function to get the keys of `object`.
  11254. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  11255. * @returns {Array} Returns the array of property names and symbols.
  11256. */
  11257. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  11258. var result = keysFunc(object);
  11259. return lodash_es_isArray(object) ? result : _arrayPush(result, symbolsFunc(object));
  11260. }
  11261. /* harmony default export */ const _baseGetAllKeys = (baseGetAllKeys);
  11262. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayFilter.js
  11263. /**
  11264. * A specialized version of `_.filter` for arrays without support for
  11265. * iteratee shorthands.
  11266. *
  11267. * @private
  11268. * @param {Array} [array] The array to iterate over.
  11269. * @param {Function} predicate The function invoked per iteration.
  11270. * @returns {Array} Returns the new filtered array.
  11271. */
  11272. function arrayFilter(array, predicate) {
  11273. var index = -1,
  11274. length = array == null ? 0 : array.length,
  11275. resIndex = 0,
  11276. result = [];
  11277. while (++index < length) {
  11278. var value = array[index];
  11279. if (predicate(value, index, array)) {
  11280. result[resIndex++] = value;
  11281. }
  11282. }
  11283. return result;
  11284. }
  11285. /* harmony default export */ const _arrayFilter = (arrayFilter);
  11286. ;// CONCATENATED MODULE: ./node_modules/lodash-es/stubArray.js
  11287. /**
  11288. * This method returns a new empty array.
  11289. *
  11290. * @static
  11291. * @memberOf _
  11292. * @since 4.13.0
  11293. * @category Util
  11294. * @returns {Array} Returns the new empty array.
  11295. * @example
  11296. *
  11297. * var arrays = _.times(2, _.stubArray);
  11298. *
  11299. * console.log(arrays);
  11300. * // => [[], []]
  11301. *
  11302. * console.log(arrays[0] === arrays[1]);
  11303. * // => false
  11304. */
  11305. function stubArray() {
  11306. return [];
  11307. }
  11308. /* harmony default export */ const lodash_es_stubArray = (stubArray);
  11309. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getSymbols.js
  11310. /** Used for built-in method references. */
  11311. var _getSymbols_objectProto = Object.prototype;
  11312. /** Built-in value references. */
  11313. var _getSymbols_propertyIsEnumerable = _getSymbols_objectProto.propertyIsEnumerable;
  11314. /* Built-in method references for those with the same name as other `lodash` methods. */
  11315. var nativeGetSymbols = Object.getOwnPropertySymbols;
  11316. /**
  11317. * Creates an array of the own enumerable symbols of `object`.
  11318. *
  11319. * @private
  11320. * @param {Object} object The object to query.
  11321. * @returns {Array} Returns the array of symbols.
  11322. */
  11323. var getSymbols = !nativeGetSymbols ? lodash_es_stubArray : function(object) {
  11324. if (object == null) {
  11325. return [];
  11326. }
  11327. object = Object(object);
  11328. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  11329. return _getSymbols_propertyIsEnumerable.call(object, symbol);
  11330. });
  11331. };
  11332. /* harmony default export */ const _getSymbols = (getSymbols);
  11333. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_nativeKeys.js
  11334. /* Built-in method references for those with the same name as other `lodash` methods. */
  11335. var nativeKeys = _overArg(Object.keys, Object);
  11336. /* harmony default export */ const _nativeKeys = (nativeKeys);
  11337. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseKeys.js
  11338. /** Used for built-in method references. */
  11339. var _baseKeys_objectProto = Object.prototype;
  11340. /** Used to check objects for own properties. */
  11341. var _baseKeys_hasOwnProperty = _baseKeys_objectProto.hasOwnProperty;
  11342. /**
  11343. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  11344. *
  11345. * @private
  11346. * @param {Object} object The object to query.
  11347. * @returns {Array} Returns the array of property names.
  11348. */
  11349. function baseKeys(object) {
  11350. if (!_isPrototype(object)) {
  11351. return _nativeKeys(object);
  11352. }
  11353. var result = [];
  11354. for (var key in Object(object)) {
  11355. if (_baseKeys_hasOwnProperty.call(object, key) && key != 'constructor') {
  11356. result.push(key);
  11357. }
  11358. }
  11359. return result;
  11360. }
  11361. /* harmony default export */ const _baseKeys = (baseKeys);
  11362. ;// CONCATENATED MODULE: ./node_modules/lodash-es/keys.js
  11363. /**
  11364. * Creates an array of the own enumerable property names of `object`.
  11365. *
  11366. * **Note:** Non-object values are coerced to objects. See the
  11367. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11368. * for more details.
  11369. *
  11370. * @static
  11371. * @since 0.1.0
  11372. * @memberOf _
  11373. * @category Object
  11374. * @param {Object} object The object to query.
  11375. * @returns {Array} Returns the array of property names.
  11376. * @example
  11377. *
  11378. * function Foo() {
  11379. * this.a = 1;
  11380. * this.b = 2;
  11381. * }
  11382. *
  11383. * Foo.prototype.c = 3;
  11384. *
  11385. * _.keys(new Foo);
  11386. * // => ['a', 'b'] (iteration order is not guaranteed)
  11387. *
  11388. * _.keys('hi');
  11389. * // => ['0', '1']
  11390. */
  11391. function keys(object) {
  11392. return lodash_es_isArrayLike(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  11393. }
  11394. /* harmony default export */ const lodash_es_keys = (keys);
  11395. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getAllKeys.js
  11396. /**
  11397. * Creates an array of own enumerable property names and symbols of `object`.
  11398. *
  11399. * @private
  11400. * @param {Object} object The object to query.
  11401. * @returns {Array} Returns the array of property names and symbols.
  11402. */
  11403. function getAllKeys(object) {
  11404. return _baseGetAllKeys(object, lodash_es_keys, _getSymbols);
  11405. }
  11406. /* harmony default export */ const _getAllKeys = (getAllKeys);
  11407. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_equalObjects.js
  11408. /** Used to compose bitmasks for value comparisons. */
  11409. var _equalObjects_COMPARE_PARTIAL_FLAG = 1;
  11410. /** Used for built-in method references. */
  11411. var _equalObjects_objectProto = Object.prototype;
  11412. /** Used to check objects for own properties. */
  11413. var _equalObjects_hasOwnProperty = _equalObjects_objectProto.hasOwnProperty;
  11414. /**
  11415. * A specialized version of `baseIsEqualDeep` for objects with support for
  11416. * partial deep comparisons.
  11417. *
  11418. * @private
  11419. * @param {Object} object The object to compare.
  11420. * @param {Object} other The other object to compare.
  11421. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11422. * @param {Function} customizer The function to customize comparisons.
  11423. * @param {Function} equalFunc The function to determine equivalents of values.
  11424. * @param {Object} stack Tracks traversed `object` and `other` objects.
  11425. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11426. */
  11427. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  11428. var isPartial = bitmask & _equalObjects_COMPARE_PARTIAL_FLAG,
  11429. objProps = _getAllKeys(object),
  11430. objLength = objProps.length,
  11431. othProps = _getAllKeys(other),
  11432. othLength = othProps.length;
  11433. if (objLength != othLength && !isPartial) {
  11434. return false;
  11435. }
  11436. var index = objLength;
  11437. while (index--) {
  11438. var key = objProps[index];
  11439. if (!(isPartial ? key in other : _equalObjects_hasOwnProperty.call(other, key))) {
  11440. return false;
  11441. }
  11442. }
  11443. // Check that cyclic values are equal.
  11444. var objStacked = stack.get(object);
  11445. var othStacked = stack.get(other);
  11446. if (objStacked && othStacked) {
  11447. return objStacked == other && othStacked == object;
  11448. }
  11449. var result = true;
  11450. stack.set(object, other);
  11451. stack.set(other, object);
  11452. var skipCtor = isPartial;
  11453. while (++index < objLength) {
  11454. key = objProps[index];
  11455. var objValue = object[key],
  11456. othValue = other[key];
  11457. if (customizer) {
  11458. var compared = isPartial
  11459. ? customizer(othValue, objValue, key, other, object, stack)
  11460. : customizer(objValue, othValue, key, object, other, stack);
  11461. }
  11462. // Recursively compare objects (susceptible to call stack limits).
  11463. if (!(compared === undefined
  11464. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  11465. : compared
  11466. )) {
  11467. result = false;
  11468. break;
  11469. }
  11470. skipCtor || (skipCtor = key == 'constructor');
  11471. }
  11472. if (result && !skipCtor) {
  11473. var objCtor = object.constructor,
  11474. othCtor = other.constructor;
  11475. // Non `Object` object instances with different constructors are not equal.
  11476. if (objCtor != othCtor &&
  11477. ('constructor' in object && 'constructor' in other) &&
  11478. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  11479. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  11480. result = false;
  11481. }
  11482. }
  11483. stack['delete'](object);
  11484. stack['delete'](other);
  11485. return result;
  11486. }
  11487. /* harmony default export */ const _equalObjects = (equalObjects);
  11488. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_DataView.js
  11489. /* Built-in method references that are verified to be native. */
  11490. var DataView = _getNative(_root, 'DataView');
  11491. /* harmony default export */ const _DataView = (DataView);
  11492. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Promise.js
  11493. /* Built-in method references that are verified to be native. */
  11494. var _Promise_Promise = _getNative(_root, 'Promise');
  11495. /* harmony default export */ const _Promise = (_Promise_Promise);
  11496. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_Set.js
  11497. /* Built-in method references that are verified to be native. */
  11498. var _Set_Set = _getNative(_root, 'Set');
  11499. /* harmony default export */ const _Set = (_Set_Set);
  11500. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_WeakMap.js
  11501. /* Built-in method references that are verified to be native. */
  11502. var _WeakMap_WeakMap = _getNative(_root, 'WeakMap');
  11503. /* harmony default export */ const _WeakMap = (_WeakMap_WeakMap);
  11504. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getTag.js
  11505. /** `Object#toString` result references. */
  11506. var _getTag_mapTag = '[object Map]',
  11507. _getTag_objectTag = '[object Object]',
  11508. promiseTag = '[object Promise]',
  11509. _getTag_setTag = '[object Set]',
  11510. _getTag_weakMapTag = '[object WeakMap]';
  11511. var _getTag_dataViewTag = '[object DataView]';
  11512. /** Used to detect maps, sets, and weakmaps. */
  11513. var dataViewCtorString = _toSource(_DataView),
  11514. mapCtorString = _toSource(_Map),
  11515. promiseCtorString = _toSource(_Promise),
  11516. setCtorString = _toSource(_Set),
  11517. weakMapCtorString = _toSource(_WeakMap);
  11518. /**
  11519. * Gets the `toStringTag` of `value`.
  11520. *
  11521. * @private
  11522. * @param {*} value The value to query.
  11523. * @returns {string} Returns the `toStringTag`.
  11524. */
  11525. var getTag = _baseGetTag;
  11526. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  11527. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != _getTag_dataViewTag) ||
  11528. (_Map && getTag(new _Map) != _getTag_mapTag) ||
  11529. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  11530. (_Set && getTag(new _Set) != _getTag_setTag) ||
  11531. (_WeakMap && getTag(new _WeakMap) != _getTag_weakMapTag)) {
  11532. getTag = function(value) {
  11533. var result = _baseGetTag(value),
  11534. Ctor = result == _getTag_objectTag ? value.constructor : undefined,
  11535. ctorString = Ctor ? _toSource(Ctor) : '';
  11536. if (ctorString) {
  11537. switch (ctorString) {
  11538. case dataViewCtorString: return _getTag_dataViewTag;
  11539. case mapCtorString: return _getTag_mapTag;
  11540. case promiseCtorString: return promiseTag;
  11541. case setCtorString: return _getTag_setTag;
  11542. case weakMapCtorString: return _getTag_weakMapTag;
  11543. }
  11544. }
  11545. return result;
  11546. };
  11547. }
  11548. /* harmony default export */ const _getTag = (getTag);
  11549. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsEqualDeep.js
  11550. /** Used to compose bitmasks for value comparisons. */
  11551. var _baseIsEqualDeep_COMPARE_PARTIAL_FLAG = 1;
  11552. /** `Object#toString` result references. */
  11553. var _baseIsEqualDeep_argsTag = '[object Arguments]',
  11554. _baseIsEqualDeep_arrayTag = '[object Array]',
  11555. _baseIsEqualDeep_objectTag = '[object Object]';
  11556. /** Used for built-in method references. */
  11557. var _baseIsEqualDeep_objectProto = Object.prototype;
  11558. /** Used to check objects for own properties. */
  11559. var _baseIsEqualDeep_hasOwnProperty = _baseIsEqualDeep_objectProto.hasOwnProperty;
  11560. /**
  11561. * A specialized version of `baseIsEqual` for arrays and objects which performs
  11562. * deep comparisons and tracks traversed objects enabling objects with circular
  11563. * references to be compared.
  11564. *
  11565. * @private
  11566. * @param {Object} object The object to compare.
  11567. * @param {Object} other The other object to compare.
  11568. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  11569. * @param {Function} customizer The function to customize comparisons.
  11570. * @param {Function} equalFunc The function to determine equivalents of values.
  11571. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  11572. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  11573. */
  11574. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  11575. var objIsArr = lodash_es_isArray(object),
  11576. othIsArr = lodash_es_isArray(other),
  11577. objTag = objIsArr ? _baseIsEqualDeep_arrayTag : _getTag(object),
  11578. othTag = othIsArr ? _baseIsEqualDeep_arrayTag : _getTag(other);
  11579. objTag = objTag == _baseIsEqualDeep_argsTag ? _baseIsEqualDeep_objectTag : objTag;
  11580. othTag = othTag == _baseIsEqualDeep_argsTag ? _baseIsEqualDeep_objectTag : othTag;
  11581. var objIsObj = objTag == _baseIsEqualDeep_objectTag,
  11582. othIsObj = othTag == _baseIsEqualDeep_objectTag,
  11583. isSameTag = objTag == othTag;
  11584. if (isSameTag && lodash_es_isBuffer(object)) {
  11585. if (!lodash_es_isBuffer(other)) {
  11586. return false;
  11587. }
  11588. objIsArr = true;
  11589. objIsObj = false;
  11590. }
  11591. if (isSameTag && !objIsObj) {
  11592. stack || (stack = new _Stack);
  11593. return (objIsArr || lodash_es_isTypedArray(object))
  11594. ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  11595. : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  11596. }
  11597. if (!(bitmask & _baseIsEqualDeep_COMPARE_PARTIAL_FLAG)) {
  11598. var objIsWrapped = objIsObj && _baseIsEqualDeep_hasOwnProperty.call(object, '__wrapped__'),
  11599. othIsWrapped = othIsObj && _baseIsEqualDeep_hasOwnProperty.call(other, '__wrapped__');
  11600. if (objIsWrapped || othIsWrapped) {
  11601. var objUnwrapped = objIsWrapped ? object.value() : object,
  11602. othUnwrapped = othIsWrapped ? other.value() : other;
  11603. stack || (stack = new _Stack);
  11604. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  11605. }
  11606. }
  11607. if (!isSameTag) {
  11608. return false;
  11609. }
  11610. stack || (stack = new _Stack);
  11611. return _equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  11612. }
  11613. /* harmony default export */ const _baseIsEqualDeep = (baseIsEqualDeep);
  11614. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsEqual.js
  11615. /**
  11616. * The base implementation of `_.isEqual` which supports partial comparisons
  11617. * and tracks traversed objects.
  11618. *
  11619. * @private
  11620. * @param {*} value The value to compare.
  11621. * @param {*} other The other value to compare.
  11622. * @param {boolean} bitmask The bitmask flags.
  11623. * 1 - Unordered comparison
  11624. * 2 - Partial comparison
  11625. * @param {Function} [customizer] The function to customize comparisons.
  11626. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  11627. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11628. */
  11629. function baseIsEqual(value, other, bitmask, customizer, stack) {
  11630. if (value === other) {
  11631. return true;
  11632. }
  11633. if (value == null || other == null || (!lodash_es_isObjectLike(value) && !lodash_es_isObjectLike(other))) {
  11634. return value !== value && other !== other;
  11635. }
  11636. return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  11637. }
  11638. /* harmony default export */ const _baseIsEqual = (baseIsEqual);
  11639. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsMatch.js
  11640. /** Used to compose bitmasks for value comparisons. */
  11641. var _baseIsMatch_COMPARE_PARTIAL_FLAG = 1,
  11642. _baseIsMatch_COMPARE_UNORDERED_FLAG = 2;
  11643. /**
  11644. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  11645. *
  11646. * @private
  11647. * @param {Object} object The object to inspect.
  11648. * @param {Object} source The object of property values to match.
  11649. * @param {Array} matchData The property names, values, and compare flags to match.
  11650. * @param {Function} [customizer] The function to customize comparisons.
  11651. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  11652. */
  11653. function baseIsMatch(object, source, matchData, customizer) {
  11654. var index = matchData.length,
  11655. length = index,
  11656. noCustomizer = !customizer;
  11657. if (object == null) {
  11658. return !length;
  11659. }
  11660. object = Object(object);
  11661. while (index--) {
  11662. var data = matchData[index];
  11663. if ((noCustomizer && data[2])
  11664. ? data[1] !== object[data[0]]
  11665. : !(data[0] in object)
  11666. ) {
  11667. return false;
  11668. }
  11669. }
  11670. while (++index < length) {
  11671. data = matchData[index];
  11672. var key = data[0],
  11673. objValue = object[key],
  11674. srcValue = data[1];
  11675. if (noCustomizer && data[2]) {
  11676. if (objValue === undefined && !(key in object)) {
  11677. return false;
  11678. }
  11679. } else {
  11680. var stack = new _Stack;
  11681. if (customizer) {
  11682. var result = customizer(objValue, srcValue, key, object, source, stack);
  11683. }
  11684. if (!(result === undefined
  11685. ? _baseIsEqual(srcValue, objValue, _baseIsMatch_COMPARE_PARTIAL_FLAG | _baseIsMatch_COMPARE_UNORDERED_FLAG, customizer, stack)
  11686. : result
  11687. )) {
  11688. return false;
  11689. }
  11690. }
  11691. }
  11692. return true;
  11693. }
  11694. /* harmony default export */ const _baseIsMatch = (baseIsMatch);
  11695. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isStrictComparable.js
  11696. /**
  11697. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  11698. *
  11699. * @private
  11700. * @param {*} value The value to check.
  11701. * @returns {boolean} Returns `true` if `value` if suitable for strict
  11702. * equality comparisons, else `false`.
  11703. */
  11704. function isStrictComparable(value) {
  11705. return value === value && !lodash_es_isObject(value);
  11706. }
  11707. /* harmony default export */ const _isStrictComparable = (isStrictComparable);
  11708. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getMatchData.js
  11709. /**
  11710. * Gets the property names, values, and compare flags of `object`.
  11711. *
  11712. * @private
  11713. * @param {Object} object The object to query.
  11714. * @returns {Array} Returns the match data of `object`.
  11715. */
  11716. function getMatchData(object) {
  11717. var result = lodash_es_keys(object),
  11718. length = result.length;
  11719. while (length--) {
  11720. var key = result[length],
  11721. value = object[key];
  11722. result[length] = [key, value, _isStrictComparable(value)];
  11723. }
  11724. return result;
  11725. }
  11726. /* harmony default export */ const _getMatchData = (getMatchData);
  11727. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_matchesStrictComparable.js
  11728. /**
  11729. * A specialized version of `matchesProperty` for source values suitable
  11730. * for strict equality comparisons, i.e. `===`.
  11731. *
  11732. * @private
  11733. * @param {string} key The key of the property to get.
  11734. * @param {*} srcValue The value to match.
  11735. * @returns {Function} Returns the new spec function.
  11736. */
  11737. function matchesStrictComparable(key, srcValue) {
  11738. return function(object) {
  11739. if (object == null) {
  11740. return false;
  11741. }
  11742. return object[key] === srcValue &&
  11743. (srcValue !== undefined || (key in Object(object)));
  11744. };
  11745. }
  11746. /* harmony default export */ const _matchesStrictComparable = (matchesStrictComparable);
  11747. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseMatches.js
  11748. /**
  11749. * The base implementation of `_.matches` which doesn't clone `source`.
  11750. *
  11751. * @private
  11752. * @param {Object} source The object of property values to match.
  11753. * @returns {Function} Returns the new spec function.
  11754. */
  11755. function baseMatches(source) {
  11756. var matchData = _getMatchData(source);
  11757. if (matchData.length == 1 && matchData[0][2]) {
  11758. return _matchesStrictComparable(matchData[0][0], matchData[0][1]);
  11759. }
  11760. return function(object) {
  11761. return object === source || _baseIsMatch(object, source, matchData);
  11762. };
  11763. }
  11764. /* harmony default export */ const _baseMatches = (baseMatches);
  11765. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isSymbol.js
  11766. /** `Object#toString` result references. */
  11767. var isSymbol_symbolTag = '[object Symbol]';
  11768. /**
  11769. * Checks if `value` is classified as a `Symbol` primitive or object.
  11770. *
  11771. * @static
  11772. * @memberOf _
  11773. * @since 4.0.0
  11774. * @category Lang
  11775. * @param {*} value The value to check.
  11776. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  11777. * @example
  11778. *
  11779. * _.isSymbol(Symbol.iterator);
  11780. * // => true
  11781. *
  11782. * _.isSymbol('abc');
  11783. * // => false
  11784. */
  11785. function isSymbol(value) {
  11786. return typeof value == 'symbol' ||
  11787. (lodash_es_isObjectLike(value) && _baseGetTag(value) == isSymbol_symbolTag);
  11788. }
  11789. /* harmony default export */ const lodash_es_isSymbol = (isSymbol);
  11790. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isKey.js
  11791. /** Used to match property names within property paths. */
  11792. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  11793. reIsPlainProp = /^\w*$/;
  11794. /**
  11795. * Checks if `value` is a property name and not a property path.
  11796. *
  11797. * @private
  11798. * @param {*} value The value to check.
  11799. * @param {Object} [object] The object to query keys on.
  11800. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  11801. */
  11802. function isKey(value, object) {
  11803. if (lodash_es_isArray(value)) {
  11804. return false;
  11805. }
  11806. var type = typeof value;
  11807. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  11808. value == null || lodash_es_isSymbol(value)) {
  11809. return true;
  11810. }
  11811. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  11812. (object != null && value in Object(object));
  11813. }
  11814. /* harmony default export */ const _isKey = (isKey);
  11815. ;// CONCATENATED MODULE: ./node_modules/lodash-es/memoize.js
  11816. /** Error message constants. */
  11817. var FUNC_ERROR_TEXT = 'Expected a function';
  11818. /**
  11819. * Creates a function that memoizes the result of `func`. If `resolver` is
  11820. * provided, it determines the cache key for storing the result based on the
  11821. * arguments provided to the memoized function. By default, the first argument
  11822. * provided to the memoized function is used as the map cache key. The `func`
  11823. * is invoked with the `this` binding of the memoized function.
  11824. *
  11825. * **Note:** The cache is exposed as the `cache` property on the memoized
  11826. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  11827. * constructor with one whose instances implement the
  11828. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  11829. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  11830. *
  11831. * @static
  11832. * @memberOf _
  11833. * @since 0.1.0
  11834. * @category Function
  11835. * @param {Function} func The function to have its output memoized.
  11836. * @param {Function} [resolver] The function to resolve the cache key.
  11837. * @returns {Function} Returns the new memoized function.
  11838. * @example
  11839. *
  11840. * var object = { 'a': 1, 'b': 2 };
  11841. * var other = { 'c': 3, 'd': 4 };
  11842. *
  11843. * var values = _.memoize(_.values);
  11844. * values(object);
  11845. * // => [1, 2]
  11846. *
  11847. * values(other);
  11848. * // => [3, 4]
  11849. *
  11850. * object.a = 2;
  11851. * values(object);
  11852. * // => [1, 2]
  11853. *
  11854. * // Modify the result cache.
  11855. * values.cache.set(object, ['a', 'b']);
  11856. * values(object);
  11857. * // => ['a', 'b']
  11858. *
  11859. * // Replace `_.memoize.Cache`.
  11860. * _.memoize.Cache = WeakMap;
  11861. */
  11862. function memoize(func, resolver) {
  11863. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  11864. throw new TypeError(FUNC_ERROR_TEXT);
  11865. }
  11866. var memoized = function() {
  11867. var args = arguments,
  11868. key = resolver ? resolver.apply(this, args) : args[0],
  11869. cache = memoized.cache;
  11870. if (cache.has(key)) {
  11871. return cache.get(key);
  11872. }
  11873. var result = func.apply(this, args);
  11874. memoized.cache = cache.set(key, result) || cache;
  11875. return result;
  11876. };
  11877. memoized.cache = new (memoize.Cache || _MapCache);
  11878. return memoized;
  11879. }
  11880. // Expose `MapCache`.
  11881. memoize.Cache = _MapCache;
  11882. /* harmony default export */ const lodash_es_memoize = (memoize);
  11883. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_memoizeCapped.js
  11884. /** Used as the maximum memoize cache size. */
  11885. var MAX_MEMOIZE_SIZE = 500;
  11886. /**
  11887. * A specialized version of `_.memoize` which clears the memoized function's
  11888. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  11889. *
  11890. * @private
  11891. * @param {Function} func The function to have its output memoized.
  11892. * @returns {Function} Returns the new memoized function.
  11893. */
  11894. function memoizeCapped(func) {
  11895. var result = lodash_es_memoize(func, function(key) {
  11896. if (cache.size === MAX_MEMOIZE_SIZE) {
  11897. cache.clear();
  11898. }
  11899. return key;
  11900. });
  11901. var cache = result.cache;
  11902. return result;
  11903. }
  11904. /* harmony default export */ const _memoizeCapped = (memoizeCapped);
  11905. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_stringToPath.js
  11906. /** Used to match property names within property paths. */
  11907. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  11908. /** Used to match backslashes in property paths. */
  11909. var reEscapeChar = /\\(\\)?/g;
  11910. /**
  11911. * Converts `string` to a property path array.
  11912. *
  11913. * @private
  11914. * @param {string} string The string to convert.
  11915. * @returns {Array} Returns the property path array.
  11916. */
  11917. var stringToPath = _memoizeCapped(function(string) {
  11918. var result = [];
  11919. if (string.charCodeAt(0) === 46 /* . */) {
  11920. result.push('');
  11921. }
  11922. string.replace(rePropName, function(match, number, quote, subString) {
  11923. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  11924. });
  11925. return result;
  11926. });
  11927. /* harmony default export */ const _stringToPath = (stringToPath);
  11928. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayMap.js
  11929. /**
  11930. * A specialized version of `_.map` for arrays without support for iteratee
  11931. * shorthands.
  11932. *
  11933. * @private
  11934. * @param {Array} [array] The array to iterate over.
  11935. * @param {Function} iteratee The function invoked per iteration.
  11936. * @returns {Array} Returns the new mapped array.
  11937. */
  11938. function arrayMap(array, iteratee) {
  11939. var index = -1,
  11940. length = array == null ? 0 : array.length,
  11941. result = Array(length);
  11942. while (++index < length) {
  11943. result[index] = iteratee(array[index], index, array);
  11944. }
  11945. return result;
  11946. }
  11947. /* harmony default export */ const _arrayMap = (arrayMap);
  11948. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseToString.js
  11949. /** Used as references for various `Number` constants. */
  11950. var INFINITY = 1 / 0;
  11951. /** Used to convert symbols to primitives and strings. */
  11952. var _baseToString_symbolProto = _Symbol ? _Symbol.prototype : undefined,
  11953. symbolToString = _baseToString_symbolProto ? _baseToString_symbolProto.toString : undefined;
  11954. /**
  11955. * The base implementation of `_.toString` which doesn't convert nullish
  11956. * values to empty strings.
  11957. *
  11958. * @private
  11959. * @param {*} value The value to process.
  11960. * @returns {string} Returns the string.
  11961. */
  11962. function baseToString(value) {
  11963. // Exit early for strings to avoid a performance hit in some environments.
  11964. if (typeof value == 'string') {
  11965. return value;
  11966. }
  11967. if (lodash_es_isArray(value)) {
  11968. // Recursively convert values (susceptible to call stack limits).
  11969. return _arrayMap(value, baseToString) + '';
  11970. }
  11971. if (lodash_es_isSymbol(value)) {
  11972. return symbolToString ? symbolToString.call(value) : '';
  11973. }
  11974. var result = (value + '');
  11975. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  11976. }
  11977. /* harmony default export */ const _baseToString = (baseToString);
  11978. ;// CONCATENATED MODULE: ./node_modules/lodash-es/toString.js
  11979. /**
  11980. * Converts `value` to a string. An empty string is returned for `null`
  11981. * and `undefined` values. The sign of `-0` is preserved.
  11982. *
  11983. * @static
  11984. * @memberOf _
  11985. * @since 4.0.0
  11986. * @category Lang
  11987. * @param {*} value The value to convert.
  11988. * @returns {string} Returns the converted string.
  11989. * @example
  11990. *
  11991. * _.toString(null);
  11992. * // => ''
  11993. *
  11994. * _.toString(-0);
  11995. * // => '-0'
  11996. *
  11997. * _.toString([1, 2, 3]);
  11998. * // => '1,2,3'
  11999. */
  12000. function toString_toString(value) {
  12001. return value == null ? '' : _baseToString(value);
  12002. }
  12003. /* harmony default export */ const lodash_es_toString = (toString_toString);
  12004. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_castPath.js
  12005. /**
  12006. * Casts `value` to a path array if it's not one.
  12007. *
  12008. * @private
  12009. * @param {*} value The value to inspect.
  12010. * @param {Object} [object] The object to query keys on.
  12011. * @returns {Array} Returns the cast property path array.
  12012. */
  12013. function castPath(value, object) {
  12014. if (lodash_es_isArray(value)) {
  12015. return value;
  12016. }
  12017. return _isKey(value, object) ? [value] : _stringToPath(lodash_es_toString(value));
  12018. }
  12019. /* harmony default export */ const _castPath = (castPath);
  12020. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_toKey.js
  12021. /** Used as references for various `Number` constants. */
  12022. var _toKey_INFINITY = 1 / 0;
  12023. /**
  12024. * Converts `value` to a string key if it's not a string or symbol.
  12025. *
  12026. * @private
  12027. * @param {*} value The value to inspect.
  12028. * @returns {string|symbol} Returns the key.
  12029. */
  12030. function toKey(value) {
  12031. if (typeof value == 'string' || lodash_es_isSymbol(value)) {
  12032. return value;
  12033. }
  12034. var result = (value + '');
  12035. return (result == '0' && (1 / value) == -_toKey_INFINITY) ? '-0' : result;
  12036. }
  12037. /* harmony default export */ const _toKey = (toKey);
  12038. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseGet.js
  12039. /**
  12040. * The base implementation of `_.get` without support for default values.
  12041. *
  12042. * @private
  12043. * @param {Object} object The object to query.
  12044. * @param {Array|string} path The path of the property to get.
  12045. * @returns {*} Returns the resolved value.
  12046. */
  12047. function baseGet(object, path) {
  12048. path = _castPath(path, object);
  12049. var index = 0,
  12050. length = path.length;
  12051. while (object != null && index < length) {
  12052. object = object[_toKey(path[index++])];
  12053. }
  12054. return (index && index == length) ? object : undefined;
  12055. }
  12056. /* harmony default export */ const _baseGet = (baseGet);
  12057. ;// CONCATENATED MODULE: ./node_modules/lodash-es/get.js
  12058. /**
  12059. * Gets the value at `path` of `object`. If the resolved value is
  12060. * `undefined`, the `defaultValue` is returned in its place.
  12061. *
  12062. * @static
  12063. * @memberOf _
  12064. * @since 3.7.0
  12065. * @category Object
  12066. * @param {Object} object The object to query.
  12067. * @param {Array|string} path The path of the property to get.
  12068. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  12069. * @returns {*} Returns the resolved value.
  12070. * @example
  12071. *
  12072. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  12073. *
  12074. * _.get(object, 'a[0].b.c');
  12075. * // => 3
  12076. *
  12077. * _.get(object, ['a', '0', 'b', 'c']);
  12078. * // => 3
  12079. *
  12080. * _.get(object, 'a.b.c', 'default');
  12081. * // => 'default'
  12082. */
  12083. function get(object, path, defaultValue) {
  12084. var result = object == null ? undefined : _baseGet(object, path);
  12085. return result === undefined ? defaultValue : result;
  12086. }
  12087. /* harmony default export */ const lodash_es_get = (get);
  12088. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseHasIn.js
  12089. /**
  12090. * The base implementation of `_.hasIn` without support for deep paths.
  12091. *
  12092. * @private
  12093. * @param {Object} [object] The object to query.
  12094. * @param {Array|string} key The key to check.
  12095. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  12096. */
  12097. function baseHasIn(object, key) {
  12098. return object != null && key in Object(object);
  12099. }
  12100. /* harmony default export */ const _baseHasIn = (baseHasIn);
  12101. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_hasPath.js
  12102. /**
  12103. * Checks if `path` exists on `object`.
  12104. *
  12105. * @private
  12106. * @param {Object} object The object to query.
  12107. * @param {Array|string} path The path to check.
  12108. * @param {Function} hasFunc The function to check properties.
  12109. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  12110. */
  12111. function hasPath(object, path, hasFunc) {
  12112. path = _castPath(path, object);
  12113. var index = -1,
  12114. length = path.length,
  12115. result = false;
  12116. while (++index < length) {
  12117. var key = _toKey(path[index]);
  12118. if (!(result = object != null && hasFunc(object, key))) {
  12119. break;
  12120. }
  12121. object = object[key];
  12122. }
  12123. if (result || ++index != length) {
  12124. return result;
  12125. }
  12126. length = object == null ? 0 : object.length;
  12127. return !!length && lodash_es_isLength(length) && _isIndex(key, length) &&
  12128. (lodash_es_isArray(object) || lodash_es_isArguments(object));
  12129. }
  12130. /* harmony default export */ const _hasPath = (hasPath);
  12131. ;// CONCATENATED MODULE: ./node_modules/lodash-es/hasIn.js
  12132. /**
  12133. * Checks if `path` is a direct or inherited property of `object`.
  12134. *
  12135. * @static
  12136. * @memberOf _
  12137. * @since 4.0.0
  12138. * @category Object
  12139. * @param {Object} object The object to query.
  12140. * @param {Array|string} path The path to check.
  12141. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  12142. * @example
  12143. *
  12144. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  12145. *
  12146. * _.hasIn(object, 'a');
  12147. * // => true
  12148. *
  12149. * _.hasIn(object, 'a.b');
  12150. * // => true
  12151. *
  12152. * _.hasIn(object, ['a', 'b']);
  12153. * // => true
  12154. *
  12155. * _.hasIn(object, 'b');
  12156. * // => false
  12157. */
  12158. function hasIn(object, path) {
  12159. return object != null && _hasPath(object, path, _baseHasIn);
  12160. }
  12161. /* harmony default export */ const lodash_es_hasIn = (hasIn);
  12162. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseMatchesProperty.js
  12163. /** Used to compose bitmasks for value comparisons. */
  12164. var _baseMatchesProperty_COMPARE_PARTIAL_FLAG = 1,
  12165. _baseMatchesProperty_COMPARE_UNORDERED_FLAG = 2;
  12166. /**
  12167. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  12168. *
  12169. * @private
  12170. * @param {string} path The path of the property to get.
  12171. * @param {*} srcValue The value to match.
  12172. * @returns {Function} Returns the new spec function.
  12173. */
  12174. function baseMatchesProperty(path, srcValue) {
  12175. if (_isKey(path) && _isStrictComparable(srcValue)) {
  12176. return _matchesStrictComparable(_toKey(path), srcValue);
  12177. }
  12178. return function(object) {
  12179. var objValue = lodash_es_get(object, path);
  12180. return (objValue === undefined && objValue === srcValue)
  12181. ? lodash_es_hasIn(object, path)
  12182. : _baseIsEqual(srcValue, objValue, _baseMatchesProperty_COMPARE_PARTIAL_FLAG | _baseMatchesProperty_COMPARE_UNORDERED_FLAG);
  12183. };
  12184. }
  12185. /* harmony default export */ const _baseMatchesProperty = (baseMatchesProperty);
  12186. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseProperty.js
  12187. /**
  12188. * The base implementation of `_.property` without support for deep paths.
  12189. *
  12190. * @private
  12191. * @param {string} key The key of the property to get.
  12192. * @returns {Function} Returns the new accessor function.
  12193. */
  12194. function baseProperty(key) {
  12195. return function(object) {
  12196. return object == null ? undefined : object[key];
  12197. };
  12198. }
  12199. /* harmony default export */ const _baseProperty = (baseProperty);
  12200. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_basePropertyDeep.js
  12201. /**
  12202. * A specialized version of `baseProperty` which supports deep paths.
  12203. *
  12204. * @private
  12205. * @param {Array|string} path The path of the property to get.
  12206. * @returns {Function} Returns the new accessor function.
  12207. */
  12208. function basePropertyDeep(path) {
  12209. return function(object) {
  12210. return _baseGet(object, path);
  12211. };
  12212. }
  12213. /* harmony default export */ const _basePropertyDeep = (basePropertyDeep);
  12214. ;// CONCATENATED MODULE: ./node_modules/lodash-es/property.js
  12215. /**
  12216. * Creates a function that returns the value at `path` of a given object.
  12217. *
  12218. * @static
  12219. * @memberOf _
  12220. * @since 2.4.0
  12221. * @category Util
  12222. * @param {Array|string} path The path of the property to get.
  12223. * @returns {Function} Returns the new accessor function.
  12224. * @example
  12225. *
  12226. * var objects = [
  12227. * { 'a': { 'b': 2 } },
  12228. * { 'a': { 'b': 1 } }
  12229. * ];
  12230. *
  12231. * _.map(objects, _.property('a.b'));
  12232. * // => [2, 1]
  12233. *
  12234. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  12235. * // => [1, 2]
  12236. */
  12237. function property(path) {
  12238. return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
  12239. }
  12240. /* harmony default export */ const lodash_es_property = (property);
  12241. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIteratee.js
  12242. /**
  12243. * The base implementation of `_.iteratee`.
  12244. *
  12245. * @private
  12246. * @param {*} [value=_.identity] The value to convert to an iteratee.
  12247. * @returns {Function} Returns the iteratee.
  12248. */
  12249. function baseIteratee(value) {
  12250. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  12251. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  12252. if (typeof value == 'function') {
  12253. return value;
  12254. }
  12255. if (value == null) {
  12256. return lodash_es_identity;
  12257. }
  12258. if (typeof value == 'object') {
  12259. return lodash_es_isArray(value)
  12260. ? _baseMatchesProperty(value[0], value[1])
  12261. : _baseMatches(value);
  12262. }
  12263. return lodash_es_property(value);
  12264. }
  12265. /* harmony default export */ const _baseIteratee = (baseIteratee);
  12266. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createBaseFor.js
  12267. /**
  12268. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  12269. *
  12270. * @private
  12271. * @param {boolean} [fromRight] Specify iterating from right to left.
  12272. * @returns {Function} Returns the new base function.
  12273. */
  12274. function createBaseFor(fromRight) {
  12275. return function(object, iteratee, keysFunc) {
  12276. var index = -1,
  12277. iterable = Object(object),
  12278. props = keysFunc(object),
  12279. length = props.length;
  12280. while (length--) {
  12281. var key = props[fromRight ? length : ++index];
  12282. if (iteratee(iterable[key], key, iterable) === false) {
  12283. break;
  12284. }
  12285. }
  12286. return object;
  12287. };
  12288. }
  12289. /* harmony default export */ const _createBaseFor = (createBaseFor);
  12290. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseFor.js
  12291. /**
  12292. * The base implementation of `baseForOwn` which iterates over `object`
  12293. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  12294. * Iteratee functions may exit iteration early by explicitly returning `false`.
  12295. *
  12296. * @private
  12297. * @param {Object} object The object to iterate over.
  12298. * @param {Function} iteratee The function invoked per iteration.
  12299. * @param {Function} keysFunc The function to get the keys of `object`.
  12300. * @returns {Object} Returns `object`.
  12301. */
  12302. var baseFor = _createBaseFor();
  12303. /* harmony default export */ const _baseFor = (baseFor);
  12304. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseForOwn.js
  12305. /**
  12306. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  12307. *
  12308. * @private
  12309. * @param {Object} object The object to iterate over.
  12310. * @param {Function} iteratee The function invoked per iteration.
  12311. * @returns {Object} Returns `object`.
  12312. */
  12313. function baseForOwn(object, iteratee) {
  12314. return object && _baseFor(object, iteratee, lodash_es_keys);
  12315. }
  12316. /* harmony default export */ const _baseForOwn = (baseForOwn);
  12317. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createBaseEach.js
  12318. /**
  12319. * Creates a `baseEach` or `baseEachRight` function.
  12320. *
  12321. * @private
  12322. * @param {Function} eachFunc The function to iterate over a collection.
  12323. * @param {boolean} [fromRight] Specify iterating from right to left.
  12324. * @returns {Function} Returns the new base function.
  12325. */
  12326. function createBaseEach(eachFunc, fromRight) {
  12327. return function(collection, iteratee) {
  12328. if (collection == null) {
  12329. return collection;
  12330. }
  12331. if (!lodash_es_isArrayLike(collection)) {
  12332. return eachFunc(collection, iteratee);
  12333. }
  12334. var length = collection.length,
  12335. index = fromRight ? length : -1,
  12336. iterable = Object(collection);
  12337. while ((fromRight ? index-- : ++index < length)) {
  12338. if (iteratee(iterable[index], index, iterable) === false) {
  12339. break;
  12340. }
  12341. }
  12342. return collection;
  12343. };
  12344. }
  12345. /* harmony default export */ const _createBaseEach = (createBaseEach);
  12346. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseEach.js
  12347. /**
  12348. * The base implementation of `_.forEach` without support for iteratee shorthands.
  12349. *
  12350. * @private
  12351. * @param {Array|Object} collection The collection to iterate over.
  12352. * @param {Function} iteratee The function invoked per iteration.
  12353. * @returns {Array|Object} Returns `collection`.
  12354. */
  12355. var baseEach = _createBaseEach(_baseForOwn);
  12356. /* harmony default export */ const _baseEach = (baseEach);
  12357. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSome.js
  12358. /**
  12359. * The base implementation of `_.some` without support for iteratee shorthands.
  12360. *
  12361. * @private
  12362. * @param {Array|Object} collection The collection to iterate over.
  12363. * @param {Function} predicate The function invoked per iteration.
  12364. * @returns {boolean} Returns `true` if any element passes the predicate check,
  12365. * else `false`.
  12366. */
  12367. function baseSome(collection, predicate) {
  12368. var result;
  12369. _baseEach(collection, function(value, index, collection) {
  12370. result = predicate(value, index, collection);
  12371. return !result;
  12372. });
  12373. return !!result;
  12374. }
  12375. /* harmony default export */ const _baseSome = (baseSome);
  12376. ;// CONCATENATED MODULE: ./node_modules/lodash-es/some.js
  12377. /**
  12378. * Checks if `predicate` returns truthy for **any** element of `collection`.
  12379. * Iteration is stopped once `predicate` returns truthy. The predicate is
  12380. * invoked with three arguments: (value, index|key, collection).
  12381. *
  12382. * @static
  12383. * @memberOf _
  12384. * @since 0.1.0
  12385. * @category Collection
  12386. * @param {Array|Object} collection The collection to iterate over.
  12387. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12388. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12389. * @returns {boolean} Returns `true` if any element passes the predicate check,
  12390. * else `false`.
  12391. * @example
  12392. *
  12393. * _.some([null, 0, 'yes', false], Boolean);
  12394. * // => true
  12395. *
  12396. * var users = [
  12397. * { 'user': 'barney', 'active': true },
  12398. * { 'user': 'fred', 'active': false }
  12399. * ];
  12400. *
  12401. * // The `_.matches` iteratee shorthand.
  12402. * _.some(users, { 'user': 'barney', 'active': false });
  12403. * // => false
  12404. *
  12405. * // The `_.matchesProperty` iteratee shorthand.
  12406. * _.some(users, ['active', false]);
  12407. * // => true
  12408. *
  12409. * // The `_.property` iteratee shorthand.
  12410. * _.some(users, 'active');
  12411. * // => true
  12412. */
  12413. function some(collection, predicate, guard) {
  12414. var func = lodash_es_isArray(collection) ? _arraySome : _baseSome;
  12415. if (guard && _isIterateeCall(collection, predicate, guard)) {
  12416. predicate = undefined;
  12417. }
  12418. return func(collection, _baseIteratee(predicate, 3));
  12419. }
  12420. /* harmony default export */ const lodash_es_some = (some);
  12421. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isEmpty.js
  12422. /** `Object#toString` result references. */
  12423. var isEmpty_mapTag = '[object Map]',
  12424. isEmpty_setTag = '[object Set]';
  12425. /** Used for built-in method references. */
  12426. var isEmpty_objectProto = Object.prototype;
  12427. /** Used to check objects for own properties. */
  12428. var isEmpty_hasOwnProperty = isEmpty_objectProto.hasOwnProperty;
  12429. /**
  12430. * Checks if `value` is an empty object, collection, map, or set.
  12431. *
  12432. * Objects are considered empty if they have no own enumerable string keyed
  12433. * properties.
  12434. *
  12435. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  12436. * jQuery-like collections are considered empty if they have a `length` of `0`.
  12437. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  12438. *
  12439. * @static
  12440. * @memberOf _
  12441. * @since 0.1.0
  12442. * @category Lang
  12443. * @param {*} value The value to check.
  12444. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  12445. * @example
  12446. *
  12447. * _.isEmpty(null);
  12448. * // => true
  12449. *
  12450. * _.isEmpty(true);
  12451. * // => true
  12452. *
  12453. * _.isEmpty(1);
  12454. * // => true
  12455. *
  12456. * _.isEmpty([1, 2, 3]);
  12457. * // => false
  12458. *
  12459. * _.isEmpty({ 'a': 1 });
  12460. * // => false
  12461. */
  12462. function isEmpty(value) {
  12463. if (value == null) {
  12464. return true;
  12465. }
  12466. if (lodash_es_isArrayLike(value) &&
  12467. (lodash_es_isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  12468. lodash_es_isBuffer(value) || lodash_es_isTypedArray(value) || lodash_es_isArguments(value))) {
  12469. return !value.length;
  12470. }
  12471. var tag = _getTag(value);
  12472. if (tag == isEmpty_mapTag || tag == isEmpty_setTag) {
  12473. return !value.size;
  12474. }
  12475. if (_isPrototype(value)) {
  12476. return !_baseKeys(value).length;
  12477. }
  12478. for (var key in value) {
  12479. if (isEmpty_hasOwnProperty.call(value, key)) {
  12480. return false;
  12481. }
  12482. }
  12483. return true;
  12484. }
  12485. /* harmony default export */ const lodash_es_isEmpty = (isEmpty);
  12486. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_trimmedEndIndex.js
  12487. /** Used to match a single whitespace character. */
  12488. var reWhitespace = /\s/;
  12489. /**
  12490. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  12491. * character of `string`.
  12492. *
  12493. * @private
  12494. * @param {string} string The string to inspect.
  12495. * @returns {number} Returns the index of the last non-whitespace character.
  12496. */
  12497. function trimmedEndIndex(string) {
  12498. var index = string.length;
  12499. while (index-- && reWhitespace.test(string.charAt(index))) {}
  12500. return index;
  12501. }
  12502. /* harmony default export */ const _trimmedEndIndex = (trimmedEndIndex);
  12503. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseTrim.js
  12504. /** Used to match leading whitespace. */
  12505. var reTrimStart = /^\s+/;
  12506. /**
  12507. * The base implementation of `_.trim`.
  12508. *
  12509. * @private
  12510. * @param {string} string The string to trim.
  12511. * @returns {string} Returns the trimmed string.
  12512. */
  12513. function baseTrim(string) {
  12514. return string
  12515. ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  12516. : string;
  12517. }
  12518. /* harmony default export */ const _baseTrim = (baseTrim);
  12519. ;// CONCATENATED MODULE: ./node_modules/lodash-es/toNumber.js
  12520. /** Used as references for various `Number` constants. */
  12521. var NAN = 0 / 0;
  12522. /** Used to detect bad signed hexadecimal string values. */
  12523. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  12524. /** Used to detect binary string values. */
  12525. var reIsBinary = /^0b[01]+$/i;
  12526. /** Used to detect octal string values. */
  12527. var reIsOctal = /^0o[0-7]+$/i;
  12528. /** Built-in method references without a dependency on `root`. */
  12529. var freeParseInt = parseInt;
  12530. /**
  12531. * Converts `value` to a number.
  12532. *
  12533. * @static
  12534. * @memberOf _
  12535. * @since 4.0.0
  12536. * @category Lang
  12537. * @param {*} value The value to process.
  12538. * @returns {number} Returns the number.
  12539. * @example
  12540. *
  12541. * _.toNumber(3.2);
  12542. * // => 3.2
  12543. *
  12544. * _.toNumber(Number.MIN_VALUE);
  12545. * // => 5e-324
  12546. *
  12547. * _.toNumber(Infinity);
  12548. * // => Infinity
  12549. *
  12550. * _.toNumber('3.2');
  12551. * // => 3.2
  12552. */
  12553. function toNumber(value) {
  12554. if (typeof value == 'number') {
  12555. return value;
  12556. }
  12557. if (lodash_es_isSymbol(value)) {
  12558. return NAN;
  12559. }
  12560. if (lodash_es_isObject(value)) {
  12561. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  12562. value = lodash_es_isObject(other) ? (other + '') : other;
  12563. }
  12564. if (typeof value != 'string') {
  12565. return value === 0 ? value : +value;
  12566. }
  12567. value = _baseTrim(value);
  12568. var isBinary = reIsBinary.test(value);
  12569. return (isBinary || reIsOctal.test(value))
  12570. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  12571. : (reIsBadHex.test(value) ? NAN : +value);
  12572. }
  12573. /* harmony default export */ const lodash_es_toNumber = (toNumber);
  12574. ;// CONCATENATED MODULE: ./node_modules/lodash-es/toFinite.js
  12575. /** Used as references for various `Number` constants. */
  12576. var toFinite_INFINITY = 1 / 0,
  12577. MAX_INTEGER = 1.7976931348623157e+308;
  12578. /**
  12579. * Converts `value` to a finite number.
  12580. *
  12581. * @static
  12582. * @memberOf _
  12583. * @since 4.12.0
  12584. * @category Lang
  12585. * @param {*} value The value to convert.
  12586. * @returns {number} Returns the converted number.
  12587. * @example
  12588. *
  12589. * _.toFinite(3.2);
  12590. * // => 3.2
  12591. *
  12592. * _.toFinite(Number.MIN_VALUE);
  12593. * // => 5e-324
  12594. *
  12595. * _.toFinite(Infinity);
  12596. * // => 1.7976931348623157e+308
  12597. *
  12598. * _.toFinite('3.2');
  12599. * // => 3.2
  12600. */
  12601. function toFinite(value) {
  12602. if (!value) {
  12603. return value === 0 ? value : 0;
  12604. }
  12605. value = lodash_es_toNumber(value);
  12606. if (value === toFinite_INFINITY || value === -toFinite_INFINITY) {
  12607. var sign = (value < 0 ? -1 : 1);
  12608. return sign * MAX_INTEGER;
  12609. }
  12610. return value === value ? value : 0;
  12611. }
  12612. /* harmony default export */ const lodash_es_toFinite = (toFinite);
  12613. ;// CONCATENATED MODULE: ./node_modules/lodash-es/toInteger.js
  12614. /**
  12615. * Converts `value` to an integer.
  12616. *
  12617. * **Note:** This method is loosely based on
  12618. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  12619. *
  12620. * @static
  12621. * @memberOf _
  12622. * @since 4.0.0
  12623. * @category Lang
  12624. * @param {*} value The value to convert.
  12625. * @returns {number} Returns the converted integer.
  12626. * @example
  12627. *
  12628. * _.toInteger(3.2);
  12629. * // => 3
  12630. *
  12631. * _.toInteger(Number.MIN_VALUE);
  12632. * // => 0
  12633. *
  12634. * _.toInteger(Infinity);
  12635. * // => 1.7976931348623157e+308
  12636. *
  12637. * _.toInteger('3.2');
  12638. * // => 3
  12639. */
  12640. function toInteger(value) {
  12641. var result = lodash_es_toFinite(value),
  12642. remainder = result % 1;
  12643. return result === result ? (remainder ? result - remainder : result) : 0;
  12644. }
  12645. /* harmony default export */ const lodash_es_toInteger = (toInteger);
  12646. ;// CONCATENATED MODULE: ./node_modules/lodash-es/before.js
  12647. /** Error message constants. */
  12648. var before_FUNC_ERROR_TEXT = 'Expected a function';
  12649. /**
  12650. * Creates a function that invokes `func`, with the `this` binding and arguments
  12651. * of the created function, while it's called less than `n` times. Subsequent
  12652. * calls to the created function return the result of the last `func` invocation.
  12653. *
  12654. * @static
  12655. * @memberOf _
  12656. * @since 3.0.0
  12657. * @category Function
  12658. * @param {number} n The number of calls at which `func` is no longer invoked.
  12659. * @param {Function} func The function to restrict.
  12660. * @returns {Function} Returns the new restricted function.
  12661. * @example
  12662. *
  12663. * jQuery(element).on('click', _.before(5, addContactToList));
  12664. * // => Allows adding up to 4 contacts to the list.
  12665. */
  12666. function before(n, func) {
  12667. var result;
  12668. if (typeof func != 'function') {
  12669. throw new TypeError(before_FUNC_ERROR_TEXT);
  12670. }
  12671. n = lodash_es_toInteger(n);
  12672. return function() {
  12673. if (--n > 0) {
  12674. result = func.apply(this, arguments);
  12675. }
  12676. if (n <= 1) {
  12677. func = undefined;
  12678. }
  12679. return result;
  12680. };
  12681. }
  12682. /* harmony default export */ const lodash_es_before = (before);
  12683. ;// CONCATENATED MODULE: ./node_modules/lodash-es/once.js
  12684. /**
  12685. * Creates a function that is restricted to invoking `func` once. Repeat calls
  12686. * to the function return the value of the first invocation. The `func` is
  12687. * invoked with the `this` binding and arguments of the created function.
  12688. *
  12689. * @static
  12690. * @memberOf _
  12691. * @since 0.1.0
  12692. * @category Function
  12693. * @param {Function} func The function to restrict.
  12694. * @returns {Function} Returns the new restricted function.
  12695. * @example
  12696. *
  12697. * var initialize = _.once(createApplication);
  12698. * initialize();
  12699. * initialize();
  12700. * // => `createApplication` is invoked once
  12701. */
  12702. function once(func) {
  12703. return lodash_es_before(2, func);
  12704. }
  12705. /* harmony default export */ const lodash_es_once = (once);
  12706. ;// CONCATENATED MODULE: ./node_modules/lodash-es/uniqueId.js
  12707. /** Used to generate unique IDs. */
  12708. var idCounter = 0;
  12709. /**
  12710. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  12711. *
  12712. * @static
  12713. * @since 0.1.0
  12714. * @memberOf _
  12715. * @category Util
  12716. * @param {string} [prefix=''] The value to prefix the ID with.
  12717. * @returns {string} Returns the unique ID.
  12718. * @example
  12719. *
  12720. * _.uniqueId('contact_');
  12721. * // => 'contact_104'
  12722. *
  12723. * _.uniqueId();
  12724. * // => '105'
  12725. */
  12726. function uniqueId(prefix) {
  12727. var id = ++idCounter;
  12728. return lodash_es_toString(prefix) + id;
  12729. }
  12730. /* harmony default export */ const lodash_es_uniqueId = (uniqueId);
  12731. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/events.js
  12732. // Backbone.js 1.4.0
  12733. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  12734. // Backbone may be freely distributed under the MIT license.
  12735. // Events
  12736. // ------
  12737. // A module that can be mixed in to *any object* in order to provide it with
  12738. // a custom event channel. You may bind a callback to an event with `on` or
  12739. // remove with `off`; `trigger`-ing an event fires all callbacks in
  12740. // succession.
  12741. //
  12742. // let object = {};
  12743. // extend(object, Backbone.Events);
  12744. // object.on('expand', function(){ alert('expanded'); });
  12745. // object.trigger('expand');
  12746. //
  12747. const Events = {}; // Regular expression used to split event strings.
  12748. const eventSplitter = /\s+/; // A private global variable to share between listeners and listenees.
  12749. let _listening; // Iterates over the standard `event, callback` (as well as the fancy multiple
  12750. // space-separated events `"change blur", callback` and jQuery-style event
  12751. // maps `{event: callback}`).
  12752. const eventsApi = function (iteratee, events, name, callback, opts) {
  12753. let i = 0,
  12754. names;
  12755. if (name && typeof name === 'object') {
  12756. // Handle event maps.
  12757. if (callback !== undefined && 'context' in opts && opts.context === undefined) opts.context = callback;
  12758. for (names = lodash_es_keys(name); i < names.length; i++) {
  12759. events = eventsApi(iteratee, events, names[i], name[names[i]], opts);
  12760. }
  12761. } else if (name && eventSplitter.test(name)) {
  12762. // Handle space-separated event names by delegating them individually.
  12763. for (names = name.split(eventSplitter); i < names.length; i++) {
  12764. events = iteratee(events, names[i], callback, opts);
  12765. }
  12766. } else {
  12767. // Finally, standard events.
  12768. events = iteratee(events, name, callback, opts);
  12769. }
  12770. return events;
  12771. }; // Bind an event to a `callback` function. Passing `"all"` will bind
  12772. // the callback to all events fired.
  12773. Events.on = function (name, callback, context) {
  12774. this._events = eventsApi(onApi, this._events || {}, name, callback, {
  12775. context: context,
  12776. ctx: this,
  12777. listening: _listening
  12778. });
  12779. if (_listening) {
  12780. const listeners = this._listeners || (this._listeners = {});
  12781. listeners[_listening.id] = _listening; // Allow the listening to use a counter, instead of tracking
  12782. // callbacks for library interop
  12783. _listening.interop = false;
  12784. }
  12785. return this;
  12786. }; // Inversion-of-control versions of `on`. Tell *this* object to listen to
  12787. // an event in another object... keeping track of what it's listening to
  12788. // for easier unbinding later.
  12789. Events.listenTo = function (obj, name, callback) {
  12790. if (!obj) return this;
  12791. const id = obj._listenId || (obj._listenId = lodash_es_uniqueId('l'));
  12792. const listeningTo = this._listeningTo || (this._listeningTo = {});
  12793. let listening = _listening = listeningTo[id]; // This object is not listening to any other events on `obj` yet.
  12794. // Setup the necessary references to track the listening callbacks.
  12795. if (!listening) {
  12796. this._listenId || (this._listenId = lodash_es_uniqueId('l'));
  12797. listening = _listening = listeningTo[id] = new Listening(this, obj);
  12798. } // Bind callbacks on obj.
  12799. const error = tryCatchOn(obj, name, callback, this);
  12800. _listening = undefined;
  12801. if (error) throw error; // If the target obj is not Backbone.Events, track events manually.
  12802. if (listening.interop) listening.on(name, callback);
  12803. return this;
  12804. }; // The reducing API that adds a callback to the `events` object.
  12805. const onApi = function (events, name, callback, options) {
  12806. if (callback) {
  12807. const handlers = events[name] || (events[name] = []);
  12808. const context = options.context,
  12809. ctx = options.ctx,
  12810. listening = options.listening;
  12811. if (listening) listening.count++;
  12812. handlers.push({
  12813. callback: callback,
  12814. context: context,
  12815. ctx: context || ctx,
  12816. listening: listening
  12817. });
  12818. }
  12819. return events;
  12820. }; // An try-catch guarded #on function, to prevent poisoning the global
  12821. // `_listening` variable.
  12822. const tryCatchOn = function (obj, name, callback, context) {
  12823. try {
  12824. obj.on(name, callback, context);
  12825. } catch (e) {
  12826. return e;
  12827. }
  12828. }; // Remove one or many callbacks. If `context` is null, removes all
  12829. // callbacks with that function. If `callback` is null, removes all
  12830. // callbacks for the event. If `name` is null, removes all bound
  12831. // callbacks for all events.
  12832. Events.off = function (name, callback, context) {
  12833. if (!this._events) return this;
  12834. this._events = eventsApi(offApi, this._events, name, callback, {
  12835. context: context,
  12836. listeners: this._listeners
  12837. });
  12838. return this;
  12839. }; // Tell this object to stop listening to either specific events ... or
  12840. // to every object it's currently listening to.
  12841. Events.stopListening = function (obj, name, callback) {
  12842. const listeningTo = this._listeningTo;
  12843. if (!listeningTo) return this;
  12844. const ids = obj ? [obj._listenId] : lodash_es_keys(listeningTo);
  12845. for (let i = 0; i < ids.length; i++) {
  12846. const listening = listeningTo[ids[i]]; // If listening doesn't exist, this object is not currently
  12847. // listening to obj. Break out early.
  12848. if (!listening) break;
  12849. listening.obj.off(name, callback, this);
  12850. if (listening.interop) listening.off(name, callback);
  12851. }
  12852. if (lodash_es_isEmpty(listeningTo)) this._listeningTo = undefined;
  12853. return this;
  12854. }; // The reducing API that removes a callback from the `events` object.
  12855. const offApi = function (events, name, callback, options) {
  12856. if (!events) return;
  12857. const context = options.context,
  12858. listeners = options.listeners;
  12859. let i = 0,
  12860. names; // Delete all event listeners and "drop" events.
  12861. if (!name && !context && !callback) {
  12862. for (names = lodash_es_keys(listeners); i < names.length; i++) {
  12863. listeners[names[i]].cleanup();
  12864. }
  12865. return;
  12866. }
  12867. names = name ? [name] : lodash_es_keys(events);
  12868. for (; i < names.length; i++) {
  12869. name = names[i];
  12870. const handlers = events[name]; // Bail out if there are no events stored.
  12871. if (!handlers) {
  12872. break;
  12873. } // Find any remaining events.
  12874. const remaining = [];
  12875. for (let j = 0; j < handlers.length; j++) {
  12876. const handler = handlers[j];
  12877. if (callback && callback !== handler.callback && callback !== handler.callback._callback || context && context !== handler.context) {
  12878. remaining.push(handler);
  12879. } else {
  12880. const listening = handler.listening;
  12881. if (listening) listening.off(name, callback);
  12882. }
  12883. } // Replace events if there are any remaining. Otherwise, clean up.
  12884. if (remaining.length) {
  12885. events[name] = remaining;
  12886. } else {
  12887. delete events[name];
  12888. }
  12889. }
  12890. return events;
  12891. }; // Bind an event to only be triggered a single time. After the first time
  12892. // the callback is invoked, its listener will be removed. If multiple events
  12893. // are passed in using the space-separated syntax, the handler will fire
  12894. // once for each event, not once for a combination of all events.
  12895. Events.once = function (name, callback, context) {
  12896. // Map the event into a `{event: once}` object.
  12897. const events = eventsApi(onceMap, {}, name, callback, this.off.bind(this));
  12898. if (typeof name === 'string' && (context === null || context === undefined)) callback = undefined;
  12899. return this.on(events, callback, context);
  12900. }; // Inversion-of-control versions of `once`.
  12901. Events.listenToOnce = function (obj, name, callback) {
  12902. // Map the event into a `{event: once}` object.
  12903. const events = eventsApi(onceMap, {}, name, callback, this.stopListening.bind(this, obj));
  12904. return this.listenTo(obj, events);
  12905. }; // Reduces the event callbacks into a map of `{event: onceWrapper}`.
  12906. // `offer` unbinds the `onceWrapper` after it has been called.
  12907. const onceMap = function (map, name, callback, offer) {
  12908. if (callback) {
  12909. const _once = map[name] = lodash_es_once(function () {
  12910. offer(name, _once);
  12911. callback.apply(this, arguments);
  12912. });
  12913. _once._callback = callback;
  12914. }
  12915. return map;
  12916. }; // Trigger one or many events, firing all bound callbacks. Callbacks are
  12917. // passed the same arguments as `trigger` is, apart from the event name
  12918. // (unless you're listening on `"all"`, which will cause your callback to
  12919. // receive the true name of the event as the first argument).
  12920. Events.trigger = function (name) {
  12921. if (!this._events) return this;
  12922. const length = Math.max(0, arguments.length - 1);
  12923. const args = Array(length);
  12924. for (let i = 0; i < length; i++) args[i] = arguments[i + 1];
  12925. eventsApi(triggerApi, this._events, name, undefined, args);
  12926. return this;
  12927. }; // Handles triggering the appropriate event callbacks.
  12928. const triggerApi = function (objEvents, name, callback, args) {
  12929. if (objEvents) {
  12930. const events = objEvents[name];
  12931. let allEvents = objEvents.all;
  12932. if (events && allEvents) allEvents = allEvents.slice();
  12933. if (events) triggerEvents(events, args);
  12934. if (allEvents) triggerEvents(allEvents, [name].concat(args));
  12935. }
  12936. return objEvents;
  12937. }; // A difficult-to-believe, but optimized internal dispatch function for
  12938. // triggering events. Tries to keep the usual cases speedy (most internal
  12939. // Backbone events have 3 arguments).
  12940. const triggerEvents = function (events, args) {
  12941. let ev,
  12942. i = -1;
  12943. const l = events.length,
  12944. a1 = args[0],
  12945. a2 = args[1],
  12946. a3 = args[2];
  12947. switch (args.length) {
  12948. case 0:
  12949. while (++i < l) (ev = events[i]).callback.call(ev.ctx);
  12950. return;
  12951. case 1:
  12952. while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
  12953. return;
  12954. case 2:
  12955. while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
  12956. return;
  12957. case 3:
  12958. while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
  12959. return;
  12960. default:
  12961. while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
  12962. return;
  12963. }
  12964. }; // A listening class that tracks and cleans up memory bindings
  12965. // when all callbacks have been offed.
  12966. const Listening = function (listener, obj) {
  12967. this.id = listener._listenId;
  12968. this.listener = listener;
  12969. this.obj = obj;
  12970. this.interop = true;
  12971. this.count = 0;
  12972. this._events = undefined;
  12973. };
  12974. Listening.prototype.on = Events.on; // Offs a callback (or several).
  12975. // Uses an optimized counter if the listenee uses Backbone.Events.
  12976. // Otherwise, falls back to manual tracking to support events
  12977. // library interop.
  12978. Listening.prototype.off = function (name, callback) {
  12979. let cleanup;
  12980. if (this.interop) {
  12981. this._events = eventsApi(offApi, this._events, name, callback, {
  12982. context: undefined,
  12983. listeners: undefined
  12984. });
  12985. cleanup = !this._events;
  12986. } else {
  12987. this.count--;
  12988. cleanup = this.count === 0;
  12989. }
  12990. if (cleanup) this.cleanup();
  12991. }; // Cleans up memory bindings between the listener and the listenee.
  12992. Listening.prototype.cleanup = function () {
  12993. delete this.listener._listeningTo[this.obj._listenId];
  12994. if (!this.interop) delete this.obj._listeners[this.id];
  12995. }; // Aliases for backwards compatibility.
  12996. Events.bind = Events.on;
  12997. Events.unbind = Events.off;
  12998. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseAssign.js
  12999. /**
  13000. * The base implementation of `_.assign` without support for multiple sources
  13001. * or `customizer` functions.
  13002. *
  13003. * @private
  13004. * @param {Object} object The destination object.
  13005. * @param {Object} source The source object.
  13006. * @returns {Object} Returns `object`.
  13007. */
  13008. function baseAssign(object, source) {
  13009. return object && _copyObject(source, lodash_es_keys(source), object);
  13010. }
  13011. /* harmony default export */ const _baseAssign = (baseAssign);
  13012. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseCreate.js
  13013. /** Built-in value references. */
  13014. var objectCreate = Object.create;
  13015. /**
  13016. * The base implementation of `_.create` without support for assigning
  13017. * properties to the created object.
  13018. *
  13019. * @private
  13020. * @param {Object} proto The object to inherit from.
  13021. * @returns {Object} Returns the new object.
  13022. */
  13023. var baseCreate = (function() {
  13024. function object() {}
  13025. return function(proto) {
  13026. if (!lodash_es_isObject(proto)) {
  13027. return {};
  13028. }
  13029. if (objectCreate) {
  13030. return objectCreate(proto);
  13031. }
  13032. object.prototype = proto;
  13033. var result = new object;
  13034. object.prototype = undefined;
  13035. return result;
  13036. };
  13037. }());
  13038. /* harmony default export */ const _baseCreate = (baseCreate);
  13039. ;// CONCATENATED MODULE: ./node_modules/lodash-es/create.js
  13040. /**
  13041. * Creates an object that inherits from the `prototype` object. If a
  13042. * `properties` object is given, its own enumerable string keyed properties
  13043. * are assigned to the created object.
  13044. *
  13045. * @static
  13046. * @memberOf _
  13047. * @since 2.3.0
  13048. * @category Object
  13049. * @param {Object} prototype The object to inherit from.
  13050. * @param {Object} [properties] The properties to assign to the object.
  13051. * @returns {Object} Returns the new object.
  13052. * @example
  13053. *
  13054. * function Shape() {
  13055. * this.x = 0;
  13056. * this.y = 0;
  13057. * }
  13058. *
  13059. * function Circle() {
  13060. * Shape.call(this);
  13061. * }
  13062. *
  13063. * Circle.prototype = _.create(Shape.prototype, {
  13064. * 'constructor': Circle
  13065. * });
  13066. *
  13067. * var circle = new Circle;
  13068. * circle instanceof Circle;
  13069. * // => true
  13070. *
  13071. * circle instanceof Shape;
  13072. * // => true
  13073. */
  13074. function create(prototype, properties) {
  13075. var result = _baseCreate(prototype);
  13076. return properties == null ? result : _baseAssign(result, properties);
  13077. }
  13078. /* harmony default export */ const lodash_es_create = (create);
  13079. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseHas.js
  13080. /** Used for built-in method references. */
  13081. var _baseHas_objectProto = Object.prototype;
  13082. /** Used to check objects for own properties. */
  13083. var _baseHas_hasOwnProperty = _baseHas_objectProto.hasOwnProperty;
  13084. /**
  13085. * The base implementation of `_.has` without support for deep paths.
  13086. *
  13087. * @private
  13088. * @param {Object} [object] The object to query.
  13089. * @param {Array|string} key The key to check.
  13090. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  13091. */
  13092. function baseHas(object, key) {
  13093. return object != null && _baseHas_hasOwnProperty.call(object, key);
  13094. }
  13095. /* harmony default export */ const _baseHas = (baseHas);
  13096. ;// CONCATENATED MODULE: ./node_modules/lodash-es/has.js
  13097. /**
  13098. * Checks if `path` is a direct property of `object`.
  13099. *
  13100. * @static
  13101. * @since 0.1.0
  13102. * @memberOf _
  13103. * @category Object
  13104. * @param {Object} object The object to query.
  13105. * @param {Array|string} path The path to check.
  13106. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13107. * @example
  13108. *
  13109. * var object = { 'a': { 'b': 2 } };
  13110. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13111. *
  13112. * _.has(object, 'a');
  13113. * // => true
  13114. *
  13115. * _.has(object, 'a.b');
  13116. * // => true
  13117. *
  13118. * _.has(object, ['a', 'b']);
  13119. * // => true
  13120. *
  13121. * _.has(other, 'a');
  13122. * // => false
  13123. */
  13124. function has(object, path) {
  13125. return object != null && _hasPath(object, path, _baseHas);
  13126. }
  13127. /* harmony default export */ const lodash_es_has = (has);
  13128. ;// CONCATENATED MODULE: ./node_modules/lodash-es/result.js
  13129. /**
  13130. * This method is like `_.get` except that if the resolved value is a
  13131. * function it's invoked with the `this` binding of its parent object and
  13132. * its result is returned.
  13133. *
  13134. * @static
  13135. * @since 0.1.0
  13136. * @memberOf _
  13137. * @category Object
  13138. * @param {Object} object The object to query.
  13139. * @param {Array|string} path The path of the property to resolve.
  13140. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13141. * @returns {*} Returns the resolved value.
  13142. * @example
  13143. *
  13144. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  13145. *
  13146. * _.result(object, 'a[0].b.c1');
  13147. * // => 3
  13148. *
  13149. * _.result(object, 'a[0].b.c2');
  13150. * // => 4
  13151. *
  13152. * _.result(object, 'a[0].b.c3', 'default');
  13153. * // => 'default'
  13154. *
  13155. * _.result(object, 'a[0].b.c3', _.constant('default'));
  13156. * // => 'default'
  13157. */
  13158. function result(object, path, defaultValue) {
  13159. path = _castPath(path, object);
  13160. var index = -1,
  13161. length = path.length;
  13162. // Ensure the loop is entered when path is empty.
  13163. if (!length) {
  13164. length = 1;
  13165. object = undefined;
  13166. }
  13167. while (++index < length) {
  13168. var value = object == null ? undefined : object[_toKey(path[index])];
  13169. if (value === undefined) {
  13170. index = length;
  13171. value = defaultValue;
  13172. }
  13173. object = lodash_es_isFunction(value) ? value.call(object) : value;
  13174. }
  13175. return object;
  13176. }
  13177. /* harmony default export */ const lodash_es_result = (result);
  13178. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/helpers.js
  13179. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  13180. /**
  13181. * Custom error for indicating timeouts
  13182. * @namespace _converse
  13183. */
  13184. class NotImplementedError extends Error {} // Helpers
  13185. // -------
  13186. // Helper function to correctly set up the prototype chain for subclasses.
  13187. // Similar to `goog.inherits`, but uses a hash of prototype properties and
  13188. // class properties to be extended.
  13189. //
  13190. function inherits(protoProps, staticProps) {
  13191. const parent = this;
  13192. let child; // The constructor function for the new subclass is either defined by you
  13193. // (the "constructor" property in your `extend` definition), or defaulted
  13194. // by us to simply call the parent constructor.
  13195. if (protoProps && lodash_es_has(protoProps, 'constructor')) {
  13196. child = protoProps.constructor;
  13197. } else {
  13198. child = function () {
  13199. return parent.apply(this, arguments);
  13200. };
  13201. } // Add static properties to the constructor function, if supplied.
  13202. lodash_es_assignIn(child, parent, staticProps); // Set the prototype chain to inherit from `parent`, without calling
  13203. // `parent`'s constructor function and add the prototype properties.
  13204. child.prototype = lodash_es_create(parent.prototype, protoProps);
  13205. child.prototype.constructor = child; // Set a convenience property in case the parent's prototype is needed
  13206. // later.
  13207. child.__super__ = parent.prototype;
  13208. return child;
  13209. }
  13210. function getResolveablePromise() {
  13211. const wrapper = {
  13212. isResolved: false,
  13213. isPending: true,
  13214. isRejected: false
  13215. };
  13216. const promise = new Promise((resolve, reject) => {
  13217. wrapper.resolve = resolve;
  13218. wrapper.reject = reject;
  13219. });
  13220. Object.assign(promise, wrapper);
  13221. promise.then(function (v) {
  13222. promise.isResolved = true;
  13223. promise.isPending = false;
  13224. promise.isRejected = false;
  13225. return v;
  13226. }, function (e) {
  13227. promise.isResolved = false;
  13228. promise.isPending = false;
  13229. promise.isRejected = true;
  13230. throw e;
  13231. });
  13232. return promise;
  13233. } // Throw an error when a URL is needed, and none is supplied.
  13234. function urlError() {
  13235. throw new Error('A "url" property or function must be specified');
  13236. } // Wrap an optional error callback with a fallback error event.
  13237. function wrapError(model, options) {
  13238. const error = options.error;
  13239. options.error = function (resp) {
  13240. if (error) error.call(options.context, model, resp, options);
  13241. model.trigger('error', model, resp, options);
  13242. };
  13243. } // Map from CRUD to HTTP for our default `sync` implementation.
  13244. const methodMap = {
  13245. create: 'POST',
  13246. update: 'PUT',
  13247. patch: 'PATCH',
  13248. delete: 'DELETE',
  13249. read: 'GET'
  13250. };
  13251. function getSyncMethod(model) {
  13252. const store = lodash_es_result(model, 'browserStorage') || lodash_es_result(model.collection, 'browserStorage');
  13253. return store ? store.sync() : sync;
  13254. } // sync
  13255. // ----
  13256. // Override this function to change the manner in which Backbone persists
  13257. // models to the server. You will be passed the type of request, and the
  13258. // model in question. By default, makes a RESTful Ajax request
  13259. // to the model's `url()`. Some possible customizations could be:
  13260. //
  13261. // * Use `setTimeout` to batch rapid-fire updates into a single request.
  13262. // * Send up the models as XML instead of JSON.
  13263. // * Persist models via WebSockets instead of Ajax.
  13264. //
  13265. function sync(method, model) {
  13266. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  13267. const type = methodMap[method]; // Default JSON-request options.
  13268. const params = {
  13269. type: type,
  13270. dataType: 'json'
  13271. }; // Ensure that we have a URL.
  13272. if (!options.url) {
  13273. params.url = lodash_es_result(model, 'url') || urlError();
  13274. } // Ensure that we have the appropriate request data.
  13275. if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
  13276. params.contentType = 'application/json';
  13277. params.data = JSON.stringify(options.attrs || model.toJSON(options));
  13278. } // Don't process data on a non-GET request.
  13279. if (params.type !== 'GET') {
  13280. params.processData = false;
  13281. } // Pass along `textStatus` and `errorThrown` from jQuery.
  13282. const error = options.error;
  13283. options.error = function (xhr, textStatus, errorThrown) {
  13284. options.textStatus = textStatus;
  13285. options.errorThrown = errorThrown;
  13286. if (error) error.call(options.context, xhr, textStatus, errorThrown);
  13287. }; // Make the request, allowing the user to override any Ajax options.
  13288. const xhr = options.xhr = ajax(lodash_es_assignIn(params, options));
  13289. model.trigger('request', model, xhr, options);
  13290. return xhr;
  13291. }
  13292. function ajax() {
  13293. return fetch.apply(this, arguments);
  13294. }
  13295. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/history.js
  13296. // Backbone.js 1.4.0
  13297. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  13298. // Backbone may be freely distributed under the MIT license.
  13299. // History
  13300. // -------
  13301. // Handles cross-browser history management, based on either
  13302. // [pushState](http://diveintohtml5.info/history.html) and real URLs, or
  13303. // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
  13304. // and URL fragments. If the browser supports neither (old IE, natch),
  13305. // falls back to polling.
  13306. const history_History = function () {
  13307. this.handlers = [];
  13308. this.checkUrl = this.checkUrl.bind(this); // Ensure that `History` can be used outside of the browser.
  13309. if (typeof window !== 'undefined') {
  13310. this.location = window.location;
  13311. this.history = window.history;
  13312. }
  13313. };
  13314. history_History.extend = inherits; // Cached regex for stripping a leading hash/slash and trailing space.
  13315. const routeStripper = /^[#\/]|\s+$/g; // Cached regex for stripping leading and trailing slashes.
  13316. const rootStripper = /^\/+|\/+$/g; // Cached regex for stripping urls of hash.
  13317. const pathStripper = /#.*$/; // Has the history handling already been started?
  13318. history_History.started = false; // Set up all inheritable **History** properties and methods.
  13319. Object.assign(history_History.prototype, Events, {
  13320. // The default interval to poll for hash changes, if necessary, is
  13321. // twenty times a second.
  13322. interval: 50,
  13323. // Are we at the app root?
  13324. atRoot: function () {
  13325. const path = this.location.pathname.replace(/[^\/]$/, '$&/');
  13326. return path === this.root && !this.getSearch();
  13327. },
  13328. // Does the pathname match the root?
  13329. matchRoot: function () {
  13330. const path = this.decodeFragment(this.location.pathname);
  13331. const rootPath = path.slice(0, this.root.length - 1) + '/';
  13332. return rootPath === this.root;
  13333. },
  13334. // Unicode characters in `location.pathname` are percent encoded so they're
  13335. // decoded for comparison. `%25` should not be decoded since it may be part
  13336. // of an encoded parameter.
  13337. decodeFragment: function (fragment) {
  13338. return decodeURI(fragment.replace(/%25/g, '%2525'));
  13339. },
  13340. // In IE6, the hash fragment and search params are incorrect if the
  13341. // fragment contains `?`.
  13342. getSearch: function () {
  13343. const match = this.location.href.replace(/#.*/, '').match(/\?.+/);
  13344. return match ? match[0] : '';
  13345. },
  13346. // Gets the true hash value. Cannot use location.hash directly due to bug
  13347. // in Firefox where location.hash will always be decoded.
  13348. getHash: function (window) {
  13349. const match = (window || this).location.href.match(/#(.*)$/);
  13350. return match ? match[1] : '';
  13351. },
  13352. // Get the pathname and search params, without the root.
  13353. getPath: function () {
  13354. const path = this.decodeFragment(this.location.pathname + this.getSearch()).slice(this.root.length - 1);
  13355. return path.charAt(0) === '/' ? path.slice(1) : path;
  13356. },
  13357. // Get the cross-browser normalized URL fragment from the path or hash.
  13358. getFragment: function (fragment) {
  13359. if (fragment == null) {
  13360. if (this._usePushState || !this._wantsHashChange) {
  13361. fragment = this.getPath();
  13362. } else {
  13363. fragment = this.getHash();
  13364. }
  13365. }
  13366. return fragment.replace(routeStripper, '');
  13367. },
  13368. // Start the hash change handling, returning `true` if the current URL matches
  13369. // an existing route, and `false` otherwise.
  13370. start: function (options) {
  13371. if (history_History.started) throw new Error('history has already been started');
  13372. history_History.started = true; // Figure out the initial configuration. Do we need an iframe?
  13373. // Is pushState desired ... is it available?
  13374. this.options = lodash_es_assignIn({
  13375. root: '/'
  13376. }, this.options, options);
  13377. this.root = this.options.root;
  13378. this._wantsHashChange = this.options.hashChange !== false;
  13379. this._hasHashChange = 'onhashchange' in window && (document.documentMode === undefined || document.documentMode > 7);
  13380. this._useHashChange = this._wantsHashChange && this._hasHashChange;
  13381. this._wantsPushState = !!this.options.pushState;
  13382. this._hasPushState = !!(this.history && this.history.pushState);
  13383. this._usePushState = this._wantsPushState && this._hasPushState;
  13384. this.fragment = this.getFragment(); // Normalize root to always include a leading and trailing slash.
  13385. this.root = ('/' + this.root + '/').replace(rootStripper, '/'); // Transition from hashChange to pushState or vice versa if both are
  13386. // requested.
  13387. if (this._wantsHashChange && this._wantsPushState) {
  13388. // If we've started off with a route from a `pushState`-enabled
  13389. // browser, but we're currently in a browser that doesn't support it...
  13390. if (!this._hasPushState && !this.atRoot()) {
  13391. const rootPath = this.root.slice(0, -1) || '/';
  13392. this.location.replace(rootPath + '#' + this.getPath()); // Return immediately as browser will do redirect to new url
  13393. return true; // Or if we've started out with a hash-based route, but we're currently
  13394. // in a browser where it could be `pushState`-based instead...
  13395. } else if (this._hasPushState && this.atRoot()) {
  13396. this.navigate(this.getHash(), {
  13397. replace: true
  13398. });
  13399. }
  13400. } // Proxy an iframe to handle location events if the browser doesn't
  13401. // support the `hashchange` event, HTML5 history, or the user wants
  13402. // `hashChange` but not `pushState`.
  13403. if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) {
  13404. this.iframe = document.createElement('iframe');
  13405. this.iframe.src = 'javascript:0';
  13406. this.iframe.style.display = 'none';
  13407. this.iframe.tabIndex = -1;
  13408. const body = document.body; // Using `appendChild` will throw on IE < 9 if the document is not ready.
  13409. const iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow;
  13410. iWindow.document.open();
  13411. iWindow.document.close();
  13412. iWindow.location.hash = '#' + this.fragment;
  13413. } // Depending on whether we're using pushState or hashes, and whether
  13414. // 'onhashchange' is supported, determine how we check the URL state.
  13415. if (this._usePushState) {
  13416. addEventListener('popstate', this.checkUrl, false);
  13417. } else if (this._useHashChange && !this.iframe) {
  13418. addEventListener('hashchange', this.checkUrl, false);
  13419. } else if (this._wantsHashChange) {
  13420. this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
  13421. }
  13422. if (!this.options.silent) return this.loadUrl();
  13423. },
  13424. // Disable history, perhaps temporarily. Not useful in a real app,
  13425. // but possibly useful for unit testing Routers.
  13426. stop: function () {
  13427. // Remove window listeners.
  13428. if (this._usePushState) {
  13429. removeEventListener('popstate', this.checkUrl, false);
  13430. } else if (this._useHashChange && !this.iframe) {
  13431. removeEventListener('hashchange', this.checkUrl, false);
  13432. } // Clean up the iframe if necessary.
  13433. if (this.iframe) {
  13434. document.body.removeChild(this.iframe);
  13435. this.iframe = null;
  13436. } // Some environments will throw when clearing an undefined interval.
  13437. if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
  13438. history_History.started = false;
  13439. },
  13440. // Add a route to be tested when the fragment changes. Routes added later
  13441. // may override previous routes.
  13442. route: function (route, callback) {
  13443. this.handlers.unshift({
  13444. route: route,
  13445. callback: callback
  13446. });
  13447. },
  13448. // Checks the current URL to see if it has changed, and if it has,
  13449. // calls `loadUrl`, normalizing across the hidden iframe.
  13450. checkUrl: function (e) {
  13451. let current = this.getFragment(); // If the user pressed the back button, the iframe's hash will have
  13452. // changed and we should use that for comparison.
  13453. if (current === this.fragment && this.iframe) {
  13454. current = this.getHash(this.iframe.contentWindow);
  13455. }
  13456. if (current === this.fragment) return false;
  13457. if (this.iframe) this.navigate(current);
  13458. this.loadUrl();
  13459. },
  13460. // Attempt to load the current URL fragment. If a route succeeds with a
  13461. // match, returns `true`. If no defined routes matches the fragment,
  13462. // returns `false`.
  13463. loadUrl: function (fragment) {
  13464. // If the root doesn't match, no routes can match either.
  13465. if (!this.matchRoot()) return false;
  13466. fragment = this.fragment = this.getFragment(fragment);
  13467. return lodash_es_some(this.handlers, function (handler) {
  13468. if (handler.route.test(fragment)) {
  13469. handler.callback(fragment);
  13470. return true;
  13471. }
  13472. });
  13473. },
  13474. // Save a fragment into the hash history, or replace the URL state if the
  13475. // 'replace' option is passed. You are responsible for properly URL-encoding
  13476. // the fragment in advance.
  13477. //
  13478. // The options object can contain `trigger: true` if you wish to have the
  13479. // route callback be fired (not usually desirable), or `replace: true`, if
  13480. // you wish to modify the current URL without adding an entry to the history.
  13481. navigate: function (fragment, options) {
  13482. if (!history_History.started) return false;
  13483. if (!options || options === true) options = {
  13484. trigger: !!options
  13485. }; // Normalize the fragment.
  13486. fragment = this.getFragment(fragment || ''); // Don't include a trailing slash on the root.
  13487. let rootPath = this.root;
  13488. if (fragment === '' || fragment.charAt(0) === '?') {
  13489. rootPath = rootPath.slice(0, -1) || '/';
  13490. }
  13491. const url = rootPath + fragment; // Strip the fragment of the query and hash for matching.
  13492. fragment = fragment.replace(pathStripper, ''); // Decode for matching.
  13493. const decodedFragment = this.decodeFragment(fragment);
  13494. if (this.fragment === decodedFragment) return;
  13495. this.fragment = decodedFragment; // If pushState is available, we use it to set the fragment as a real URL.
  13496. if (this._usePushState) {
  13497. this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); // If hash changes haven't been explicitly disabled, update the hash
  13498. // fragment to store history.
  13499. } else if (this._wantsHashChange) {
  13500. this._updateHash(this.location, fragment, options.replace);
  13501. if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) {
  13502. const iWindow = this.iframe.contentWindow; // Opening and closing the iframe tricks IE7 and earlier to push a
  13503. // history entry on hash-tag change. When replace is true, we don't
  13504. // want this.
  13505. if (!options.replace) {
  13506. iWindow.document.open();
  13507. iWindow.document.close();
  13508. }
  13509. this._updateHash(iWindow.location, fragment, options.replace);
  13510. } // If you've told us that you explicitly don't want fallback hashchange-
  13511. // based history, then `navigate` becomes a page refresh.
  13512. } else {
  13513. return this.location.assign(url);
  13514. }
  13515. if (options.trigger) return this.loadUrl(fragment);
  13516. },
  13517. // Update the hash location, either replacing the current entry, or adding
  13518. // a new one to the browser history.
  13519. _updateHash: function (location, fragment, replace) {
  13520. if (replace) {
  13521. const href = location.href.replace(/(javascript:|#).*$/, '');
  13522. location.replace(href + '#' + fragment);
  13523. } else {
  13524. // Some browsers require that `hash` contains a leading #.
  13525. location.hash = '#' + fragment;
  13526. }
  13527. }
  13528. });
  13529. /* harmony default export */ const src_history = (history_History);
  13530. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsRegExp.js
  13531. /** `Object#toString` result references. */
  13532. var _baseIsRegExp_regexpTag = '[object RegExp]';
  13533. /**
  13534. * The base implementation of `_.isRegExp` without Node.js optimizations.
  13535. *
  13536. * @private
  13537. * @param {*} value The value to check.
  13538. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  13539. */
  13540. function baseIsRegExp(value) {
  13541. return lodash_es_isObjectLike(value) && _baseGetTag(value) == _baseIsRegExp_regexpTag;
  13542. }
  13543. /* harmony default export */ const _baseIsRegExp = (baseIsRegExp);
  13544. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isRegExp.js
  13545. /* Node.js helper references. */
  13546. var nodeIsRegExp = _nodeUtil && _nodeUtil.isRegExp;
  13547. /**
  13548. * Checks if `value` is classified as a `RegExp` object.
  13549. *
  13550. * @static
  13551. * @memberOf _
  13552. * @since 0.1.0
  13553. * @category Lang
  13554. * @param {*} value The value to check.
  13555. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  13556. * @example
  13557. *
  13558. * _.isRegExp(/abc/);
  13559. * // => true
  13560. *
  13561. * _.isRegExp('/abc/');
  13562. * // => false
  13563. */
  13564. var isRegExp = nodeIsRegExp ? _baseUnary(nodeIsRegExp) : _baseIsRegExp;
  13565. /* harmony default export */ const lodash_es_isRegExp = (isRegExp);
  13566. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/router.js
  13567. // Backbone.js 1.4.0
  13568. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  13569. // Backbone may be freely distributed under the MIT license.
  13570. // Router
  13571. // ------
  13572. // Routers map faux-URLs to actions, and fire events when routes are
  13573. // matched. Creating a new one sets its `routes` hash, if not set statically.
  13574. const Router = function () {
  13575. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13576. this.history = options.history || new src_history();
  13577. this.preinitialize.apply(this, arguments);
  13578. if (options.routes) this.routes = options.routes;
  13579. this._bindRoutes();
  13580. this.initialize.apply(this, arguments);
  13581. };
  13582. Router.extend = inherits; // Cached regular expressions for matching named param parts and splatted
  13583. // parts of route strings.
  13584. const optionalParam = /\((.*?)\)/g;
  13585. const namedParam = /(\(\?)?:\w+/g;
  13586. const splatParam = /\*\w+/g;
  13587. const escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; // Set up all inheritable **Router** properties and methods.
  13588. Object.assign(Router.prototype, Events, {
  13589. // preinitialize is an empty function by default. You can override it with a function
  13590. // or object. preinitialize will run before any instantiation logic is run in the Router.
  13591. preinitialize: function () {},
  13592. // Initialize is an empty function by default. Override it with your own
  13593. // initialization logic.
  13594. initialize: function () {},
  13595. // Manually bind a single named route to a callback. For example:
  13596. //
  13597. // this.route('search/:query/p:num', 'search', function(query, num) {
  13598. // ...
  13599. // });
  13600. //
  13601. route: function (route, name, callback) {
  13602. if (!lodash_es_isRegExp(route)) route = this._routeToRegExp(route);
  13603. if (lodash_es_isFunction(name)) {
  13604. callback = name;
  13605. name = '';
  13606. }
  13607. if (!callback) callback = this[name];
  13608. this.history.route(route, fragment => {
  13609. const args = this._extractParameters(route, fragment);
  13610. if (this.execute(callback, args, name) !== false) {
  13611. this.trigger.apply(this, ['route:' + name].concat(args));
  13612. this.trigger('route', name, args);
  13613. this.history.trigger('route', this, name, args);
  13614. }
  13615. });
  13616. return this;
  13617. },
  13618. // Execute a route handler with the provided parameters. This is an
  13619. // excellent place to do pre-route setup or post-route cleanup.
  13620. execute: function (callback, args, name) {
  13621. if (callback) callback.apply(this, args);
  13622. },
  13623. // Simple proxy to `history` to save a fragment into the history.
  13624. navigate: function (fragment, options) {
  13625. this.history.navigate(fragment, options);
  13626. return this;
  13627. },
  13628. // Bind all defined routes to `history`. We have to reverse the
  13629. // order of the routes here to support behavior where the most general
  13630. // routes can be defined at the bottom of the route map.
  13631. _bindRoutes: function () {
  13632. if (!this.routes) return;
  13633. this.routes = lodash_es_result(this, 'routes');
  13634. let route;
  13635. const routes = lodash_es_keys(this.routes);
  13636. while ((route = routes.pop()) != null) {
  13637. this.route(route, this.routes[route]);
  13638. }
  13639. },
  13640. // Convert a route string into a regular expression, suitable for matching
  13641. // against the current location hash.
  13642. _routeToRegExp: function (route) {
  13643. route = route.replace(escapeRegExp, '\\$&').replace(optionalParam, '(?:$1)?').replace(namedParam, function (match, optional) {
  13644. return optional ? match : '([^/?]+)';
  13645. }).replace(splatParam, '([^?]*?)');
  13646. return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
  13647. },
  13648. // Given a route, and a URL fragment that it matches, return the array of
  13649. // extracted decoded parameters. Empty or unmatched parameters will be
  13650. // treated as `null` to normalize cross-browser behavior.
  13651. _extractParameters: function (route, fragment) {
  13652. const params = route.exec(fragment).slice(1);
  13653. return params.map(function (param, i) {
  13654. // Don't decode the search params.
  13655. if (i === params.length - 1) return param || null;
  13656. return param ? decodeURIComponent(param) : null;
  13657. });
  13658. }
  13659. });
  13660. ;// CONCATENATED MODULE: ./src/headless/shared/errors.js
  13661. /**
  13662. * Custom error for indicating timeouts
  13663. * @namespace _converse
  13664. */
  13665. class TimeoutError extends Error {}
  13666. // EXTERNAL MODULE: ./node_modules/localforage-driver-memory/_bundle/umd.js
  13667. var umd = __webpack_require__(3245);
  13668. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayEach.js
  13669. /**
  13670. * A specialized version of `_.forEach` for arrays without support for
  13671. * iteratee shorthands.
  13672. *
  13673. * @private
  13674. * @param {Array} [array] The array to iterate over.
  13675. * @param {Function} iteratee The function invoked per iteration.
  13676. * @returns {Array} Returns `array`.
  13677. */
  13678. function arrayEach(array, iteratee) {
  13679. var index = -1,
  13680. length = array == null ? 0 : array.length;
  13681. while (++index < length) {
  13682. if (iteratee(array[index], index, array) === false) {
  13683. break;
  13684. }
  13685. }
  13686. return array;
  13687. }
  13688. /* harmony default export */ const _arrayEach = (arrayEach);
  13689. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseAssignIn.js
  13690. /**
  13691. * The base implementation of `_.assignIn` without support for multiple sources
  13692. * or `customizer` functions.
  13693. *
  13694. * @private
  13695. * @param {Object} object The destination object.
  13696. * @param {Object} source The source object.
  13697. * @returns {Object} Returns `object`.
  13698. */
  13699. function baseAssignIn(object, source) {
  13700. return object && _copyObject(source, lodash_es_keysIn(source), object);
  13701. }
  13702. /* harmony default export */ const _baseAssignIn = (baseAssignIn);
  13703. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneBuffer.js
  13704. /** Detect free variable `exports`. */
  13705. var _cloneBuffer_freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  13706. /** Detect free variable `module`. */
  13707. var _cloneBuffer_freeModule = _cloneBuffer_freeExports && typeof module == 'object' && module && !module.nodeType && module;
  13708. /** Detect the popular CommonJS extension `module.exports`. */
  13709. var _cloneBuffer_moduleExports = _cloneBuffer_freeModule && _cloneBuffer_freeModule.exports === _cloneBuffer_freeExports;
  13710. /** Built-in value references. */
  13711. var _cloneBuffer_Buffer = _cloneBuffer_moduleExports ? _root.Buffer : undefined,
  13712. allocUnsafe = _cloneBuffer_Buffer ? _cloneBuffer_Buffer.allocUnsafe : undefined;
  13713. /**
  13714. * Creates a clone of `buffer`.
  13715. *
  13716. * @private
  13717. * @param {Buffer} buffer The buffer to clone.
  13718. * @param {boolean} [isDeep] Specify a deep clone.
  13719. * @returns {Buffer} Returns the cloned buffer.
  13720. */
  13721. function cloneBuffer(buffer, isDeep) {
  13722. if (isDeep) {
  13723. return buffer.slice();
  13724. }
  13725. var length = buffer.length,
  13726. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  13727. buffer.copy(result);
  13728. return result;
  13729. }
  13730. /* harmony default export */ const _cloneBuffer = (cloneBuffer);
  13731. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_copyArray.js
  13732. /**
  13733. * Copies the values of `source` to `array`.
  13734. *
  13735. * @private
  13736. * @param {Array} source The array to copy values from.
  13737. * @param {Array} [array=[]] The array to copy values to.
  13738. * @returns {Array} Returns `array`.
  13739. */
  13740. function copyArray(source, array) {
  13741. var index = -1,
  13742. length = source.length;
  13743. array || (array = Array(length));
  13744. while (++index < length) {
  13745. array[index] = source[index];
  13746. }
  13747. return array;
  13748. }
  13749. /* harmony default export */ const _copyArray = (copyArray);
  13750. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_copySymbols.js
  13751. /**
  13752. * Copies own symbols of `source` to `object`.
  13753. *
  13754. * @private
  13755. * @param {Object} source The object to copy symbols from.
  13756. * @param {Object} [object={}] The object to copy symbols to.
  13757. * @returns {Object} Returns `object`.
  13758. */
  13759. function copySymbols(source, object) {
  13760. return _copyObject(source, _getSymbols(source), object);
  13761. }
  13762. /* harmony default export */ const _copySymbols = (copySymbols);
  13763. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getSymbolsIn.js
  13764. /* Built-in method references for those with the same name as other `lodash` methods. */
  13765. var _getSymbolsIn_nativeGetSymbols = Object.getOwnPropertySymbols;
  13766. /**
  13767. * Creates an array of the own and inherited enumerable symbols of `object`.
  13768. *
  13769. * @private
  13770. * @param {Object} object The object to query.
  13771. * @returns {Array} Returns the array of symbols.
  13772. */
  13773. var getSymbolsIn = !_getSymbolsIn_nativeGetSymbols ? lodash_es_stubArray : function(object) {
  13774. var result = [];
  13775. while (object) {
  13776. _arrayPush(result, _getSymbols(object));
  13777. object = _getPrototype(object);
  13778. }
  13779. return result;
  13780. };
  13781. /* harmony default export */ const _getSymbolsIn = (getSymbolsIn);
  13782. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_copySymbolsIn.js
  13783. /**
  13784. * Copies own and inherited symbols of `source` to `object`.
  13785. *
  13786. * @private
  13787. * @param {Object} source The object to copy symbols from.
  13788. * @param {Object} [object={}] The object to copy symbols to.
  13789. * @returns {Object} Returns `object`.
  13790. */
  13791. function copySymbolsIn(source, object) {
  13792. return _copyObject(source, _getSymbolsIn(source), object);
  13793. }
  13794. /* harmony default export */ const _copySymbolsIn = (copySymbolsIn);
  13795. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_getAllKeysIn.js
  13796. /**
  13797. * Creates an array of own and inherited enumerable property names and
  13798. * symbols of `object`.
  13799. *
  13800. * @private
  13801. * @param {Object} object The object to query.
  13802. * @returns {Array} Returns the array of property names and symbols.
  13803. */
  13804. function getAllKeysIn(object) {
  13805. return _baseGetAllKeys(object, lodash_es_keysIn, _getSymbolsIn);
  13806. }
  13807. /* harmony default export */ const _getAllKeysIn = (getAllKeysIn);
  13808. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_initCloneArray.js
  13809. /** Used for built-in method references. */
  13810. var _initCloneArray_objectProto = Object.prototype;
  13811. /** Used to check objects for own properties. */
  13812. var _initCloneArray_hasOwnProperty = _initCloneArray_objectProto.hasOwnProperty;
  13813. /**
  13814. * Initializes an array clone.
  13815. *
  13816. * @private
  13817. * @param {Array} array The array to clone.
  13818. * @returns {Array} Returns the initialized clone.
  13819. */
  13820. function initCloneArray(array) {
  13821. var length = array.length,
  13822. result = new array.constructor(length);
  13823. // Add properties assigned by `RegExp#exec`.
  13824. if (length && typeof array[0] == 'string' && _initCloneArray_hasOwnProperty.call(array, 'index')) {
  13825. result.index = array.index;
  13826. result.input = array.input;
  13827. }
  13828. return result;
  13829. }
  13830. /* harmony default export */ const _initCloneArray = (initCloneArray);
  13831. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneArrayBuffer.js
  13832. /**
  13833. * Creates a clone of `arrayBuffer`.
  13834. *
  13835. * @private
  13836. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  13837. * @returns {ArrayBuffer} Returns the cloned array buffer.
  13838. */
  13839. function cloneArrayBuffer(arrayBuffer) {
  13840. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  13841. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  13842. return result;
  13843. }
  13844. /* harmony default export */ const _cloneArrayBuffer = (cloneArrayBuffer);
  13845. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneDataView.js
  13846. /**
  13847. * Creates a clone of `dataView`.
  13848. *
  13849. * @private
  13850. * @param {Object} dataView The data view to clone.
  13851. * @param {boolean} [isDeep] Specify a deep clone.
  13852. * @returns {Object} Returns the cloned data view.
  13853. */
  13854. function cloneDataView(dataView, isDeep) {
  13855. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  13856. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  13857. }
  13858. /* harmony default export */ const _cloneDataView = (cloneDataView);
  13859. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneRegExp.js
  13860. /** Used to match `RegExp` flags from their coerced string values. */
  13861. var reFlags = /\w*$/;
  13862. /**
  13863. * Creates a clone of `regexp`.
  13864. *
  13865. * @private
  13866. * @param {Object} regexp The regexp to clone.
  13867. * @returns {Object} Returns the cloned regexp.
  13868. */
  13869. function cloneRegExp(regexp) {
  13870. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  13871. result.lastIndex = regexp.lastIndex;
  13872. return result;
  13873. }
  13874. /* harmony default export */ const _cloneRegExp = (cloneRegExp);
  13875. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneSymbol.js
  13876. /** Used to convert symbols to primitives and strings. */
  13877. var _cloneSymbol_symbolProto = _Symbol ? _Symbol.prototype : undefined,
  13878. _cloneSymbol_symbolValueOf = _cloneSymbol_symbolProto ? _cloneSymbol_symbolProto.valueOf : undefined;
  13879. /**
  13880. * Creates a clone of the `symbol` object.
  13881. *
  13882. * @private
  13883. * @param {Object} symbol The symbol object to clone.
  13884. * @returns {Object} Returns the cloned symbol object.
  13885. */
  13886. function cloneSymbol(symbol) {
  13887. return _cloneSymbol_symbolValueOf ? Object(_cloneSymbol_symbolValueOf.call(symbol)) : {};
  13888. }
  13889. /* harmony default export */ const _cloneSymbol = (cloneSymbol);
  13890. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_cloneTypedArray.js
  13891. /**
  13892. * Creates a clone of `typedArray`.
  13893. *
  13894. * @private
  13895. * @param {Object} typedArray The typed array to clone.
  13896. * @param {boolean} [isDeep] Specify a deep clone.
  13897. * @returns {Object} Returns the cloned typed array.
  13898. */
  13899. function cloneTypedArray(typedArray, isDeep) {
  13900. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  13901. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  13902. }
  13903. /* harmony default export */ const _cloneTypedArray = (cloneTypedArray);
  13904. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_initCloneByTag.js
  13905. /** `Object#toString` result references. */
  13906. var _initCloneByTag_boolTag = '[object Boolean]',
  13907. _initCloneByTag_dateTag = '[object Date]',
  13908. _initCloneByTag_mapTag = '[object Map]',
  13909. _initCloneByTag_numberTag = '[object Number]',
  13910. _initCloneByTag_regexpTag = '[object RegExp]',
  13911. _initCloneByTag_setTag = '[object Set]',
  13912. _initCloneByTag_stringTag = '[object String]',
  13913. _initCloneByTag_symbolTag = '[object Symbol]';
  13914. var _initCloneByTag_arrayBufferTag = '[object ArrayBuffer]',
  13915. _initCloneByTag_dataViewTag = '[object DataView]',
  13916. _initCloneByTag_float32Tag = '[object Float32Array]',
  13917. _initCloneByTag_float64Tag = '[object Float64Array]',
  13918. _initCloneByTag_int8Tag = '[object Int8Array]',
  13919. _initCloneByTag_int16Tag = '[object Int16Array]',
  13920. _initCloneByTag_int32Tag = '[object Int32Array]',
  13921. _initCloneByTag_uint8Tag = '[object Uint8Array]',
  13922. _initCloneByTag_uint8ClampedTag = '[object Uint8ClampedArray]',
  13923. _initCloneByTag_uint16Tag = '[object Uint16Array]',
  13924. _initCloneByTag_uint32Tag = '[object Uint32Array]';
  13925. /**
  13926. * Initializes an object clone based on its `toStringTag`.
  13927. *
  13928. * **Note:** This function only supports cloning values with tags of
  13929. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  13930. *
  13931. * @private
  13932. * @param {Object} object The object to clone.
  13933. * @param {string} tag The `toStringTag` of the object to clone.
  13934. * @param {boolean} [isDeep] Specify a deep clone.
  13935. * @returns {Object} Returns the initialized clone.
  13936. */
  13937. function initCloneByTag(object, tag, isDeep) {
  13938. var Ctor = object.constructor;
  13939. switch (tag) {
  13940. case _initCloneByTag_arrayBufferTag:
  13941. return _cloneArrayBuffer(object);
  13942. case _initCloneByTag_boolTag:
  13943. case _initCloneByTag_dateTag:
  13944. return new Ctor(+object);
  13945. case _initCloneByTag_dataViewTag:
  13946. return _cloneDataView(object, isDeep);
  13947. case _initCloneByTag_float32Tag: case _initCloneByTag_float64Tag:
  13948. case _initCloneByTag_int8Tag: case _initCloneByTag_int16Tag: case _initCloneByTag_int32Tag:
  13949. case _initCloneByTag_uint8Tag: case _initCloneByTag_uint8ClampedTag: case _initCloneByTag_uint16Tag: case _initCloneByTag_uint32Tag:
  13950. return _cloneTypedArray(object, isDeep);
  13951. case _initCloneByTag_mapTag:
  13952. return new Ctor;
  13953. case _initCloneByTag_numberTag:
  13954. case _initCloneByTag_stringTag:
  13955. return new Ctor(object);
  13956. case _initCloneByTag_regexpTag:
  13957. return _cloneRegExp(object);
  13958. case _initCloneByTag_setTag:
  13959. return new Ctor;
  13960. case _initCloneByTag_symbolTag:
  13961. return _cloneSymbol(object);
  13962. }
  13963. }
  13964. /* harmony default export */ const _initCloneByTag = (initCloneByTag);
  13965. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_initCloneObject.js
  13966. /**
  13967. * Initializes an object clone.
  13968. *
  13969. * @private
  13970. * @param {Object} object The object to clone.
  13971. * @returns {Object} Returns the initialized clone.
  13972. */
  13973. function initCloneObject(object) {
  13974. return (typeof object.constructor == 'function' && !_isPrototype(object))
  13975. ? _baseCreate(_getPrototype(object))
  13976. : {};
  13977. }
  13978. /* harmony default export */ const _initCloneObject = (initCloneObject);
  13979. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsMap.js
  13980. /** `Object#toString` result references. */
  13981. var _baseIsMap_mapTag = '[object Map]';
  13982. /**
  13983. * The base implementation of `_.isMap` without Node.js optimizations.
  13984. *
  13985. * @private
  13986. * @param {*} value The value to check.
  13987. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  13988. */
  13989. function baseIsMap(value) {
  13990. return lodash_es_isObjectLike(value) && _getTag(value) == _baseIsMap_mapTag;
  13991. }
  13992. /* harmony default export */ const _baseIsMap = (baseIsMap);
  13993. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isMap.js
  13994. /* Node.js helper references. */
  13995. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  13996. /**
  13997. * Checks if `value` is classified as a `Map` object.
  13998. *
  13999. * @static
  14000. * @memberOf _
  14001. * @since 4.3.0
  14002. * @category Lang
  14003. * @param {*} value The value to check.
  14004. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  14005. * @example
  14006. *
  14007. * _.isMap(new Map);
  14008. * // => true
  14009. *
  14010. * _.isMap(new WeakMap);
  14011. * // => false
  14012. */
  14013. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  14014. /* harmony default export */ const lodash_es_isMap = (isMap);
  14015. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsSet.js
  14016. /** `Object#toString` result references. */
  14017. var _baseIsSet_setTag = '[object Set]';
  14018. /**
  14019. * The base implementation of `_.isSet` without Node.js optimizations.
  14020. *
  14021. * @private
  14022. * @param {*} value The value to check.
  14023. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  14024. */
  14025. function baseIsSet(value) {
  14026. return lodash_es_isObjectLike(value) && _getTag(value) == _baseIsSet_setTag;
  14027. }
  14028. /* harmony default export */ const _baseIsSet = (baseIsSet);
  14029. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isSet.js
  14030. /* Node.js helper references. */
  14031. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  14032. /**
  14033. * Checks if `value` is classified as a `Set` object.
  14034. *
  14035. * @static
  14036. * @memberOf _
  14037. * @since 4.3.0
  14038. * @category Lang
  14039. * @param {*} value The value to check.
  14040. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  14041. * @example
  14042. *
  14043. * _.isSet(new Set);
  14044. * // => true
  14045. *
  14046. * _.isSet(new WeakSet);
  14047. * // => false
  14048. */
  14049. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  14050. /* harmony default export */ const lodash_es_isSet = (isSet);
  14051. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseClone.js
  14052. /** Used to compose bitmasks for cloning. */
  14053. var CLONE_DEEP_FLAG = 1,
  14054. CLONE_FLAT_FLAG = 2,
  14055. CLONE_SYMBOLS_FLAG = 4;
  14056. /** `Object#toString` result references. */
  14057. var _baseClone_argsTag = '[object Arguments]',
  14058. _baseClone_arrayTag = '[object Array]',
  14059. _baseClone_boolTag = '[object Boolean]',
  14060. _baseClone_dateTag = '[object Date]',
  14061. _baseClone_errorTag = '[object Error]',
  14062. _baseClone_funcTag = '[object Function]',
  14063. _baseClone_genTag = '[object GeneratorFunction]',
  14064. _baseClone_mapTag = '[object Map]',
  14065. _baseClone_numberTag = '[object Number]',
  14066. _baseClone_objectTag = '[object Object]',
  14067. _baseClone_regexpTag = '[object RegExp]',
  14068. _baseClone_setTag = '[object Set]',
  14069. _baseClone_stringTag = '[object String]',
  14070. _baseClone_symbolTag = '[object Symbol]',
  14071. _baseClone_weakMapTag = '[object WeakMap]';
  14072. var _baseClone_arrayBufferTag = '[object ArrayBuffer]',
  14073. _baseClone_dataViewTag = '[object DataView]',
  14074. _baseClone_float32Tag = '[object Float32Array]',
  14075. _baseClone_float64Tag = '[object Float64Array]',
  14076. _baseClone_int8Tag = '[object Int8Array]',
  14077. _baseClone_int16Tag = '[object Int16Array]',
  14078. _baseClone_int32Tag = '[object Int32Array]',
  14079. _baseClone_uint8Tag = '[object Uint8Array]',
  14080. _baseClone_uint8ClampedTag = '[object Uint8ClampedArray]',
  14081. _baseClone_uint16Tag = '[object Uint16Array]',
  14082. _baseClone_uint32Tag = '[object Uint32Array]';
  14083. /** Used to identify `toStringTag` values supported by `_.clone`. */
  14084. var cloneableTags = {};
  14085. cloneableTags[_baseClone_argsTag] = cloneableTags[_baseClone_arrayTag] =
  14086. cloneableTags[_baseClone_arrayBufferTag] = cloneableTags[_baseClone_dataViewTag] =
  14087. cloneableTags[_baseClone_boolTag] = cloneableTags[_baseClone_dateTag] =
  14088. cloneableTags[_baseClone_float32Tag] = cloneableTags[_baseClone_float64Tag] =
  14089. cloneableTags[_baseClone_int8Tag] = cloneableTags[_baseClone_int16Tag] =
  14090. cloneableTags[_baseClone_int32Tag] = cloneableTags[_baseClone_mapTag] =
  14091. cloneableTags[_baseClone_numberTag] = cloneableTags[_baseClone_objectTag] =
  14092. cloneableTags[_baseClone_regexpTag] = cloneableTags[_baseClone_setTag] =
  14093. cloneableTags[_baseClone_stringTag] = cloneableTags[_baseClone_symbolTag] =
  14094. cloneableTags[_baseClone_uint8Tag] = cloneableTags[_baseClone_uint8ClampedTag] =
  14095. cloneableTags[_baseClone_uint16Tag] = cloneableTags[_baseClone_uint32Tag] = true;
  14096. cloneableTags[_baseClone_errorTag] = cloneableTags[_baseClone_funcTag] =
  14097. cloneableTags[_baseClone_weakMapTag] = false;
  14098. /**
  14099. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  14100. * traversed objects.
  14101. *
  14102. * @private
  14103. * @param {*} value The value to clone.
  14104. * @param {boolean} bitmask The bitmask flags.
  14105. * 1 - Deep clone
  14106. * 2 - Flatten inherited properties
  14107. * 4 - Clone symbols
  14108. * @param {Function} [customizer] The function to customize cloning.
  14109. * @param {string} [key] The key of `value`.
  14110. * @param {Object} [object] The parent object of `value`.
  14111. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  14112. * @returns {*} Returns the cloned value.
  14113. */
  14114. function baseClone(value, bitmask, customizer, key, object, stack) {
  14115. var result,
  14116. isDeep = bitmask & CLONE_DEEP_FLAG,
  14117. isFlat = bitmask & CLONE_FLAT_FLAG,
  14118. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  14119. if (customizer) {
  14120. result = object ? customizer(value, key, object, stack) : customizer(value);
  14121. }
  14122. if (result !== undefined) {
  14123. return result;
  14124. }
  14125. if (!lodash_es_isObject(value)) {
  14126. return value;
  14127. }
  14128. var isArr = lodash_es_isArray(value);
  14129. if (isArr) {
  14130. result = _initCloneArray(value);
  14131. if (!isDeep) {
  14132. return _copyArray(value, result);
  14133. }
  14134. } else {
  14135. var tag = _getTag(value),
  14136. isFunc = tag == _baseClone_funcTag || tag == _baseClone_genTag;
  14137. if (lodash_es_isBuffer(value)) {
  14138. return _cloneBuffer(value, isDeep);
  14139. }
  14140. if (tag == _baseClone_objectTag || tag == _baseClone_argsTag || (isFunc && !object)) {
  14141. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  14142. if (!isDeep) {
  14143. return isFlat
  14144. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  14145. : _copySymbols(value, _baseAssign(result, value));
  14146. }
  14147. } else {
  14148. if (!cloneableTags[tag]) {
  14149. return object ? value : {};
  14150. }
  14151. result = _initCloneByTag(value, tag, isDeep);
  14152. }
  14153. }
  14154. // Check for circular references and return its corresponding clone.
  14155. stack || (stack = new _Stack);
  14156. var stacked = stack.get(value);
  14157. if (stacked) {
  14158. return stacked;
  14159. }
  14160. stack.set(value, result);
  14161. if (lodash_es_isSet(value)) {
  14162. value.forEach(function(subValue) {
  14163. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  14164. });
  14165. } else if (lodash_es_isMap(value)) {
  14166. value.forEach(function(subValue, key) {
  14167. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  14168. });
  14169. }
  14170. var keysFunc = isFull
  14171. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  14172. : (isFlat ? lodash_es_keysIn : lodash_es_keys);
  14173. var props = isArr ? undefined : keysFunc(value);
  14174. _arrayEach(props || value, function(subValue, key) {
  14175. if (props) {
  14176. key = subValue;
  14177. subValue = value[key];
  14178. }
  14179. // Recursively populate clone (susceptible to call stack limits).
  14180. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  14181. });
  14182. return result;
  14183. }
  14184. /* harmony default export */ const _baseClone = (baseClone);
  14185. ;// CONCATENATED MODULE: ./node_modules/lodash-es/cloneDeep.js
  14186. /** Used to compose bitmasks for cloning. */
  14187. var cloneDeep_CLONE_DEEP_FLAG = 1,
  14188. cloneDeep_CLONE_SYMBOLS_FLAG = 4;
  14189. /**
  14190. * This method is like `_.clone` except that it recursively clones `value`.
  14191. *
  14192. * @static
  14193. * @memberOf _
  14194. * @since 1.0.0
  14195. * @category Lang
  14196. * @param {*} value The value to recursively clone.
  14197. * @returns {*} Returns the deep cloned value.
  14198. * @see _.clone
  14199. * @example
  14200. *
  14201. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  14202. *
  14203. * var deep = _.cloneDeep(objects);
  14204. * console.log(deep[0] === objects[0]);
  14205. * // => false
  14206. */
  14207. function cloneDeep(value) {
  14208. return _baseClone(value, cloneDeep_CLONE_DEEP_FLAG | cloneDeep_CLONE_SYMBOLS_FLAG);
  14209. }
  14210. /* harmony default export */ const lodash_es_cloneDeep = (cloneDeep);
  14211. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isString.js
  14212. /** `Object#toString` result references. */
  14213. var isString_stringTag = '[object String]';
  14214. /**
  14215. * Checks if `value` is classified as a `String` primitive or object.
  14216. *
  14217. * @static
  14218. * @since 0.1.0
  14219. * @memberOf _
  14220. * @category Lang
  14221. * @param {*} value The value to check.
  14222. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  14223. * @example
  14224. *
  14225. * _.isString('abc');
  14226. * // => true
  14227. *
  14228. * _.isString(1);
  14229. * // => false
  14230. */
  14231. function isString(value) {
  14232. return typeof value == 'string' ||
  14233. (!lodash_es_isArray(value) && lodash_es_isObjectLike(value) && _baseGetTag(value) == isString_stringTag);
  14234. }
  14235. /* harmony default export */ const lodash_es_isString = (isString);
  14236. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/idb.js
  14237. function getIDB() {
  14238. /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */
  14239. try {
  14240. if (typeof indexedDB !== 'undefined') {
  14241. return indexedDB;
  14242. }
  14243. if (typeof webkitIndexedDB !== 'undefined') {
  14244. return webkitIndexedDB;
  14245. }
  14246. if (typeof mozIndexedDB !== 'undefined') {
  14247. return mozIndexedDB;
  14248. }
  14249. if (typeof OIndexedDB !== 'undefined') {
  14250. return OIndexedDB;
  14251. }
  14252. if (typeof msIndexedDB !== 'undefined') {
  14253. return msIndexedDB;
  14254. }
  14255. } catch (e) {
  14256. return;
  14257. }
  14258. }
  14259. var idb = getIDB();
  14260. /* harmony default export */ const utils_idb = (idb);
  14261. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/isIndexedDBValid.js
  14262. function isIndexedDBValid() {
  14263. try {
  14264. // Initialize IndexedDB; fall back to vendor-prefixed versions
  14265. // if needed.
  14266. if (!utils_idb || !utils_idb.open) {
  14267. return false;
  14268. } // We mimic PouchDB here;
  14269. //
  14270. // We test for openDatabase because IE Mobile identifies itself
  14271. // as Safari. Oh the lulz...
  14272. var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);
  14273. var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1; // Safari <10.1 does not meet our requirements for IDB support
  14274. // (see: https://github.com/pouchdb/pouchdb/issues/5572).
  14275. // Safari 10.1 shipped with fetch, we can use that to detect it.
  14276. // Note: this creates issues with `window.fetch` polyfills and
  14277. // overrides; see:
  14278. // https://github.com/localForage/localForage/issues/856
  14279. return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' && // some outdated implementations of IDB that appear on Samsung
  14280. // and HTC Android devices <4.4 are missing IDBKeyRange
  14281. // See: https://github.com/mozilla/localForage/issues/128
  14282. // See: https://github.com/mozilla/localForage/issues/272
  14283. typeof IDBKeyRange !== 'undefined';
  14284. } catch (e) {
  14285. return false;
  14286. }
  14287. }
  14288. /* harmony default export */ const utils_isIndexedDBValid = (isIndexedDBValid);
  14289. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/createBlob.js
  14290. // Abstracts constructing a Blob object, so it also works in older
  14291. // browsers that don't support the native Blob constructor. (i.e.
  14292. // old QtWebKit versions, at least).
  14293. // Abstracts constructing a Blob object, so it also works in older
  14294. // browsers that don't support the native Blob constructor. (i.e.
  14295. // old QtWebKit versions, at least).
  14296. function createBlob(parts, properties) {
  14297. /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */
  14298. parts = parts || [];
  14299. properties = properties || {};
  14300. try {
  14301. return new Blob(parts, properties);
  14302. } catch (e) {
  14303. if (e.name !== 'TypeError') {
  14304. throw e;
  14305. }
  14306. var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;
  14307. var builder = new Builder();
  14308. for (var i = 0; i < parts.length; i += 1) {
  14309. builder.append(parts[i]);
  14310. }
  14311. return builder.getBlob(properties.type);
  14312. }
  14313. }
  14314. /* harmony default export */ const utils_createBlob = (createBlob);
  14315. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/promise.js
  14316. // This is CommonJS because lie is an external dependency, so Rollup
  14317. // can just ignore it.
  14318. if (typeof Promise === 'undefined') {
  14319. // In the "nopromises" build this will just throw if you don't have
  14320. // a global promise object, but it would throw anyway later.
  14321. __webpack_require__(9236);
  14322. }
  14323. /* harmony default export */ const utils_promise = (Promise);
  14324. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/executeCallback.js
  14325. function executeCallback(promise, callback) {
  14326. if (callback) {
  14327. promise.then(function (result) {
  14328. callback(null, result);
  14329. }, function (error) {
  14330. callback(error);
  14331. });
  14332. }
  14333. }
  14334. /* harmony default export */ const utils_executeCallback = (executeCallback);
  14335. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/executeTwoCallbacks.js
  14336. function executeTwoCallbacks(promise, callback, errorCallback) {
  14337. if (typeof callback === 'function') {
  14338. promise.then(callback);
  14339. }
  14340. if (typeof errorCallback === 'function') {
  14341. promise.catch(errorCallback);
  14342. }
  14343. }
  14344. /* harmony default export */ const utils_executeTwoCallbacks = (executeTwoCallbacks);
  14345. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/normalizeKey.js
  14346. function normalizeKey(key) {
  14347. // Cast the key to a string, as that's all we can set as a key.
  14348. if (typeof key !== 'string') {
  14349. console.warn(`${key} used as a key, but it is not a string.`);
  14350. key = String(key);
  14351. }
  14352. return key;
  14353. }
  14354. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/getCallback.js
  14355. function getCallback() {
  14356. if (arguments.length && typeof arguments[arguments.length - 1] === 'function') {
  14357. return arguments[arguments.length - 1];
  14358. }
  14359. }
  14360. ;// CONCATENATED MODULE: ./node_modules/localforage/src/drivers/indexeddb.js
  14361. // Some code originally from async_storage.js in
  14362. // [Gaia](https://github.com/mozilla-b2g/gaia).
  14363. const DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';
  14364. let supportsBlobs;
  14365. const dbContexts = {};
  14366. const indexeddb_toString = Object.prototype.toString; // Transaction Modes
  14367. const READ_ONLY = 'readonly';
  14368. const READ_WRITE = 'readwrite'; // Transform a binary string to an array buffer, because otherwise
  14369. // weird stuff happens when you try to work with the binary string directly.
  14370. // It is known.
  14371. // From http://stackoverflow.com/questions/14967647/ (continues on next line)
  14372. // encode-decode-image-with-base64-breaks-image (2013-04-21)
  14373. function _binStringToArrayBuffer(bin) {
  14374. var length = bin.length;
  14375. var buf = new ArrayBuffer(length);
  14376. var arr = new Uint8Array(buf);
  14377. for (var i = 0; i < length; i++) {
  14378. arr[i] = bin.charCodeAt(i);
  14379. }
  14380. return buf;
  14381. } //
  14382. // Blobs are not supported in all versions of IndexedDB, notably
  14383. // Chrome <37 and Android <5. In those versions, storing a blob will throw.
  14384. //
  14385. // Various other blob bugs exist in Chrome v37-42 (inclusive).
  14386. // Detecting them is expensive and confusing to users, and Chrome 37-42
  14387. // is at very low usage worldwide, so we do a hacky userAgent check instead.
  14388. //
  14389. // content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120
  14390. // 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916
  14391. // FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836
  14392. //
  14393. // Code borrowed from PouchDB. See:
  14394. // https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js
  14395. //
  14396. function _checkBlobSupportWithoutCaching(idb) {
  14397. return new utils_promise(function (resolve) {
  14398. var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
  14399. var blob = utils_createBlob(['']);
  14400. txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');
  14401. txn.onabort = function (e) {
  14402. // If the transaction aborts now its due to not being able to
  14403. // write to the database, likely due to the disk being full
  14404. e.preventDefault();
  14405. e.stopPropagation();
  14406. resolve(false);
  14407. };
  14408. txn.oncomplete = function () {
  14409. var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
  14410. var matchedEdge = navigator.userAgent.match(/Edge\//); // MS Edge pretends to be Chrome 42:
  14411. // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
  14412. resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
  14413. };
  14414. }).catch(function () {
  14415. return false; // error, so assume unsupported
  14416. });
  14417. }
  14418. function _checkBlobSupport(idb) {
  14419. if (typeof supportsBlobs === 'boolean') {
  14420. return utils_promise.resolve(supportsBlobs);
  14421. }
  14422. return _checkBlobSupportWithoutCaching(idb).then(function (value) {
  14423. supportsBlobs = value;
  14424. return supportsBlobs;
  14425. });
  14426. }
  14427. function _deferReadiness(dbInfo) {
  14428. var dbContext = dbContexts[dbInfo.name]; // Create a deferred object representing the current database operation.
  14429. var deferredOperation = {};
  14430. deferredOperation.promise = new utils_promise(function (resolve, reject) {
  14431. deferredOperation.resolve = resolve;
  14432. deferredOperation.reject = reject;
  14433. }); // Enqueue the deferred operation.
  14434. dbContext.deferredOperations.push(deferredOperation); // Chain its promise to the database readiness.
  14435. if (!dbContext.dbReady) {
  14436. dbContext.dbReady = deferredOperation.promise;
  14437. } else {
  14438. dbContext.dbReady = dbContext.dbReady.then(function () {
  14439. return deferredOperation.promise;
  14440. });
  14441. }
  14442. }
  14443. function _advanceReadiness(dbInfo) {
  14444. var dbContext = dbContexts[dbInfo.name]; // Dequeue a deferred operation.
  14445. var deferredOperation = dbContext.deferredOperations.pop(); // Resolve its promise (which is part of the database readiness
  14446. // chain of promises).
  14447. if (deferredOperation) {
  14448. deferredOperation.resolve();
  14449. return deferredOperation.promise;
  14450. }
  14451. }
  14452. function _rejectReadiness(dbInfo, err) {
  14453. var dbContext = dbContexts[dbInfo.name]; // Dequeue a deferred operation.
  14454. var deferredOperation = dbContext.deferredOperations.pop(); // Reject its promise (which is part of the database readiness
  14455. // chain of promises).
  14456. if (deferredOperation) {
  14457. deferredOperation.reject(err);
  14458. return deferredOperation.promise;
  14459. }
  14460. }
  14461. function _getConnection(dbInfo, upgradeNeeded) {
  14462. return new utils_promise(function (resolve, reject) {
  14463. dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
  14464. if (dbInfo.db) {
  14465. if (upgradeNeeded) {
  14466. _deferReadiness(dbInfo);
  14467. dbInfo.db.close();
  14468. } else {
  14469. return resolve(dbInfo.db);
  14470. }
  14471. }
  14472. var dbArgs = [dbInfo.name];
  14473. if (upgradeNeeded) {
  14474. dbArgs.push(dbInfo.version);
  14475. }
  14476. var openreq = utils_idb.open.apply(utils_idb, dbArgs);
  14477. if (upgradeNeeded) {
  14478. openreq.onupgradeneeded = function (e) {
  14479. var db = openreq.result;
  14480. try {
  14481. db.createObjectStore(dbInfo.storeName);
  14482. if (e.oldVersion <= 1) {
  14483. // Added when support for blob shims was added
  14484. db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);
  14485. }
  14486. } catch (ex) {
  14487. if (ex.name === 'ConstraintError') {
  14488. console.warn('The database "' + dbInfo.name + '"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage "' + dbInfo.storeName + '" already exists.');
  14489. } else {
  14490. throw ex;
  14491. }
  14492. }
  14493. };
  14494. }
  14495. openreq.onerror = function (e) {
  14496. e.preventDefault();
  14497. reject(openreq.error);
  14498. };
  14499. openreq.onsuccess = function () {
  14500. var db = openreq.result;
  14501. db.onversionchange = function (e) {
  14502. // Triggered when the database is modified (e.g. adding an objectStore) or
  14503. // deleted (even when initiated by other sessions in different tabs).
  14504. // Closing the connection here prevents those operations from being blocked.
  14505. // If the database is accessed again later by this instance, the connection
  14506. // will be reopened or the database recreated as needed.
  14507. e.target.close();
  14508. };
  14509. resolve(db);
  14510. _advanceReadiness(dbInfo);
  14511. };
  14512. });
  14513. }
  14514. function _getOriginalConnection(dbInfo) {
  14515. return _getConnection(dbInfo, false);
  14516. }
  14517. function _getUpgradedConnection(dbInfo) {
  14518. return _getConnection(dbInfo, true);
  14519. }
  14520. function _isUpgradeNeeded(dbInfo, defaultVersion) {
  14521. if (!dbInfo.db) {
  14522. return true;
  14523. }
  14524. var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);
  14525. var isDowngrade = dbInfo.version < dbInfo.db.version;
  14526. var isUpgrade = dbInfo.version > dbInfo.db.version;
  14527. if (isDowngrade) {
  14528. // If the version is not the default one
  14529. // then warn for impossible downgrade.
  14530. if (dbInfo.version !== defaultVersion) {
  14531. console.warn('The database "' + dbInfo.name + '"' + " can't be downgraded from version " + dbInfo.db.version + ' to version ' + dbInfo.version + '.');
  14532. } // Align the versions to prevent errors.
  14533. dbInfo.version = dbInfo.db.version;
  14534. }
  14535. if (isUpgrade || isNewStore) {
  14536. // If the store is new then increment the version (if needed).
  14537. // This will trigger an "upgradeneeded" event which is required
  14538. // for creating a store.
  14539. if (isNewStore) {
  14540. var incVersion = dbInfo.db.version + 1;
  14541. if (incVersion > dbInfo.version) {
  14542. dbInfo.version = incVersion;
  14543. }
  14544. }
  14545. return true;
  14546. }
  14547. return false;
  14548. } // encode a blob for indexeddb engines that don't support blobs
  14549. function _encodeBlob(blob) {
  14550. return new utils_promise(function (resolve, reject) {
  14551. var reader = new FileReader();
  14552. reader.onerror = reject;
  14553. reader.onloadend = function (e) {
  14554. var base64 = btoa(e.target.result || '');
  14555. resolve({
  14556. __local_forage_encoded_blob: true,
  14557. data: base64,
  14558. type: blob.type
  14559. });
  14560. };
  14561. reader.readAsBinaryString(blob);
  14562. });
  14563. } // decode an encoded blob
  14564. function _decodeBlob(encodedBlob) {
  14565. var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
  14566. return utils_createBlob([arrayBuff], {
  14567. type: encodedBlob.type
  14568. });
  14569. } // is this one of our fancy encoded blobs?
  14570. function _isEncodedBlob(value) {
  14571. return value && value.__local_forage_encoded_blob;
  14572. } // Specialize the default `ready()` function by making it dependent
  14573. // on the current database operations. Thus, the driver will be actually
  14574. // ready when it's been initialized (default) *and* there are no pending
  14575. // operations on the database (initiated by some other instances).
  14576. function _fullyReady(callback) {
  14577. var self = this;
  14578. var promise = self._initReady().then(function () {
  14579. var dbContext = dbContexts[self._dbInfo.name];
  14580. if (dbContext && dbContext.dbReady) {
  14581. return dbContext.dbReady;
  14582. }
  14583. });
  14584. utils_executeTwoCallbacks(promise, callback, callback);
  14585. return promise;
  14586. } // Try to establish a new db connection to replace the
  14587. // current one which is broken (i.e. experiencing
  14588. // InvalidStateError while creating a transaction).
  14589. function _tryReconnect(dbInfo) {
  14590. _deferReadiness(dbInfo);
  14591. var dbContext = dbContexts[dbInfo.name];
  14592. var forages = dbContext.forages;
  14593. for (var i = 0; i < forages.length; i++) {
  14594. const forage = forages[i];
  14595. if (forage._dbInfo.db) {
  14596. forage._dbInfo.db.close();
  14597. forage._dbInfo.db = null;
  14598. }
  14599. }
  14600. dbInfo.db = null;
  14601. return _getOriginalConnection(dbInfo).then(db => {
  14602. dbInfo.db = db;
  14603. if (_isUpgradeNeeded(dbInfo)) {
  14604. // Reopen the database for upgrading.
  14605. return _getUpgradedConnection(dbInfo);
  14606. }
  14607. return db;
  14608. }).then(db => {
  14609. // store the latest db reference
  14610. // in case the db was upgraded
  14611. dbInfo.db = dbContext.db = db;
  14612. for (var i = 0; i < forages.length; i++) {
  14613. forages[i]._dbInfo.db = db;
  14614. }
  14615. }).catch(err => {
  14616. _rejectReadiness(dbInfo, err);
  14617. throw err;
  14618. });
  14619. } // FF doesn't like Promises (micro-tasks) and IDDB store operations,
  14620. // so we have to do it with callbacks
  14621. function createTransaction(dbInfo, mode, callback, retries) {
  14622. if (retries === undefined) {
  14623. retries = 1;
  14624. }
  14625. try {
  14626. var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
  14627. callback(null, tx);
  14628. } catch (err) {
  14629. if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
  14630. return utils_promise.resolve().then(() => {
  14631. if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
  14632. // increase the db version, to create the new ObjectStore
  14633. if (dbInfo.db) {
  14634. dbInfo.version = dbInfo.db.version + 1;
  14635. } // Reopen the database for upgrading.
  14636. return _getUpgradedConnection(dbInfo);
  14637. }
  14638. }).then(() => {
  14639. return _tryReconnect(dbInfo).then(function () {
  14640. createTransaction(dbInfo, mode, callback, retries - 1);
  14641. });
  14642. }).catch(callback);
  14643. }
  14644. callback(err);
  14645. }
  14646. }
  14647. function createDbContext() {
  14648. return {
  14649. // Running localForages sharing a database.
  14650. forages: [],
  14651. // Shared database.
  14652. db: null,
  14653. // Database readiness (promise).
  14654. dbReady: null,
  14655. // Deferred operations on the database.
  14656. deferredOperations: []
  14657. };
  14658. } // Open the IndexedDB database (automatically creates one if one didn't
  14659. // previously exist), using any options set in the config.
  14660. function _initStorage(options) {
  14661. var self = this;
  14662. var dbInfo = {
  14663. db: null
  14664. };
  14665. if (options) {
  14666. for (var i in options) {
  14667. dbInfo[i] = options[i];
  14668. }
  14669. } // Get the current context of the database;
  14670. var dbContext = dbContexts[dbInfo.name]; // ...or create a new context.
  14671. if (!dbContext) {
  14672. dbContext = createDbContext(); // Register the new context in the global container.
  14673. dbContexts[dbInfo.name] = dbContext;
  14674. } // Register itself as a running localForage in the current context.
  14675. dbContext.forages.push(self); // Replace the default `ready()` function with the specialized one.
  14676. if (!self._initReady) {
  14677. self._initReady = self.ready;
  14678. self.ready = _fullyReady;
  14679. } // Create an array of initialization states of the related localForages.
  14680. var initPromises = [];
  14681. function ignoreErrors() {
  14682. // Don't handle errors here,
  14683. // just makes sure related localForages aren't pending.
  14684. return utils_promise.resolve();
  14685. }
  14686. for (var j = 0; j < dbContext.forages.length; j++) {
  14687. var forage = dbContext.forages[j];
  14688. if (forage !== self) {
  14689. // Don't wait for itself...
  14690. initPromises.push(forage._initReady().catch(ignoreErrors));
  14691. }
  14692. } // Take a snapshot of the related localForages.
  14693. var forages = dbContext.forages.slice(0); // Initialize the connection process only when
  14694. // all the related localForages aren't pending.
  14695. return utils_promise.all(initPromises).then(function () {
  14696. dbInfo.db = dbContext.db; // Get the connection or open a new one without upgrade.
  14697. return _getOriginalConnection(dbInfo);
  14698. }).then(function (db) {
  14699. dbInfo.db = db;
  14700. if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {
  14701. // Reopen the database for upgrading.
  14702. return _getUpgradedConnection(dbInfo);
  14703. }
  14704. return db;
  14705. }).then(function (db) {
  14706. dbInfo.db = dbContext.db = db;
  14707. self._dbInfo = dbInfo; // Share the final connection amongst related localForages.
  14708. for (var k = 0; k < forages.length; k++) {
  14709. var forage = forages[k];
  14710. if (forage !== self) {
  14711. // Self is already up-to-date.
  14712. forage._dbInfo.db = dbInfo.db;
  14713. forage._dbInfo.version = dbInfo.version;
  14714. }
  14715. }
  14716. });
  14717. }
  14718. function getItem(key, callback) {
  14719. var self = this;
  14720. key = normalizeKey(key);
  14721. var promise = new utils_promise(function (resolve, reject) {
  14722. self.ready().then(function () {
  14723. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  14724. if (err) {
  14725. return reject(err);
  14726. }
  14727. try {
  14728. var store = transaction.objectStore(self._dbInfo.storeName);
  14729. var req = store.get(key);
  14730. req.onsuccess = function () {
  14731. var value = req.result;
  14732. if (value === undefined) {
  14733. value = null;
  14734. }
  14735. if (_isEncodedBlob(value)) {
  14736. value = _decodeBlob(value);
  14737. }
  14738. resolve(value);
  14739. };
  14740. req.onerror = function () {
  14741. reject(req.error);
  14742. };
  14743. } catch (e) {
  14744. reject(e);
  14745. }
  14746. });
  14747. }).catch(reject);
  14748. });
  14749. utils_executeCallback(promise, callback);
  14750. return promise;
  14751. } // Iterate over all items stored in database.
  14752. function iterate(iterator, callback) {
  14753. var self = this;
  14754. var promise = new utils_promise(function (resolve, reject) {
  14755. self.ready().then(function () {
  14756. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  14757. if (err) {
  14758. return reject(err);
  14759. }
  14760. try {
  14761. var store = transaction.objectStore(self._dbInfo.storeName);
  14762. var req = store.openCursor();
  14763. var iterationNumber = 1;
  14764. req.onsuccess = function () {
  14765. var cursor = req.result;
  14766. if (cursor) {
  14767. var value = cursor.value;
  14768. if (_isEncodedBlob(value)) {
  14769. value = _decodeBlob(value);
  14770. }
  14771. var result = iterator(value, cursor.key, iterationNumber++); // when the iterator callback returns any
  14772. // (non-`undefined`) value, then we stop
  14773. // the iteration immediately
  14774. if (result !== void 0) {
  14775. resolve(result);
  14776. } else {
  14777. cursor.continue();
  14778. }
  14779. } else {
  14780. resolve();
  14781. }
  14782. };
  14783. req.onerror = function () {
  14784. reject(req.error);
  14785. };
  14786. } catch (e) {
  14787. reject(e);
  14788. }
  14789. });
  14790. }).catch(reject);
  14791. });
  14792. utils_executeCallback(promise, callback);
  14793. return promise;
  14794. }
  14795. function setItem(key, value, callback) {
  14796. var self = this;
  14797. key = normalizeKey(key);
  14798. var promise = new utils_promise(function (resolve, reject) {
  14799. var dbInfo;
  14800. self.ready().then(function () {
  14801. dbInfo = self._dbInfo;
  14802. if (indexeddb_toString.call(value) === '[object Blob]') {
  14803. return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {
  14804. if (blobSupport) {
  14805. return value;
  14806. }
  14807. return _encodeBlob(value);
  14808. });
  14809. }
  14810. return value;
  14811. }).then(function (value) {
  14812. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  14813. if (err) {
  14814. return reject(err);
  14815. }
  14816. try {
  14817. var store = transaction.objectStore(self._dbInfo.storeName); // The reason we don't _save_ null is because IE 10 does
  14818. // not support saving the `null` type in IndexedDB. How
  14819. // ironic, given the bug below!
  14820. // See: https://github.com/mozilla/localForage/issues/161
  14821. if (value === null) {
  14822. value = undefined;
  14823. }
  14824. var req = store.put(value, key);
  14825. transaction.oncomplete = function () {
  14826. // Cast to undefined so the value passed to
  14827. // callback/promise is the same as what one would get out
  14828. // of `getItem()` later. This leads to some weirdness
  14829. // (setItem('foo', undefined) will return `null`), but
  14830. // it's not my fault localStorage is our baseline and that
  14831. // it's weird.
  14832. if (value === undefined) {
  14833. value = null;
  14834. }
  14835. resolve(value);
  14836. };
  14837. transaction.onabort = transaction.onerror = function () {
  14838. var err = req.error ? req.error : req.transaction.error;
  14839. reject(err);
  14840. };
  14841. } catch (e) {
  14842. reject(e);
  14843. }
  14844. });
  14845. }).catch(reject);
  14846. });
  14847. utils_executeCallback(promise, callback);
  14848. return promise;
  14849. }
  14850. function removeItem(key, callback) {
  14851. var self = this;
  14852. key = normalizeKey(key);
  14853. var promise = new utils_promise(function (resolve, reject) {
  14854. self.ready().then(function () {
  14855. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  14856. if (err) {
  14857. return reject(err);
  14858. }
  14859. try {
  14860. var store = transaction.objectStore(self._dbInfo.storeName); // We use a Grunt task to make this safe for IE and some
  14861. // versions of Android (including those used by Cordova).
  14862. // Normally IE won't like `.delete()` and will insist on
  14863. // using `['delete']()`, but we have a build step that
  14864. // fixes this for us now.
  14865. var req = store.delete(key);
  14866. transaction.oncomplete = function () {
  14867. resolve();
  14868. };
  14869. transaction.onerror = function () {
  14870. reject(req.error);
  14871. }; // The request will be also be aborted if we've exceeded our storage
  14872. // space.
  14873. transaction.onabort = function () {
  14874. var err = req.error ? req.error : req.transaction.error;
  14875. reject(err);
  14876. };
  14877. } catch (e) {
  14878. reject(e);
  14879. }
  14880. });
  14881. }).catch(reject);
  14882. });
  14883. utils_executeCallback(promise, callback);
  14884. return promise;
  14885. }
  14886. function clear(callback) {
  14887. var self = this;
  14888. var promise = new utils_promise(function (resolve, reject) {
  14889. self.ready().then(function () {
  14890. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  14891. if (err) {
  14892. return reject(err);
  14893. }
  14894. try {
  14895. var store = transaction.objectStore(self._dbInfo.storeName);
  14896. var req = store.clear();
  14897. transaction.oncomplete = function () {
  14898. resolve();
  14899. };
  14900. transaction.onabort = transaction.onerror = function () {
  14901. var err = req.error ? req.error : req.transaction.error;
  14902. reject(err);
  14903. };
  14904. } catch (e) {
  14905. reject(e);
  14906. }
  14907. });
  14908. }).catch(reject);
  14909. });
  14910. utils_executeCallback(promise, callback);
  14911. return promise;
  14912. }
  14913. function indexeddb_length(callback) {
  14914. var self = this;
  14915. var promise = new utils_promise(function (resolve, reject) {
  14916. self.ready().then(function () {
  14917. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  14918. if (err) {
  14919. return reject(err);
  14920. }
  14921. try {
  14922. var store = transaction.objectStore(self._dbInfo.storeName);
  14923. var req = store.count();
  14924. req.onsuccess = function () {
  14925. resolve(req.result);
  14926. };
  14927. req.onerror = function () {
  14928. reject(req.error);
  14929. };
  14930. } catch (e) {
  14931. reject(e);
  14932. }
  14933. });
  14934. }).catch(reject);
  14935. });
  14936. utils_executeCallback(promise, callback);
  14937. return promise;
  14938. }
  14939. function key(n, callback) {
  14940. var self = this;
  14941. var promise = new utils_promise(function (resolve, reject) {
  14942. if (n < 0) {
  14943. resolve(null);
  14944. return;
  14945. }
  14946. self.ready().then(function () {
  14947. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  14948. if (err) {
  14949. return reject(err);
  14950. }
  14951. try {
  14952. var store = transaction.objectStore(self._dbInfo.storeName);
  14953. var advanced = false;
  14954. var req = store.openKeyCursor();
  14955. req.onsuccess = function () {
  14956. var cursor = req.result;
  14957. if (!cursor) {
  14958. // this means there weren't enough keys
  14959. resolve(null);
  14960. return;
  14961. }
  14962. if (n === 0) {
  14963. // We have the first key, return it if that's what they
  14964. // wanted.
  14965. resolve(cursor.key);
  14966. } else {
  14967. if (!advanced) {
  14968. // Otherwise, ask the cursor to skip ahead n
  14969. // records.
  14970. advanced = true;
  14971. cursor.advance(n);
  14972. } else {
  14973. // When we get here, we've got the nth key.
  14974. resolve(cursor.key);
  14975. }
  14976. }
  14977. };
  14978. req.onerror = function () {
  14979. reject(req.error);
  14980. };
  14981. } catch (e) {
  14982. reject(e);
  14983. }
  14984. });
  14985. }).catch(reject);
  14986. });
  14987. utils_executeCallback(promise, callback);
  14988. return promise;
  14989. }
  14990. function indexeddb_keys(callback) {
  14991. var self = this;
  14992. var promise = new utils_promise(function (resolve, reject) {
  14993. self.ready().then(function () {
  14994. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  14995. if (err) {
  14996. return reject(err);
  14997. }
  14998. try {
  14999. var store = transaction.objectStore(self._dbInfo.storeName);
  15000. var req = store.openKeyCursor();
  15001. var keys = [];
  15002. req.onsuccess = function () {
  15003. var cursor = req.result;
  15004. if (!cursor) {
  15005. resolve(keys);
  15006. return;
  15007. }
  15008. keys.push(cursor.key);
  15009. cursor.continue();
  15010. };
  15011. req.onerror = function () {
  15012. reject(req.error);
  15013. };
  15014. } catch (e) {
  15015. reject(e);
  15016. }
  15017. });
  15018. }).catch(reject);
  15019. });
  15020. utils_executeCallback(promise, callback);
  15021. return promise;
  15022. }
  15023. function dropInstance(options, callback) {
  15024. callback = getCallback.apply(this, arguments);
  15025. var currentConfig = this.config();
  15026. options = typeof options !== 'function' && options || {};
  15027. if (!options.name) {
  15028. options.name = options.name || currentConfig.name;
  15029. options.storeName = options.storeName || currentConfig.storeName;
  15030. }
  15031. var self = this;
  15032. var promise;
  15033. if (!options.name) {
  15034. promise = utils_promise.reject('Invalid arguments');
  15035. } else {
  15036. const isCurrentDb = options.name === currentConfig.name && self._dbInfo.db;
  15037. const dbPromise = isCurrentDb ? utils_promise.resolve(self._dbInfo.db) : _getOriginalConnection(options).then(db => {
  15038. const dbContext = dbContexts[options.name];
  15039. const forages = dbContext.forages;
  15040. dbContext.db = db;
  15041. for (var i = 0; i < forages.length; i++) {
  15042. forages[i]._dbInfo.db = db;
  15043. }
  15044. return db;
  15045. });
  15046. if (!options.storeName) {
  15047. promise = dbPromise.then(db => {
  15048. _deferReadiness(options);
  15049. const dbContext = dbContexts[options.name];
  15050. const forages = dbContext.forages;
  15051. db.close();
  15052. for (var i = 0; i < forages.length; i++) {
  15053. const forage = forages[i];
  15054. forage._dbInfo.db = null;
  15055. }
  15056. const dropDBPromise = new utils_promise((resolve, reject) => {
  15057. var req = utils_idb.deleteDatabase(options.name);
  15058. req.onerror = () => {
  15059. const db = req.result;
  15060. if (db) {
  15061. db.close();
  15062. }
  15063. reject(req.error);
  15064. };
  15065. req.onblocked = () => {
  15066. // Closing all open connections in onversionchange handler should prevent this situation, but if
  15067. // we do get here, it just means the request remains pending - eventually it will succeed or error
  15068. console.warn('dropInstance blocked for database "' + options.name + '" until all open connections are closed');
  15069. };
  15070. req.onsuccess = () => {
  15071. const db = req.result;
  15072. if (db) {
  15073. db.close();
  15074. }
  15075. resolve(db);
  15076. };
  15077. });
  15078. return dropDBPromise.then(db => {
  15079. dbContext.db = db;
  15080. for (var i = 0; i < forages.length; i++) {
  15081. const forage = forages[i];
  15082. _advanceReadiness(forage._dbInfo);
  15083. }
  15084. }).catch(err => {
  15085. (_rejectReadiness(options, err) || utils_promise.resolve()).catch(() => {});
  15086. throw err;
  15087. });
  15088. });
  15089. } else {
  15090. promise = dbPromise.then(db => {
  15091. if (!db.objectStoreNames.contains(options.storeName)) {
  15092. return;
  15093. }
  15094. const newVersion = db.version + 1;
  15095. _deferReadiness(options);
  15096. const dbContext = dbContexts[options.name];
  15097. const forages = dbContext.forages;
  15098. db.close();
  15099. for (let i = 0; i < forages.length; i++) {
  15100. const forage = forages[i];
  15101. forage._dbInfo.db = null;
  15102. forage._dbInfo.version = newVersion;
  15103. }
  15104. const dropObjectPromise = new utils_promise((resolve, reject) => {
  15105. const req = utils_idb.open(options.name, newVersion);
  15106. req.onerror = err => {
  15107. const db = req.result;
  15108. db.close();
  15109. reject(err);
  15110. };
  15111. req.onupgradeneeded = () => {
  15112. var db = req.result;
  15113. db.deleteObjectStore(options.storeName);
  15114. };
  15115. req.onsuccess = () => {
  15116. const db = req.result;
  15117. db.close();
  15118. resolve(db);
  15119. };
  15120. });
  15121. return dropObjectPromise.then(db => {
  15122. dbContext.db = db;
  15123. for (let j = 0; j < forages.length; j++) {
  15124. const forage = forages[j];
  15125. forage._dbInfo.db = db;
  15126. _advanceReadiness(forage._dbInfo);
  15127. }
  15128. }).catch(err => {
  15129. (_rejectReadiness(options, err) || utils_promise.resolve()).catch(() => {});
  15130. throw err;
  15131. });
  15132. });
  15133. }
  15134. }
  15135. utils_executeCallback(promise, callback);
  15136. return promise;
  15137. }
  15138. var asyncStorage = {
  15139. _driver: 'asyncStorage',
  15140. _initStorage: _initStorage,
  15141. _support: utils_isIndexedDBValid(),
  15142. iterate: iterate,
  15143. getItem: getItem,
  15144. setItem: setItem,
  15145. removeItem: removeItem,
  15146. clear: clear,
  15147. length: indexeddb_length,
  15148. key: key,
  15149. keys: indexeddb_keys,
  15150. dropInstance: dropInstance
  15151. };
  15152. /* harmony default export */ const indexeddb = (asyncStorage);
  15153. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/isWebSQLValid.js
  15154. function isWebSQLValid() {
  15155. return typeof openDatabase === 'function';
  15156. }
  15157. /* harmony default export */ const utils_isWebSQLValid = (isWebSQLValid);
  15158. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/serializer.js
  15159. /* eslint-disable no-bitwise */
  15160. // Sadly, the best way to save binary data in WebSQL/localStorage is serializing
  15161. // it to Base64, so this is how we store it to prevent very strange errors with less
  15162. // verbose ways of binary <-> string data storage.
  15163. var BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  15164. var BLOB_TYPE_PREFIX = '~~local_forage_type~';
  15165. var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
  15166. var SERIALIZED_MARKER = '__lfsc__:';
  15167. var SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length; // OMG the serializations!
  15168. var TYPE_ARRAYBUFFER = 'arbf';
  15169. var TYPE_BLOB = 'blob';
  15170. var TYPE_INT8ARRAY = 'si08';
  15171. var TYPE_UINT8ARRAY = 'ui08';
  15172. var TYPE_UINT8CLAMPEDARRAY = 'uic8';
  15173. var TYPE_INT16ARRAY = 'si16';
  15174. var TYPE_INT32ARRAY = 'si32';
  15175. var TYPE_UINT16ARRAY = 'ur16';
  15176. var TYPE_UINT32ARRAY = 'ui32';
  15177. var TYPE_FLOAT32ARRAY = 'fl32';
  15178. var TYPE_FLOAT64ARRAY = 'fl64';
  15179. var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;
  15180. var serializer_toString = Object.prototype.toString;
  15181. function stringToBuffer(serializedString) {
  15182. // Fill the string into a ArrayBuffer.
  15183. var bufferLength = serializedString.length * 0.75;
  15184. var len = serializedString.length;
  15185. var i;
  15186. var p = 0;
  15187. var encoded1, encoded2, encoded3, encoded4;
  15188. if (serializedString[serializedString.length - 1] === '=') {
  15189. bufferLength--;
  15190. if (serializedString[serializedString.length - 2] === '=') {
  15191. bufferLength--;
  15192. }
  15193. }
  15194. var buffer = new ArrayBuffer(bufferLength);
  15195. var bytes = new Uint8Array(buffer);
  15196. for (i = 0; i < len; i += 4) {
  15197. encoded1 = BASE_CHARS.indexOf(serializedString[i]);
  15198. encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);
  15199. encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);
  15200. encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);
  15201. /*jslint bitwise: true */
  15202. bytes[p++] = encoded1 << 2 | encoded2 >> 4;
  15203. bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  15204. bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
  15205. }
  15206. return buffer;
  15207. } // Converts a buffer to a string to store, serialized, in the backend
  15208. // storage library.
  15209. function bufferToString(buffer) {
  15210. // base64-arraybuffer
  15211. var bytes = new Uint8Array(buffer);
  15212. var base64String = '';
  15213. var i;
  15214. for (i = 0; i < bytes.length; i += 3) {
  15215. /*jslint bitwise: true */
  15216. base64String += BASE_CHARS[bytes[i] >> 2];
  15217. base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
  15218. base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
  15219. base64String += BASE_CHARS[bytes[i + 2] & 63];
  15220. }
  15221. if (bytes.length % 3 === 2) {
  15222. base64String = base64String.substring(0, base64String.length - 1) + '=';
  15223. } else if (bytes.length % 3 === 1) {
  15224. base64String = base64String.substring(0, base64String.length - 2) + '==';
  15225. }
  15226. return base64String;
  15227. } // Serialize a value, afterwards executing a callback (which usually
  15228. // instructs the `setItem()` callback/promise to be executed). This is how
  15229. // we store binary data with localStorage.
  15230. function serialize(value, callback) {
  15231. var valueType = '';
  15232. if (value) {
  15233. valueType = serializer_toString.call(value);
  15234. } // Cannot use `value instanceof ArrayBuffer` or such here, as these
  15235. // checks fail when running the tests using casper.js...
  15236. //
  15237. // TODO: See why those tests fail and use a better solution.
  15238. if (value && (valueType === '[object ArrayBuffer]' || value.buffer && serializer_toString.call(value.buffer) === '[object ArrayBuffer]')) {
  15239. // Convert binary arrays to a string and prefix the string with
  15240. // a special marker.
  15241. var buffer;
  15242. var marker = SERIALIZED_MARKER;
  15243. if (value instanceof ArrayBuffer) {
  15244. buffer = value;
  15245. marker += TYPE_ARRAYBUFFER;
  15246. } else {
  15247. buffer = value.buffer;
  15248. if (valueType === '[object Int8Array]') {
  15249. marker += TYPE_INT8ARRAY;
  15250. } else if (valueType === '[object Uint8Array]') {
  15251. marker += TYPE_UINT8ARRAY;
  15252. } else if (valueType === '[object Uint8ClampedArray]') {
  15253. marker += TYPE_UINT8CLAMPEDARRAY;
  15254. } else if (valueType === '[object Int16Array]') {
  15255. marker += TYPE_INT16ARRAY;
  15256. } else if (valueType === '[object Uint16Array]') {
  15257. marker += TYPE_UINT16ARRAY;
  15258. } else if (valueType === '[object Int32Array]') {
  15259. marker += TYPE_INT32ARRAY;
  15260. } else if (valueType === '[object Uint32Array]') {
  15261. marker += TYPE_UINT32ARRAY;
  15262. } else if (valueType === '[object Float32Array]') {
  15263. marker += TYPE_FLOAT32ARRAY;
  15264. } else if (valueType === '[object Float64Array]') {
  15265. marker += TYPE_FLOAT64ARRAY;
  15266. } else {
  15267. callback(new Error('Failed to get type for BinaryArray'));
  15268. }
  15269. }
  15270. callback(marker + bufferToString(buffer));
  15271. } else if (valueType === '[object Blob]') {
  15272. // Conver the blob to a binaryArray and then to a string.
  15273. var fileReader = new FileReader();
  15274. fileReader.onload = function () {
  15275. // Backwards-compatible prefix for the blob type.
  15276. var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);
  15277. callback(SERIALIZED_MARKER + TYPE_BLOB + str);
  15278. };
  15279. fileReader.readAsArrayBuffer(value);
  15280. } else {
  15281. try {
  15282. callback(JSON.stringify(value));
  15283. } catch (e) {
  15284. console.error("Couldn't convert value into a JSON string: ", value);
  15285. callback(null, e);
  15286. }
  15287. }
  15288. } // Deserialize data we've inserted into a value column/field. We place
  15289. // special markers into our strings to mark them as encoded; this isn't
  15290. // as nice as a meta field, but it's the only sane thing we can do whilst
  15291. // keeping localStorage support intact.
  15292. //
  15293. // Oftentimes this will just deserialize JSON content, but if we have a
  15294. // special marker (SERIALIZED_MARKER, defined above), we will extract
  15295. // some kind of arraybuffer/binary data/typed array out of the string.
  15296. function deserialize(value) {
  15297. // If we haven't marked this string as being specially serialized (i.e.
  15298. // something other than serialized JSON), we can just return it and be
  15299. // done with it.
  15300. if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {
  15301. return JSON.parse(value);
  15302. } // The following code deals with deserializing some kind of Blob or
  15303. // TypedArray. First we separate out the type of data we're dealing
  15304. // with from the data itself.
  15305. var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
  15306. var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
  15307. var blobType; // Backwards-compatible blob type serialization strategy.
  15308. // DBs created with older versions of localForage will simply not have the blob type.
  15309. if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
  15310. var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
  15311. blobType = matcher[1];
  15312. serializedString = serializedString.substring(matcher[0].length);
  15313. }
  15314. var buffer = stringToBuffer(serializedString); // Return the right type based on the code/type set during
  15315. // serialization.
  15316. switch (type) {
  15317. case TYPE_ARRAYBUFFER:
  15318. return buffer;
  15319. case TYPE_BLOB:
  15320. return utils_createBlob([buffer], {
  15321. type: blobType
  15322. });
  15323. case TYPE_INT8ARRAY:
  15324. return new Int8Array(buffer);
  15325. case TYPE_UINT8ARRAY:
  15326. return new Uint8Array(buffer);
  15327. case TYPE_UINT8CLAMPEDARRAY:
  15328. return new Uint8ClampedArray(buffer);
  15329. case TYPE_INT16ARRAY:
  15330. return new Int16Array(buffer);
  15331. case TYPE_UINT16ARRAY:
  15332. return new Uint16Array(buffer);
  15333. case TYPE_INT32ARRAY:
  15334. return new Int32Array(buffer);
  15335. case TYPE_UINT32ARRAY:
  15336. return new Uint32Array(buffer);
  15337. case TYPE_FLOAT32ARRAY:
  15338. return new Float32Array(buffer);
  15339. case TYPE_FLOAT64ARRAY:
  15340. return new Float64Array(buffer);
  15341. default:
  15342. throw new Error('Unkown type: ' + type);
  15343. }
  15344. }
  15345. var localforageSerializer = {
  15346. serialize: serialize,
  15347. deserialize: deserialize,
  15348. stringToBuffer: stringToBuffer,
  15349. bufferToString: bufferToString
  15350. };
  15351. /* harmony default export */ const serializer = (localforageSerializer);
  15352. ;// CONCATENATED MODULE: ./node_modules/localforage/src/drivers/websql.js
  15353. /*
  15354. * Includes code from:
  15355. *
  15356. * base64-arraybuffer
  15357. * https://github.com/niklasvh/base64-arraybuffer
  15358. *
  15359. * Copyright (c) 2012 Niklas von Hertzen
  15360. * Licensed under the MIT license.
  15361. */
  15362. function createDbTable(t, dbInfo, callback, errorCallback) {
  15363. t.executeSql(`CREATE TABLE IF NOT EXISTS ${dbInfo.storeName} ` + '(id INTEGER PRIMARY KEY, key unique, value)', [], callback, errorCallback);
  15364. } // Open the WebSQL database (automatically creates one if one didn't
  15365. // previously exist), using any options set in the config.
  15366. function websql_initStorage(options) {
  15367. var self = this;
  15368. var dbInfo = {
  15369. db: null
  15370. };
  15371. if (options) {
  15372. for (var i in options) {
  15373. dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];
  15374. }
  15375. }
  15376. var dbInfoPromise = new utils_promise(function (resolve, reject) {
  15377. // Open the database; the openDatabase API will automatically
  15378. // create it for us if it doesn't exist.
  15379. try {
  15380. dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
  15381. } catch (e) {
  15382. return reject(e);
  15383. } // Create our key/value table if it doesn't exist.
  15384. dbInfo.db.transaction(function (t) {
  15385. createDbTable(t, dbInfo, function () {
  15386. self._dbInfo = dbInfo;
  15387. resolve();
  15388. }, function (t, error) {
  15389. reject(error);
  15390. });
  15391. }, reject);
  15392. });
  15393. dbInfo.serializer = serializer;
  15394. return dbInfoPromise;
  15395. }
  15396. function tryExecuteSql(t, dbInfo, sqlStatement, args, callback, errorCallback) {
  15397. t.executeSql(sqlStatement, args, callback, function (t, error) {
  15398. if (error.code === error.SYNTAX_ERR) {
  15399. t.executeSql('SELECT name FROM sqlite_master ' + "WHERE type='table' AND name = ?", [dbInfo.storeName], function (t, results) {
  15400. if (!results.rows.length) {
  15401. // if the table is missing (was deleted)
  15402. // re-create it table and retry
  15403. createDbTable(t, dbInfo, function () {
  15404. t.executeSql(sqlStatement, args, callback, errorCallback);
  15405. }, errorCallback);
  15406. } else {
  15407. errorCallback(t, error);
  15408. }
  15409. }, errorCallback);
  15410. } else {
  15411. errorCallback(t, error);
  15412. }
  15413. }, errorCallback);
  15414. }
  15415. function websql_getItem(key, callback) {
  15416. var self = this;
  15417. key = normalizeKey(key);
  15418. var promise = new utils_promise(function (resolve, reject) {
  15419. self.ready().then(function () {
  15420. var dbInfo = self._dbInfo;
  15421. dbInfo.db.transaction(function (t) {
  15422. tryExecuteSql(t, dbInfo, `SELECT * FROM ${dbInfo.storeName} WHERE key = ? LIMIT 1`, [key], function (t, results) {
  15423. var result = results.rows.length ? results.rows.item(0).value : null; // Check to see if this is serialized content we need to
  15424. // unpack.
  15425. if (result) {
  15426. result = dbInfo.serializer.deserialize(result);
  15427. }
  15428. resolve(result);
  15429. }, function (t, error) {
  15430. reject(error);
  15431. });
  15432. });
  15433. }).catch(reject);
  15434. });
  15435. utils_executeCallback(promise, callback);
  15436. return promise;
  15437. }
  15438. function websql_iterate(iterator, callback) {
  15439. var self = this;
  15440. var promise = new utils_promise(function (resolve, reject) {
  15441. self.ready().then(function () {
  15442. var dbInfo = self._dbInfo;
  15443. dbInfo.db.transaction(function (t) {
  15444. tryExecuteSql(t, dbInfo, `SELECT * FROM ${dbInfo.storeName}`, [], function (t, results) {
  15445. var rows = results.rows;
  15446. var length = rows.length;
  15447. for (var i = 0; i < length; i++) {
  15448. var item = rows.item(i);
  15449. var result = item.value; // Check to see if this is serialized content
  15450. // we need to unpack.
  15451. if (result) {
  15452. result = dbInfo.serializer.deserialize(result);
  15453. }
  15454. result = iterator(result, item.key, i + 1); // void(0) prevents problems with redefinition
  15455. // of `undefined`.
  15456. if (result !== void 0) {
  15457. resolve(result);
  15458. return;
  15459. }
  15460. }
  15461. resolve();
  15462. }, function (t, error) {
  15463. reject(error);
  15464. });
  15465. });
  15466. }).catch(reject);
  15467. });
  15468. utils_executeCallback(promise, callback);
  15469. return promise;
  15470. }
  15471. function _setItem(key, value, callback, retriesLeft) {
  15472. var self = this;
  15473. key = normalizeKey(key);
  15474. var promise = new utils_promise(function (resolve, reject) {
  15475. self.ready().then(function () {
  15476. // The localStorage API doesn't return undefined values in an
  15477. // "expected" way, so undefined is always cast to null in all
  15478. // drivers. See: https://github.com/mozilla/localForage/pull/42
  15479. if (value === undefined) {
  15480. value = null;
  15481. } // Save the original value to pass to the callback.
  15482. var originalValue = value;
  15483. var dbInfo = self._dbInfo;
  15484. dbInfo.serializer.serialize(value, function (value, error) {
  15485. if (error) {
  15486. reject(error);
  15487. } else {
  15488. dbInfo.db.transaction(function (t) {
  15489. tryExecuteSql(t, dbInfo, `INSERT OR REPLACE INTO ${dbInfo.storeName} ` + '(key, value) VALUES (?, ?)', [key, value], function () {
  15490. resolve(originalValue);
  15491. }, function (t, error) {
  15492. reject(error);
  15493. });
  15494. }, function (sqlError) {
  15495. // The transaction failed; check
  15496. // to see if it's a quota error.
  15497. if (sqlError.code === sqlError.QUOTA_ERR) {
  15498. // We reject the callback outright for now, but
  15499. // it's worth trying to re-run the transaction.
  15500. // Even if the user accepts the prompt to use
  15501. // more storage on Safari, this error will
  15502. // be called.
  15503. //
  15504. // Try to re-run the transaction.
  15505. if (retriesLeft > 0) {
  15506. resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));
  15507. return;
  15508. }
  15509. reject(sqlError);
  15510. }
  15511. });
  15512. }
  15513. });
  15514. }).catch(reject);
  15515. });
  15516. utils_executeCallback(promise, callback);
  15517. return promise;
  15518. }
  15519. function websql_setItem(key, value, callback) {
  15520. return _setItem.apply(this, [key, value, callback, 1]);
  15521. }
  15522. function websql_removeItem(key, callback) {
  15523. var self = this;
  15524. key = normalizeKey(key);
  15525. var promise = new utils_promise(function (resolve, reject) {
  15526. self.ready().then(function () {
  15527. var dbInfo = self._dbInfo;
  15528. dbInfo.db.transaction(function (t) {
  15529. tryExecuteSql(t, dbInfo, `DELETE FROM ${dbInfo.storeName} WHERE key = ?`, [key], function () {
  15530. resolve();
  15531. }, function (t, error) {
  15532. reject(error);
  15533. });
  15534. });
  15535. }).catch(reject);
  15536. });
  15537. utils_executeCallback(promise, callback);
  15538. return promise;
  15539. } // Deletes every item in the table.
  15540. // TODO: Find out if this resets the AUTO_INCREMENT number.
  15541. function websql_clear(callback) {
  15542. var self = this;
  15543. var promise = new utils_promise(function (resolve, reject) {
  15544. self.ready().then(function () {
  15545. var dbInfo = self._dbInfo;
  15546. dbInfo.db.transaction(function (t) {
  15547. tryExecuteSql(t, dbInfo, `DELETE FROM ${dbInfo.storeName}`, [], function () {
  15548. resolve();
  15549. }, function (t, error) {
  15550. reject(error);
  15551. });
  15552. });
  15553. }).catch(reject);
  15554. });
  15555. utils_executeCallback(promise, callback);
  15556. return promise;
  15557. } // Does a simple `COUNT(key)` to get the number of items stored in
  15558. // localForage.
  15559. function websql_length(callback) {
  15560. var self = this;
  15561. var promise = new utils_promise(function (resolve, reject) {
  15562. self.ready().then(function () {
  15563. var dbInfo = self._dbInfo;
  15564. dbInfo.db.transaction(function (t) {
  15565. // Ahhh, SQL makes this one soooooo easy.
  15566. tryExecuteSql(t, dbInfo, `SELECT COUNT(key) as c FROM ${dbInfo.storeName}`, [], function (t, results) {
  15567. var result = results.rows.item(0).c;
  15568. resolve(result);
  15569. }, function (t, error) {
  15570. reject(error);
  15571. });
  15572. });
  15573. }).catch(reject);
  15574. });
  15575. utils_executeCallback(promise, callback);
  15576. return promise;
  15577. } // Return the key located at key index X; essentially gets the key from a
  15578. // `WHERE id = ?`. This is the most efficient way I can think to implement
  15579. // this rarely-used (in my experience) part of the API, but it can seem
  15580. // inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so
  15581. // the ID of each key will change every time it's updated. Perhaps a stored
  15582. // procedure for the `setItem()` SQL would solve this problem?
  15583. // TODO: Don't change ID on `setItem()`.
  15584. function websql_key(n, callback) {
  15585. var self = this;
  15586. var promise = new utils_promise(function (resolve, reject) {
  15587. self.ready().then(function () {
  15588. var dbInfo = self._dbInfo;
  15589. dbInfo.db.transaction(function (t) {
  15590. tryExecuteSql(t, dbInfo, `SELECT key FROM ${dbInfo.storeName} WHERE id = ? LIMIT 1`, [n + 1], function (t, results) {
  15591. var result = results.rows.length ? results.rows.item(0).key : null;
  15592. resolve(result);
  15593. }, function (t, error) {
  15594. reject(error);
  15595. });
  15596. });
  15597. }).catch(reject);
  15598. });
  15599. utils_executeCallback(promise, callback);
  15600. return promise;
  15601. }
  15602. function websql_keys(callback) {
  15603. var self = this;
  15604. var promise = new utils_promise(function (resolve, reject) {
  15605. self.ready().then(function () {
  15606. var dbInfo = self._dbInfo;
  15607. dbInfo.db.transaction(function (t) {
  15608. tryExecuteSql(t, dbInfo, `SELECT key FROM ${dbInfo.storeName}`, [], function (t, results) {
  15609. var keys = [];
  15610. for (var i = 0; i < results.rows.length; i++) {
  15611. keys.push(results.rows.item(i).key);
  15612. }
  15613. resolve(keys);
  15614. }, function (t, error) {
  15615. reject(error);
  15616. });
  15617. });
  15618. }).catch(reject);
  15619. });
  15620. utils_executeCallback(promise, callback);
  15621. return promise;
  15622. } // https://www.w3.org/TR/webdatabase/#databases
  15623. // > There is no way to enumerate or delete the databases available for an origin from this API.
  15624. function getAllStoreNames(db) {
  15625. return new utils_promise(function (resolve, reject) {
  15626. db.transaction(function (t) {
  15627. t.executeSql('SELECT name FROM sqlite_master ' + "WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function (t, results) {
  15628. var storeNames = [];
  15629. for (var i = 0; i < results.rows.length; i++) {
  15630. storeNames.push(results.rows.item(i).name);
  15631. }
  15632. resolve({
  15633. db,
  15634. storeNames
  15635. });
  15636. }, function (t, error) {
  15637. reject(error);
  15638. });
  15639. }, function (sqlError) {
  15640. reject(sqlError);
  15641. });
  15642. });
  15643. }
  15644. function websql_dropInstance(options, callback) {
  15645. callback = getCallback.apply(this, arguments);
  15646. var currentConfig = this.config();
  15647. options = typeof options !== 'function' && options || {};
  15648. if (!options.name) {
  15649. options.name = options.name || currentConfig.name;
  15650. options.storeName = options.storeName || currentConfig.storeName;
  15651. }
  15652. var self = this;
  15653. var promise;
  15654. if (!options.name) {
  15655. promise = utils_promise.reject('Invalid arguments');
  15656. } else {
  15657. promise = new utils_promise(function (resolve) {
  15658. var db;
  15659. if (options.name === currentConfig.name) {
  15660. // use the db reference of the current instance
  15661. db = self._dbInfo.db;
  15662. } else {
  15663. db = openDatabase(options.name, '', '', 0);
  15664. }
  15665. if (!options.storeName) {
  15666. // drop all database tables
  15667. resolve(getAllStoreNames(db));
  15668. } else {
  15669. resolve({
  15670. db,
  15671. storeNames: [options.storeName]
  15672. });
  15673. }
  15674. }).then(function (operationInfo) {
  15675. return new utils_promise(function (resolve, reject) {
  15676. operationInfo.db.transaction(function (t) {
  15677. function dropTable(storeName) {
  15678. return new utils_promise(function (resolve, reject) {
  15679. t.executeSql(`DROP TABLE IF EXISTS ${storeName}`, [], function () {
  15680. resolve();
  15681. }, function (t, error) {
  15682. reject(error);
  15683. });
  15684. });
  15685. }
  15686. var operations = [];
  15687. for (var i = 0, len = operationInfo.storeNames.length; i < len; i++) {
  15688. operations.push(dropTable(operationInfo.storeNames[i]));
  15689. }
  15690. utils_promise.all(operations).then(function () {
  15691. resolve();
  15692. }).catch(function (e) {
  15693. reject(e);
  15694. });
  15695. }, function (sqlError) {
  15696. reject(sqlError);
  15697. });
  15698. });
  15699. });
  15700. }
  15701. utils_executeCallback(promise, callback);
  15702. return promise;
  15703. }
  15704. var webSQLStorage = {
  15705. _driver: 'webSQLStorage',
  15706. _initStorage: websql_initStorage,
  15707. _support: utils_isWebSQLValid(),
  15708. iterate: websql_iterate,
  15709. getItem: websql_getItem,
  15710. setItem: websql_setItem,
  15711. removeItem: websql_removeItem,
  15712. clear: websql_clear,
  15713. length: websql_length,
  15714. key: websql_key,
  15715. keys: websql_keys,
  15716. dropInstance: websql_dropInstance
  15717. };
  15718. /* harmony default export */ const websql = (webSQLStorage);
  15719. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/isLocalStorageValid.js
  15720. function isLocalStorageValid() {
  15721. try {
  15722. return typeof localStorage !== 'undefined' && 'setItem' in localStorage && // in IE8 typeof localStorage.setItem === 'object'
  15723. !!localStorage.setItem;
  15724. } catch (e) {
  15725. return false;
  15726. }
  15727. }
  15728. /* harmony default export */ const utils_isLocalStorageValid = (isLocalStorageValid);
  15729. ;// CONCATENATED MODULE: ./node_modules/localforage/src/drivers/localstorage.js
  15730. // If IndexedDB isn't available, we'll fall back to localStorage.
  15731. // Note that this will have considerable performance and storage
  15732. // side-effects (all data will be serialized on save and only data that
  15733. // can be converted to a string via `JSON.stringify()` will be saved).
  15734. function _getKeyPrefix(options, defaultConfig) {
  15735. var keyPrefix = options.name + '/';
  15736. if (options.storeName !== defaultConfig.storeName) {
  15737. keyPrefix += options.storeName + '/';
  15738. }
  15739. return keyPrefix;
  15740. } // Check if localStorage throws when saving an item
  15741. function checkIfLocalStorageThrows() {
  15742. var localStorageTestKey = '_localforage_support_test';
  15743. try {
  15744. localStorage.setItem(localStorageTestKey, true);
  15745. localStorage.removeItem(localStorageTestKey);
  15746. return false;
  15747. } catch (e) {
  15748. return true;
  15749. }
  15750. } // Check if localStorage is usable and allows to save an item
  15751. // This method checks if localStorage is usable in Safari Private Browsing
  15752. // mode, or in any other case where the available quota for localStorage
  15753. // is 0 and there wasn't any saved items yet.
  15754. function _isLocalStorageUsable() {
  15755. return !checkIfLocalStorageThrows() || localStorage.length > 0;
  15756. } // Config the localStorage backend, using options set in the config.
  15757. function localstorage_initStorage(options) {
  15758. var self = this;
  15759. var dbInfo = {};
  15760. if (options) {
  15761. for (var i in options) {
  15762. dbInfo[i] = options[i];
  15763. }
  15764. }
  15765. dbInfo.keyPrefix = _getKeyPrefix(options, self._defaultConfig);
  15766. if (!_isLocalStorageUsable()) {
  15767. return utils_promise.reject();
  15768. }
  15769. self._dbInfo = dbInfo;
  15770. dbInfo.serializer = serializer;
  15771. return utils_promise.resolve();
  15772. } // Remove all keys from the datastore, effectively destroying all data in
  15773. // the app's key/value store!
  15774. function localstorage_clear(callback) {
  15775. var self = this;
  15776. var promise = self.ready().then(function () {
  15777. var keyPrefix = self._dbInfo.keyPrefix;
  15778. for (var i = localStorage.length - 1; i >= 0; i--) {
  15779. var key = localStorage.key(i);
  15780. if (key.indexOf(keyPrefix) === 0) {
  15781. localStorage.removeItem(key);
  15782. }
  15783. }
  15784. });
  15785. utils_executeCallback(promise, callback);
  15786. return promise;
  15787. } // Retrieve an item from the store. Unlike the original async_storage
  15788. // library in Gaia, we don't modify return values at all. If a key's value
  15789. // is `undefined`, we pass that value to the callback function.
  15790. function localstorage_getItem(key, callback) {
  15791. var self = this;
  15792. key = normalizeKey(key);
  15793. var promise = self.ready().then(function () {
  15794. var dbInfo = self._dbInfo;
  15795. var result = localStorage.getItem(dbInfo.keyPrefix + key); // If a result was found, parse it from the serialized
  15796. // string into a JS object. If result isn't truthy, the key
  15797. // is likely undefined and we'll pass it straight to the
  15798. // callback.
  15799. if (result) {
  15800. result = dbInfo.serializer.deserialize(result);
  15801. }
  15802. return result;
  15803. });
  15804. utils_executeCallback(promise, callback);
  15805. return promise;
  15806. } // Iterate over all items in the store.
  15807. function localstorage_iterate(iterator, callback) {
  15808. var self = this;
  15809. var promise = self.ready().then(function () {
  15810. var dbInfo = self._dbInfo;
  15811. var keyPrefix = dbInfo.keyPrefix;
  15812. var keyPrefixLength = keyPrefix.length;
  15813. var length = localStorage.length; // We use a dedicated iterator instead of the `i` variable below
  15814. // so other keys we fetch in localStorage aren't counted in
  15815. // the `iterationNumber` argument passed to the `iterate()`
  15816. // callback.
  15817. //
  15818. // See: github.com/mozilla/localForage/pull/435#discussion_r38061530
  15819. var iterationNumber = 1;
  15820. for (var i = 0; i < length; i++) {
  15821. var key = localStorage.key(i);
  15822. if (key.indexOf(keyPrefix) !== 0) {
  15823. continue;
  15824. }
  15825. var value = localStorage.getItem(key); // If a result was found, parse it from the serialized
  15826. // string into a JS object. If result isn't truthy, the
  15827. // key is likely undefined and we'll pass it straight
  15828. // to the iterator.
  15829. if (value) {
  15830. value = dbInfo.serializer.deserialize(value);
  15831. }
  15832. value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);
  15833. if (value !== void 0) {
  15834. return value;
  15835. }
  15836. }
  15837. });
  15838. utils_executeCallback(promise, callback);
  15839. return promise;
  15840. } // Same as localStorage's key() method, except takes a callback.
  15841. function localstorage_key(n, callback) {
  15842. var self = this;
  15843. var promise = self.ready().then(function () {
  15844. var dbInfo = self._dbInfo;
  15845. var result;
  15846. try {
  15847. result = localStorage.key(n);
  15848. } catch (error) {
  15849. result = null;
  15850. } // Remove the prefix from the key, if a key is found.
  15851. if (result) {
  15852. result = result.substring(dbInfo.keyPrefix.length);
  15853. }
  15854. return result;
  15855. });
  15856. utils_executeCallback(promise, callback);
  15857. return promise;
  15858. }
  15859. function localstorage_keys(callback) {
  15860. var self = this;
  15861. var promise = self.ready().then(function () {
  15862. var dbInfo = self._dbInfo;
  15863. var length = localStorage.length;
  15864. var keys = [];
  15865. for (var i = 0; i < length; i++) {
  15866. var itemKey = localStorage.key(i);
  15867. if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {
  15868. keys.push(itemKey.substring(dbInfo.keyPrefix.length));
  15869. }
  15870. }
  15871. return keys;
  15872. });
  15873. utils_executeCallback(promise, callback);
  15874. return promise;
  15875. } // Supply the number of keys in the datastore to the callback function.
  15876. function localstorage_length(callback) {
  15877. var self = this;
  15878. var promise = self.keys().then(function (keys) {
  15879. return keys.length;
  15880. });
  15881. utils_executeCallback(promise, callback);
  15882. return promise;
  15883. } // Remove an item from the store, nice and simple.
  15884. function localstorage_removeItem(key, callback) {
  15885. var self = this;
  15886. key = normalizeKey(key);
  15887. var promise = self.ready().then(function () {
  15888. var dbInfo = self._dbInfo;
  15889. localStorage.removeItem(dbInfo.keyPrefix + key);
  15890. });
  15891. utils_executeCallback(promise, callback);
  15892. return promise;
  15893. } // Set a key's value and run an optional callback once the value is set.
  15894. // Unlike Gaia's implementation, the callback function is passed the value,
  15895. // in case you want to operate on that value only after you're sure it
  15896. // saved, or something like that.
  15897. function localstorage_setItem(key, value, callback) {
  15898. var self = this;
  15899. key = normalizeKey(key);
  15900. var promise = self.ready().then(function () {
  15901. // Convert undefined values to null.
  15902. // https://github.com/mozilla/localForage/pull/42
  15903. if (value === undefined) {
  15904. value = null;
  15905. } // Save the original value to pass to the callback.
  15906. var originalValue = value;
  15907. return new utils_promise(function (resolve, reject) {
  15908. var dbInfo = self._dbInfo;
  15909. dbInfo.serializer.serialize(value, function (value, error) {
  15910. if (error) {
  15911. reject(error);
  15912. } else {
  15913. try {
  15914. localStorage.setItem(dbInfo.keyPrefix + key, value);
  15915. resolve(originalValue);
  15916. } catch (e) {
  15917. // localStorage capacity exceeded.
  15918. // TODO: Make this a specific error/event.
  15919. if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
  15920. reject(e);
  15921. }
  15922. reject(e);
  15923. }
  15924. }
  15925. });
  15926. });
  15927. });
  15928. utils_executeCallback(promise, callback);
  15929. return promise;
  15930. }
  15931. function localstorage_dropInstance(options, callback) {
  15932. callback = getCallback.apply(this, arguments);
  15933. options = typeof options !== 'function' && options || {};
  15934. if (!options.name) {
  15935. var currentConfig = this.config();
  15936. options.name = options.name || currentConfig.name;
  15937. options.storeName = options.storeName || currentConfig.storeName;
  15938. }
  15939. var self = this;
  15940. var promise;
  15941. if (!options.name) {
  15942. promise = utils_promise.reject('Invalid arguments');
  15943. } else {
  15944. promise = new utils_promise(function (resolve) {
  15945. if (!options.storeName) {
  15946. resolve(`${options.name}/`);
  15947. } else {
  15948. resolve(_getKeyPrefix(options, self._defaultConfig));
  15949. }
  15950. }).then(function (keyPrefix) {
  15951. for (var i = localStorage.length - 1; i >= 0; i--) {
  15952. var key = localStorage.key(i);
  15953. if (key.indexOf(keyPrefix) === 0) {
  15954. localStorage.removeItem(key);
  15955. }
  15956. }
  15957. });
  15958. }
  15959. utils_executeCallback(promise, callback);
  15960. return promise;
  15961. }
  15962. var localStorageWrapper = {
  15963. _driver: 'localStorageWrapper',
  15964. _initStorage: localstorage_initStorage,
  15965. _support: utils_isLocalStorageValid(),
  15966. iterate: localstorage_iterate,
  15967. getItem: localstorage_getItem,
  15968. setItem: localstorage_setItem,
  15969. removeItem: localstorage_removeItem,
  15970. clear: localstorage_clear,
  15971. length: localstorage_length,
  15972. key: localstorage_key,
  15973. keys: localstorage_keys,
  15974. dropInstance: localstorage_dropInstance
  15975. };
  15976. /* harmony default export */ const localstorage = (localStorageWrapper);
  15977. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/includes.js
  15978. const sameValue = (x, y) => x === y || typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y);
  15979. const includes = (array, searchElement) => {
  15980. const len = array.length;
  15981. let i = 0;
  15982. while (i < len) {
  15983. if (sameValue(array[i], searchElement)) {
  15984. return true;
  15985. }
  15986. i++;
  15987. }
  15988. return false;
  15989. };
  15990. /* harmony default export */ const utils_includes = (includes);
  15991. ;// CONCATENATED MODULE: ./node_modules/localforage/src/utils/isArray.js
  15992. const isArray_isArray = Array.isArray || function (arg) {
  15993. return Object.prototype.toString.call(arg) === '[object Array]';
  15994. };
  15995. /* harmony default export */ const utils_isArray = (isArray_isArray);
  15996. ;// CONCATENATED MODULE: ./node_modules/localforage/src/localforage.js
  15997. // Drivers are stored here when `defineDriver()` is called.
  15998. // They are shared across all instances of localForage.
  15999. const DefinedDrivers = {};
  16000. const DriverSupport = {};
  16001. const DefaultDrivers = {
  16002. INDEXEDDB: indexeddb,
  16003. WEBSQL: websql,
  16004. LOCALSTORAGE: localstorage
  16005. };
  16006. const DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];
  16007. const OptionalDriverMethods = ['dropInstance'];
  16008. const LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'].concat(OptionalDriverMethods);
  16009. const DefaultConfig = {
  16010. description: '',
  16011. driver: DefaultDriverOrder.slice(),
  16012. name: 'localforage',
  16013. // Default DB size is _JUST UNDER_ 5MB, as it's the highest size
  16014. // we can use without a prompt.
  16015. size: 4980736,
  16016. storeName: 'keyvaluepairs',
  16017. version: 1.0
  16018. };
  16019. function callWhenReady(localForageInstance, libraryMethod) {
  16020. localForageInstance[libraryMethod] = function () {
  16021. const _args = arguments;
  16022. return localForageInstance.ready().then(function () {
  16023. return localForageInstance[libraryMethod].apply(localForageInstance, _args);
  16024. });
  16025. };
  16026. }
  16027. function extend() {
  16028. for (let i = 1; i < arguments.length; i++) {
  16029. const arg = arguments[i];
  16030. if (arg) {
  16031. for (let key in arg) {
  16032. if (arg.hasOwnProperty(key)) {
  16033. if (utils_isArray(arg[key])) {
  16034. arguments[0][key] = arg[key].slice();
  16035. } else {
  16036. arguments[0][key] = arg[key];
  16037. }
  16038. }
  16039. }
  16040. }
  16041. }
  16042. return arguments[0];
  16043. }
  16044. class LocalForage {
  16045. constructor(options) {
  16046. for (let driverTypeKey in DefaultDrivers) {
  16047. if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {
  16048. const driver = DefaultDrivers[driverTypeKey];
  16049. const driverName = driver._driver;
  16050. this[driverTypeKey] = driverName;
  16051. if (!DefinedDrivers[driverName]) {
  16052. // we don't need to wait for the promise,
  16053. // since the default drivers can be defined
  16054. // in a blocking manner
  16055. this.defineDriver(driver);
  16056. }
  16057. }
  16058. }
  16059. this._defaultConfig = extend({}, DefaultConfig);
  16060. this._config = extend({}, this._defaultConfig, options);
  16061. this._driverSet = null;
  16062. this._initDriver = null;
  16063. this._ready = false;
  16064. this._dbInfo = null;
  16065. this._wrapLibraryMethodsWithReady();
  16066. this.setDriver(this._config.driver).catch(() => {});
  16067. } // Set any config values for localForage; can be called anytime before
  16068. // the first API call (e.g. `getItem`, `setItem`).
  16069. // We loop through options so we don't overwrite existing config
  16070. // values.
  16071. config(options) {
  16072. // If the options argument is an object, we use it to set values.
  16073. // Otherwise, we return either a specified config value or all
  16074. // config values.
  16075. if (typeof options === 'object') {
  16076. // If localforage is ready and fully initialized, we can't set
  16077. // any new configuration values. Instead, we return an error.
  16078. if (this._ready) {
  16079. return new Error("Can't call config() after localforage " + 'has been used.');
  16080. }
  16081. for (let i in options) {
  16082. if (i === 'storeName') {
  16083. options[i] = options[i].replace(/\W/g, '_');
  16084. }
  16085. if (i === 'version' && typeof options[i] !== 'number') {
  16086. return new Error('Database version must be a number.');
  16087. }
  16088. this._config[i] = options[i];
  16089. } // after all config options are set and
  16090. // the driver option is used, try setting it
  16091. if ('driver' in options && options.driver) {
  16092. return this.setDriver(this._config.driver);
  16093. }
  16094. return true;
  16095. } else if (typeof options === 'string') {
  16096. return this._config[options];
  16097. } else {
  16098. return this._config;
  16099. }
  16100. } // Used to define a custom driver, shared across all instances of
  16101. // localForage.
  16102. defineDriver(driverObject, callback, errorCallback) {
  16103. const promise = new utils_promise(function (resolve, reject) {
  16104. try {
  16105. const driverName = driverObject._driver;
  16106. const complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver'); // A driver name should be defined and not overlap with the
  16107. // library-defined, default drivers.
  16108. if (!driverObject._driver) {
  16109. reject(complianceError);
  16110. return;
  16111. }
  16112. const driverMethods = LibraryMethods.concat('_initStorage');
  16113. for (let i = 0, len = driverMethods.length; i < len; i++) {
  16114. const driverMethodName = driverMethods[i]; // when the property is there,
  16115. // it should be a method even when optional
  16116. const isRequired = !utils_includes(OptionalDriverMethods, driverMethodName);
  16117. if ((isRequired || driverObject[driverMethodName]) && typeof driverObject[driverMethodName] !== 'function') {
  16118. reject(complianceError);
  16119. return;
  16120. }
  16121. }
  16122. const configureMissingMethods = function () {
  16123. const methodNotImplementedFactory = function (methodName) {
  16124. return function () {
  16125. const error = new Error(`Method ${methodName} is not implemented by the current driver`);
  16126. const promise = utils_promise.reject(error);
  16127. utils_executeCallback(promise, arguments[arguments.length - 1]);
  16128. return promise;
  16129. };
  16130. };
  16131. for (let i = 0, len = OptionalDriverMethods.length; i < len; i++) {
  16132. const optionalDriverMethod = OptionalDriverMethods[i];
  16133. if (!driverObject[optionalDriverMethod]) {
  16134. driverObject[optionalDriverMethod] = methodNotImplementedFactory(optionalDriverMethod);
  16135. }
  16136. }
  16137. };
  16138. configureMissingMethods();
  16139. const setDriverSupport = function (support) {
  16140. if (DefinedDrivers[driverName]) {
  16141. console.info(`Redefining LocalForage driver: ${driverName}`);
  16142. }
  16143. DefinedDrivers[driverName] = driverObject;
  16144. DriverSupport[driverName] = support; // don't use a then, so that we can define
  16145. // drivers that have simple _support methods
  16146. // in a blocking manner
  16147. resolve();
  16148. };
  16149. if ('_support' in driverObject) {
  16150. if (driverObject._support && typeof driverObject._support === 'function') {
  16151. driverObject._support().then(setDriverSupport, reject);
  16152. } else {
  16153. setDriverSupport(!!driverObject._support);
  16154. }
  16155. } else {
  16156. setDriverSupport(true);
  16157. }
  16158. } catch (e) {
  16159. reject(e);
  16160. }
  16161. });
  16162. utils_executeTwoCallbacks(promise, callback, errorCallback);
  16163. return promise;
  16164. }
  16165. driver() {
  16166. return this._driver || null;
  16167. }
  16168. getDriver(driverName, callback, errorCallback) {
  16169. const getDriverPromise = DefinedDrivers[driverName] ? utils_promise.resolve(DefinedDrivers[driverName]) : utils_promise.reject(new Error('Driver not found.'));
  16170. utils_executeTwoCallbacks(getDriverPromise, callback, errorCallback);
  16171. return getDriverPromise;
  16172. }
  16173. getSerializer(callback) {
  16174. const serializerPromise = utils_promise.resolve(serializer);
  16175. utils_executeTwoCallbacks(serializerPromise, callback);
  16176. return serializerPromise;
  16177. }
  16178. ready(callback) {
  16179. const self = this;
  16180. const promise = self._driverSet.then(() => {
  16181. if (self._ready === null) {
  16182. self._ready = self._initDriver();
  16183. }
  16184. return self._ready;
  16185. });
  16186. utils_executeTwoCallbacks(promise, callback, callback);
  16187. return promise;
  16188. }
  16189. setDriver(drivers, callback, errorCallback) {
  16190. const self = this;
  16191. if (!utils_isArray(drivers)) {
  16192. drivers = [drivers];
  16193. }
  16194. const supportedDrivers = this._getSupportedDrivers(drivers);
  16195. function setDriverToConfig() {
  16196. self._config.driver = self.driver();
  16197. }
  16198. function extendSelfWithDriver(driver) {
  16199. self._extend(driver);
  16200. setDriverToConfig();
  16201. self._ready = self._initStorage(self._config);
  16202. return self._ready;
  16203. }
  16204. function initDriver(supportedDrivers) {
  16205. return function () {
  16206. let currentDriverIndex = 0;
  16207. function driverPromiseLoop() {
  16208. while (currentDriverIndex < supportedDrivers.length) {
  16209. let driverName = supportedDrivers[currentDriverIndex];
  16210. currentDriverIndex++;
  16211. self._dbInfo = null;
  16212. self._ready = null;
  16213. return self.getDriver(driverName).then(extendSelfWithDriver).catch(driverPromiseLoop);
  16214. }
  16215. setDriverToConfig();
  16216. const error = new Error('No available storage method found.');
  16217. self._driverSet = utils_promise.reject(error);
  16218. return self._driverSet;
  16219. }
  16220. return driverPromiseLoop();
  16221. };
  16222. } // There might be a driver initialization in progress
  16223. // so wait for it to finish in order to avoid a possible
  16224. // race condition to set _dbInfo
  16225. const oldDriverSetDone = this._driverSet !== null ? this._driverSet.catch(() => utils_promise.resolve()) : utils_promise.resolve();
  16226. this._driverSet = oldDriverSetDone.then(() => {
  16227. const driverName = supportedDrivers[0];
  16228. self._dbInfo = null;
  16229. self._ready = null;
  16230. return self.getDriver(driverName).then(driver => {
  16231. self._driver = driver._driver;
  16232. setDriverToConfig();
  16233. self._wrapLibraryMethodsWithReady();
  16234. self._initDriver = initDriver(supportedDrivers);
  16235. });
  16236. }).catch(() => {
  16237. setDriverToConfig();
  16238. const error = new Error('No available storage method found.');
  16239. self._driverSet = utils_promise.reject(error);
  16240. return self._driverSet;
  16241. });
  16242. utils_executeTwoCallbacks(this._driverSet, callback, errorCallback);
  16243. return this._driverSet;
  16244. }
  16245. supports(driverName) {
  16246. return !!DriverSupport[driverName];
  16247. }
  16248. _extend(libraryMethodsAndProperties) {
  16249. extend(this, libraryMethodsAndProperties);
  16250. }
  16251. _getSupportedDrivers(drivers) {
  16252. const supportedDrivers = [];
  16253. for (let i = 0, len = drivers.length; i < len; i++) {
  16254. const driverName = drivers[i];
  16255. if (this.supports(driverName)) {
  16256. supportedDrivers.push(driverName);
  16257. }
  16258. }
  16259. return supportedDrivers;
  16260. }
  16261. _wrapLibraryMethodsWithReady() {
  16262. // Add a stub for each driver API method that delays the call to the
  16263. // corresponding driver method until localForage is ready. These stubs
  16264. // will be replaced by the driver methods as soon as the driver is
  16265. // loaded, so there is no performance impact.
  16266. for (let i = 0, len = LibraryMethods.length; i < len; i++) {
  16267. callWhenReady(this, LibraryMethods[i]);
  16268. }
  16269. }
  16270. createInstance(options) {
  16271. return new LocalForage(options);
  16272. }
  16273. } // The actual localForage object that we expose as a module or via a
  16274. // global. It's extended by pulling in one of our other libraries.
  16275. /* harmony default export */ const localforage = (new LocalForage());
  16276. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_assignMergeValue.js
  16277. /**
  16278. * This function is like `assignValue` except that it doesn't assign
  16279. * `undefined` values.
  16280. *
  16281. * @private
  16282. * @param {Object} object The object to modify.
  16283. * @param {string} key The key of the property to assign.
  16284. * @param {*} value The value to assign.
  16285. */
  16286. function assignMergeValue(object, key, value) {
  16287. if ((value !== undefined && !lodash_es_eq(object[key], value)) ||
  16288. (value === undefined && !(key in object))) {
  16289. _baseAssignValue(object, key, value);
  16290. }
  16291. }
  16292. /* harmony default export */ const _assignMergeValue = (assignMergeValue);
  16293. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isArrayLikeObject.js
  16294. /**
  16295. * This method is like `_.isArrayLike` except that it also checks if `value`
  16296. * is an object.
  16297. *
  16298. * @static
  16299. * @memberOf _
  16300. * @since 4.0.0
  16301. * @category Lang
  16302. * @param {*} value The value to check.
  16303. * @returns {boolean} Returns `true` if `value` is an array-like object,
  16304. * else `false`.
  16305. * @example
  16306. *
  16307. * _.isArrayLikeObject([1, 2, 3]);
  16308. * // => true
  16309. *
  16310. * _.isArrayLikeObject(document.body.children);
  16311. * // => true
  16312. *
  16313. * _.isArrayLikeObject('abc');
  16314. * // => false
  16315. *
  16316. * _.isArrayLikeObject(_.noop);
  16317. * // => false
  16318. */
  16319. function isArrayLikeObject(value) {
  16320. return lodash_es_isObjectLike(value) && lodash_es_isArrayLike(value);
  16321. }
  16322. /* harmony default export */ const lodash_es_isArrayLikeObject = (isArrayLikeObject);
  16323. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_safeGet.js
  16324. /**
  16325. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  16326. *
  16327. * @private
  16328. * @param {Object} object The object to query.
  16329. * @param {string} key The key of the property to get.
  16330. * @returns {*} Returns the property value.
  16331. */
  16332. function safeGet(object, key) {
  16333. if (key === 'constructor' && typeof object[key] === 'function') {
  16334. return;
  16335. }
  16336. if (key == '__proto__') {
  16337. return;
  16338. }
  16339. return object[key];
  16340. }
  16341. /* harmony default export */ const _safeGet = (safeGet);
  16342. ;// CONCATENATED MODULE: ./node_modules/lodash-es/toPlainObject.js
  16343. /**
  16344. * Converts `value` to a plain object flattening inherited enumerable string
  16345. * keyed properties of `value` to own properties of the plain object.
  16346. *
  16347. * @static
  16348. * @memberOf _
  16349. * @since 3.0.0
  16350. * @category Lang
  16351. * @param {*} value The value to convert.
  16352. * @returns {Object} Returns the converted plain object.
  16353. * @example
  16354. *
  16355. * function Foo() {
  16356. * this.b = 2;
  16357. * }
  16358. *
  16359. * Foo.prototype.c = 3;
  16360. *
  16361. * _.assign({ 'a': 1 }, new Foo);
  16362. * // => { 'a': 1, 'b': 2 }
  16363. *
  16364. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  16365. * // => { 'a': 1, 'b': 2, 'c': 3 }
  16366. */
  16367. function toPlainObject(value) {
  16368. return _copyObject(value, lodash_es_keysIn(value));
  16369. }
  16370. /* harmony default export */ const lodash_es_toPlainObject = (toPlainObject);
  16371. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseMergeDeep.js
  16372. /**
  16373. * A specialized version of `baseMerge` for arrays and objects which performs
  16374. * deep merges and tracks traversed objects enabling objects with circular
  16375. * references to be merged.
  16376. *
  16377. * @private
  16378. * @param {Object} object The destination object.
  16379. * @param {Object} source The source object.
  16380. * @param {string} key The key of the value to merge.
  16381. * @param {number} srcIndex The index of `source`.
  16382. * @param {Function} mergeFunc The function to merge values.
  16383. * @param {Function} [customizer] The function to customize assigned values.
  16384. * @param {Object} [stack] Tracks traversed source values and their merged
  16385. * counterparts.
  16386. */
  16387. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  16388. var objValue = _safeGet(object, key),
  16389. srcValue = _safeGet(source, key),
  16390. stacked = stack.get(srcValue);
  16391. if (stacked) {
  16392. _assignMergeValue(object, key, stacked);
  16393. return;
  16394. }
  16395. var newValue = customizer
  16396. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  16397. : undefined;
  16398. var isCommon = newValue === undefined;
  16399. if (isCommon) {
  16400. var isArr = lodash_es_isArray(srcValue),
  16401. isBuff = !isArr && lodash_es_isBuffer(srcValue),
  16402. isTyped = !isArr && !isBuff && lodash_es_isTypedArray(srcValue);
  16403. newValue = srcValue;
  16404. if (isArr || isBuff || isTyped) {
  16405. if (lodash_es_isArray(objValue)) {
  16406. newValue = objValue;
  16407. }
  16408. else if (lodash_es_isArrayLikeObject(objValue)) {
  16409. newValue = _copyArray(objValue);
  16410. }
  16411. else if (isBuff) {
  16412. isCommon = false;
  16413. newValue = _cloneBuffer(srcValue, true);
  16414. }
  16415. else if (isTyped) {
  16416. isCommon = false;
  16417. newValue = _cloneTypedArray(srcValue, true);
  16418. }
  16419. else {
  16420. newValue = [];
  16421. }
  16422. }
  16423. else if (lodash_es_isPlainObject(srcValue) || lodash_es_isArguments(srcValue)) {
  16424. newValue = objValue;
  16425. if (lodash_es_isArguments(objValue)) {
  16426. newValue = lodash_es_toPlainObject(objValue);
  16427. }
  16428. else if (!lodash_es_isObject(objValue) || lodash_es_isFunction(objValue)) {
  16429. newValue = _initCloneObject(srcValue);
  16430. }
  16431. }
  16432. else {
  16433. isCommon = false;
  16434. }
  16435. }
  16436. if (isCommon) {
  16437. // Recursively merge objects and arrays (susceptible to call stack limits).
  16438. stack.set(srcValue, newValue);
  16439. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  16440. stack['delete'](srcValue);
  16441. }
  16442. _assignMergeValue(object, key, newValue);
  16443. }
  16444. /* harmony default export */ const _baseMergeDeep = (baseMergeDeep);
  16445. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseMerge.js
  16446. /**
  16447. * The base implementation of `_.merge` without support for multiple sources.
  16448. *
  16449. * @private
  16450. * @param {Object} object The destination object.
  16451. * @param {Object} source The source object.
  16452. * @param {number} srcIndex The index of `source`.
  16453. * @param {Function} [customizer] The function to customize merged values.
  16454. * @param {Object} [stack] Tracks traversed source values and their merged
  16455. * counterparts.
  16456. */
  16457. function baseMerge(object, source, srcIndex, customizer, stack) {
  16458. if (object === source) {
  16459. return;
  16460. }
  16461. _baseFor(source, function(srcValue, key) {
  16462. stack || (stack = new _Stack);
  16463. if (lodash_es_isObject(srcValue)) {
  16464. _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  16465. }
  16466. else {
  16467. var newValue = customizer
  16468. ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
  16469. : undefined;
  16470. if (newValue === undefined) {
  16471. newValue = srcValue;
  16472. }
  16473. _assignMergeValue(object, key, newValue);
  16474. }
  16475. }, lodash_es_keysIn);
  16476. }
  16477. /* harmony default export */ const _baseMerge = (baseMerge);
  16478. ;// CONCATENATED MODULE: ./node_modules/lodash-es/merge.js
  16479. /**
  16480. * This method is like `_.assign` except that it recursively merges own and
  16481. * inherited enumerable string keyed properties of source objects into the
  16482. * destination object. Source properties that resolve to `undefined` are
  16483. * skipped if a destination value exists. Array and plain object properties
  16484. * are merged recursively. Other objects and value types are overridden by
  16485. * assignment. Source objects are applied from left to right. Subsequent
  16486. * sources overwrite property assignments of previous sources.
  16487. *
  16488. * **Note:** This method mutates `object`.
  16489. *
  16490. * @static
  16491. * @memberOf _
  16492. * @since 0.5.0
  16493. * @category Object
  16494. * @param {Object} object The destination object.
  16495. * @param {...Object} [sources] The source objects.
  16496. * @returns {Object} Returns `object`.
  16497. * @example
  16498. *
  16499. * var object = {
  16500. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  16501. * };
  16502. *
  16503. * var other = {
  16504. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  16505. * };
  16506. *
  16507. * _.merge(object, other);
  16508. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  16509. */
  16510. var merge = _createAssigner(function(object, source, srcIndex) {
  16511. _baseMerge(object, source, srcIndex);
  16512. });
  16513. /* harmony default export */ const lodash_es_merge = (merge);
  16514. ;// CONCATENATED MODULE: ./node_modules/lodash-es/mergeWith.js
  16515. /**
  16516. * This method is like `_.merge` except that it accepts `customizer` which
  16517. * is invoked to produce the merged values of the destination and source
  16518. * properties. If `customizer` returns `undefined`, merging is handled by the
  16519. * method instead. The `customizer` is invoked with six arguments:
  16520. * (objValue, srcValue, key, object, source, stack).
  16521. *
  16522. * **Note:** This method mutates `object`.
  16523. *
  16524. * @static
  16525. * @memberOf _
  16526. * @since 4.0.0
  16527. * @category Object
  16528. * @param {Object} object The destination object.
  16529. * @param {...Object} sources The source objects.
  16530. * @param {Function} customizer The function to customize assigned values.
  16531. * @returns {Object} Returns `object`.
  16532. * @example
  16533. *
  16534. * function customizer(objValue, srcValue) {
  16535. * if (_.isArray(objValue)) {
  16536. * return objValue.concat(srcValue);
  16537. * }
  16538. * }
  16539. *
  16540. * var object = { 'a': [1], 'b': [2] };
  16541. * var other = { 'a': [3], 'b': [4] };
  16542. *
  16543. * _.mergeWith(object, other, customizer);
  16544. * // => { 'a': [1, 3], 'b': [2, 4] }
  16545. */
  16546. var mergeWith = _createAssigner(function(object, source, srcIndex, customizer) {
  16547. _baseMerge(object, source, srcIndex, customizer);
  16548. });
  16549. /* harmony default export */ const lodash_es_mergeWith = (mergeWith);
  16550. ;// CONCATENATED MODULE: ./node_modules/lodash-es/now.js
  16551. /**
  16552. * Gets the timestamp of the number of milliseconds that have elapsed since
  16553. * the Unix epoch (1 January 1970 00:00:00 UTC).
  16554. *
  16555. * @static
  16556. * @memberOf _
  16557. * @since 2.4.0
  16558. * @category Date
  16559. * @returns {number} Returns the timestamp.
  16560. * @example
  16561. *
  16562. * _.defer(function(stamp) {
  16563. * console.log(_.now() - stamp);
  16564. * }, _.now());
  16565. * // => Logs the number of milliseconds it took for the deferred invocation.
  16566. */
  16567. var now = function() {
  16568. return _root.Date.now();
  16569. };
  16570. /* harmony default export */ const lodash_es_now = (now);
  16571. ;// CONCATENATED MODULE: ./node_modules/@converse/openpromise/openpromise.js
  16572. function getOpenPromise() {
  16573. const wrapper = {
  16574. isResolved: false,
  16575. isPending: true,
  16576. isRejected: false
  16577. };
  16578. const promise = new Promise((resolve, reject) => {
  16579. wrapper.resolve = resolve;
  16580. wrapper.reject = reject;
  16581. });
  16582. Object.assign(promise, wrapper);
  16583. promise.then(function (v) {
  16584. promise.isResolved = true;
  16585. promise.isPending = false;
  16586. promise.isRejected = false;
  16587. return v;
  16588. }, function (e) {
  16589. promise.isResolved = false;
  16590. promise.isPending = false;
  16591. promise.isRejected = true;
  16592. throw e;
  16593. });
  16594. return promise;
  16595. }
  16596. ;// CONCATENATED MODULE: ./node_modules/mergebounce/mergebounce.js
  16597. /** Error message constants. */
  16598. const mergebounce_FUNC_ERROR_TEXT = 'Expected a function';
  16599. /* Built-in method references for those with the same name as other `lodash` methods. */
  16600. const mergebounce_nativeMax = Math.max;
  16601. const nativeMin = Math.min;
  16602. /**
  16603. * Creates a debounced function that delays invoking `func` until after `wait`
  16604. * milliseconds have elapsed since the last time the debounced function was
  16605. * invoked. The debounced function comes with a `cancel` method to cancel
  16606. * delayed `func` invocations and a `flush` method to immediately invoke them.
  16607. *
  16608. * This function differs from lodash's debounce by merging all passed objects
  16609. * before passing them to the final invoked function.
  16610. *
  16611. * Because of this, invoking can only happen on the trailing edge, since
  16612. * passed-in data would be discarded if invoking happened on the leading edge.
  16613. *
  16614. * If `wait` is `0`, `func` invocation is deferred until to the next tick,
  16615. * similar to `setTimeout` with a timeout of `0`.
  16616. *
  16617. * @static
  16618. * @category Function
  16619. * @param {Function} func The function to mergebounce.
  16620. * @param {number} [wait=0] The number of milliseconds to delay.
  16621. * @param {Object} [options={}] The options object.
  16622. * @param {number} [options.maxWait]
  16623. * The maximum time `func` is allowed to be delayed before it's invoked.
  16624. * @param {boolean} [options.concatArrays=false]
  16625. * By default arrays will be treated as objects when being merged. When
  16626. * merging two arrays, the values in the 2nd arrray will replace the
  16627. * corresponding values (i.e. those with the same indexes) in the first array.
  16628. * When `concatArrays` is set to `true`, arrays will be concatenated instead.
  16629. * @param {boolean} [options.dedupeArrays=false]
  16630. * This option is similar to `concatArrays`, except that the concatenated
  16631. * array will also be deduplicated. Thus any entries that are concatenated to the
  16632. * existing array, which are already contained in the existing array, will
  16633. * first be removed.
  16634. * @param {boolean} [options.promise=false]
  16635. * By default, when calling a merge-debounced function that doesn't execute
  16636. * immediately, you'll receive the result from its previous execution, or
  16637. * `undefined` if it has never executed before. By setting the `promise`
  16638. * option to `true`, a promise will be returned instead of the previous
  16639. * execution result when the function is debounced. The promise will resolve
  16640. * with the result of the next execution, as soon as it happens.
  16641. * @returns {Function} Returns the new debounced function.
  16642. * @example
  16643. *
  16644. * // Avoid costly calculations while the window size is in flux.
  16645. * window.addEventListener('resize', mergebounce(calculateLayout, 150));
  16646. *
  16647. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  16648. * element.addEventListner('click', mergebounce(sendMail, 300));
  16649. *
  16650. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  16651. * const mergebounced = mergebounce(batchLog, 250, { 'maxWait': 1000 });
  16652. * const source = new EventSource('/stream');
  16653. * jQuery(source).on('message', mergebounced);
  16654. *
  16655. * // Cancel the trailing debounced invocation.
  16656. * window.addEventListener('popstate', mergebounced.cancel);
  16657. */
  16658. function mergebounce(func, wait) {
  16659. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  16660. let lastArgs,
  16661. lastThis,
  16662. maxWait,
  16663. result,
  16664. timerId,
  16665. lastCallTime,
  16666. lastInvokeTime = 0,
  16667. maxing = false;
  16668. let promise = options.promise ? getOpenPromise() : null;
  16669. if (typeof func != 'function') {
  16670. throw new TypeError(mergebounce_FUNC_ERROR_TEXT);
  16671. }
  16672. wait = lodash_es_toNumber(wait) || 0;
  16673. if (lodash_es_isObject(options)) {
  16674. maxing = 'maxWait' in options;
  16675. maxWait = maxing ? mergebounce_nativeMax(lodash_es_toNumber(options.maxWait) || 0, wait) : maxWait;
  16676. }
  16677. function invokeFunc(time) {
  16678. const args = lastArgs;
  16679. const thisArg = lastThis;
  16680. const existingPromise = promise;
  16681. lastArgs = lastThis = undefined;
  16682. lastInvokeTime = time;
  16683. result = func.apply(thisArg, args);
  16684. if (options.promise) {
  16685. existingPromise.resolve(result);
  16686. promise = getOpenPromise();
  16687. }
  16688. return options.promise ? existingPromise : result;
  16689. }
  16690. function leadingEdge(time) {
  16691. // Reset any `maxWait` timer.
  16692. lastInvokeTime = time; // Start the timer for the trailing edge.
  16693. timerId = setTimeout(timerExpired, wait);
  16694. return options.promise ? promise : result;
  16695. }
  16696. function remainingWait(time) {
  16697. const timeSinceLastCall = time - lastCallTime;
  16698. const timeSinceLastInvoke = time - lastInvokeTime;
  16699. const timeWaiting = wait - timeSinceLastCall;
  16700. return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
  16701. }
  16702. function shouldInvoke(time) {
  16703. const timeSinceLastCall = time - lastCallTime;
  16704. const timeSinceLastInvoke = time - lastInvokeTime; // Either this is the first call, activity has stopped and we're at the
  16705. // trailing edge, the system time has gone backwards and we're treating
  16706. // it as the trailing edge, or we've hit the `maxWait` limit.
  16707. return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
  16708. }
  16709. function timerExpired() {
  16710. const time = lodash_es_now();
  16711. if (shouldInvoke(time)) {
  16712. return trailingEdge(time);
  16713. } // Restart the timer.
  16714. timerId = setTimeout(timerExpired, remainingWait(time));
  16715. }
  16716. function trailingEdge(time) {
  16717. timerId = undefined; // Only invoke if we have `lastArgs` which means `func` has been
  16718. // debounced at least once.
  16719. if (lastArgs) {
  16720. return invokeFunc(time);
  16721. }
  16722. lastArgs = lastThis = undefined;
  16723. return options.promise ? promise : result;
  16724. }
  16725. function cancel() {
  16726. if (timerId !== undefined) {
  16727. clearTimeout(timerId);
  16728. }
  16729. lastInvokeTime = 0;
  16730. lastArgs = lastCallTime = lastThis = timerId = undefined;
  16731. }
  16732. function flush() {
  16733. return timerId === undefined ? result : trailingEdge(lodash_es_now());
  16734. }
  16735. function concatArrays(objValue, srcValue) {
  16736. if (Array.isArray(objValue) && Array.isArray(srcValue)) {
  16737. if (options !== null && options !== void 0 && options.dedupeArrays) {
  16738. return objValue.concat(srcValue.filter(i => objValue.indexOf(i) === -1));
  16739. } else {
  16740. return objValue.concat(srcValue);
  16741. }
  16742. }
  16743. }
  16744. function mergeArguments(args) {
  16745. var _lastArgs;
  16746. if ((_lastArgs = lastArgs) !== null && _lastArgs !== void 0 && _lastArgs.length) {
  16747. if (!args.length) {
  16748. return lastArgs;
  16749. }
  16750. if (options !== null && options !== void 0 && options.concatArrays || options !== null && options !== void 0 && options.dedupeArrays) {
  16751. return lodash_es_mergeWith(lastArgs, args, concatArrays);
  16752. } else {
  16753. return lodash_es_merge(lastArgs, args);
  16754. }
  16755. } else {
  16756. return args || [];
  16757. }
  16758. }
  16759. function debounced() {
  16760. const time = lodash_es_now();
  16761. const isInvoking = shouldInvoke(time);
  16762. lastArgs = mergeArguments(Array.from(arguments));
  16763. lastThis = this;
  16764. lastCallTime = time;
  16765. if (isInvoking) {
  16766. if (timerId === undefined) {
  16767. return leadingEdge(lastCallTime);
  16768. }
  16769. if (maxing) {
  16770. // Handle invocations in a tight loop.
  16771. clearTimeout(timerId);
  16772. timerId = setTimeout(timerExpired, wait);
  16773. return invokeFunc(lastCallTime);
  16774. }
  16775. }
  16776. if (timerId === undefined) {
  16777. timerId = setTimeout(timerExpired, wait);
  16778. }
  16779. return options.promise ? promise : result;
  16780. }
  16781. debounced.cancel = cancel;
  16782. debounced.flush = flush;
  16783. return debounced;
  16784. }
  16785. /* harmony default export */ const mergebounce_mergebounce = (mergebounce);
  16786. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/drivers/sessionStorage.js
  16787. // Copyright 2014 Mozilla
  16788. // Copyright 2015 Thodoris Greasidis
  16789. // Copyright 2018 JC Brand
  16790. //
  16791. // Licensed under the Apache License, Version 2.0 (the "License");
  16792. // you may not use this file except in compliance with the License.
  16793. // You may obtain a copy of the License at
  16794. //
  16795. // http://www.apache.org/licenses/LICENSE-2.0
  16796. //
  16797. // Unless required by applicable law or agreed to in writing, software
  16798. // distributed under the License is distributed on an "AS IS" BASIS,
  16799. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16800. // See the License for the specific language governing permissions and
  16801. // limitations under the License.
  16802. const sessionStorage_serialize = serializer.serialize;
  16803. const sessionStorage_deserialize = serializer.deserialize;
  16804. function isSessionStorageValid() {
  16805. // If the app is running inside a Google Chrome packaged webapp, or some
  16806. // other context where sessionStorage isn't available, we don't use
  16807. // sessionStorage. This feature detection is preferred over the old
  16808. // `if (window.chrome && window.chrome.runtime)` code.
  16809. // See: https://github.com/mozilla/localForage/issues/68
  16810. try {
  16811. // If sessionStorage isn't available, we get outta here!
  16812. // This should be inside a try catch
  16813. if (sessionStorage && 'setItem' in sessionStorage) {
  16814. return true;
  16815. }
  16816. } catch (e) {
  16817. console.log(e);
  16818. }
  16819. return false;
  16820. }
  16821. function sessionStorage_getKeyPrefix(options, defaultConfig) {
  16822. let keyPrefix = options.name + '/';
  16823. if (options.storeName !== defaultConfig.storeName) {
  16824. keyPrefix += options.storeName + '/';
  16825. }
  16826. return keyPrefix;
  16827. }
  16828. const dbInfo = {
  16829. 'serializer': {
  16830. 'serialize': sessionStorage_serialize,
  16831. 'deserialize': sessionStorage_deserialize
  16832. }
  16833. };
  16834. function sessionStorage_initStorage(options) {
  16835. dbInfo.keyPrefix = sessionStorage_getKeyPrefix(options, this._defaultConfig);
  16836. if (options) {
  16837. for (const i in options) {
  16838. // eslint-disable-line guard-for-in
  16839. dbInfo[i] = options[i];
  16840. }
  16841. }
  16842. } // Remove all keys from the datastore, effectively destroying all data in
  16843. // the app's key/value store!
  16844. function sessionStorage_clear(callback) {
  16845. const promise = this.ready().then(function () {
  16846. const keyPrefix = dbInfo.keyPrefix;
  16847. for (let i = sessionStorage.length - 1; i >= 0; i--) {
  16848. const key = sessionStorage.key(i);
  16849. if (key.indexOf(keyPrefix) === 0) {
  16850. sessionStorage.removeItem(key);
  16851. }
  16852. }
  16853. });
  16854. utils_executeCallback(promise, callback);
  16855. return promise;
  16856. } // Retrieve an item from the store. Unlike the original async_storage
  16857. // library in Gaia, we don't modify return values at all. If a key's value
  16858. // is `undefined`, we pass that value to the callback function.
  16859. function sessionStorage_getItem(key, callback) {
  16860. key = normalizeKey(key);
  16861. const promise = this.ready().then(function () {
  16862. let result = sessionStorage.getItem(dbInfo.keyPrefix + key); // If a result was found, parse it from the serialized
  16863. // string into a JS object. If result isn't truthy, the key
  16864. // is likely undefined and we'll pass it straight to the
  16865. // callback.
  16866. if (result) {
  16867. result = dbInfo.serializer.deserialize(result);
  16868. }
  16869. return result;
  16870. });
  16871. utils_executeCallback(promise, callback);
  16872. return promise;
  16873. } // Iterate over all items in the store.
  16874. function sessionStorage_iterate(iterator, callback) {
  16875. const self = this;
  16876. const promise = self.ready().then(function () {
  16877. const keyPrefix = dbInfo.keyPrefix;
  16878. const keyPrefixLength = keyPrefix.length;
  16879. const length = sessionStorage.length; // We use a dedicated iterator instead of the `i` variable below
  16880. // so other keys we fetch in sessionStorage aren't counted in
  16881. // the `iterationNumber` argument passed to the `iterate()`
  16882. // callback.
  16883. //
  16884. // See: github.com/mozilla/localForage/pull/435#discussion_r38061530
  16885. let iterationNumber = 1;
  16886. for (let i = 0; i < length; i++) {
  16887. const key = sessionStorage.key(i);
  16888. if (key.indexOf(keyPrefix) !== 0) {
  16889. continue;
  16890. }
  16891. let value = sessionStorage.getItem(key); // If a result was found, parse it from the serialized
  16892. // string into a JS object. If result isn't truthy, the
  16893. // key is likely undefined and we'll pass it straight
  16894. // to the iterator.
  16895. if (value) {
  16896. value = dbInfo.serializer.deserialize(value);
  16897. }
  16898. value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);
  16899. if (value !== void 0) {
  16900. // eslint-disable-line no-void
  16901. return value;
  16902. }
  16903. }
  16904. });
  16905. utils_executeCallback(promise, callback);
  16906. return promise;
  16907. } // Same as sessionStorage's key() method, except takes a callback.
  16908. function sessionStorage_key(n, callback) {
  16909. const self = this;
  16910. const promise = self.ready().then(function () {
  16911. let result;
  16912. try {
  16913. result = sessionStorage.key(n);
  16914. } catch (error) {
  16915. result = null;
  16916. } // Remove the prefix from the key, if a key is found.
  16917. if (result) {
  16918. result = result.substring(dbInfo.keyPrefix.length);
  16919. }
  16920. return result;
  16921. });
  16922. utils_executeCallback(promise, callback);
  16923. return promise;
  16924. }
  16925. function sessionStorage_keys(callback) {
  16926. const self = this;
  16927. const promise = self.ready().then(function () {
  16928. const length = sessionStorage.length;
  16929. const keys = [];
  16930. for (let i = 0; i < length; i++) {
  16931. const itemKey = sessionStorage.key(i);
  16932. if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {
  16933. keys.push(itemKey.substring(dbInfo.keyPrefix.length));
  16934. }
  16935. }
  16936. return keys;
  16937. });
  16938. utils_executeCallback(promise, callback);
  16939. return promise;
  16940. } // Supply the number of keys in the datastore to the callback function.
  16941. function sessionStorage_length(callback) {
  16942. const self = this;
  16943. const promise = self.keys().then(function (keys) {
  16944. return keys.length;
  16945. });
  16946. utils_executeCallback(promise, callback);
  16947. return promise;
  16948. } // Remove an item from the store, nice and simple.
  16949. function sessionStorage_removeItem(key, callback) {
  16950. key = normalizeKey(key);
  16951. const promise = this.ready().then(function () {
  16952. sessionStorage.removeItem(dbInfo.keyPrefix + key);
  16953. });
  16954. utils_executeCallback(promise, callback);
  16955. return promise;
  16956. } // Set a key's value and run an optional callback once the value is set.
  16957. // Unlike Gaia's implementation, the callback function is passed the value,
  16958. // in case you want to operate on that value only after you're sure it
  16959. // saved, or something like that.
  16960. function sessionStorage_setItem(key, value, callback) {
  16961. key = normalizeKey(key);
  16962. const promise = this.ready().then(function () {
  16963. // Convert undefined values to null.
  16964. // https://github.com/mozilla/localForage/pull/42
  16965. if (value === undefined) {
  16966. value = null;
  16967. } // Save the original value to pass to the callback.
  16968. const originalValue = value;
  16969. return new Promise(function (resolve, reject) {
  16970. dbInfo.serializer.serialize(value, function (value, error) {
  16971. if (error) {
  16972. reject(error);
  16973. } else {
  16974. try {
  16975. sessionStorage.setItem(dbInfo.keyPrefix + key, value);
  16976. resolve(originalValue);
  16977. } catch (e) {
  16978. // sessionStorage capacity exceeded.
  16979. // TODO: Make this a specific error/event.
  16980. if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
  16981. reject(e);
  16982. }
  16983. reject(e);
  16984. }
  16985. }
  16986. });
  16987. });
  16988. });
  16989. utils_executeCallback(promise, callback);
  16990. return promise;
  16991. }
  16992. function sessionStorage_dropInstance(options, callback) {
  16993. callback = getCallback.apply(this, arguments);
  16994. options = typeof options !== 'function' && options || {};
  16995. if (!options.name) {
  16996. const currentConfig = this.config();
  16997. options.name = options.name || currentConfig.name;
  16998. options.storeName = options.storeName || currentConfig.storeName;
  16999. }
  17000. const self = this;
  17001. let promise;
  17002. if (!options.name) {
  17003. promise = Promise.reject(new Error('Invalid arguments'));
  17004. } else {
  17005. promise = new Promise(function (resolve) {
  17006. if (!options.storeName) {
  17007. resolve(`${options.name}/`);
  17008. } else {
  17009. resolve(sessionStorage_getKeyPrefix(options, self._defaultConfig));
  17010. }
  17011. }).then(function (keyPrefix) {
  17012. for (let i = sessionStorage.length - 1; i >= 0; i--) {
  17013. const key = sessionStorage.key(i);
  17014. if (key.indexOf(keyPrefix) === 0) {
  17015. sessionStorage.removeItem(key);
  17016. }
  17017. }
  17018. });
  17019. }
  17020. utils_executeCallback(promise, callback);
  17021. return promise;
  17022. }
  17023. const sessionStorageWrapper = {
  17024. _driver: 'sessionStorageWrapper',
  17025. _initStorage: sessionStorage_initStorage,
  17026. _support: isSessionStorageValid(),
  17027. iterate: sessionStorage_iterate,
  17028. getItem: sessionStorage_getItem,
  17029. setItem: sessionStorage_setItem,
  17030. removeItem: sessionStorage_removeItem,
  17031. clear: sessionStorage_clear,
  17032. length: sessionStorage_length,
  17033. key: sessionStorage_key,
  17034. keys: sessionStorage_keys,
  17035. dropInstance: sessionStorage_dropInstance
  17036. };
  17037. /* harmony default export */ const drivers_sessionStorage = (sessionStorageWrapper);
  17038. // EXTERNAL MODULE: ./node_modules/localforage-setitems/dist/localforage-setitems.js
  17039. var localforage_setitems = __webpack_require__(1459);
  17040. // EXTERNAL MODULE: ./node_modules/localforage-getitems/dist/localforage-getitems.js
  17041. var localforage_getitems = __webpack_require__(642);
  17042. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/storage.js
  17043. /**
  17044. * IndexedDB, localStorage and sessionStorage adapter
  17045. */
  17046. const IN_MEMORY = umd._driver;
  17047. localforage.defineDriver(umd);
  17048. (0,localforage_setitems.extendPrototype)(localforage);
  17049. (0,localforage_getitems.extendPrototype)(localforage);
  17050. function S4() {
  17051. // Generate four random hex digits.
  17052. return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
  17053. }
  17054. function guid() {
  17055. // Generate a pseudo-GUID by concatenating random hexadecimal.
  17056. return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
  17057. }
  17058. class Storage {
  17059. constructor(id, type) {
  17060. let batchedWrites = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  17061. if (type === 'local' && !window.localStorage) {
  17062. throw new Error("Skeletor.storage: Environment does not support localStorage.");
  17063. } else if (type === 'session' && !window.sessionStorage) {
  17064. throw new Error("Skeletor.storage: Environment does not support sessionStorage.");
  17065. }
  17066. if (lodash_es_isString(type)) {
  17067. this.storeInitialized = this.initStore(type, batchedWrites);
  17068. } else {
  17069. this.store = type;
  17070. if (batchedWrites) {
  17071. this.store.debouncedSetItems = mergebounce_mergebounce(items => this.store.setItems(items), 50, {
  17072. 'promise': true
  17073. });
  17074. }
  17075. this.storeInitialized = Promise.resolve();
  17076. }
  17077. this.name = id;
  17078. }
  17079. async initStore(type, batchedWrites) {
  17080. if (type === 'session') {
  17081. localforage.setDriver(drivers_sessionStorage._driver);
  17082. } else if (type === 'local') {
  17083. await localforage.config({
  17084. 'driver': localforage.LOCALSTORAGE
  17085. });
  17086. } else if (type === 'in_memory') {
  17087. localforage.config({
  17088. 'driver': IN_MEMORY
  17089. });
  17090. } else if (type !== 'indexed') {
  17091. throw new Error("Skeletor.storage: No storage type was specified");
  17092. }
  17093. this.store = localforage;
  17094. if (batchedWrites) {
  17095. this.store.debouncedSetItems = mergebounce_mergebounce(items => this.store.setItems(items), 50, {
  17096. 'promise': true
  17097. });
  17098. }
  17099. }
  17100. flush() {
  17101. var _this$store$debounced;
  17102. return (_this$store$debounced = this.store.debouncedSetItems) === null || _this$store$debounced === void 0 ? void 0 : _this$store$debounced.flush();
  17103. }
  17104. async clear() {
  17105. await this.store.removeItem(this.name).catch(e => console.error(e));
  17106. const re = new RegExp(`^${this.name}-`);
  17107. const keys = await this.store.keys();
  17108. const removed_keys = keys.filter(k => re.test(k));
  17109. await Promise.all(removed_keys.map(k => this.store.removeItem(k).catch(e => console.error(e))));
  17110. }
  17111. sync() {
  17112. const that = this;
  17113. async function localSync(method, model, options) {
  17114. let resp, errorMessage, promise, new_attributes; // We get the collection (and if necessary the model attribute.
  17115. // Waiting for storeInitialized will cause another iteration of
  17116. // the event loop, after which the collection reference will
  17117. // be removed from the model.
  17118. const collection = model.collection;
  17119. if (['patch', 'update'].includes(method)) {
  17120. new_attributes = lodash_es_cloneDeep(model.attributes);
  17121. }
  17122. await that.storeInitialized;
  17123. try {
  17124. const original_attributes = model.attributes;
  17125. switch (method) {
  17126. case "read":
  17127. if (model.id !== undefined) {
  17128. resp = await that.find(model);
  17129. } else {
  17130. resp = await that.findAll();
  17131. }
  17132. break;
  17133. case "create":
  17134. resp = await that.create(model, options);
  17135. break;
  17136. case 'patch':
  17137. case "update":
  17138. if (options.wait) {
  17139. // When `wait` is set to true, Skeletor waits until
  17140. // confirmation of storage before setting the values on
  17141. // the model.
  17142. // However, the new attributes needs to be sent, so it
  17143. // sets them manually on the model and then removes
  17144. // them after calling `sync`.
  17145. // Because our `sync` method is asynchronous and we
  17146. // wait for `storeInitialized`, the attributes are
  17147. // already restored once we get here, so we need to do
  17148. // the attributes dance again.
  17149. model.attributes = new_attributes;
  17150. }
  17151. promise = that.update(model, options);
  17152. if (options.wait) {
  17153. model.attributes = original_attributes;
  17154. }
  17155. resp = await promise;
  17156. break;
  17157. case "delete":
  17158. resp = await that.destroy(model, collection);
  17159. break;
  17160. }
  17161. } catch (error) {
  17162. if (error.code === 22 && that.getStorageSize() === 0) {
  17163. errorMessage = "Private browsing is unsupported";
  17164. } else {
  17165. errorMessage = error.message;
  17166. }
  17167. }
  17168. if (resp) {
  17169. if (options && options.success) {
  17170. // When storing, we don't pass back the response (which is
  17171. // the set attributes returned from localforage because
  17172. // Skeletor sets them again on the model and due to the async
  17173. // nature of localforage it can cause stale attributes to be
  17174. // set on a model after it's been updated in the meantime.
  17175. const data = method === "read" ? resp : null;
  17176. options.success(data, options);
  17177. }
  17178. } else {
  17179. errorMessage = errorMessage ? errorMessage : "Record Not Found";
  17180. if (options && options.error) {
  17181. options.error(errorMessage);
  17182. }
  17183. }
  17184. }
  17185. localSync.__name__ = 'localSync';
  17186. return localSync;
  17187. }
  17188. removeCollectionReference(model, collection) {
  17189. if (!collection) {
  17190. return;
  17191. }
  17192. const ids = collection.filter(m => m.id !== model.id).map(m => this.getItemName(m.id));
  17193. return this.store.setItem(this.name, ids);
  17194. }
  17195. addCollectionReference(model, collection) {
  17196. if (!collection) {
  17197. return;
  17198. }
  17199. const ids = collection.map(m => this.getItemName(m.id));
  17200. const new_id = this.getItemName(model.id);
  17201. if (!ids.includes(new_id)) {
  17202. ids.push(new_id);
  17203. }
  17204. return this.store.setItem(this.name, ids);
  17205. }
  17206. getCollectionReferenceData(model) {
  17207. if (!model.collection) {
  17208. return {};
  17209. }
  17210. const ids = model.collection.map(m => this.getItemName(m.id));
  17211. const new_id = this.getItemName(model.id);
  17212. if (!ids.includes(new_id)) {
  17213. ids.push(new_id);
  17214. }
  17215. const result = {};
  17216. result[this.name] = ids;
  17217. return result;
  17218. }
  17219. async save(model) {
  17220. if (this.store.setItems) {
  17221. const items = {};
  17222. items[this.getItemName(model.id)] = model.toJSON();
  17223. Object.assign(items, this.getCollectionReferenceData(model));
  17224. return this.store.debouncedSetItems ? this.store.debouncedSetItems(items) : this.store.setItems(items);
  17225. } else {
  17226. const key = this.getItemName(model.id);
  17227. const data = await this.store.setItem(key, model.toJSON());
  17228. await this.addCollectionReference(model, model.collection);
  17229. return data;
  17230. }
  17231. }
  17232. create(model, options) {
  17233. /* Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
  17234. * have an id of it's own.
  17235. */
  17236. if (!model.id) {
  17237. model.id = guid();
  17238. model.set(model.idAttribute, model.id, options);
  17239. }
  17240. return this.save(model);
  17241. }
  17242. update(model) {
  17243. return this.save(model);
  17244. }
  17245. find(model) {
  17246. return this.store.getItem(this.getItemName(model.id));
  17247. }
  17248. async findAll() {
  17249. /* Return the array of all models currently in storage.
  17250. */
  17251. const keys = await this.store.getItem(this.name);
  17252. if (keys !== null && keys !== void 0 && keys.length) {
  17253. const items = await this.store.getItems(keys);
  17254. return Object.values(items);
  17255. }
  17256. return [];
  17257. }
  17258. async destroy(model, collection) {
  17259. await this.flush();
  17260. await this.store.removeItem(this.getItemName(model.id));
  17261. await this.removeCollectionReference(model, collection);
  17262. return model;
  17263. }
  17264. getStorageSize() {
  17265. return this.store.length;
  17266. }
  17267. getItemName(id) {
  17268. return this.name + "-" + id;
  17269. }
  17270. }
  17271. Storage.sessionStorageInitialized = localforage.defineDriver(drivers_sessionStorage);
  17272. Storage.localForage = localforage;
  17273. /* harmony default export */ const storage = (Storage);
  17274. ;// CONCATENATED MODULE: ./src/headless/utils/storage.js
  17275. function getDefaultStore() {
  17276. if (shared_converse.config.get('trusted')) {
  17277. const is_non_persistent = core_api.settings.get('persistent_store') === 'sessionStorage';
  17278. return is_non_persistent ? 'session' : 'persistent';
  17279. } else {
  17280. return 'session';
  17281. }
  17282. }
  17283. function storeUsesIndexedDB(store) {
  17284. return store === 'persistent' && core_api.settings.get('persistent_store') === 'IndexedDB';
  17285. }
  17286. function createStore(id, store) {
  17287. const name = store || getDefaultStore();
  17288. const s = shared_converse.storage[name];
  17289. if (typeof s === 'undefined') {
  17290. throw new TypeError(`createStore: Could not find store for ${id}`);
  17291. }
  17292. return new storage(id, s, storeUsesIndexedDB(store));
  17293. }
  17294. function initStorage(model, id, type) {
  17295. const store = type || getDefaultStore();
  17296. model.browserStorage = createStore(id, store);
  17297. if (storeUsesIndexedDB(store)) {
  17298. const flush = () => model.browserStorage.flush();
  17299. window.addEventListener(shared_converse.unloadevent, flush);
  17300. model.on('destroy', () => window.removeEventListener(shared_converse.unloadevent, flush));
  17301. model.listenTo(shared_converse, 'beforeLogout', flush);
  17302. }
  17303. }
  17304. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isEqual.js
  17305. /**
  17306. * Performs a deep comparison between two values to determine if they are
  17307. * equivalent.
  17308. *
  17309. * **Note:** This method supports comparing arrays, array buffers, booleans,
  17310. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  17311. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  17312. * by their own, not inherited, enumerable properties. Functions and DOM
  17313. * nodes are compared by strict equality, i.e. `===`.
  17314. *
  17315. * @static
  17316. * @memberOf _
  17317. * @since 0.1.0
  17318. * @category Lang
  17319. * @param {*} value The value to compare.
  17320. * @param {*} other The other value to compare.
  17321. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  17322. * @example
  17323. *
  17324. * var object = { 'a': 1 };
  17325. * var other = { 'a': 1 };
  17326. *
  17327. * _.isEqual(object, other);
  17328. * // => true
  17329. *
  17330. * object === other;
  17331. * // => false
  17332. */
  17333. function isEqual(value, other) {
  17334. return _baseIsEqual(value, other);
  17335. }
  17336. /* harmony default export */ const lodash_es_isEqual = (isEqual);
  17337. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSet.js
  17338. /**
  17339. * The base implementation of `_.set`.
  17340. *
  17341. * @private
  17342. * @param {Object} object The object to modify.
  17343. * @param {Array|string} path The path of the property to set.
  17344. * @param {*} value The value to set.
  17345. * @param {Function} [customizer] The function to customize path creation.
  17346. * @returns {Object} Returns `object`.
  17347. */
  17348. function baseSet(object, path, value, customizer) {
  17349. if (!lodash_es_isObject(object)) {
  17350. return object;
  17351. }
  17352. path = _castPath(path, object);
  17353. var index = -1,
  17354. length = path.length,
  17355. lastIndex = length - 1,
  17356. nested = object;
  17357. while (nested != null && ++index < length) {
  17358. var key = _toKey(path[index]),
  17359. newValue = value;
  17360. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  17361. return object;
  17362. }
  17363. if (index != lastIndex) {
  17364. var objValue = nested[key];
  17365. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  17366. if (newValue === undefined) {
  17367. newValue = lodash_es_isObject(objValue)
  17368. ? objValue
  17369. : (_isIndex(path[index + 1]) ? [] : {});
  17370. }
  17371. }
  17372. _assignValue(nested, key, newValue);
  17373. nested = nested[key];
  17374. }
  17375. return object;
  17376. }
  17377. /* harmony default export */ const _baseSet = (baseSet);
  17378. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_basePickBy.js
  17379. /**
  17380. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  17381. *
  17382. * @private
  17383. * @param {Object} object The source object.
  17384. * @param {string[]} paths The property paths to pick.
  17385. * @param {Function} predicate The function invoked per property.
  17386. * @returns {Object} Returns the new object.
  17387. */
  17388. function basePickBy(object, paths, predicate) {
  17389. var index = -1,
  17390. length = paths.length,
  17391. result = {};
  17392. while (++index < length) {
  17393. var path = paths[index],
  17394. value = _baseGet(object, path);
  17395. if (predicate(value, path)) {
  17396. _baseSet(result, _castPath(path, object), value);
  17397. }
  17398. }
  17399. return result;
  17400. }
  17401. /* harmony default export */ const _basePickBy = (basePickBy);
  17402. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_basePick.js
  17403. /**
  17404. * The base implementation of `_.pick` without support for individual
  17405. * property identifiers.
  17406. *
  17407. * @private
  17408. * @param {Object} object The source object.
  17409. * @param {string[]} paths The property paths to pick.
  17410. * @returns {Object} Returns the new object.
  17411. */
  17412. function basePick(object, paths) {
  17413. return _basePickBy(object, paths, function(value, path) {
  17414. return lodash_es_hasIn(object, path);
  17415. });
  17416. }
  17417. /* harmony default export */ const _basePick = (basePick);
  17418. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_isFlattenable.js
  17419. /** Built-in value references. */
  17420. var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
  17421. /**
  17422. * Checks if `value` is a flattenable `arguments` object or array.
  17423. *
  17424. * @private
  17425. * @param {*} value The value to check.
  17426. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  17427. */
  17428. function isFlattenable(value) {
  17429. return lodash_es_isArray(value) || lodash_es_isArguments(value) ||
  17430. !!(spreadableSymbol && value && value[spreadableSymbol]);
  17431. }
  17432. /* harmony default export */ const _isFlattenable = (isFlattenable);
  17433. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseFlatten.js
  17434. /**
  17435. * The base implementation of `_.flatten` with support for restricting flattening.
  17436. *
  17437. * @private
  17438. * @param {Array} array The array to flatten.
  17439. * @param {number} depth The maximum recursion depth.
  17440. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  17441. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  17442. * @param {Array} [result=[]] The initial result value.
  17443. * @returns {Array} Returns the new flattened array.
  17444. */
  17445. function baseFlatten(array, depth, predicate, isStrict, result) {
  17446. var index = -1,
  17447. length = array.length;
  17448. predicate || (predicate = _isFlattenable);
  17449. result || (result = []);
  17450. while (++index < length) {
  17451. var value = array[index];
  17452. if (depth > 0 && predicate(value)) {
  17453. if (depth > 1) {
  17454. // Recursively flatten arrays (susceptible to call stack limits).
  17455. baseFlatten(value, depth - 1, predicate, isStrict, result);
  17456. } else {
  17457. _arrayPush(result, value);
  17458. }
  17459. } else if (!isStrict) {
  17460. result[result.length] = value;
  17461. }
  17462. }
  17463. return result;
  17464. }
  17465. /* harmony default export */ const _baseFlatten = (baseFlatten);
  17466. ;// CONCATENATED MODULE: ./node_modules/lodash-es/flatten.js
  17467. /**
  17468. * Flattens `array` a single level deep.
  17469. *
  17470. * @static
  17471. * @memberOf _
  17472. * @since 0.1.0
  17473. * @category Array
  17474. * @param {Array} array The array to flatten.
  17475. * @returns {Array} Returns the new flattened array.
  17476. * @example
  17477. *
  17478. * _.flatten([1, [2, [3, [4]], 5]]);
  17479. * // => [1, 2, [3, [4]], 5]
  17480. */
  17481. function flatten(array) {
  17482. var length = array == null ? 0 : array.length;
  17483. return length ? _baseFlatten(array, 1) : [];
  17484. }
  17485. /* harmony default export */ const lodash_es_flatten = (flatten);
  17486. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_flatRest.js
  17487. /**
  17488. * A specialized version of `baseRest` which flattens the rest array.
  17489. *
  17490. * @private
  17491. * @param {Function} func The function to apply a rest parameter to.
  17492. * @returns {Function} Returns the new function.
  17493. */
  17494. function flatRest(func) {
  17495. return _setToString(_overRest(func, undefined, lodash_es_flatten), func + '');
  17496. }
  17497. /* harmony default export */ const _flatRest = (flatRest);
  17498. ;// CONCATENATED MODULE: ./node_modules/lodash-es/pick.js
  17499. /**
  17500. * Creates an object composed of the picked `object` properties.
  17501. *
  17502. * @static
  17503. * @since 0.1.0
  17504. * @memberOf _
  17505. * @category Object
  17506. * @param {Object} object The source object.
  17507. * @param {...(string|string[])} [paths] The property paths to pick.
  17508. * @returns {Object} Returns the new object.
  17509. * @example
  17510. *
  17511. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17512. *
  17513. * _.pick(object, ['a', 'c']);
  17514. * // => { 'a': 1, 'c': 3 }
  17515. */
  17516. var pick = _flatRest(function(object, paths) {
  17517. return object == null ? {} : _basePick(object, paths);
  17518. });
  17519. /* harmony default export */ const lodash_es_pick = (pick);
  17520. // EXTERNAL MODULE: ./node_modules/dompurify/dist/purify.js
  17521. var purify = __webpack_require__(7856);
  17522. var purify_default = /*#__PURE__*/__webpack_require__.n(purify);
  17523. ;// CONCATENATED MODULE: ./node_modules/lodash-es/compact.js
  17524. /**
  17525. * Creates an array with all falsey values removed. The values `false`, `null`,
  17526. * `0`, `""`, `undefined`, and `NaN` are falsey.
  17527. *
  17528. * @static
  17529. * @memberOf _
  17530. * @since 0.1.0
  17531. * @category Array
  17532. * @param {Array} array The array to compact.
  17533. * @returns {Array} Returns the new array of filtered values.
  17534. * @example
  17535. *
  17536. * _.compact([0, 1, false, 2, '', 3]);
  17537. * // => [1, 2, 3]
  17538. */
  17539. function compact(array) {
  17540. var index = -1,
  17541. length = array == null ? 0 : array.length,
  17542. resIndex = 0,
  17543. result = [];
  17544. while (++index < length) {
  17545. var value = array[index];
  17546. if (value) {
  17547. result[resIndex++] = value;
  17548. }
  17549. }
  17550. return result;
  17551. }
  17552. /* harmony default export */ const lodash_es_compact = (compact);
  17553. ;// CONCATENATED MODULE: ./node_modules/lodash-es/last.js
  17554. /**
  17555. * Gets the last element of `array`.
  17556. *
  17557. * @static
  17558. * @memberOf _
  17559. * @since 0.1.0
  17560. * @category Array
  17561. * @param {Array} array The array to query.
  17562. * @returns {*} Returns the last element of `array`.
  17563. * @example
  17564. *
  17565. * _.last([1, 2, 3]);
  17566. * // => 3
  17567. */
  17568. function last(array) {
  17569. var length = array == null ? 0 : array.length;
  17570. return length ? array[length - 1] : undefined;
  17571. }
  17572. /* harmony default export */ const lodash_es_last = (last);
  17573. // EXTERNAL MODULE: ./node_modules/sizzle/dist/sizzle.js
  17574. var sizzle = __webpack_require__(1271);
  17575. var sizzle_default = /*#__PURE__*/__webpack_require__.n(sizzle);
  17576. ;// CONCATENATED MODULE: ./node_modules/lodash-es/clone.js
  17577. /** Used to compose bitmasks for cloning. */
  17578. var clone_CLONE_SYMBOLS_FLAG = 4;
  17579. /**
  17580. * Creates a shallow clone of `value`.
  17581. *
  17582. * **Note:** This method is loosely based on the
  17583. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  17584. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  17585. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  17586. * arrays. The own enumerable properties of `arguments` objects are cloned
  17587. * as plain objects. An empty object is returned for uncloneable values such
  17588. * as error objects, functions, DOM nodes, and WeakMaps.
  17589. *
  17590. * @static
  17591. * @memberOf _
  17592. * @since 0.1.0
  17593. * @category Lang
  17594. * @param {*} value The value to clone.
  17595. * @returns {*} Returns the cloned value.
  17596. * @see _.cloneDeep
  17597. * @example
  17598. *
  17599. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  17600. *
  17601. * var shallow = _.clone(objects);
  17602. * console.log(shallow[0] === objects[0]);
  17603. * // => true
  17604. */
  17605. function clone(value) {
  17606. return _baseClone(value, clone_CLONE_SYMBOLS_FLAG);
  17607. }
  17608. /* harmony default export */ const lodash_es_clone = (clone);
  17609. ;// CONCATENATED MODULE: ./node_modules/lodash-es/defaults.js
  17610. /** Used for built-in method references. */
  17611. var defaults_objectProto = Object.prototype;
  17612. /** Used to check objects for own properties. */
  17613. var defaults_hasOwnProperty = defaults_objectProto.hasOwnProperty;
  17614. /**
  17615. * Assigns own and inherited enumerable string keyed properties of source
  17616. * objects to the destination object for all destination properties that
  17617. * resolve to `undefined`. Source objects are applied from left to right.
  17618. * Once a property is set, additional values of the same property are ignored.
  17619. *
  17620. * **Note:** This method mutates `object`.
  17621. *
  17622. * @static
  17623. * @since 0.1.0
  17624. * @memberOf _
  17625. * @category Object
  17626. * @param {Object} object The destination object.
  17627. * @param {...Object} [sources] The source objects.
  17628. * @returns {Object} Returns `object`.
  17629. * @see _.defaultsDeep
  17630. * @example
  17631. *
  17632. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  17633. * // => { 'a': 1, 'b': 2 }
  17634. */
  17635. var defaults = _baseRest(function(object, sources) {
  17636. object = Object(object);
  17637. var index = -1;
  17638. var length = sources.length;
  17639. var guard = length > 2 ? sources[2] : undefined;
  17640. if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
  17641. length = 1;
  17642. }
  17643. while (++index < length) {
  17644. var source = sources[index];
  17645. var props = lodash_es_keysIn(source);
  17646. var propsIndex = -1;
  17647. var propsLength = props.length;
  17648. while (++propsIndex < propsLength) {
  17649. var key = props[propsIndex];
  17650. var value = object[key];
  17651. if (value === undefined ||
  17652. (lodash_es_eq(value, defaults_objectProto[key]) && !defaults_hasOwnProperty.call(object, key))) {
  17653. object[key] = source[key];
  17654. }
  17655. }
  17656. }
  17657. return object;
  17658. });
  17659. /* harmony default export */ const lodash_es_defaults = (defaults);
  17660. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseDelay.js
  17661. /** Error message constants. */
  17662. var _baseDelay_FUNC_ERROR_TEXT = 'Expected a function';
  17663. /**
  17664. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  17665. * to provide to `func`.
  17666. *
  17667. * @private
  17668. * @param {Function} func The function to delay.
  17669. * @param {number} wait The number of milliseconds to delay invocation.
  17670. * @param {Array} args The arguments to provide to `func`.
  17671. * @returns {number|Object} Returns the timer id or timeout object.
  17672. */
  17673. function baseDelay(func, wait, args) {
  17674. if (typeof func != 'function') {
  17675. throw new TypeError(_baseDelay_FUNC_ERROR_TEXT);
  17676. }
  17677. return setTimeout(function() { func.apply(undefined, args); }, wait);
  17678. }
  17679. /* harmony default export */ const _baseDelay = (baseDelay);
  17680. ;// CONCATENATED MODULE: ./node_modules/lodash-es/defer.js
  17681. /**
  17682. * Defers invoking the `func` until the current call stack has cleared. Any
  17683. * additional arguments are provided to `func` when it's invoked.
  17684. *
  17685. * @static
  17686. * @memberOf _
  17687. * @since 0.1.0
  17688. * @category Function
  17689. * @param {Function} func The function to defer.
  17690. * @param {...*} [args] The arguments to invoke `func` with.
  17691. * @returns {number} Returns the timer id.
  17692. * @example
  17693. *
  17694. * _.defer(function(text) {
  17695. * console.log(text);
  17696. * }, 'deferred');
  17697. * // => Logs 'deferred' after one millisecond.
  17698. */
  17699. var defer = _baseRest(function(func, args) {
  17700. return _baseDelay(func, 1, args);
  17701. });
  17702. /* harmony default export */ const lodash_es_defer = (defer);
  17703. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_basePropertyOf.js
  17704. /**
  17705. * The base implementation of `_.propertyOf` without support for deep paths.
  17706. *
  17707. * @private
  17708. * @param {Object} object The object to query.
  17709. * @returns {Function} Returns the new accessor function.
  17710. */
  17711. function basePropertyOf(object) {
  17712. return function(key) {
  17713. return object == null ? undefined : object[key];
  17714. };
  17715. }
  17716. /* harmony default export */ const _basePropertyOf = (basePropertyOf);
  17717. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_escapeHtmlChar.js
  17718. /** Used to map characters to HTML entities. */
  17719. var htmlEscapes = {
  17720. '&': '&amp;',
  17721. '<': '&lt;',
  17722. '>': '&gt;',
  17723. '"': '&quot;',
  17724. "'": '&#39;'
  17725. };
  17726. /**
  17727. * Used by `_.escape` to convert characters to HTML entities.
  17728. *
  17729. * @private
  17730. * @param {string} chr The matched character to escape.
  17731. * @returns {string} Returns the escaped character.
  17732. */
  17733. var escapeHtmlChar = _basePropertyOf(htmlEscapes);
  17734. /* harmony default export */ const _escapeHtmlChar = (escapeHtmlChar);
  17735. ;// CONCATENATED MODULE: ./node_modules/lodash-es/escape.js
  17736. /** Used to match HTML entities and HTML characters. */
  17737. var reUnescapedHtml = /[&<>"']/g,
  17738. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17739. /**
  17740. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  17741. * corresponding HTML entities.
  17742. *
  17743. * **Note:** No other characters are escaped. To escape additional
  17744. * characters use a third-party library like [_he_](https://mths.be/he).
  17745. *
  17746. * Though the ">" character is escaped for symmetry, characters like
  17747. * ">" and "/" don't need escaping in HTML and have no special meaning
  17748. * unless they're part of a tag or unquoted attribute value. See
  17749. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  17750. * (under "semi-related fun fact") for more details.
  17751. *
  17752. * When working with HTML you should always
  17753. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  17754. * XSS vectors.
  17755. *
  17756. * @static
  17757. * @since 0.1.0
  17758. * @memberOf _
  17759. * @category String
  17760. * @param {string} [string=''] The string to escape.
  17761. * @returns {string} Returns the escaped string.
  17762. * @example
  17763. *
  17764. * _.escape('fred, barney, & pebbles');
  17765. * // => 'fred, barney, &amp; pebbles'
  17766. */
  17767. function escape_escape(string) {
  17768. string = lodash_es_toString(string);
  17769. return (string && reHasUnescapedHtml.test(string))
  17770. ? string.replace(reUnescapedHtml, _escapeHtmlChar)
  17771. : string;
  17772. }
  17773. /* harmony default export */ const lodash_es_escape = (escape_escape);
  17774. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseInverter.js
  17775. /**
  17776. * The base implementation of `_.invert` and `_.invertBy` which inverts
  17777. * `object` with values transformed by `iteratee` and set by `setter`.
  17778. *
  17779. * @private
  17780. * @param {Object} object The object to iterate over.
  17781. * @param {Function} setter The function to set `accumulator` values.
  17782. * @param {Function} iteratee The iteratee to transform values.
  17783. * @param {Object} accumulator The initial inverted object.
  17784. * @returns {Function} Returns `accumulator`.
  17785. */
  17786. function baseInverter(object, setter, iteratee, accumulator) {
  17787. _baseForOwn(object, function(value, key, object) {
  17788. setter(accumulator, iteratee(value), key, object);
  17789. });
  17790. return accumulator;
  17791. }
  17792. /* harmony default export */ const _baseInverter = (baseInverter);
  17793. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createInverter.js
  17794. /**
  17795. * Creates a function like `_.invertBy`.
  17796. *
  17797. * @private
  17798. * @param {Function} setter The function to set accumulator values.
  17799. * @param {Function} toIteratee The function to resolve iteratees.
  17800. * @returns {Function} Returns the new inverter function.
  17801. */
  17802. function createInverter(setter, toIteratee) {
  17803. return function(object, iteratee) {
  17804. return _baseInverter(object, setter, toIteratee(iteratee), {});
  17805. };
  17806. }
  17807. /* harmony default export */ const _createInverter = (createInverter);
  17808. ;// CONCATENATED MODULE: ./node_modules/lodash-es/invert.js
  17809. /** Used for built-in method references. */
  17810. var invert_objectProto = Object.prototype;
  17811. /**
  17812. * Used to resolve the
  17813. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  17814. * of values.
  17815. */
  17816. var invert_nativeObjectToString = invert_objectProto.toString;
  17817. /**
  17818. * Creates an object composed of the inverted keys and values of `object`.
  17819. * If `object` contains duplicate values, subsequent values overwrite
  17820. * property assignments of previous values.
  17821. *
  17822. * @static
  17823. * @memberOf _
  17824. * @since 0.7.0
  17825. * @category Object
  17826. * @param {Object} object The object to invert.
  17827. * @returns {Object} Returns the new inverted object.
  17828. * @example
  17829. *
  17830. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  17831. *
  17832. * _.invert(object);
  17833. * // => { '1': 'c', '2': 'b' }
  17834. */
  17835. var invert = _createInverter(function(result, value, key) {
  17836. if (value != null &&
  17837. typeof value.toString != 'function') {
  17838. value = invert_nativeObjectToString.call(value);
  17839. }
  17840. result[value] = key;
  17841. }, lodash_es_constant(lodash_es_identity));
  17842. /* harmony default export */ const lodash_es_invert = (invert);
  17843. ;// CONCATENATED MODULE: ./node_modules/lodash-es/iteratee.js
  17844. /** Used to compose bitmasks for cloning. */
  17845. var iteratee_CLONE_DEEP_FLAG = 1;
  17846. /**
  17847. * Creates a function that invokes `func` with the arguments of the created
  17848. * function. If `func` is a property name, the created function returns the
  17849. * property value for a given element. If `func` is an array or object, the
  17850. * created function returns `true` for elements that contain the equivalent
  17851. * source properties, otherwise it returns `false`.
  17852. *
  17853. * @static
  17854. * @since 4.0.0
  17855. * @memberOf _
  17856. * @category Util
  17857. * @param {*} [func=_.identity] The value to convert to a callback.
  17858. * @returns {Function} Returns the callback.
  17859. * @example
  17860. *
  17861. * var users = [
  17862. * { 'user': 'barney', 'age': 36, 'active': true },
  17863. * { 'user': 'fred', 'age': 40, 'active': false }
  17864. * ];
  17865. *
  17866. * // The `_.matches` iteratee shorthand.
  17867. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  17868. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  17869. *
  17870. * // The `_.matchesProperty` iteratee shorthand.
  17871. * _.filter(users, _.iteratee(['user', 'fred']));
  17872. * // => [{ 'user': 'fred', 'age': 40 }]
  17873. *
  17874. * // The `_.property` iteratee shorthand.
  17875. * _.map(users, _.iteratee('user'));
  17876. * // => ['barney', 'fred']
  17877. *
  17878. * // Create custom iteratee shorthands.
  17879. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  17880. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  17881. * return func.test(string);
  17882. * };
  17883. * });
  17884. *
  17885. * _.filter(['abc', 'def'], /ef/);
  17886. * // => ['def']
  17887. */
  17888. function iteratee(func) {
  17889. return _baseIteratee(typeof func == 'function' ? func : _baseClone(func, iteratee_CLONE_DEEP_FLAG));
  17890. }
  17891. /* harmony default export */ const lodash_es_iteratee = (iteratee);
  17892. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSlice.js
  17893. /**
  17894. * The base implementation of `_.slice` without an iteratee call guard.
  17895. *
  17896. * @private
  17897. * @param {Array} array The array to slice.
  17898. * @param {number} [start=0] The start position.
  17899. * @param {number} [end=array.length] The end position.
  17900. * @returns {Array} Returns the slice of `array`.
  17901. */
  17902. function baseSlice(array, start, end) {
  17903. var index = -1,
  17904. length = array.length;
  17905. if (start < 0) {
  17906. start = -start > length ? 0 : (length + start);
  17907. }
  17908. end = end > length ? length : end;
  17909. if (end < 0) {
  17910. end += length;
  17911. }
  17912. length = start > end ? 0 : ((end - start) >>> 0);
  17913. start >>>= 0;
  17914. var result = Array(length);
  17915. while (++index < length) {
  17916. result[index] = array[index + start];
  17917. }
  17918. return result;
  17919. }
  17920. /* harmony default export */ const _baseSlice = (baseSlice);
  17921. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_parent.js
  17922. /**
  17923. * Gets the parent value at `path` of `object`.
  17924. *
  17925. * @private
  17926. * @param {Object} object The object to query.
  17927. * @param {Array} path The path to get the parent value of.
  17928. * @returns {*} Returns the parent value.
  17929. */
  17930. function _parent_parent(object, path) {
  17931. return path.length < 2 ? object : _baseGet(object, _baseSlice(path, 0, -1));
  17932. }
  17933. /* harmony default export */ const _parent = (_parent_parent);
  17934. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseUnset.js
  17935. /**
  17936. * The base implementation of `_.unset`.
  17937. *
  17938. * @private
  17939. * @param {Object} object The object to modify.
  17940. * @param {Array|string} path The property path to unset.
  17941. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17942. */
  17943. function baseUnset(object, path) {
  17944. path = _castPath(path, object);
  17945. object = _parent(object, path);
  17946. return object == null || delete object[_toKey(lodash_es_last(path))];
  17947. }
  17948. /* harmony default export */ const _baseUnset = (baseUnset);
  17949. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_customOmitClone.js
  17950. /**
  17951. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  17952. * objects.
  17953. *
  17954. * @private
  17955. * @param {*} value The value to inspect.
  17956. * @param {string} key The key of the property to inspect.
  17957. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  17958. */
  17959. function customOmitClone(value) {
  17960. return lodash_es_isPlainObject(value) ? undefined : value;
  17961. }
  17962. /* harmony default export */ const _customOmitClone = (customOmitClone);
  17963. ;// CONCATENATED MODULE: ./node_modules/lodash-es/omit.js
  17964. /** Used to compose bitmasks for cloning. */
  17965. var omit_CLONE_DEEP_FLAG = 1,
  17966. omit_CLONE_FLAT_FLAG = 2,
  17967. omit_CLONE_SYMBOLS_FLAG = 4;
  17968. /**
  17969. * The opposite of `_.pick`; this method creates an object composed of the
  17970. * own and inherited enumerable property paths of `object` that are not omitted.
  17971. *
  17972. * **Note:** This method is considerably slower than `_.pick`.
  17973. *
  17974. * @static
  17975. * @since 0.1.0
  17976. * @memberOf _
  17977. * @category Object
  17978. * @param {Object} object The source object.
  17979. * @param {...(string|string[])} [paths] The property paths to omit.
  17980. * @returns {Object} Returns the new object.
  17981. * @example
  17982. *
  17983. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17984. *
  17985. * _.omit(object, ['a', 'c']);
  17986. * // => { 'b': '2' }
  17987. */
  17988. var omit = _flatRest(function(object, paths) {
  17989. var result = {};
  17990. if (object == null) {
  17991. return result;
  17992. }
  17993. var isDeep = false;
  17994. paths = _arrayMap(paths, function(path) {
  17995. path = _castPath(path, object);
  17996. isDeep || (isDeep = path.length > 1);
  17997. return path;
  17998. });
  17999. _copyObject(object, _getAllKeysIn(object), result);
  18000. if (isDeep) {
  18001. result = _baseClone(result, omit_CLONE_DEEP_FLAG | omit_CLONE_FLAT_FLAG | omit_CLONE_SYMBOLS_FLAG, _customOmitClone);
  18002. }
  18003. var length = paths.length;
  18004. while (length--) {
  18005. _baseUnset(result, paths[length]);
  18006. }
  18007. return result;
  18008. });
  18009. /* harmony default export */ const lodash_es_omit = (omit);
  18010. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/model.js
  18011. // Backbone.js 1.4.0
  18012. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  18013. // Backbone may be freely distributed under the MIT license.
  18014. // Model
  18015. // -----
  18016. // **Models** are the basic data object in the framework --
  18017. // frequently representing a row in a table in a database on your server.
  18018. // A discrete chunk of data and a bunch of useful, related methods for
  18019. // performing computations and transformations on that data.
  18020. // Create a new model with the specified attributes. A client id (`cid`)
  18021. // is automatically generated and assigned for you.
  18022. const Model = function (attributes, options) {
  18023. let attrs = attributes || {};
  18024. options || (options = {});
  18025. this.preinitialize.apply(this, arguments);
  18026. this.cid = lodash_es_uniqueId(this.cidPrefix);
  18027. this.attributes = {};
  18028. if (options.collection) this.collection = options.collection;
  18029. if (options.parse) attrs = this.parse(attrs, options) || {};
  18030. const default_attrs = lodash_es_result(this, 'defaults');
  18031. attrs = lodash_es_defaults(lodash_es_assignIn({}, default_attrs, attrs), default_attrs);
  18032. this.set(attrs, options);
  18033. this.changed = {};
  18034. this.initialize.apply(this, arguments);
  18035. };
  18036. Model.extend = inherits; // Attach all inheritable methods to the Model prototype.
  18037. Object.assign(Model.prototype, Events, {
  18038. // A hash of attributes whose current and previous value differ.
  18039. changed: null,
  18040. // The value returned during the last failed validation.
  18041. validationError: null,
  18042. // The default name for the JSON `id` attribute is `"id"`. MongoDB and
  18043. // CouchDB users may want to set this to `"_id"`.
  18044. idAttribute: 'id',
  18045. // The prefix is used to create the client id which is used to identify models locally.
  18046. // You may want to override this if you're experiencing name clashes with model ids.
  18047. cidPrefix: 'c',
  18048. // preinitialize is an empty function by default. You can override it with a function
  18049. // or object. preinitialize will run before any instantiation logic is run in the Model.
  18050. preinitialize: function () {},
  18051. // Initialize is an empty function by default. Override it with your own
  18052. // initialization logic.
  18053. initialize: function () {},
  18054. // Return a copy of the model's `attributes` object.
  18055. toJSON: function (options) {
  18056. return lodash_es_clone(this.attributes);
  18057. },
  18058. // Proxy `Backbone.sync` by default -- but override this if you need
  18059. // custom syncing semantics for *this* particular model.
  18060. sync: function (method, model, options) {
  18061. return getSyncMethod(this)(method, model, options);
  18062. },
  18063. // Get the value of an attribute.
  18064. get: function (attr) {
  18065. return this.attributes[attr];
  18066. },
  18067. keys: function () {
  18068. return Object.keys(this.attributes);
  18069. },
  18070. values: function () {
  18071. return Object.values(this.attributes);
  18072. },
  18073. pairs: function () {
  18074. return this.entries();
  18075. },
  18076. entries: function () {
  18077. return Object.entries(this.attributes);
  18078. },
  18079. invert: function () {
  18080. return lodash_es_invert(this.attributes);
  18081. },
  18082. pick: function () {
  18083. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  18084. args[_key] = arguments[_key];
  18085. }
  18086. if (args.length === 1 && Array.isArray(args[0])) {
  18087. args = args[0];
  18088. }
  18089. return lodash_es_pick(this.attributes, args);
  18090. },
  18091. omit: function () {
  18092. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  18093. args[_key2] = arguments[_key2];
  18094. }
  18095. if (args.length === 1 && Array.isArray(args[0])) {
  18096. args = args[0];
  18097. }
  18098. return lodash_es_omit(this.attributes, args);
  18099. },
  18100. isEmpty: function () {
  18101. return lodash_es_isEmpty(this.attributes);
  18102. },
  18103. // Get the HTML-escaped value of an attribute.
  18104. escape: function (attr) {
  18105. return lodash_es_escape(this.get(attr));
  18106. },
  18107. // Returns `true` if the attribute contains a value that is not null
  18108. // or undefined.
  18109. has: function (attr) {
  18110. return this.get(attr) != null;
  18111. },
  18112. // Special-cased proxy to lodash's `matches` method.
  18113. matches: function (attrs) {
  18114. return !!lodash_es_iteratee(attrs, this)(this.attributes);
  18115. },
  18116. // Set a hash of model attributes on the object, firing `"change"`. This is
  18117. // the core primitive operation of a model, updating the data and notifying
  18118. // anyone who needs to know about the change in state. The heart of the beast.
  18119. set: function (key, val, options) {
  18120. if (key == null) return this; // Handle both `"key", value` and `{key: value}` -style arguments.
  18121. let attrs;
  18122. if (typeof key === 'object') {
  18123. attrs = key;
  18124. options = val;
  18125. } else {
  18126. (attrs = {})[key] = val;
  18127. }
  18128. options || (options = {}); // Run validation.
  18129. if (!this._validate(attrs, options)) return false; // Extract attributes and options.
  18130. const unset = options.unset;
  18131. const silent = options.silent;
  18132. const changes = [];
  18133. const changing = this._changing;
  18134. this._changing = true;
  18135. if (!changing) {
  18136. this._previousAttributes = lodash_es_clone(this.attributes);
  18137. this.changed = {};
  18138. }
  18139. const current = this.attributes;
  18140. const changed = this.changed;
  18141. const prev = this._previousAttributes; // For each `set` attribute, update or delete the current value.
  18142. for (const attr in attrs) {
  18143. val = attrs[attr];
  18144. if (!lodash_es_isEqual(current[attr], val)) changes.push(attr);
  18145. if (!lodash_es_isEqual(prev[attr], val)) {
  18146. changed[attr] = val;
  18147. } else {
  18148. delete changed[attr];
  18149. }
  18150. unset ? delete current[attr] : current[attr] = val;
  18151. } // Update the `id`.
  18152. if (this.idAttribute in attrs) this.id = this.get(this.idAttribute); // Trigger all relevant attribute changes.
  18153. if (!silent) {
  18154. if (changes.length) this._pending = options;
  18155. for (let i = 0; i < changes.length; i++) {
  18156. this.trigger('change:' + changes[i], this, current[changes[i]], options);
  18157. }
  18158. } // You might be wondering why there's a `while` loop here. Changes can
  18159. // be recursively nested within `"change"` events.
  18160. if (changing) return this;
  18161. if (!silent) {
  18162. while (this._pending) {
  18163. options = this._pending;
  18164. this._pending = false;
  18165. this.trigger('change', this, options);
  18166. }
  18167. }
  18168. this._pending = false;
  18169. this._changing = false;
  18170. return this;
  18171. },
  18172. // Remove an attribute from the model, firing `"change"`. `unset` is a noop
  18173. // if the attribute doesn't exist.
  18174. unset: function (attr, options) {
  18175. return this.set(attr, undefined, lodash_es_assignIn({}, options, {
  18176. unset: true
  18177. }));
  18178. },
  18179. // Clear all attributes on the model, firing `"change"`.
  18180. clear: function (options) {
  18181. const attrs = {};
  18182. for (const key in this.attributes) attrs[key] = undefined;
  18183. return this.set(attrs, lodash_es_assignIn({}, options, {
  18184. unset: true
  18185. }));
  18186. },
  18187. // Determine if the model has changed since the last `"change"` event.
  18188. // If you specify an attribute name, determine if that attribute has changed.
  18189. hasChanged: function (attr) {
  18190. if (attr == null) return !lodash_es_isEmpty(this.changed);
  18191. return lodash_es_has(this.changed, attr);
  18192. },
  18193. // Return an object containing all the attributes that have changed, or
  18194. // false if there are no changed attributes. Useful for determining what
  18195. // parts of a view need to be updated and/or what attributes need to be
  18196. // persisted to the server. Unset attributes will be set to undefined.
  18197. // You can also pass an attributes object to diff against the model,
  18198. // determining if there *would be* a change.
  18199. changedAttributes: function (diff) {
  18200. if (!diff) return this.hasChanged() ? lodash_es_clone(this.changed) : false;
  18201. const old = this._changing ? this._previousAttributes : this.attributes;
  18202. const changed = {};
  18203. let hasChanged;
  18204. for (const attr in diff) {
  18205. const val = diff[attr];
  18206. if (lodash_es_isEqual(old[attr], val)) continue;
  18207. changed[attr] = val;
  18208. hasChanged = true;
  18209. }
  18210. return hasChanged ? changed : false;
  18211. },
  18212. // Get the previous value of an attribute, recorded at the time the last
  18213. // `"change"` event was fired.
  18214. previous: function (attr) {
  18215. if (attr == null || !this._previousAttributes) return null;
  18216. return this._previousAttributes[attr];
  18217. },
  18218. // Get all of the attributes of the model at the time of the previous
  18219. // `"change"` event.
  18220. previousAttributes: function () {
  18221. return lodash_es_clone(this._previousAttributes);
  18222. },
  18223. // Fetch the model from the server, merging the response with the model's
  18224. // local attributes. Any changed attributes will trigger a "change" event.
  18225. fetch: function (options) {
  18226. options = lodash_es_assignIn({
  18227. parse: true
  18228. }, options);
  18229. const model = this;
  18230. const success = options.success;
  18231. options.success = function (resp) {
  18232. const serverAttrs = options.parse ? model.parse(resp, options) : resp;
  18233. if (!model.set(serverAttrs, options)) return false;
  18234. if (success) success.call(options.context, model, resp, options);
  18235. model.trigger('sync', model, resp, options);
  18236. };
  18237. wrapError(this, options);
  18238. return this.sync('read', this, options);
  18239. },
  18240. // Set a hash of model attributes, and sync the model to the server.
  18241. // If the server returns an attributes hash that differs, the model's
  18242. // state will be `set` again.
  18243. save: function (key, val, options) {
  18244. // Handle both `"key", value` and `{key: value}` -style arguments.
  18245. let attrs;
  18246. if (key == null || typeof key === 'object') {
  18247. attrs = key;
  18248. options = val;
  18249. } else {
  18250. (attrs = {})[key] = val;
  18251. }
  18252. options = lodash_es_assignIn({
  18253. validate: true,
  18254. parse: true
  18255. }, options);
  18256. const wait = options.wait;
  18257. const return_promise = options.promise;
  18258. const promise = return_promise && getResolveablePromise(); // If we're not waiting and attributes exist, save acts as
  18259. // `set(attr).save(null, opts)` with validation. Otherwise, check if
  18260. // the model will be valid when the attributes, if any, are set.
  18261. if (attrs && !wait) {
  18262. if (!this.set(attrs, options)) return false;
  18263. } else if (!this._validate(attrs, options)) {
  18264. return false;
  18265. } // After a successful server-side save, the client is (optionally)
  18266. // updated with the server-side state.
  18267. const model = this;
  18268. const success = options.success;
  18269. const error = options.error;
  18270. const attributes = this.attributes;
  18271. options.success = function (resp) {
  18272. // Ensure attributes are restored during synchronous saves.
  18273. model.attributes = attributes;
  18274. let serverAttrs = options.parse ? model.parse(resp, options) : resp;
  18275. if (wait) serverAttrs = lodash_es_assignIn({}, attrs, serverAttrs);
  18276. if (serverAttrs && !model.set(serverAttrs, options)) return false;
  18277. if (success) success.call(options.context, model, resp, options);
  18278. model.trigger('sync', model, resp, options);
  18279. return_promise && promise.resolve();
  18280. };
  18281. options.error = function (model, e, options) {
  18282. error && error.call(options.context, model, e, options);
  18283. return_promise && promise.reject(e);
  18284. };
  18285. wrapError(this, options); // Set temporary attributes if `{wait: true}` to properly find new ids.
  18286. if (attrs && wait) this.attributes = lodash_es_assignIn({}, attributes, attrs);
  18287. const method = this.isNew() ? 'create' : options.patch ? 'patch' : 'update';
  18288. if (method === 'patch' && !options.attrs) options.attrs = attrs;
  18289. const xhr = this.sync(method, this, options); // Restore attributes.
  18290. this.attributes = attributes;
  18291. if (return_promise) {
  18292. return promise;
  18293. } else {
  18294. return xhr;
  18295. }
  18296. },
  18297. // Destroy this model on the server if it was already persisted.
  18298. // Optimistically removes the model from its collection, if it has one.
  18299. // If `wait: true` is passed, waits for the server to respond before removal.
  18300. destroy: function (options) {
  18301. options = options ? lodash_es_clone(options) : {};
  18302. const model = this;
  18303. const success = options.success;
  18304. const wait = options.wait;
  18305. const destroy = function () {
  18306. model.stopListening();
  18307. model.trigger('destroy', model, model.collection, options);
  18308. };
  18309. options.success = function (resp) {
  18310. if (wait) destroy();
  18311. if (success) success.call(options.context, model, resp, options);
  18312. if (!model.isNew()) model.trigger('sync', model, resp, options);
  18313. };
  18314. let xhr = false;
  18315. if (this.isNew()) {
  18316. lodash_es_defer(options.success);
  18317. } else {
  18318. wrapError(this, options);
  18319. xhr = this.sync('delete', this, options);
  18320. }
  18321. if (!wait) destroy();
  18322. return xhr;
  18323. },
  18324. // Default URL for the model's representation on the server -- if you're
  18325. // using Backbone's restful methods, override this to change the endpoint
  18326. // that will be called.
  18327. url: function () {
  18328. const base = lodash_es_result(this, 'urlRoot') || lodash_es_result(this.collection, 'url') || urlError();
  18329. if (this.isNew()) return base;
  18330. const id = this.get(this.idAttribute);
  18331. return base.replace(/[^\/]$/, '$&/') + encodeURIComponent(id);
  18332. },
  18333. // **parse** converts a response into the hash of attributes to be `set` on
  18334. // the model. The default implementation is just to pass the response along.
  18335. parse: function (resp, options) {
  18336. return resp;
  18337. },
  18338. // Create a new model with identical attributes to this one.
  18339. clone: function () {
  18340. return new this.constructor(this.attributes);
  18341. },
  18342. // A model is new if it has never been saved to the server, and lacks an id.
  18343. isNew: function () {
  18344. return !this.has(this.idAttribute);
  18345. },
  18346. // Check if the model is currently in a valid state.
  18347. isValid: function (options) {
  18348. return this._validate({}, lodash_es_assignIn({}, options, {
  18349. validate: true
  18350. }));
  18351. },
  18352. // Run validation against the next complete set of model attributes,
  18353. // returning `true` if all is well. Otherwise, fire an `"invalid"` event.
  18354. _validate: function (attrs, options) {
  18355. if (!options.validate || !this.validate) return true;
  18356. attrs = lodash_es_assignIn({}, this.attributes, attrs);
  18357. const error = this.validationError = this.validate(attrs, options) || null;
  18358. if (!error) return true;
  18359. this.trigger('invalid', this, error, lodash_es_assignIn(options, {
  18360. validationError: error
  18361. }));
  18362. return false;
  18363. }
  18364. });
  18365. ;// CONCATENATED MODULE: ./node_modules/lodash-es/debounce.js
  18366. /** Error message constants. */
  18367. var debounce_FUNC_ERROR_TEXT = 'Expected a function';
  18368. /* Built-in method references for those with the same name as other `lodash` methods. */
  18369. var debounce_nativeMax = Math.max,
  18370. debounce_nativeMin = Math.min;
  18371. /**
  18372. * Creates a debounced function that delays invoking `func` until after `wait`
  18373. * milliseconds have elapsed since the last time the debounced function was
  18374. * invoked. The debounced function comes with a `cancel` method to cancel
  18375. * delayed `func` invocations and a `flush` method to immediately invoke them.
  18376. * Provide `options` to indicate whether `func` should be invoked on the
  18377. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  18378. * with the last arguments provided to the debounced function. Subsequent
  18379. * calls to the debounced function return the result of the last `func`
  18380. * invocation.
  18381. *
  18382. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  18383. * invoked on the trailing edge of the timeout only if the debounced function
  18384. * is invoked more than once during the `wait` timeout.
  18385. *
  18386. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  18387. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  18388. *
  18389. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  18390. * for details over the differences between `_.debounce` and `_.throttle`.
  18391. *
  18392. * @static
  18393. * @memberOf _
  18394. * @since 0.1.0
  18395. * @category Function
  18396. * @param {Function} func The function to debounce.
  18397. * @param {number} [wait=0] The number of milliseconds to delay.
  18398. * @param {Object} [options={}] The options object.
  18399. * @param {boolean} [options.leading=false]
  18400. * Specify invoking on the leading edge of the timeout.
  18401. * @param {number} [options.maxWait]
  18402. * The maximum time `func` is allowed to be delayed before it's invoked.
  18403. * @param {boolean} [options.trailing=true]
  18404. * Specify invoking on the trailing edge of the timeout.
  18405. * @returns {Function} Returns the new debounced function.
  18406. * @example
  18407. *
  18408. * // Avoid costly calculations while the window size is in flux.
  18409. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  18410. *
  18411. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  18412. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  18413. * 'leading': true,
  18414. * 'trailing': false
  18415. * }));
  18416. *
  18417. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  18418. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  18419. * var source = new EventSource('/stream');
  18420. * jQuery(source).on('message', debounced);
  18421. *
  18422. * // Cancel the trailing debounced invocation.
  18423. * jQuery(window).on('popstate', debounced.cancel);
  18424. */
  18425. function debounce(func, wait, options) {
  18426. var lastArgs,
  18427. lastThis,
  18428. maxWait,
  18429. result,
  18430. timerId,
  18431. lastCallTime,
  18432. lastInvokeTime = 0,
  18433. leading = false,
  18434. maxing = false,
  18435. trailing = true;
  18436. if (typeof func != 'function') {
  18437. throw new TypeError(debounce_FUNC_ERROR_TEXT);
  18438. }
  18439. wait = lodash_es_toNumber(wait) || 0;
  18440. if (lodash_es_isObject(options)) {
  18441. leading = !!options.leading;
  18442. maxing = 'maxWait' in options;
  18443. maxWait = maxing ? debounce_nativeMax(lodash_es_toNumber(options.maxWait) || 0, wait) : maxWait;
  18444. trailing = 'trailing' in options ? !!options.trailing : trailing;
  18445. }
  18446. function invokeFunc(time) {
  18447. var args = lastArgs,
  18448. thisArg = lastThis;
  18449. lastArgs = lastThis = undefined;
  18450. lastInvokeTime = time;
  18451. result = func.apply(thisArg, args);
  18452. return result;
  18453. }
  18454. function leadingEdge(time) {
  18455. // Reset any `maxWait` timer.
  18456. lastInvokeTime = time;
  18457. // Start the timer for the trailing edge.
  18458. timerId = setTimeout(timerExpired, wait);
  18459. // Invoke the leading edge.
  18460. return leading ? invokeFunc(time) : result;
  18461. }
  18462. function remainingWait(time) {
  18463. var timeSinceLastCall = time - lastCallTime,
  18464. timeSinceLastInvoke = time - lastInvokeTime,
  18465. timeWaiting = wait - timeSinceLastCall;
  18466. return maxing
  18467. ? debounce_nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  18468. : timeWaiting;
  18469. }
  18470. function shouldInvoke(time) {
  18471. var timeSinceLastCall = time - lastCallTime,
  18472. timeSinceLastInvoke = time - lastInvokeTime;
  18473. // Either this is the first call, activity has stopped and we're at the
  18474. // trailing edge, the system time has gone backwards and we're treating
  18475. // it as the trailing edge, or we've hit the `maxWait` limit.
  18476. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  18477. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  18478. }
  18479. function timerExpired() {
  18480. var time = lodash_es_now();
  18481. if (shouldInvoke(time)) {
  18482. return trailingEdge(time);
  18483. }
  18484. // Restart the timer.
  18485. timerId = setTimeout(timerExpired, remainingWait(time));
  18486. }
  18487. function trailingEdge(time) {
  18488. timerId = undefined;
  18489. // Only invoke if we have `lastArgs` which means `func` has been
  18490. // debounced at least once.
  18491. if (trailing && lastArgs) {
  18492. return invokeFunc(time);
  18493. }
  18494. lastArgs = lastThis = undefined;
  18495. return result;
  18496. }
  18497. function cancel() {
  18498. if (timerId !== undefined) {
  18499. clearTimeout(timerId);
  18500. }
  18501. lastInvokeTime = 0;
  18502. lastArgs = lastCallTime = lastThis = timerId = undefined;
  18503. }
  18504. function flush() {
  18505. return timerId === undefined ? result : trailingEdge(lodash_es_now());
  18506. }
  18507. function debounced() {
  18508. var time = lodash_es_now(),
  18509. isInvoking = shouldInvoke(time);
  18510. lastArgs = arguments;
  18511. lastThis = this;
  18512. lastCallTime = time;
  18513. if (isInvoking) {
  18514. if (timerId === undefined) {
  18515. return leadingEdge(lastCallTime);
  18516. }
  18517. if (maxing) {
  18518. // Handle invocations in a tight loop.
  18519. clearTimeout(timerId);
  18520. timerId = setTimeout(timerExpired, wait);
  18521. return invokeFunc(lastCallTime);
  18522. }
  18523. }
  18524. if (timerId === undefined) {
  18525. timerId = setTimeout(timerExpired, wait);
  18526. }
  18527. return result;
  18528. }
  18529. debounced.cancel = cancel;
  18530. debounced.flush = flush;
  18531. return debounced;
  18532. }
  18533. /* harmony default export */ const lodash_es_debounce = (debounce);
  18534. // EXTERNAL MODULE: ./node_modules/localforage-webextensionstorage-driver/local.js
  18535. var local = __webpack_require__(7002);
  18536. // EXTERNAL MODULE: ./node_modules/localforage-webextensionstorage-driver/sync.js
  18537. var localforage_webextensionstorage_driver_sync = __webpack_require__(1063);
  18538. ;// CONCATENATED MODULE: ./src/headless/shared/connection/index.js
  18539. const i = Object.keys(Strophe.Status).reduce((max, k) => Math.max(max, Strophe.Status[k]), 0);
  18540. Strophe.Status.RECONNECTING = i + 1;
  18541. /**
  18542. * The Connection class manages the connection to the XMPP server. It's
  18543. * agnostic concerning the underlying protocol (i.e. websocket, long-polling
  18544. * via BOSH or websocket inside a shared worker).
  18545. */
  18546. class Connection extends Strophe.Connection {
  18547. constructor(service, options) {
  18548. super(service, options);
  18549. this.debouncedReconnect = lodash_es_debounce(this.reconnect, 3000);
  18550. }
  18551. static generateResource() {
  18552. return `/converse.js-${Math.floor(Math.random() * 139749528).toString()}`;
  18553. }
  18554. async bind() {
  18555. /**
  18556. * Synchronous event triggered before we send an IQ to bind the user's
  18557. * JID resource for this session.
  18558. * @event _converse#beforeResourceBinding
  18559. */
  18560. await core_api.trigger('beforeResourceBinding', {
  18561. 'synchronous': true
  18562. });
  18563. super.bind();
  18564. }
  18565. async onDomainDiscovered(response) {
  18566. const text = await response.text();
  18567. const xrd = new window.DOMParser().parseFromString(text, "text/xml").firstElementChild;
  18568. if (xrd.nodeName != "XRD" || xrd.namespaceURI != "http://docs.oasis-open.org/ns/xri/xrd-1.0") {
  18569. return headless_log.warn("Could not discover XEP-0156 connection methods");
  18570. }
  18571. const bosh_links = sizzle_default()(`Link[rel="urn:xmpp:alt-connections:xbosh"]`, xrd);
  18572. const ws_links = sizzle_default()(`Link[rel="urn:xmpp:alt-connections:websocket"]`, xrd);
  18573. const bosh_methods = bosh_links.map(el => el.getAttribute('href'));
  18574. const ws_methods = ws_links.map(el => el.getAttribute('href'));
  18575. if (bosh_methods.length === 0 && ws_methods.length === 0) {
  18576. headless_log.warn("Neither BOSH nor WebSocket connection methods have been specified with XEP-0156.");
  18577. } else {
  18578. // TODO: support multiple endpoints
  18579. core_api.settings.set("websocket_url", ws_methods.pop());
  18580. core_api.settings.set('bosh_service_url', bosh_methods.pop());
  18581. this.service = core_api.settings.get("websocket_url") || core_api.settings.get('bosh_service_url');
  18582. this.setProtocol();
  18583. }
  18584. }
  18585. /**
  18586. * Adds support for XEP-0156 by quering the XMPP server for alternate
  18587. * connection methods. This allows users to use the websocket or BOSH
  18588. * connection of their own XMPP server instead of a proxy provided by the
  18589. * host of Converse.js.
  18590. * @method Connnection.discoverConnectionMethods
  18591. */
  18592. async discoverConnectionMethods(domain) {
  18593. // Use XEP-0156 to check whether this host advertises websocket or BOSH connection methods.
  18594. const options = {
  18595. 'mode': 'cors',
  18596. 'headers': {
  18597. 'Accept': 'application/xrd+xml, text/xml'
  18598. }
  18599. };
  18600. const url = `https://${domain}/.well-known/host-meta`;
  18601. let response;
  18602. try {
  18603. response = await fetch(url, options);
  18604. } catch (e) {
  18605. headless_log.error(`Failed to discover alternative connection methods at ${url}`);
  18606. headless_log.error(e);
  18607. return;
  18608. }
  18609. if (response.status >= 200 && response.status < 400) {
  18610. await this.onDomainDiscovered(response);
  18611. } else {
  18612. headless_log.warn("Could not discover XEP-0156 connection methods");
  18613. }
  18614. }
  18615. /**
  18616. * Establish a new XMPP session by logging in with the supplied JID and
  18617. * password.
  18618. * @method Connnection.connect
  18619. * @param { String } jid
  18620. * @param { String } password
  18621. * @param { Funtion } callback
  18622. */
  18623. async connect(jid, password, callback) {
  18624. if (core_api.settings.get("discover_connection_methods")) {
  18625. const domain = Strophe.getDomainFromJid(jid);
  18626. await this.discoverConnectionMethods(domain);
  18627. }
  18628. if (!core_api.settings.get('bosh_service_url') && !core_api.settings.get("websocket_url")) {
  18629. throw new Error("You must supply a value for either the bosh_service_url or websocket_url or both.");
  18630. }
  18631. super.connect(jid, password, callback || this.onConnectStatusChanged, BOSH_WAIT);
  18632. }
  18633. /**
  18634. * Switch to a different transport if a service URL is available for it.
  18635. *
  18636. * When reconnecting with a new transport, we call setUserJID
  18637. * so that a new resource is generated, to avoid multiple
  18638. * server-side sessions with the same resource.
  18639. *
  18640. * We also call `_proto._doDisconnect` so that connection event handlers
  18641. * for the old transport are removed.
  18642. */
  18643. async switchTransport() {
  18644. if (core_api.connection.isType('websocket') && core_api.settings.get('bosh_service_url')) {
  18645. await setUserJID(shared_converse.bare_jid);
  18646. this._proto._doDisconnect();
  18647. this._proto = new Strophe.Bosh(this);
  18648. this.service = core_api.settings.get('bosh_service_url');
  18649. } else if (core_api.connection.isType('bosh') && core_api.settings.get("websocket_url")) {
  18650. if (core_api.settings.get("authentication") === shared_converse.ANONYMOUS) {
  18651. // When reconnecting anonymously, we need to connect with only
  18652. // the domain, not the full JID that we had in our previous
  18653. // (now failed) session.
  18654. await setUserJID(core_api.settings.get("jid"));
  18655. } else {
  18656. await setUserJID(shared_converse.bare_jid);
  18657. }
  18658. this._proto._doDisconnect();
  18659. this._proto = new Strophe.Websocket(this);
  18660. this.service = core_api.settings.get("websocket_url");
  18661. }
  18662. }
  18663. async reconnect() {
  18664. headless_log.debug('RECONNECTING: the connection has dropped, attempting to reconnect.');
  18665. this.reconnecting = true;
  18666. await tearDown();
  18667. const conn_status = shared_converse.connfeedback.get('connection_status');
  18668. if (conn_status === Strophe.Status.CONNFAIL) {
  18669. this.switchTransport();
  18670. } else if (conn_status === Strophe.Status.AUTHFAIL && core_api.settings.get("authentication") === shared_converse.ANONYMOUS) {
  18671. // When reconnecting anonymously, we need to connect with only
  18672. // the domain, not the full JID that we had in our previous
  18673. // (now failed) session.
  18674. await setUserJID(core_api.settings.get("jid"));
  18675. }
  18676. /**
  18677. * Triggered when the connection has dropped, but Converse will attempt
  18678. * to reconnect again.
  18679. * @event _converse#will-reconnect
  18680. */
  18681. core_api.trigger('will-reconnect');
  18682. if (core_api.settings.get("authentication") === shared_converse.ANONYMOUS) {
  18683. await clearSession();
  18684. }
  18685. return core_api.user.login();
  18686. }
  18687. /**
  18688. * Called as soon as a new connection has been established, either
  18689. * by logging in or by attaching to an existing BOSH session.
  18690. * @method Connection.onConnected
  18691. * @param { Boolean } reconnecting - Whether Converse.js reconnected from an earlier dropped session.
  18692. */
  18693. async onConnected(reconnecting) {
  18694. delete this.reconnecting;
  18695. this.flush(); // Solves problem of returned PubSub BOSH response not received by browser
  18696. await setUserJID(this.jid);
  18697. /**
  18698. * Synchronous event triggered after we've sent an IQ to bind the
  18699. * user's JID resource for this session.
  18700. * @event _converse#afterResourceBinding
  18701. */
  18702. await core_api.trigger('afterResourceBinding', reconnecting, {
  18703. 'synchronous': true
  18704. });
  18705. if (reconnecting) {
  18706. /**
  18707. * After the connection has dropped and converse.js has reconnected.
  18708. * Any Strophe stanza handlers (as registered via `converse.listen.stanza`) will
  18709. * have to be registered anew.
  18710. * @event _converse#reconnected
  18711. * @example _converse.api.listen.on('reconnected', () => { ... });
  18712. */
  18713. core_api.trigger('reconnected');
  18714. } else {
  18715. /**
  18716. * Triggered after the connection has been established and Converse
  18717. * has got all its ducks in a row.
  18718. * @event _converse#initialized
  18719. */
  18720. core_api.trigger('connected');
  18721. }
  18722. }
  18723. /**
  18724. * Used to keep track of why we got disconnected, so that we can
  18725. * decide on what the next appropriate action is (in onDisconnected)
  18726. * @method Connection.setDisconnectionCause
  18727. * @param { Number } cause - The status number as received from Strophe.
  18728. * @param { String } [reason] - An optional user-facing message as to why
  18729. * there was a disconnection.
  18730. * @param { Boolean } [override] - An optional flag to replace any previous
  18731. * disconnection cause and reason.
  18732. */
  18733. setDisconnectionCause(cause, reason, override) {
  18734. if (cause === undefined) {
  18735. delete this.disconnection_cause;
  18736. delete this.disconnection_reason;
  18737. } else if (this.disconnection_cause === undefined || override) {
  18738. this.disconnection_cause = cause;
  18739. this.disconnection_reason = reason;
  18740. }
  18741. }
  18742. setConnectionStatus(status, message) {
  18743. this.status = status;
  18744. shared_converse.connfeedback.set({
  18745. 'connection_status': status,
  18746. message
  18747. });
  18748. }
  18749. async finishDisconnection() {
  18750. // Properly tear down the session so that it's possible to manually connect again.
  18751. headless_log.debug('DISCONNECTED');
  18752. delete this.reconnecting;
  18753. this.reset();
  18754. tearDown();
  18755. await clearSession();
  18756. delete shared_converse.connection;
  18757. /**
  18758. * Triggered after converse.js has disconnected from the XMPP server.
  18759. * @event _converse#disconnected
  18760. * @memberOf _converse
  18761. * @example _converse.api.listen.on('disconnected', () => { ... });
  18762. */
  18763. core_api.trigger('disconnected');
  18764. }
  18765. /**
  18766. * Gets called once strophe's status reaches Strophe.Status.DISCONNECTED.
  18767. * Will either start a teardown process for converse.js or attempt
  18768. * to reconnect.
  18769. * @method onDisconnected
  18770. */
  18771. onDisconnected() {
  18772. if (core_api.settings.get("auto_reconnect")) {
  18773. const reason = this.disconnection_reason;
  18774. if (this.disconnection_cause === Strophe.Status.AUTHFAIL) {
  18775. if (core_api.settings.get("credentials_url") || core_api.settings.get("authentication") === shared_converse.ANONYMOUS) {
  18776. // If `credentials_url` is set, we reconnect, because we might
  18777. // be receiving expirable tokens from the credentials_url.
  18778. //
  18779. // If `authentication` is anonymous, we reconnect because we
  18780. // might have tried to attach with stale BOSH session tokens
  18781. // or with a cached JID and password
  18782. return core_api.connection.reconnect();
  18783. } else {
  18784. return this.finishDisconnection();
  18785. }
  18786. } else if (this.status === Strophe.Status.CONNECTING) {
  18787. // Don't try to reconnect if we were never connected to begin
  18788. // with, otherwise an infinite loop can occur (e.g. when the
  18789. // BOSH service URL returns a 404).
  18790. const {
  18791. __
  18792. } = shared_converse;
  18793. this.setConnectionStatus(Strophe.Status.CONNFAIL, __('An error occurred while connecting to the chat server.'));
  18794. return this.finishDisconnection();
  18795. } else if (this.disconnection_cause === shared_converse.LOGOUT || reason === Strophe.ErrorCondition.NO_AUTH_MECH || reason === "host-unknown" || reason === "remote-connection-failed") {
  18796. return this.finishDisconnection();
  18797. }
  18798. core_api.connection.reconnect();
  18799. } else {
  18800. return this.finishDisconnection();
  18801. }
  18802. }
  18803. /**
  18804. * Callback method called by Strophe as the Connection goes
  18805. * through various states while establishing or tearing down a
  18806. * connection.
  18807. * @param { Number } status
  18808. * @param { String } message
  18809. */
  18810. onConnectStatusChanged(status, message) {
  18811. const {
  18812. __
  18813. } = shared_converse;
  18814. headless_log.debug(`Status changed to: ${shared_converse.CONNECTION_STATUS[status]}`);
  18815. if (status === Strophe.Status.ATTACHFAIL) {
  18816. var _this$worker_attach_p;
  18817. this.setConnectionStatus(status);
  18818. (_this$worker_attach_p = this.worker_attach_promise) === null || _this$worker_attach_p === void 0 ? void 0 : _this$worker_attach_p.resolve(false);
  18819. } else if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED) {
  18820. var _this$worker_attach_p2, _this$worker_attach_p3;
  18821. if ((_this$worker_attach_p2 = this.worker_attach_promise) !== null && _this$worker_attach_p2 !== void 0 && _this$worker_attach_p2.isResolved && this.status === Strophe.Status.ATTACHED) {
  18822. // A different tab must have attached, so nothing to do for us here.
  18823. return;
  18824. }
  18825. this.setConnectionStatus(status);
  18826. (_this$worker_attach_p3 = this.worker_attach_promise) === null || _this$worker_attach_p3 === void 0 ? void 0 : _this$worker_attach_p3.resolve(true); // By default we always want to send out an initial presence stanza.
  18827. shared_converse.send_initial_presence = true;
  18828. this.setDisconnectionCause();
  18829. if (this.reconnecting) {
  18830. headless_log.debug(status === Strophe.Status.CONNECTED ? 'Reconnected' : 'Reattached');
  18831. this.onConnected(true);
  18832. } else {
  18833. headless_log.debug(status === Strophe.Status.CONNECTED ? 'Connected' : 'Attached');
  18834. if (this.restored) {
  18835. // No need to send an initial presence stanza when
  18836. // we're restoring an existing session.
  18837. shared_converse.send_initial_presence = false;
  18838. }
  18839. this.onConnected();
  18840. }
  18841. } else if (status === Strophe.Status.DISCONNECTED) {
  18842. this.setDisconnectionCause(status, message);
  18843. this.onDisconnected();
  18844. } else if (status === Strophe.Status.BINDREQUIRED) {
  18845. this.bind();
  18846. } else if (status === Strophe.Status.ERROR) {
  18847. this.setConnectionStatus(status, __('An error occurred while connecting to the chat server.'));
  18848. } else if (status === Strophe.Status.CONNECTING) {
  18849. this.setConnectionStatus(status);
  18850. } else if (status === Strophe.Status.AUTHENTICATING) {
  18851. this.setConnectionStatus(status);
  18852. } else if (status === Strophe.Status.AUTHFAIL) {
  18853. if (!message) {
  18854. message = __('Your XMPP address and/or password is incorrect. Please try again.');
  18855. }
  18856. this.setConnectionStatus(status, message);
  18857. this.setDisconnectionCause(status, message, true);
  18858. this.onDisconnected();
  18859. } else if (status === Strophe.Status.CONNFAIL) {
  18860. var _Strophe$ErrorConditi;
  18861. let feedback = message;
  18862. if (message === "host-unknown" || message == "remote-connection-failed") {
  18863. feedback = __("Sorry, we could not connect to the XMPP host with domain: %1$s", `\"${Strophe.getDomainFromJid(this.jid)}\"`);
  18864. } else if (message !== undefined && message === (Strophe === null || Strophe === void 0 ? void 0 : (_Strophe$ErrorConditi = Strophe.ErrorCondition) === null || _Strophe$ErrorConditi === void 0 ? void 0 : _Strophe$ErrorConditi.NO_AUTH_MECH)) {
  18865. feedback = __("The XMPP server did not offer a supported authentication mechanism");
  18866. }
  18867. this.setConnectionStatus(status, feedback);
  18868. this.setDisconnectionCause(status, message);
  18869. } else if (status === Strophe.Status.DISCONNECTING) {
  18870. this.setDisconnectionCause(status, message);
  18871. }
  18872. }
  18873. isType(type) {
  18874. if (type.toLowerCase() === 'websocket') {
  18875. return this._proto instanceof Strophe.Websocket;
  18876. } else if (type.toLowerCase() === 'bosh') {
  18877. return Strophe.Bosh && this._proto instanceof Strophe.Bosh;
  18878. }
  18879. }
  18880. hasResumed() {
  18881. var _api$settings$get;
  18882. if ((_api$settings$get = core_api.settings.get("connection_options")) !== null && _api$settings$get !== void 0 && _api$settings$get.worker || this.isType('bosh')) {
  18883. return shared_converse.connfeedback.get('connection_status') === Strophe.Status.ATTACHED;
  18884. } else {
  18885. // Not binding means that the session was resumed.
  18886. return !this.do_bind;
  18887. }
  18888. }
  18889. restoreWorkerSession() {
  18890. this.attach(this.onConnectStatusChanged);
  18891. this.worker_attach_promise = getOpenPromise();
  18892. return this.worker_attach_promise;
  18893. }
  18894. }
  18895. /**
  18896. * The MockConnection class is used during testing, to mock an XMPP connection.
  18897. * @class
  18898. */
  18899. class MockConnection extends Connection {
  18900. constructor(service, options) {
  18901. super(service, options);
  18902. this.sent_stanzas = [];
  18903. this.IQ_stanzas = [];
  18904. this.IQ_ids = [];
  18905. this.features = Strophe.xmlHtmlNode('<stream:features xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">' + '<ver xmlns="urn:xmpp:features:rosterver"/>' + '<csi xmlns="urn:xmpp:csi:0"/>' + '<this xmlns="http://jabber.org/protocol/caps" ver="UwBpfJpEt3IoLYfWma/o/p3FFRo=" hash="sha-1" node="http://prosody.im"/>' + '<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">' + '<required/>' + '</bind>' + `<sm xmlns='urn:xmpp:sm:3'/>` + '<session xmlns="urn:ietf:params:xml:ns:xmpp-session">' + '<optional/>' + '</session>' + '</stream:features>').firstChild;
  18906. this._proto._processRequest = () => {};
  18907. this._proto._disconnect = () => this._onDisconnectTimeout();
  18908. this._proto._onDisconnectTimeout = () => {};
  18909. this._proto._connect = () => {
  18910. this.connected = true;
  18911. this.mock = true;
  18912. this.jid = 'romeo@montague.lit/orchard';
  18913. this._changeConnectStatus(Strophe.Status.BINDREQUIRED);
  18914. };
  18915. }
  18916. _processRequest() {// eslint-disable-line class-methods-use-this
  18917. // Don't attempt to send out stanzas
  18918. }
  18919. sendIQ(iq, callback, errback) {
  18920. if (!lodash_es_isElement(iq)) {
  18921. iq = iq.nodeTree;
  18922. }
  18923. this.IQ_stanzas.push(iq);
  18924. const id = super.sendIQ(iq, callback, errback);
  18925. this.IQ_ids.push(id);
  18926. return id;
  18927. }
  18928. send(stanza) {
  18929. if (lodash_es_isElement(stanza)) {
  18930. this.sent_stanzas.push(stanza);
  18931. } else {
  18932. this.sent_stanzas.push(stanza.nodeTree);
  18933. }
  18934. return super.send(stanza);
  18935. }
  18936. async bind() {
  18937. await core_api.trigger('beforeResourceBinding', {
  18938. 'synchronous': true
  18939. });
  18940. this.authenticated = true;
  18941. if (!shared_converse.no_connection_on_bind) {
  18942. this._changeConnectStatus(Strophe.Status.CONNECTED);
  18943. }
  18944. }
  18945. }
  18946. ;// CONCATENATED MODULE: ./src/headless/utils/init.js
  18947. function initPlugins(_converse) {
  18948. // If initialize gets called a second time (e.g. during tests), then we
  18949. // need to re-apply all plugins (for a new converse instance), and we
  18950. // therefore need to clear this array that prevents plugins from being
  18951. // initialized twice.
  18952. // If initialize is called for the first time, then this array is empty
  18953. // in any case.
  18954. _converse.pluggable.initialized_plugins = [];
  18955. const whitelist = CORE_PLUGINS.concat(_converse.api.settings.get("whitelisted_plugins"));
  18956. if (_converse.api.settings.get("singleton")) {
  18957. ['converse-bookmarks', 'converse-controlbox', 'converse-headline', 'converse-register'].forEach(name => _converse.api.settings.get("blacklisted_plugins").push(name));
  18958. }
  18959. _converse.pluggable.initializePlugins({
  18960. _converse
  18961. }, whitelist, _converse.api.settings.get("blacklisted_plugins"));
  18962. /**
  18963. * Triggered once all plugins have been initialized. This is a useful event if you want to
  18964. * register event handlers but would like your own handlers to be overridable by
  18965. * plugins. In that case, you need to first wait until all plugins have been
  18966. * initialized, so that their overrides are active. One example where this is used
  18967. * is in [converse-notifications.js](https://github.com/jcbrand/converse.js/blob/master/src/converse-notification.js)`.
  18968. *
  18969. * Also available as an [ES2015 Promise](http://es6-features.org/#PromiseUsage)
  18970. * which can be listened to with `_converse.api.waitUntil`.
  18971. *
  18972. * @event _converse#pluginsInitialized
  18973. * @memberOf _converse
  18974. * @example _converse.api.listen.on('pluginsInitialized', () => { ... });
  18975. */
  18976. _converse.api.trigger('pluginsInitialized');
  18977. }
  18978. async function initClientConfig(_converse) {
  18979. /* The client config refers to configuration of the client which is
  18980. * independent of any particular user.
  18981. * What this means is that config values need to persist across
  18982. * user sessions.
  18983. */
  18984. const id = 'converse.client-config';
  18985. _converse.config = new Model({
  18986. id,
  18987. 'trusted': true
  18988. });
  18989. _converse.config.browserStorage = createStore(id, "session");
  18990. await new Promise(r => _converse.config.fetch({
  18991. 'success': r,
  18992. 'error': r
  18993. }));
  18994. /**
  18995. * Triggered once the XMPP-client configuration has been initialized.
  18996. * The client configuration is independent of any particular and its values
  18997. * persist across user sessions.
  18998. *
  18999. * @event _converse#clientConfigInitialized
  19000. * @example
  19001. * _converse.api.listen.on('clientConfigInitialized', () => { ... });
  19002. */
  19003. _converse.api.trigger('clientConfigInitialized');
  19004. }
  19005. async function initSessionStorage(_converse) {
  19006. await storage.sessionStorageInitialized;
  19007. _converse.storage = {
  19008. 'session': storage.localForage.createInstance({
  19009. 'name': _converse.isTestEnv() ? 'converse-test-session' : 'converse-session',
  19010. 'description': 'sessionStorage instance',
  19011. 'driver': ['sessionStorageWrapper']
  19012. })
  19013. };
  19014. }
  19015. function initPersistentStorage(_converse, store_name) {
  19016. if (_converse.api.settings.get('persistent_store') === 'sessionStorage') {
  19017. return;
  19018. } else if (_converse.api.settings.get("persistent_store") === 'BrowserExtLocal') {
  19019. storage.localForage.defineDriver(local/* default */.Z).then(() => storage.localForage.setDriver('webExtensionLocalStorage'));
  19020. _converse.storage['persistent'] = storage.localForage;
  19021. return;
  19022. } else if (_converse.api.settings.get("persistent_store") === 'BrowserExtSync') {
  19023. storage.localForage.defineDriver(localforage_webextensionstorage_driver_sync/* default */.Z).then(() => storage.localForage.setDriver('webExtensionSyncStorage'));
  19024. _converse.storage['persistent'] = storage.localForage;
  19025. return;
  19026. }
  19027. const config = {
  19028. 'name': _converse.isTestEnv() ? 'converse-test-persistent' : 'converse-persistent',
  19029. 'storeName': store_name
  19030. };
  19031. if (_converse.api.settings.get("persistent_store") === 'localStorage') {
  19032. config['description'] = 'localStorage instance';
  19033. config['driver'] = [storage.localForage.LOCALSTORAGE];
  19034. } else if (_converse.api.settings.get("persistent_store") === 'IndexedDB') {
  19035. config['description'] = 'indexedDB instance';
  19036. config['driver'] = [storage.localForage.INDEXEDDB];
  19037. }
  19038. _converse.storage['persistent'] = storage.localForage.createInstance(config);
  19039. }
  19040. function saveJIDtoSession(_converse, jid) {
  19041. jid = _converse.session.get('jid') || jid;
  19042. if (_converse.api.settings.get("authentication") !== _converse.ANONYMOUS && !Strophe.getResourceFromJid(jid)) {
  19043. jid = jid.toLowerCase() + Connection.generateResource();
  19044. }
  19045. _converse.jid = jid;
  19046. _converse.bare_jid = Strophe.getBareJidFromJid(jid);
  19047. _converse.resource = Strophe.getResourceFromJid(jid);
  19048. _converse.domain = Strophe.getDomainFromJid(jid);
  19049. _converse.session.save({
  19050. 'jid': jid,
  19051. 'bare_jid': _converse.bare_jid,
  19052. 'resource': _converse.resource,
  19053. 'domain': _converse.domain,
  19054. // We use the `active` flag to determine whether we should use the values from sessionStorage.
  19055. // When "cloning" a tab (e.g. via middle-click), the `active` flag will be set and we'll create
  19056. // a new empty user session, otherwise it'll be false and we can re-use the user session.
  19057. 'active': true
  19058. }); // Set JID on the connection object so that when we call `connection.bind`
  19059. // the new resource is found by Strophe.js and sent to the XMPP server.
  19060. _converse.connection.jid = jid;
  19061. }
  19062. /**
  19063. * Stores the passed in JID for the current user, potentially creating a
  19064. * resource if the JID is bare.
  19065. *
  19066. * Given that we can only create an XMPP connection if we know the domain of
  19067. * the server connect to and we only know this once we know the JID, we also
  19068. * call {@link _converse.initConnection } (if necessary) to make sure that the
  19069. * connection is set up.
  19070. *
  19071. * @emits _converse#setUserJID
  19072. * @params { String } jid
  19073. */
  19074. async function setUserJID(jid) {
  19075. await initSession(shared_converse, jid);
  19076. /**
  19077. * Triggered whenever the user's JID has been updated
  19078. * @event _converse#setUserJID
  19079. */
  19080. shared_converse.api.trigger('setUserJID');
  19081. return jid;
  19082. }
  19083. async function initSession(_converse, jid) {
  19084. var _converse$session;
  19085. const is_shared_session = _converse.api.settings.get('connection_options').worker;
  19086. const bare_jid = Strophe.getBareJidFromJid(jid).toLowerCase();
  19087. const id = `converse.session-${bare_jid}`;
  19088. if (((_converse$session = _converse.session) === null || _converse$session === void 0 ? void 0 : _converse$session.get('id')) !== id) {
  19089. initPersistentStorage(_converse, bare_jid);
  19090. _converse.session = new Model({
  19091. id
  19092. });
  19093. initStorage(_converse.session, id, is_shared_session ? "persistent" : "session");
  19094. await new Promise(r => _converse.session.fetch({
  19095. 'success': r,
  19096. 'error': r
  19097. }));
  19098. if (!is_shared_session && _converse.session.get('active')) {
  19099. // If the `active` flag is set, it means this tab was cloned from
  19100. // another (e.g. via middle-click), and its session data was copied over.
  19101. _converse.session.clear();
  19102. _converse.session.save({
  19103. id
  19104. });
  19105. }
  19106. saveJIDtoSession(_converse, jid);
  19107. /**
  19108. * Triggered once the user's session has been initialized. The session is a
  19109. * cache which stores information about the user's current session.
  19110. * @event _converse#userSessionInitialized
  19111. * @memberOf _converse
  19112. */
  19113. _converse.api.trigger('userSessionInitialized');
  19114. } else {
  19115. saveJIDtoSession(_converse, jid);
  19116. }
  19117. }
  19118. function registerGlobalEventHandlers(_converse) {
  19119. document.addEventListener("visibilitychange", _converse.saveWindowState);
  19120. _converse.saveWindowState({
  19121. 'type': document.hidden ? "blur" : "focus"
  19122. }); // Set initial state
  19123. /**
  19124. * Called once Converse has registered its global event handlers
  19125. * (for events such as window resize or unload).
  19126. * Plugins can listen to this event as cue to register their own
  19127. * global event handlers.
  19128. * @event _converse#registeredGlobalEventHandlers
  19129. * @example _converse.api.listen.on('registeredGlobalEventHandlers', () => { ... });
  19130. */
  19131. _converse.api.trigger('registeredGlobalEventHandlers');
  19132. }
  19133. function unregisterGlobalEventHandlers(_converse) {
  19134. const {
  19135. api
  19136. } = _converse;
  19137. document.removeEventListener("visibilitychange", _converse.saveWindowState);
  19138. api.trigger('unregisteredGlobalEventHandlers');
  19139. } // Make sure everything is reset in case this is a subsequent call to
  19140. // converse.initialize (happens during tests).
  19141. async function cleanup(_converse) {
  19142. var _converse$connection;
  19143. const {
  19144. api
  19145. } = _converse;
  19146. await api.trigger('cleanup', {
  19147. 'synchronous': true
  19148. });
  19149. _converse.router.history.stop();
  19150. unregisterGlobalEventHandlers(_converse);
  19151. (_converse$connection = _converse.connection) === null || _converse$connection === void 0 ? void 0 : _converse$connection.reset();
  19152. _converse.stopListening();
  19153. _converse.off();
  19154. if (_converse.promises['initialized'].isResolved) {
  19155. api.promises.add('initialized');
  19156. }
  19157. }
  19158. async function getLoginCredentials() {
  19159. let credentials;
  19160. let wait = 0;
  19161. while (!credentials) {
  19162. try {
  19163. credentials = await fetchLoginCredentials(wait); // eslint-disable-line no-await-in-loop
  19164. } catch (e) {
  19165. headless_log.error('Could not fetch login credentials');
  19166. headless_log.error(e);
  19167. } // If unsuccessful, we wait 2 seconds between subsequent attempts to
  19168. // fetch the credentials.
  19169. wait = 2000;
  19170. }
  19171. return credentials;
  19172. }
  19173. function fetchLoginCredentials() {
  19174. let wait = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  19175. return new Promise(lodash_es_debounce(async (resolve, reject) => {
  19176. let xhr = new XMLHttpRequest();
  19177. xhr.open('GET', shared_converse.api.settings.get("credentials_url"), true);
  19178. xhr.setRequestHeader('Accept', 'application/json, text/javascript');
  19179. xhr.onload = () => {
  19180. if (xhr.status >= 200 && xhr.status < 400) {
  19181. const data = JSON.parse(xhr.responseText);
  19182. setUserJID(data.jid).then(() => {
  19183. resolve({
  19184. jid: data.jid,
  19185. password: data.password
  19186. });
  19187. });
  19188. } else {
  19189. reject(new Error(`${xhr.status}: ${xhr.responseText}`));
  19190. }
  19191. };
  19192. xhr.onerror = reject;
  19193. /**
  19194. * *Hook* which allows modifying the server request
  19195. * @event _converse#beforeFetchLoginCredentials
  19196. */
  19197. xhr = await shared_converse.api.hook('beforeFetchLoginCredentials', this, xhr);
  19198. xhr.send();
  19199. }, wait));
  19200. }
  19201. async function attemptNonPreboundSession(credentials, automatic) {
  19202. const {
  19203. api
  19204. } = shared_converse;
  19205. if (api.settings.get("authentication") === shared_converse.LOGIN) {
  19206. // XXX: If EITHER ``keepalive`` or ``auto_login`` is ``true`` and
  19207. // ``authentication`` is set to ``login``, then Converse will try to log the user in,
  19208. // since we don't have a way to distinguish between wether we're
  19209. // restoring a previous session (``keepalive``) or whether we're
  19210. // automatically setting up a new session (``auto_login``).
  19211. // So we can't do the check (!automatic || _converse.api.settings.get("auto_login")) here.
  19212. if (credentials) {
  19213. connect(credentials);
  19214. } else if (api.settings.get("credentials_url")) {
  19215. // We give credentials_url preference, because
  19216. // _converse.connection.pass might be an expired token.
  19217. connect(await getLoginCredentials());
  19218. } else if (shared_converse.jid && (api.settings.get("password") || shared_converse.connection.pass)) {
  19219. connect();
  19220. } else if (!shared_converse.isTestEnv() && 'credentials' in navigator) {
  19221. connect(await getLoginCredentialsFromBrowser());
  19222. } else {
  19223. !shared_converse.isTestEnv() && headless_log.warn("attemptNonPreboundSession: Couldn't find credentials to log in with");
  19224. }
  19225. } else if ([shared_converse.ANONYMOUS, shared_converse.EXTERNAL].includes(api.settings.get("authentication")) && (!automatic || api.settings.get("auto_login"))) {
  19226. connect();
  19227. }
  19228. }
  19229. function getConnectionServiceURL() {
  19230. const {
  19231. api
  19232. } = shared_converse;
  19233. if (('WebSocket' in window || 'MozWebSocket' in window) && api.settings.get("websocket_url")) {
  19234. return api.settings.get('websocket_url');
  19235. } else if (api.settings.get('bosh_service_url')) {
  19236. return api.settings.get('bosh_service_url');
  19237. }
  19238. return '';
  19239. }
  19240. function connect(credentials) {
  19241. const {
  19242. api
  19243. } = shared_converse;
  19244. if ([shared_converse.ANONYMOUS, shared_converse.EXTERNAL].includes(api.settings.get("authentication"))) {
  19245. if (!shared_converse.jid) {
  19246. throw new Error("Config Error: when using anonymous login " + "you need to provide the server's domain via the 'jid' option. " + "Either when calling converse.initialize, or when calling " + "_converse.api.user.login.");
  19247. }
  19248. if (!shared_converse.connection.reconnecting) {
  19249. shared_converse.connection.reset();
  19250. }
  19251. shared_converse.connection.connect(shared_converse.jid.toLowerCase());
  19252. } else if (api.settings.get("authentication") === shared_converse.LOGIN) {
  19253. var _converse$connection2;
  19254. const password = (credentials === null || credentials === void 0 ? void 0 : credentials.password) ?? (((_converse$connection2 = shared_converse.connection) === null || _converse$connection2 === void 0 ? void 0 : _converse$connection2.pass) || api.settings.get("password"));
  19255. if (!password) {
  19256. if (api.settings.get("auto_login")) {
  19257. throw new Error("autoLogin: If you use auto_login and " + "authentication='login' then you also need to provide a password.");
  19258. }
  19259. shared_converse.connection.setDisconnectionCause(Strophe.Status.AUTHFAIL, undefined, true);
  19260. api.connection.disconnect();
  19261. return;
  19262. }
  19263. if (!shared_converse.connection.reconnecting) {
  19264. shared_converse.connection.reset();
  19265. shared_converse.connection.service = getConnectionServiceURL();
  19266. }
  19267. shared_converse.connection.connect(shared_converse.jid, password);
  19268. }
  19269. }
  19270. ;// CONCATENATED MODULE: ./src/headless/shared/settings/api.js
  19271. /**
  19272. * This grouping allows access to the
  19273. * [configuration settings](/docs/html/configuration.html#configuration-settings)
  19274. * of Converse.
  19275. *
  19276. * @namespace _converse.api.settings
  19277. * @memberOf _converse.api
  19278. */
  19279. const settings_api = {
  19280. /**
  19281. * Allows new configuration settings to be specified, or new default values for
  19282. * existing configuration settings to be specified.
  19283. *
  19284. * Note, calling this method *after* converse.initialize has been
  19285. * called will *not* change the initialization settings provided via
  19286. * `converse.initialize`.
  19287. *
  19288. * @method _converse.api.settings.extend
  19289. * @param {object} settings The configuration settings
  19290. * @example
  19291. * _converse.api.settings.extend({
  19292. * 'enable_foo': true
  19293. * });
  19294. *
  19295. * // The user can then override the default value of the configuration setting when
  19296. * // calling `converse.initialize`.
  19297. * converse.initialize({
  19298. * 'enable_foo': false
  19299. * });
  19300. */
  19301. extend(settings) {
  19302. return extendAppSettings(settings);
  19303. },
  19304. update(settings) {
  19305. headless_log.warn('The api.settings.update method has been deprecated and will be removed. ' + 'Please use api.settings.extend instead.');
  19306. return this.extend(settings);
  19307. },
  19308. /**
  19309. * @method _converse.api.settings.get
  19310. * @returns {*} Value of the particular configuration setting.
  19311. * @example _converse.api.settings.get("play_sounds");
  19312. */
  19313. get(key) {
  19314. return getAppSetting(key);
  19315. },
  19316. /**
  19317. * Set one or many configuration settings.
  19318. *
  19319. * Note, this is not an alternative to calling {@link converse.initialize}, which still needs
  19320. * to be called. Generally, you'd use this method after Converse is already
  19321. * running and you want to change the configuration on-the-fly.
  19322. *
  19323. * @method _converse.api.settings.set
  19324. * @param {Object} [settings] An object containing configuration settings.
  19325. * @param {string} [key] Alternatively to passing in an object, you can pass in a key and a value.
  19326. * @param {string} [value]
  19327. * @example _converse.api.settings.set("play_sounds", true);
  19328. * @example
  19329. * _converse.api.settings.set({
  19330. * "play_sounds": true,
  19331. * "hide_offline_users": true
  19332. * });
  19333. */
  19334. set(key, val) {
  19335. updateAppSettings(key, val);
  19336. },
  19337. /**
  19338. * The `listen` namespace exposes methods for creating event listeners
  19339. * (aka handlers) for events related to settings.
  19340. *
  19341. * @namespace _converse.api.settings.listen
  19342. * @memberOf _converse.api.settings
  19343. */
  19344. listen: {
  19345. /**
  19346. * Register an event listener for the passed in event.
  19347. * @method _converse.api.settings.listen.on
  19348. * @param { ('change') } name - The name of the event to listen for.
  19349. * Currently there is only the 'change' event.
  19350. * @param { Function } handler - The event handler function
  19351. * @param { Object } [context] - The context of the `this` attribute of the
  19352. * handler function.
  19353. * @example _converse.api.settings.listen.on('change', callback);
  19354. */
  19355. on(name, handler, context) {
  19356. registerListener(name, handler, context);
  19357. },
  19358. /**
  19359. * To stop listening to an event, you can use the `not` method.
  19360. * @method _converse.api.settings.listen.not
  19361. * @param { String } name The event's name
  19362. * @param { Function } callback The callback method that is to no longer be called when the event fires
  19363. * @example _converse.api.settings.listen.not('change', callback);
  19364. */
  19365. not(name, handler) {
  19366. unregisterListener(name, handler);
  19367. }
  19368. }
  19369. };
  19370. /**
  19371. * API for accessing and setting user settings. User settings are
  19372. * different from the application settings from {@link _converse.api.settings}
  19373. * because they are per-user and set via user action.
  19374. * @namespace _converse.api.user.settings
  19375. * @memberOf _converse.api.user
  19376. */
  19377. const user_settings_api = {
  19378. /**
  19379. * Returns the user settings model. Useful when you want to listen for change events.
  19380. * @async
  19381. * @method _converse.api.user.settings.getModel
  19382. * @returns {Promise<Model>}
  19383. * @example const settings = await _converse.api.user.settings.getModel();
  19384. */
  19385. getModel() {
  19386. return getUserSettings();
  19387. },
  19388. /**
  19389. * Get the value of a particular user setting.
  19390. * @method _converse.api.user.settings.get
  19391. * @param {String} key - The setting name
  19392. * @param {*} [fallback] - An optional fallback value if the user setting is undefined
  19393. * @returns {Promise} Promise which resolves with the value of the particular configuration setting.
  19394. * @example _converse.api.user.settings.get("foo");
  19395. */
  19396. async get(key, fallback) {
  19397. const user_settings = await getUserSettings();
  19398. return user_settings.get(key) === undefined ? fallback : user_settings.get(key);
  19399. },
  19400. /**
  19401. * Set one or many user settings.
  19402. * @async
  19403. * @method _converse.api.user.settings.set
  19404. * @param {Object} [settings] An object containing configuration settings.
  19405. * @param {string} [key] Alternatively to passing in an object, you can pass in a key and a value.
  19406. * @param {string} [value]
  19407. * @example _converse.api.user.settings.set("foo", "bar");
  19408. * @example
  19409. * _converse.api.user.settings.set({
  19410. * "foo": "bar",
  19411. * "baz": "buz"
  19412. * });
  19413. */
  19414. set(key, val) {
  19415. if (lodash_es_isObject(key)) {
  19416. return updateUserSettings(key, {
  19417. 'promise': true
  19418. });
  19419. } else {
  19420. const o = {};
  19421. o[key] = val;
  19422. return updateUserSettings(o, {
  19423. 'promise': true
  19424. });
  19425. }
  19426. },
  19427. /**
  19428. * Clears all the user settings
  19429. * @async
  19430. * @method _converse.api.user.settings.clear
  19431. */
  19432. clear() {
  19433. return clearUserSettings();
  19434. }
  19435. };
  19436. ;// CONCATENATED MODULE: ./src/headless/utils/core.js
  19437. /**
  19438. * @copyright The Converse.js contributors
  19439. * @license Mozilla Public License (MPLv2)
  19440. * @description This is the core utilities module.
  19441. */
  19442. function isEmptyMessage(attrs) {
  19443. if (attrs instanceof Model) {
  19444. attrs = attrs.attributes;
  19445. }
  19446. return !attrs['oob_url'] && !attrs['file'] && !(attrs['is_encrypted'] && attrs['plaintext']) && !attrs['message'];
  19447. }
  19448. /* We distinguish between UniView and MultiView instances.
  19449. *
  19450. * UniView means that only one chat is visible, even though there might be multiple ongoing chats.
  19451. * MultiView means that multiple chats may be visible simultaneously.
  19452. */
  19453. function isUniView() {
  19454. return ['mobile', 'fullscreen', 'embedded'].includes(settings_api.get("view_mode"));
  19455. }
  19456. async function tearDown() {
  19457. await shared_converse.api.trigger('beforeTearDown', {
  19458. 'synchronous': true
  19459. });
  19460. window.removeEventListener('click', shared_converse.onUserActivity);
  19461. window.removeEventListener('focus', shared_converse.onUserActivity);
  19462. window.removeEventListener('keypress', shared_converse.onUserActivity);
  19463. window.removeEventListener('mousemove', shared_converse.onUserActivity);
  19464. window.removeEventListener(shared_converse.unloadevent, shared_converse.onUserActivity);
  19465. window.clearInterval(shared_converse.everySecondTrigger);
  19466. shared_converse.api.trigger('afterTearDown');
  19467. return shared_converse;
  19468. }
  19469. /**
  19470. * The utils object
  19471. * @namespace u
  19472. */
  19473. const u = {};
  19474. u.isTagEqual = function (stanza, name) {
  19475. if (stanza.nodeTree) {
  19476. return u.isTagEqual(stanza.nodeTree, name);
  19477. } else if (!(stanza instanceof Element)) {
  19478. throw Error("isTagEqual called with value which isn't " + "an element or Strophe.Builder instance");
  19479. } else {
  19480. return Strophe.isTagEqual(stanza, name);
  19481. }
  19482. };
  19483. const parser = new DOMParser();
  19484. const parserErrorNS = parser.parseFromString('invalid', 'text/xml').getElementsByTagName("parsererror")[0].namespaceURI;
  19485. u.getJIDFromURI = function (jid) {
  19486. return jid.startsWith('xmpp:') && jid.endsWith('?join') ? jid.replace(/^xmpp:/, '').replace(/\?join$/, '') : jid;
  19487. };
  19488. u.toStanza = function (string) {
  19489. const node = parser.parseFromString(string, "text/xml");
  19490. if (node.getElementsByTagNameNS(parserErrorNS, 'parsererror').length) {
  19491. throw new Error(`Parser Error: ${string}`);
  19492. }
  19493. return node.firstElementChild;
  19494. };
  19495. u.getLongestSubstring = function (string, candidates) {
  19496. function reducer(accumulator, current_value) {
  19497. if (string.startsWith(current_value)) {
  19498. if (current_value.length > accumulator.length) {
  19499. return current_value;
  19500. } else {
  19501. return accumulator;
  19502. }
  19503. } else {
  19504. return accumulator;
  19505. }
  19506. }
  19507. return candidates.reduce(reducer, '');
  19508. };
  19509. /**
  19510. * Given a message object, return its text with @ chars
  19511. * inserted before the mentioned nicknames.
  19512. */
  19513. function prefixMentions(message) {
  19514. let text = message.getMessageText();
  19515. (message.get('references') || []).sort((a, b) => b.begin - a.begin).forEach(ref => {
  19516. text = `${text.slice(0, ref.begin)}@${text.slice(ref.begin)}`;
  19517. });
  19518. return text;
  19519. }
  19520. u.isValidJID = function (jid) {
  19521. if (typeof jid === 'string') {
  19522. return lodash_es_compact(jid.split('@')).length === 2 && !jid.startsWith('@') && !jid.endsWith('@');
  19523. }
  19524. return false;
  19525. };
  19526. u.isValidMUCJID = function (jid) {
  19527. return !jid.startsWith('@') && !jid.endsWith('@');
  19528. };
  19529. u.isSameBareJID = function (jid1, jid2) {
  19530. if (typeof jid1 !== 'string' || typeof jid2 !== 'string') {
  19531. return false;
  19532. }
  19533. return Strophe.getBareJidFromJid(jid1).toLowerCase() === Strophe.getBareJidFromJid(jid2).toLowerCase();
  19534. };
  19535. u.isSameDomain = function (jid1, jid2) {
  19536. if (typeof jid1 !== 'string' || typeof jid2 !== 'string') {
  19537. return false;
  19538. }
  19539. return Strophe.getDomainFromJid(jid1).toLowerCase() === Strophe.getDomainFromJid(jid2).toLowerCase();
  19540. };
  19541. u.isNewMessage = function (message) {
  19542. /* Given a stanza, determine whether it's a new
  19543. * message, i.e. not a MAM archived one.
  19544. */
  19545. if (message instanceof Element) {
  19546. return !(sizzle_default()(`result[xmlns="${Strophe.NS.MAM}"]`, message).length && sizzle_default()(`delay[xmlns="${Strophe.NS.DELAY}"]`, message).length);
  19547. } else if (message instanceof Model) {
  19548. message = message.attributes;
  19549. }
  19550. return !(message['is_delayed'] && message['is_archived']);
  19551. };
  19552. u.shouldCreateMessage = function (attrs) {
  19553. return attrs['retracted'] || // Retraction received *before* the message
  19554. !isEmptyMessage(attrs);
  19555. };
  19556. u.shouldCreateGroupchatMessage = function (attrs) {
  19557. return attrs.nick && (u.shouldCreateMessage(attrs) || attrs.is_tombstone);
  19558. };
  19559. u.isChatRoom = function (model) {
  19560. return model && model.get('type') === 'chatroom';
  19561. };
  19562. u.isErrorObject = function (o) {
  19563. return o instanceof Error;
  19564. };
  19565. u.isErrorStanza = function (stanza) {
  19566. if (!lodash_es_isElement(stanza)) {
  19567. return false;
  19568. }
  19569. return stanza.getAttribute('type') === 'error';
  19570. };
  19571. u.isForbiddenError = function (stanza) {
  19572. if (!lodash_es_isElement(stanza)) {
  19573. return false;
  19574. }
  19575. return sizzle_default()(`error[type="auth"] forbidden[xmlns="${Strophe.NS.STANZAS}"]`, stanza).length > 0;
  19576. };
  19577. u.isServiceUnavailableError = function (stanza) {
  19578. if (!lodash_es_isElement(stanza)) {
  19579. return false;
  19580. }
  19581. return sizzle_default()(`error[type="cancel"] service-unavailable[xmlns="${Strophe.NS.STANZAS}"]`, stanza).length > 0;
  19582. };
  19583. /**
  19584. * Merge the second object into the first one.
  19585. * @private
  19586. * @method u#merge
  19587. * @param { Object } first
  19588. * @param { Object } second
  19589. */
  19590. u.merge = function merge(first, second) {
  19591. for (const k in second) {
  19592. if (lodash_es_isObject(first[k])) {
  19593. merge(first[k], second[k]);
  19594. } else {
  19595. first[k] = second[k];
  19596. }
  19597. }
  19598. };
  19599. u.getOuterWidth = function (el) {
  19600. let include_margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19601. let width = el.offsetWidth;
  19602. if (!include_margin) {
  19603. return width;
  19604. }
  19605. const style = window.getComputedStyle(el);
  19606. width += parseInt(style.marginLeft ? style.marginLeft : 0, 10) + parseInt(style.marginRight ? style.marginRight : 0, 10);
  19607. return width;
  19608. };
  19609. /**
  19610. * Converts an HTML string into a DOM element.
  19611. * Expects that the HTML string has only one top-level element,
  19612. * i.e. not multiple ones.
  19613. * @private
  19614. * @method u#stringToElement
  19615. * @param { String } s - The HTML string
  19616. */
  19617. u.stringToElement = function (s) {
  19618. var div = document.createElement('div');
  19619. div.innerHTML = s;
  19620. return div.firstElementChild;
  19621. };
  19622. /**
  19623. * Checks whether the DOM element matches the given selector.
  19624. * @private
  19625. * @method u#matchesSelector
  19626. * @param { DOMElement } el - The DOM element
  19627. * @param { String } selector - The selector
  19628. */
  19629. u.matchesSelector = function (el, selector) {
  19630. const match = el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector;
  19631. return match ? match.call(el, selector) : false;
  19632. };
  19633. /**
  19634. * Returns a list of children of the DOM element that match the selector.
  19635. * @private
  19636. * @method u#queryChildren
  19637. * @param { DOMElement } el - the DOM element
  19638. * @param { String } selector - the selector they should be matched against
  19639. */
  19640. u.queryChildren = function (el, selector) {
  19641. return Array.from(el.childNodes).filter(el => u.matchesSelector(el, selector));
  19642. };
  19643. u.contains = function (attr, query) {
  19644. const checker = (item, key) => item.get(key).toLowerCase().includes(query.toLowerCase());
  19645. return function (item) {
  19646. if (typeof attr === 'object') {
  19647. return Object.keys(attr).reduce((acc, k) => acc || checker(item, k), false);
  19648. } else if (typeof attr === 'string') {
  19649. return checker(item, attr);
  19650. } else {
  19651. throw new TypeError('contains: wrong attribute type. Must be string or array.');
  19652. }
  19653. };
  19654. };
  19655. u.isOfType = function (type, item) {
  19656. return item.get('type') == type;
  19657. };
  19658. u.isInstance = function (type, item) {
  19659. return item instanceof type;
  19660. };
  19661. u.getAttribute = function (key, item) {
  19662. return item.get(key);
  19663. };
  19664. u.contains.not = function (attr, query) {
  19665. return function (item) {
  19666. return !u.contains(attr, query)(item);
  19667. };
  19668. };
  19669. u.rootContains = function (root, el) {
  19670. // The document element does not have the contains method in IE.
  19671. if (root === document && !root.contains) {
  19672. return document.head.contains(el) || document.body.contains(el);
  19673. }
  19674. return root.contains ? root.contains(el) : window.HTMLElement.prototype.contains.call(root, el);
  19675. };
  19676. u.createFragmentFromText = function (markup) {
  19677. /* Returns a DocumentFragment containing DOM nodes based on the
  19678. * passed-in markup text.
  19679. */
  19680. // http://stackoverflow.com/questions/9334645/create-node-from-markup-string
  19681. var frag = document.createDocumentFragment(),
  19682. tmp = document.createElement('body'),
  19683. child;
  19684. tmp.innerHTML = markup; // Append elements in a loop to a DocumentFragment, so that the
  19685. // browser does not re-render the document for each node.
  19686. while (child = tmp.firstChild) {
  19687. // eslint-disable-line no-cond-assign
  19688. frag.appendChild(child);
  19689. }
  19690. return frag;
  19691. };
  19692. u.isPersistableModel = function (model) {
  19693. return model.collection && model.collection.browserStorage;
  19694. };
  19695. u.getResolveablePromise = getOpenPromise;
  19696. u.getOpenPromise = getOpenPromise;
  19697. u.interpolate = function (string, o) {
  19698. return string.replace(/{{{([^{}]*)}}}/g, (a, b) => {
  19699. var r = o[b];
  19700. return typeof r === 'string' || typeof r === 'number' ? r : a;
  19701. });
  19702. };
  19703. /**
  19704. * Call the callback once all the events have been triggered
  19705. * @private
  19706. * @method u#onMultipleEvents
  19707. * @param { Array } events: An array of objects, with keys `object` and
  19708. * `event`, representing the event name and the object it's triggered upon.
  19709. * @param { Function } callback: The function to call once all events have
  19710. * been triggered.
  19711. */
  19712. u.onMultipleEvents = function () {
  19713. let events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  19714. let callback = arguments.length > 1 ? arguments[1] : undefined;
  19715. let triggered = [];
  19716. function handler(result) {
  19717. triggered.push(result);
  19718. if (events.length === triggered.length) {
  19719. callback(triggered);
  19720. triggered = [];
  19721. }
  19722. }
  19723. events.forEach(e => e.object.on(e.event, handler));
  19724. };
  19725. function safeSave(model, attributes, options) {
  19726. if (u.isPersistableModel(model)) {
  19727. model.save(attributes, options);
  19728. } else {
  19729. model.set(attributes, options);
  19730. }
  19731. }
  19732. u.safeSave = safeSave;
  19733. u.siblingIndex = function (el) {
  19734. /* eslint-disable no-cond-assign */
  19735. for (var i = 0; el = el.previousElementSibling; i++);
  19736. return i;
  19737. };
  19738. /**
  19739. * Returns the current word being written in the input element
  19740. * @method u#getCurrentWord
  19741. * @param {HTMLElement} input - The HTMLElement in which text is being entered
  19742. * @param {integer} [index] - An optional rightmost boundary index. If given, the text
  19743. * value of the input element will only be considered up until this index.
  19744. * @param {string} [delineator] - An optional string delineator to
  19745. * differentiate between words.
  19746. * @private
  19747. */
  19748. u.getCurrentWord = function (input, index, delineator) {
  19749. if (!index) {
  19750. index = input.selectionEnd || undefined;
  19751. }
  19752. let [word] = input.value.slice(0, index).split(/\s/).slice(-1);
  19753. if (delineator) {
  19754. [word] = word.split(delineator).slice(-1);
  19755. }
  19756. return word;
  19757. };
  19758. u.isMentionBoundary = s => s !== '@' && RegExp(`(\\p{Z}|\\p{P})`, 'u').test(s);
  19759. u.replaceCurrentWord = function (input, new_value) {
  19760. const caret = input.selectionEnd || undefined;
  19761. const current_word = lodash_es_last(input.value.slice(0, caret).split(/\s/));
  19762. const value = input.value;
  19763. const mention_boundary = u.isMentionBoundary(current_word[0]) ? current_word[0] : '';
  19764. input.value = value.slice(0, caret - current_word.length) + mention_boundary + `${new_value} ` + value.slice(caret);
  19765. const selection_end = caret - current_word.length + new_value.length + 1;
  19766. input.selectionEnd = mention_boundary ? selection_end + 1 : selection_end;
  19767. };
  19768. u.triggerEvent = function (el, name) {
  19769. let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Event";
  19770. let bubbles = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  19771. let cancelable = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  19772. const evt = document.createEvent(type);
  19773. evt.initEvent(name, bubbles, cancelable);
  19774. el.dispatchEvent(evt);
  19775. };
  19776. u.getSelectValues = function (select) {
  19777. const result = [];
  19778. const options = select && select.options;
  19779. for (var i = 0, iLen = options.length; i < iLen; i++) {
  19780. const opt = options[i];
  19781. if (opt.selected) {
  19782. result.push(opt.value || opt.text);
  19783. }
  19784. }
  19785. return result;
  19786. };
  19787. u.getRandomInt = function (max) {
  19788. return Math.floor(Math.random() * Math.floor(max));
  19789. };
  19790. u.placeCaretAtEnd = function (textarea) {
  19791. if (textarea !== document.activeElement) {
  19792. textarea.focus();
  19793. } // Double the length because Opera is inconsistent about whether a carriage return is one character or two.
  19794. const len = textarea.value.length * 2; // Timeout seems to be required for Blink
  19795. setTimeout(() => textarea.setSelectionRange(len, len), 1); // Scroll to the bottom, in case we're in a tall textarea
  19796. // (Necessary for Firefox and Chrome)
  19797. this.scrollTop = 999999;
  19798. };
  19799. function getUniqueId(suffix) {
  19800. const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  19801. const r = Math.random() * 16 | 0;
  19802. const v = c === 'x' ? r : r & 0x3 | 0x8;
  19803. return v.toString(16);
  19804. });
  19805. if (typeof suffix === "string" || typeof suffix === "number") {
  19806. return uuid + ":" + suffix;
  19807. } else {
  19808. return uuid;
  19809. }
  19810. }
  19811. u.httpToGeoUri = function (text) {
  19812. const replacement = 'geo:$1,$2';
  19813. return text.replace(settings_api.get("geouri_regex"), replacement);
  19814. };
  19815. /**
  19816. * Clears the specified timeout and interval.
  19817. * @method u#clearTimers
  19818. * @param {number} timeout - Id if the timeout to clear.
  19819. * @param {number} interval - Id of the interval to clear.
  19820. * @private
  19821. * @copyright Simen Bekkhus 2016
  19822. * @license MIT
  19823. */
  19824. function clearTimers(timeout, interval) {
  19825. clearTimeout(timeout);
  19826. clearInterval(interval);
  19827. }
  19828. /**
  19829. * Creates a {@link Promise} that resolves if the passed in function returns a truthy value.
  19830. * Rejects if it throws or does not return truthy within the given max_wait.
  19831. * @method u#waitUntil
  19832. * @param {Function} func - The function called every check_delay,
  19833. * and the result of which is the resolved value of the promise.
  19834. * @param {number} [max_wait=300] - The time to wait before rejecting the promise.
  19835. * @param {number} [check_delay=3] - The time to wait before each invocation of {func}.
  19836. * @returns {Promise} A promise resolved with the value of func,
  19837. * or rejected with the exception thrown by it or it times out.
  19838. * @copyright Simen Bekkhus 2016
  19839. * @license MIT
  19840. */
  19841. u.waitUntil = function (func) {
  19842. let max_wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
  19843. let check_delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
  19844. // Run the function once without setting up any listeners in case it's already true
  19845. try {
  19846. const result = func();
  19847. if (result) {
  19848. return Promise.resolve(result);
  19849. }
  19850. } catch (e) {
  19851. return Promise.reject(e);
  19852. }
  19853. const promise = getOpenPromise();
  19854. const timeout_err = new Error();
  19855. function checker() {
  19856. try {
  19857. const result = func();
  19858. if (result) {
  19859. clearTimers(max_wait_timeout, interval);
  19860. promise.resolve(result);
  19861. }
  19862. } catch (e) {
  19863. clearTimers(max_wait_timeout, interval);
  19864. promise.reject(e);
  19865. }
  19866. }
  19867. const interval = setInterval(checker, check_delay);
  19868. function handler() {
  19869. clearTimers(max_wait_timeout, interval);
  19870. const err_msg = `Wait until promise timed out: \n\n${timeout_err.stack}`;
  19871. console.trace();
  19872. headless_log.error(err_msg);
  19873. promise.reject(new Error(err_msg));
  19874. }
  19875. const max_wait_timeout = setTimeout(handler, max_wait);
  19876. return promise;
  19877. };
  19878. function setUnloadEvent() {
  19879. if ('onpagehide' in window) {
  19880. // Pagehide gets thrown in more cases than unload. Specifically it
  19881. // gets thrown when the page is cached and not just
  19882. // closed/destroyed. It's the only viable event on mobile Safari.
  19883. // https://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/
  19884. shared_converse.unloadevent = 'pagehide';
  19885. } else if ('onbeforeunload' in window) {
  19886. shared_converse.unloadevent = 'beforeunload';
  19887. } else if ('onunload' in window) {
  19888. shared_converse.unloadevent = 'unload';
  19889. }
  19890. }
  19891. async function getLoginCredentialsFromBrowser() {
  19892. try {
  19893. const creds = await navigator.credentials.get({
  19894. 'password': true
  19895. });
  19896. if (creds && creds.type == 'password' && u.isValidJID(creds.id)) {
  19897. await setUserJID(creds.id);
  19898. return {
  19899. 'jid': creds.id,
  19900. 'password': creds.password
  19901. };
  19902. }
  19903. } catch (e) {
  19904. headless_log.error(e);
  19905. }
  19906. }
  19907. function replacePromise(name) {
  19908. const existing_promise = shared_converse.promises[name];
  19909. if (!existing_promise) {
  19910. throw new Error(`Tried to replace non-existing promise: ${name}`);
  19911. }
  19912. if (existing_promise.replace) {
  19913. const promise = getOpenPromise();
  19914. promise.replace = existing_promise.replace;
  19915. shared_converse.promises[name] = promise;
  19916. } else {
  19917. headless_log.debug(`Not replacing promise "${name}"`);
  19918. }
  19919. }
  19920. const core_element = document.createElement('div');
  19921. function decodeHTMLEntities(str) {
  19922. if (str && typeof str === 'string') {
  19923. core_element.innerHTML = purify_default().sanitize(str);
  19924. str = core_element.textContent;
  19925. core_element.textContent = '';
  19926. }
  19927. return str;
  19928. }
  19929. /* harmony default export */ const utils_core = (Object.assign({
  19930. prefixMentions,
  19931. isEmptyMessage,
  19932. getUniqueId
  19933. }, u));
  19934. ;// CONCATENATED MODULE: ./src/headless/shared/settings/constants.js
  19935. /**
  19936. * @typedef { Object } ConfigurationSettings
  19937. * Converse's core configuration values
  19938. * @property { Boolean } [allow_non_roster_messaging=false]
  19939. * @property { Boolean } [allow_url_history_change=true]
  19940. * @property { String } [assets_path='/dist']
  19941. * @property { ('login'|'prebind'|'anonymous'|'external') } [authentication='login']
  19942. * @property { Boolean } [auto_login=false] - Currently only used in connection with anonymous login
  19943. * @property { Boolean } [auto_reconnect=true]
  19944. * @property { Array<String>} [blacklisted_plugins]
  19945. * @property { Boolean } [clear_cache_on_logout=false]
  19946. * @property { Object } [connection_options]
  19947. * @property { String } [credentials_url] - URL from where login credentials can be fetched
  19948. * @property { Boolean } [discover_connection_methods=true]
  19949. * @property { RegExp } [geouri_regex]
  19950. * @property { RegExp } [geouri_replacement='https - //www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2']
  19951. * @property { String } [i18n]
  19952. * @property { String } [jid]
  19953. * @property { Boolean } [keepalive=true]
  19954. * @property { ('debug'|'info'|'eror') } [loglevel='info']
  19955. * @property { Array<String> } [locales]
  19956. * @property { String } [nickname]
  19957. * @property { String } [password]
  19958. * @property { ('IndexedDB'|'localStorage') } [persistent_store='IndexedDB']
  19959. * @property { String } [rid]
  19960. * @property { Element } [root=window.document]
  19961. * @property { String } [sid]
  19962. * @property { Boolean } [singleton=false]
  19963. * @property { Boolean } [strict_plugin_dependencies=false]
  19964. * @property { ('overlayed'|'fullscreen'|'mobile') } [view_mode='overlayed']
  19965. * @property { String } [websocket_url]
  19966. * @property { Array<String>} [whitelisted_plugins]
  19967. */
  19968. const DEFAULT_SETTINGS = {
  19969. allow_non_roster_messaging: false,
  19970. allow_url_history_change: true,
  19971. assets_path: '/dist',
  19972. authentication: 'login',
  19973. // Available values are "login", "prebind", "anonymous" and "external".
  19974. auto_login: false,
  19975. // Currently only used in connection with anonymous login
  19976. auto_reconnect: true,
  19977. blacklisted_plugins: [],
  19978. clear_cache_on_logout: false,
  19979. connection_options: {},
  19980. credentials_url: null,
  19981. // URL from where login credentials can be fetched
  19982. discover_connection_methods: true,
  19983. geouri_regex: /https\:\/\/www.openstreetmap.org\/.*#map=[0-9]+\/([\-0-9.]+)\/([\-0-9.]+)\S*/g,
  19984. geouri_replacement: 'https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2',
  19985. i18n: undefined,
  19986. jid: undefined,
  19987. keepalive: true,
  19988. loglevel: 'info',
  19989. locales: ['af', 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'eo', 'es', 'eu', 'en', 'fa', 'fi', 'fr', 'gl', 'he', 'hi', 'hu', 'id', 'it', 'ja', 'lt', 'nb', 'nl', 'mr', 'oc', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'sv', 'th', 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW'],
  19990. nickname: undefined,
  19991. password: undefined,
  19992. persistent_store: 'IndexedDB',
  19993. rid: undefined,
  19994. root: window.document,
  19995. sid: undefined,
  19996. singleton: false,
  19997. strict_plugin_dependencies: false,
  19998. view_mode: 'overlayed',
  19999. // Choices are 'overlayed', 'fullscreen', 'mobile'
  20000. websocket_url: undefined,
  20001. whitelisted_plugins: []
  20002. };
  20003. ;// CONCATENATED MODULE: ./src/headless/shared/settings/utils.js
  20004. let app_settings;
  20005. let init_settings = {}; // Container for settings passed in via converse.initialize
  20006. let user_settings; // User settings, populated via api.users.settings
  20007. function getAppSettings() {
  20008. return app_settings;
  20009. }
  20010. function initAppSettings(settings) {
  20011. init_settings = settings;
  20012. app_settings = {};
  20013. Object.assign(app_settings, Events); // Allow only whitelisted settings to be overwritten via converse.initialize
  20014. const allowed_settings = lodash_es_pick(settings, Object.keys(DEFAULT_SETTINGS));
  20015. lodash_es_assignIn(app_settings, DEFAULT_SETTINGS, allowed_settings);
  20016. }
  20017. function getInitSettings() {
  20018. return init_settings;
  20019. }
  20020. function getAppSetting(key) {
  20021. if (Object.keys(DEFAULT_SETTINGS).includes(key)) {
  20022. return app_settings[key];
  20023. }
  20024. }
  20025. function extendAppSettings(settings) {
  20026. utils_core.merge(DEFAULT_SETTINGS, settings); // When updating the settings, we need to avoid overwriting the
  20027. // initialization_settings (i.e. the settings passed in via converse.initialize).
  20028. const allowed_keys = Object.keys(lodash_es_pick(settings, Object.keys(DEFAULT_SETTINGS)));
  20029. const allowed_site_settings = lodash_es_pick(init_settings, allowed_keys);
  20030. const updated_settings = lodash_es_assignIn(lodash_es_pick(settings, allowed_keys), allowed_site_settings);
  20031. utils_core.merge(app_settings, updated_settings);
  20032. }
  20033. function registerListener(name, func, context) {
  20034. app_settings.on(name, func, context);
  20035. }
  20036. function unregisterListener(name, func) {
  20037. app_settings.off(name, func);
  20038. }
  20039. function updateAppSettings(key, val) {
  20040. if (key == null) return this; // eslint-disable-line no-eq-null
  20041. let attrs;
  20042. if (lodash_es_isObject(key)) {
  20043. attrs = key;
  20044. } else if (typeof key === 'string') {
  20045. attrs = {};
  20046. attrs[key] = val;
  20047. }
  20048. const allowed_keys = Object.keys(lodash_es_pick(attrs, Object.keys(DEFAULT_SETTINGS)));
  20049. const changed = {};
  20050. allowed_keys.forEach(k => {
  20051. const val = attrs[k];
  20052. if (!lodash_es_isEqual(app_settings[k], val)) {
  20053. changed[k] = val;
  20054. app_settings[k] = val;
  20055. }
  20056. });
  20057. Object.keys(changed).forEach(k => app_settings.trigger('change:' + k, changed[k]));
  20058. app_settings.trigger('change', changed);
  20059. }
  20060. /**
  20061. * @async
  20062. */
  20063. function initUserSettings() {
  20064. var _user_settings;
  20065. if (!shared_converse.bare_jid) {
  20066. const msg = "No JID to fetch user settings for";
  20067. headless_log.error(msg);
  20068. throw Error(msg);
  20069. }
  20070. if (!((_user_settings = user_settings) !== null && _user_settings !== void 0 && _user_settings.fetched)) {
  20071. const id = `converse.user-settings.${shared_converse.bare_jid}`;
  20072. user_settings = new Model({
  20073. id
  20074. });
  20075. initStorage(user_settings, id);
  20076. user_settings.fetched = user_settings.fetch({
  20077. 'promise': true
  20078. });
  20079. }
  20080. return user_settings.fetched;
  20081. }
  20082. async function getUserSettings() {
  20083. await initUserSettings();
  20084. return user_settings;
  20085. }
  20086. async function updateUserSettings(data, options) {
  20087. await initUserSettings();
  20088. return user_settings.save(data, options);
  20089. }
  20090. async function clearUserSettings() {
  20091. await initUserSettings();
  20092. return user_settings.clear();
  20093. }
  20094. ;// CONCATENATED MODULE: ./src/headless/shared/_converse.js
  20095. /**
  20096. * A private, closured object containing the private api (via {@link _converse.api})
  20097. * as well as private methods and internal data-structures.
  20098. * @global
  20099. * @namespace _converse
  20100. */
  20101. const _converse = {
  20102. log: headless_log,
  20103. CONNECTION_STATUS: CONNECTION_STATUS,
  20104. templates: {},
  20105. promises: {
  20106. 'initialized': getOpenPromise()
  20107. },
  20108. STATUS_WEIGHTS: {
  20109. 'offline': 6,
  20110. 'unavailable': 5,
  20111. 'xa': 4,
  20112. 'away': 3,
  20113. 'dnd': 2,
  20114. 'chat': 1,
  20115. // We currently don't differentiate between "chat" and "online"
  20116. 'online': 1
  20117. },
  20118. ANONYMOUS: 'anonymous',
  20119. CLOSED: 'closed',
  20120. EXTERNAL: 'external',
  20121. LOGIN: 'login',
  20122. LOGOUT: 'logout',
  20123. OPENED: 'opened',
  20124. PREBIND: 'prebind',
  20125. /**
  20126. * @constant
  20127. * @type { integer }
  20128. */
  20129. STANZA_TIMEOUT: 20000,
  20130. SUCCESS: 'success',
  20131. FAILURE: 'failure',
  20132. // Generated from css/images/user.svg
  20133. DEFAULT_IMAGE_TYPE: 'image/svg+xml',
  20134. DEFAULT_IMAGE: "PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+CiA8cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iIzU1NSIvPgogPGNpcmNsZSBjeD0iNjQiIGN5PSI0MSIgcj0iMjQiIGZpbGw9IiNmZmYiLz4KIDxwYXRoIGQ9Im0yOC41IDExMiB2LTEyIGMwLTEyIDEwLTI0IDI0LTI0IGgyMyBjMTQgMCAyNCAxMiAyNCAyNCB2MTIiIGZpbGw9IiNmZmYiLz4KPC9zdmc+Cg==",
  20135. TIMEOUTS: {
  20136. // Set as module attr so that we can override in tests.
  20137. PAUSED: 10000,
  20138. INACTIVE: 90000
  20139. },
  20140. // XEP-0085 Chat states
  20141. // https://xmpp.org/extensions/xep-0085.html
  20142. INACTIVE: 'inactive',
  20143. ACTIVE: 'active',
  20144. COMPOSING: 'composing',
  20145. PAUSED: 'paused',
  20146. GONE: 'gone',
  20147. // Chat types
  20148. PRIVATE_CHAT_TYPE: 'chatbox',
  20149. CHATROOMS_TYPE: 'chatroom',
  20150. HEADLINES_TYPE: 'headline',
  20151. CONTROLBOX_TYPE: 'controlbox',
  20152. default_connection_options: {
  20153. 'explicitResourceBinding': true
  20154. },
  20155. router: new Router(),
  20156. TimeoutError: TimeoutError,
  20157. isTestEnv: () => {
  20158. return getInitSettings()['bosh_service_url'] === 'montague.lit/http-bind';
  20159. },
  20160. getDefaultStore: getDefaultStore,
  20161. createStore: createStore,
  20162. /**
  20163. * Translate the given string based on the current locale.
  20164. * @method __
  20165. * @private
  20166. * @memberOf _converse
  20167. * @param { String } str
  20168. */
  20169. '__': function () {
  20170. return i18n.__(...arguments);
  20171. },
  20172. /**
  20173. * A no-op method which is used to signal to gettext that the passed in string
  20174. * should be included in the pot translation file.
  20175. *
  20176. * In contrast to the double-underscore method, the triple underscore method
  20177. * doesn't actually translate the strings.
  20178. *
  20179. * One reason for this method might be because we're using strings we cannot
  20180. * send to the translation function because they require variable interpolation
  20181. * and we don't yet have the variables at scan time.
  20182. *
  20183. * @method ___
  20184. * @private
  20185. * @memberOf _converse
  20186. * @param { String } str
  20187. */
  20188. '___': str => str
  20189. };
  20190. /* harmony default export */ const shared_converse = (_converse);
  20191. // EXTERNAL MODULE: ./node_modules/dayjs/plugin/advancedFormat.js
  20192. var advancedFormat = __webpack_require__(8734);
  20193. var advancedFormat_default = /*#__PURE__*/__webpack_require__.n(advancedFormat);
  20194. ;// CONCATENATED MODULE: ./src/headless/shared/connection/api.js
  20195. /**
  20196. * This grouping collects API functions related to the XMPP connection.
  20197. *
  20198. * @namespace _converse.api.connection
  20199. * @memberOf _converse.api
  20200. */
  20201. /* harmony default export */ const api = ({
  20202. /**
  20203. * @method _converse.api.connection.connected
  20204. * @memberOf _converse.api.connection
  20205. * @returns {boolean} Whether there is an established connection or not.
  20206. */
  20207. connected() {
  20208. var _converse$connection;
  20209. return (shared_converse === null || shared_converse === void 0 ? void 0 : (_converse$connection = shared_converse.connection) === null || _converse$connection === void 0 ? void 0 : _converse$connection.connected) && true;
  20210. },
  20211. /**
  20212. * Terminates the connection.
  20213. *
  20214. * @method _converse.api.connection.disconnect
  20215. * @memberOf _converse.api.connection
  20216. */
  20217. disconnect() {
  20218. if (shared_converse.connection) {
  20219. shared_converse.connection.disconnect();
  20220. }
  20221. },
  20222. /**
  20223. * Can be called once the XMPP connection has dropped and we want
  20224. * to attempt reconnection.
  20225. * Only needs to be called once, if reconnect fails Converse will
  20226. * attempt to reconnect every two seconds, alternating between BOSH and
  20227. * Websocket if URLs for both were provided.
  20228. * @method reconnect
  20229. * @memberOf _converse.api.connection
  20230. */
  20231. reconnect() {
  20232. const {
  20233. __,
  20234. connection
  20235. } = shared_converse;
  20236. connection.setConnectionStatus(Strophe.Status.RECONNECTING, __('The connection has dropped, attempting to reconnect.'));
  20237. if (connection !== null && connection !== void 0 && connection.reconnecting) {
  20238. return connection.debouncedReconnect();
  20239. } else {
  20240. return connection.reconnect();
  20241. }
  20242. },
  20243. /**
  20244. * Utility method to determine the type of connection we have
  20245. * @method isType
  20246. * @memberOf _converse.api.connection
  20247. * @returns {boolean}
  20248. */
  20249. isType(type) {
  20250. return shared_converse.connection.isType(type);
  20251. }
  20252. });
  20253. // EXTERNAL MODULE: ./node_modules/dayjs/dayjs.min.js
  20254. var dayjs_min = __webpack_require__(7484);
  20255. var dayjs_min_default = /*#__PURE__*/__webpack_require__.n(dayjs_min);
  20256. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseInvoke.js
  20257. /**
  20258. * The base implementation of `_.invoke` without support for individual
  20259. * method arguments.
  20260. *
  20261. * @private
  20262. * @param {Object} object The object to query.
  20263. * @param {Array|string} path The path of the method to invoke.
  20264. * @param {Array} args The arguments to invoke the method with.
  20265. * @returns {*} Returns the result of the invoked method.
  20266. */
  20267. function baseInvoke(object, path, args) {
  20268. path = _castPath(path, object);
  20269. object = _parent(object, path);
  20270. var func = object == null ? object : object[_toKey(lodash_es_last(path))];
  20271. return func == null ? undefined : _apply(func, object, args);
  20272. }
  20273. /* harmony default export */ const _baseInvoke = (baseInvoke);
  20274. ;// CONCATENATED MODULE: ./node_modules/lodash-es/invoke.js
  20275. /**
  20276. * Invokes the method at `path` of `object`.
  20277. *
  20278. * @static
  20279. * @memberOf _
  20280. * @since 4.0.0
  20281. * @category Object
  20282. * @param {Object} object The object to query.
  20283. * @param {Array|string} path The path of the method to invoke.
  20284. * @param {...*} [args] The arguments to invoke the method with.
  20285. * @returns {*} Returns the result of the invoked method.
  20286. * @example
  20287. *
  20288. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  20289. *
  20290. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  20291. * // => [2, 3]
  20292. */
  20293. var invoke = _baseRest(_baseInvoke);
  20294. /* harmony default export */ const lodash_es_invoke = (invoke);
  20295. ;// CONCATENATED MODULE: ./node_modules/pluggable.js/src/pluggable.js
  20296. /*
  20297. ____ __ __ __ _
  20298. / __ \/ /_ __ ___ ___ ____ _/ /_ / /__ (_)____
  20299. / /_/ / / / / / __ \/ __ \/ __/ / __ \/ / _ \ / / ___/
  20300. / ____/ / /_/ / /_/ / /_/ / /_/ / /_/ / / __/ / (__ )
  20301. /_/ /_/\__,_/\__, /\__, /\__/_/_.___/_/\___(_)_/ /____/
  20302. /____//____/ /___/
  20303. */
  20304. // Pluggable.js lets you to make your Javascript code pluggable while still
  20305. // keeping sensitive objects and data private through closures.
  20306. // `wrappedOverride` creates a partially applied wrapper function
  20307. // that makes sure to set the proper super method when the
  20308. // overriding method is called. This is done to enable
  20309. // chaining of plugin methods, all the way up to the
  20310. // original method.
  20311. function wrappedOverride(key, value, super_method, default_super) {
  20312. if (typeof super_method === "function") {
  20313. if (typeof this.__super__ === "undefined") {
  20314. /* We're not on the context of the plugged object.
  20315. * This can happen when the overridden method is called via
  20316. * an event handler or when it's a constructor.
  20317. *
  20318. * In this case, we simply tack on the __super__ obj.
  20319. */
  20320. this.__super__ = default_super;
  20321. }
  20322. this.__super__[key] = super_method.bind(this);
  20323. }
  20324. for (var _len = arguments.length, args = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
  20325. args[_key - 4] = arguments[_key];
  20326. }
  20327. return value.apply(this, args);
  20328. } // The `PluginSocket` class contains the plugin architecture, and gets
  20329. // created whenever `pluggable.enable(obj);` is called on the object
  20330. // that you want to make pluggable.
  20331. // You can also see it as the thing into which the plugins are plugged.
  20332. // It takes two parameters, first, the object being made pluggable, and
  20333. // then the name by which the pluggable object may be referenced on the
  20334. // __super__ object (inside overrides).
  20335. class PluginSocket {
  20336. constructor(plugged, name) {
  20337. this.name = name;
  20338. this.plugged = plugged;
  20339. if (typeof this.plugged.__super__ === 'undefined') {
  20340. this.plugged.__super__ = {};
  20341. } else if (typeof this.plugged.__super__ === 'string') {
  20342. this.plugged.__super__ = {
  20343. '__string__': this.plugged.__super__
  20344. };
  20345. }
  20346. this.plugged.__super__[name] = this.plugged;
  20347. this.plugins = {};
  20348. this.initialized_plugins = [];
  20349. } // `_overrideAttribute` overrides an attribute on the original object
  20350. // (the thing being plugged into).
  20351. //
  20352. // If the attribute being overridden is a function, then the original
  20353. // function will still be available via the `__super__` attribute.
  20354. //
  20355. // If the same function is being overridden multiple times, then
  20356. // the original function will be available at the end of a chain of
  20357. // functions, starting from the most recent override, all the way
  20358. // back to the original function, each being referenced by the
  20359. // previous' __super__ attribute.
  20360. //
  20361. // For example:
  20362. //
  20363. // `plugin2.MyFunc.__super__.myFunc => plugin1.MyFunc.__super__.myFunc => original.myFunc`
  20364. _overrideAttribute(key, plugin) {
  20365. const value = plugin.overrides[key];
  20366. if (typeof value === "function") {
  20367. const default_super = {};
  20368. default_super[this.name] = this.plugged;
  20369. const super_method = this.plugged[key];
  20370. this.plugged[key] = function () {
  20371. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  20372. args[_key2] = arguments[_key2];
  20373. }
  20374. return wrappedOverride.apply(this, [key, value, super_method, default_super, ...args]);
  20375. };
  20376. } else {
  20377. this.plugged[key] = value;
  20378. }
  20379. }
  20380. _extendObject(obj, attributes) {
  20381. if (!obj.prototype.__super__) {
  20382. obj.prototype.__super__ = {};
  20383. obj.prototype.__super__[this.name] = this.plugged;
  20384. }
  20385. for (const [key, value] of Object.entries(attributes)) {
  20386. if (key === 'events') {
  20387. obj.prototype[key] = Object.assign(value, obj.prototype[key]);
  20388. } else if (typeof value === 'function') {
  20389. // We create a partially applied wrapper function, that
  20390. // makes sure to set the proper super method when the
  20391. // overriding method is called. This is done to enable
  20392. // chaining of plugin methods, all the way up to the
  20393. // original method.
  20394. const default_super = {};
  20395. default_super[this.name] = this.plugged;
  20396. const super_method = obj.prototype[key];
  20397. obj.prototype[key] = function () {
  20398. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  20399. args[_key3] = arguments[_key3];
  20400. }
  20401. return wrappedOverride.apply(this, [key, value, super_method, default_super, ...args]);
  20402. };
  20403. } else {
  20404. obj.prototype[key] = value;
  20405. }
  20406. }
  20407. } // Plugins can specify dependencies (by means of the
  20408. // `dependencies` list attribute) which refers to dependencies
  20409. // which will be initialized first, before the plugin itself gets initialized.
  20410. //
  20411. // If `strict_plugin_dependencies` is set to `false` (on the object being
  20412. // made pluggable), then no error will be thrown if any of these plugins aren't
  20413. // available.
  20414. loadPluginDependencies(plugin) {
  20415. var _plugin$dependencies;
  20416. (_plugin$dependencies = plugin.dependencies) === null || _plugin$dependencies === void 0 ? void 0 : _plugin$dependencies.forEach(name => {
  20417. const dep = this.plugins[name];
  20418. if (dep) {
  20419. var _dep$dependencies;
  20420. if ((_dep$dependencies = dep.dependencies) !== null && _dep$dependencies !== void 0 && _dep$dependencies.includes(plugin.__name__)) {
  20421. /* FIXME: circular dependency checking is only one level deep. */
  20422. throw "Found a circular dependency between the plugins \"" + plugin.__name__ + "\" and \"" + name + "\"";
  20423. }
  20424. this.initializePlugin(dep);
  20425. } else {
  20426. this.throwUndefinedDependencyError("Could not find dependency \"" + name + "\" " + "for the plugin \"" + plugin.__name__ + "\". " + "If it's needed, make sure it's loaded by require.js");
  20427. }
  20428. });
  20429. }
  20430. throwUndefinedDependencyError(msg) {
  20431. if (this.plugged.strict_plugin_dependencies) {
  20432. throw msg;
  20433. } else {
  20434. if (console.warn) {
  20435. console.warn(msg);
  20436. } else {
  20437. console.log(msg);
  20438. }
  20439. }
  20440. } // `applyOverrides` is called by initializePlugin. It applies any
  20441. // and all overrides of methods or Backbone views and models that
  20442. // are defined on any of the plugins.
  20443. applyOverrides(plugin) {
  20444. Object.keys(plugin.overrides || {}).forEach(key => {
  20445. const override = plugin.overrides[key];
  20446. if (typeof override === "object") {
  20447. if (typeof this.plugged[key] === 'undefined') {
  20448. this.throwUndefinedDependencyError(`Plugin "${plugin.__name__}" tried to override "${key}" but it's not found.`);
  20449. } else {
  20450. this._extendObject(this.plugged[key], override);
  20451. }
  20452. } else {
  20453. this._overrideAttribute(key, plugin);
  20454. }
  20455. });
  20456. } // `initializePlugin` applies the overrides (if any) defined on all
  20457. // the registered plugins and then calls the initialize method of the plugin
  20458. initializePlugin(plugin) {
  20459. var _plugin$enabled;
  20460. if (!Object.keys(this.allowed_plugins).includes(plugin.__name__)) {
  20461. /* Don't initialize disallowed plugins. */
  20462. return;
  20463. }
  20464. if (this.initialized_plugins.includes(plugin.__name__)) {
  20465. /* Don't initialize plugins twice, otherwise we get
  20466. * infinite recursion in overridden methods.
  20467. */
  20468. return;
  20469. }
  20470. if (typeof plugin.enabled === 'boolean' && plugin.enabled || (_plugin$enabled = plugin.enabled) !== null && _plugin$enabled !== void 0 && _plugin$enabled.call(plugin, this.plugged) || plugin.enabled == null) {
  20471. // isNil
  20472. Object.assign(plugin, this.properties);
  20473. if (plugin.dependencies) {
  20474. this.loadPluginDependencies(plugin);
  20475. }
  20476. this.applyOverrides(plugin);
  20477. if (typeof plugin.initialize === "function") {
  20478. plugin.initialize.bind(plugin)(this);
  20479. }
  20480. this.initialized_plugins.push(plugin.__name__);
  20481. }
  20482. } // `registerPlugin` registers (or inserts, if you'd like) a plugin,
  20483. // by adding it to the `plugins` map on the PluginSocket instance.
  20484. registerPlugin(name, plugin) {
  20485. if (name in this.plugins) {
  20486. throw new Error('Error: Plugin name ' + name + ' is already taken');
  20487. }
  20488. plugin.__name__ = name;
  20489. this.plugins[name] = plugin;
  20490. } // `initializePlugins` should get called once all plugins have been
  20491. // registered. It will then iterate through all the plugins, calling
  20492. // `initializePlugin` for each.
  20493. // The passed in properties variable is an object with attributes and methods
  20494. // which will be attached to the plugins.
  20495. initializePlugins() {
  20496. let properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  20497. let whitelist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  20498. let blacklist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  20499. if (!Object.keys(this.plugins).length) {
  20500. return;
  20501. }
  20502. this.properties = properties;
  20503. this.allowed_plugins = {};
  20504. for (const [key, plugin] of Object.entries(this.plugins)) {
  20505. if ((!whitelist.length || whitelist.includes(key)) && !blacklist.includes(key)) {
  20506. this.allowed_plugins[key] = plugin;
  20507. }
  20508. }
  20509. Object.values(this.allowed_plugins).forEach(o => this.initializePlugin(o));
  20510. }
  20511. }
  20512. function enable(object, name, attrname) {
  20513. // Call the `enable` method to make an object pluggable
  20514. //
  20515. // It takes three parameters:
  20516. // - `object`: The object that gets made pluggable.
  20517. // - `name`: The string name by which the now pluggable object
  20518. // may be referenced on the __super__ obj (in overrides).
  20519. // The default value is "plugged".
  20520. // - `attrname`: The string name of the attribute on the now
  20521. // pluggable object, which refers to the PluginSocket instance
  20522. // that gets created.
  20523. if (typeof attrname === "undefined") {
  20524. attrname = "pluginSocket";
  20525. }
  20526. if (typeof name === 'undefined') {
  20527. name = 'plugged';
  20528. }
  20529. object[attrname] = new PluginSocket(object, name);
  20530. return object;
  20531. }
  20532. /* harmony default export */ const pluggable = ({
  20533. enable
  20534. });
  20535. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayAggregator.js
  20536. /**
  20537. * A specialized version of `baseAggregator` for arrays.
  20538. *
  20539. * @private
  20540. * @param {Array} [array] The array to iterate over.
  20541. * @param {Function} setter The function to set `accumulator` values.
  20542. * @param {Function} iteratee The iteratee to transform keys.
  20543. * @param {Object} accumulator The initial aggregated object.
  20544. * @returns {Function} Returns `accumulator`.
  20545. */
  20546. function arrayAggregator(array, setter, iteratee, accumulator) {
  20547. var index = -1,
  20548. length = array == null ? 0 : array.length;
  20549. while (++index < length) {
  20550. var value = array[index];
  20551. setter(accumulator, value, iteratee(value), array);
  20552. }
  20553. return accumulator;
  20554. }
  20555. /* harmony default export */ const _arrayAggregator = (arrayAggregator);
  20556. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseAggregator.js
  20557. /**
  20558. * Aggregates elements of `collection` on `accumulator` with keys transformed
  20559. * by `iteratee` and values set by `setter`.
  20560. *
  20561. * @private
  20562. * @param {Array|Object} collection The collection to iterate over.
  20563. * @param {Function} setter The function to set `accumulator` values.
  20564. * @param {Function} iteratee The iteratee to transform keys.
  20565. * @param {Object} accumulator The initial aggregated object.
  20566. * @returns {Function} Returns `accumulator`.
  20567. */
  20568. function baseAggregator(collection, setter, iteratee, accumulator) {
  20569. _baseEach(collection, function(value, key, collection) {
  20570. setter(accumulator, value, iteratee(value), collection);
  20571. });
  20572. return accumulator;
  20573. }
  20574. /* harmony default export */ const _baseAggregator = (baseAggregator);
  20575. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createAggregator.js
  20576. /**
  20577. * Creates a function like `_.groupBy`.
  20578. *
  20579. * @private
  20580. * @param {Function} setter The function to set accumulator values.
  20581. * @param {Function} [initializer] The accumulator object initializer.
  20582. * @returns {Function} Returns the new aggregator function.
  20583. */
  20584. function createAggregator(setter, initializer) {
  20585. return function(collection, iteratee) {
  20586. var func = lodash_es_isArray(collection) ? _arrayAggregator : _baseAggregator,
  20587. accumulator = initializer ? initializer() : {};
  20588. return func(collection, setter, _baseIteratee(iteratee, 2), accumulator);
  20589. };
  20590. }
  20591. /* harmony default export */ const _createAggregator = (createAggregator);
  20592. ;// CONCATENATED MODULE: ./node_modules/lodash-es/countBy.js
  20593. /** Used for built-in method references. */
  20594. var countBy_objectProto = Object.prototype;
  20595. /** Used to check objects for own properties. */
  20596. var countBy_hasOwnProperty = countBy_objectProto.hasOwnProperty;
  20597. /**
  20598. * Creates an object composed of keys generated from the results of running
  20599. * each element of `collection` thru `iteratee`. The corresponding value of
  20600. * each key is the number of times the key was returned by `iteratee`. The
  20601. * iteratee is invoked with one argument: (value).
  20602. *
  20603. * @static
  20604. * @memberOf _
  20605. * @since 0.5.0
  20606. * @category Collection
  20607. * @param {Array|Object} collection The collection to iterate over.
  20608. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  20609. * @returns {Object} Returns the composed aggregate object.
  20610. * @example
  20611. *
  20612. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  20613. * // => { '4': 1, '6': 2 }
  20614. *
  20615. * // The `_.property` iteratee shorthand.
  20616. * _.countBy(['one', 'two', 'three'], 'length');
  20617. * // => { '3': 2, '5': 1 }
  20618. */
  20619. var countBy = _createAggregator(function(result, value, key) {
  20620. if (countBy_hasOwnProperty.call(result, key)) {
  20621. ++result[key];
  20622. } else {
  20623. _baseAssignValue(result, key, 1);
  20624. }
  20625. });
  20626. /* harmony default export */ const lodash_es_countBy = (countBy);
  20627. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseFindIndex.js
  20628. /**
  20629. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  20630. * support for iteratee shorthands.
  20631. *
  20632. * @private
  20633. * @param {Array} array The array to inspect.
  20634. * @param {Function} predicate The function invoked per iteration.
  20635. * @param {number} fromIndex The index to search from.
  20636. * @param {boolean} [fromRight] Specify iterating from right to left.
  20637. * @returns {number} Returns the index of the matched value, else `-1`.
  20638. */
  20639. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  20640. var length = array.length,
  20641. index = fromIndex + (fromRight ? 1 : -1);
  20642. while ((fromRight ? index-- : ++index < length)) {
  20643. if (predicate(array[index], index, array)) {
  20644. return index;
  20645. }
  20646. }
  20647. return -1;
  20648. }
  20649. /* harmony default export */ const _baseFindIndex = (baseFindIndex);
  20650. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIsNaN.js
  20651. /**
  20652. * The base implementation of `_.isNaN` without support for number objects.
  20653. *
  20654. * @private
  20655. * @param {*} value The value to check.
  20656. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  20657. */
  20658. function baseIsNaN(value) {
  20659. return value !== value;
  20660. }
  20661. /* harmony default export */ const _baseIsNaN = (baseIsNaN);
  20662. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_strictIndexOf.js
  20663. /**
  20664. * A specialized version of `_.indexOf` which performs strict equality
  20665. * comparisons of values, i.e. `===`.
  20666. *
  20667. * @private
  20668. * @param {Array} array The array to inspect.
  20669. * @param {*} value The value to search for.
  20670. * @param {number} fromIndex The index to search from.
  20671. * @returns {number} Returns the index of the matched value, else `-1`.
  20672. */
  20673. function strictIndexOf(array, value, fromIndex) {
  20674. var index = fromIndex - 1,
  20675. length = array.length;
  20676. while (++index < length) {
  20677. if (array[index] === value) {
  20678. return index;
  20679. }
  20680. }
  20681. return -1;
  20682. }
  20683. /* harmony default export */ const _strictIndexOf = (strictIndexOf);
  20684. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseIndexOf.js
  20685. /**
  20686. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  20687. *
  20688. * @private
  20689. * @param {Array} array The array to inspect.
  20690. * @param {*} value The value to search for.
  20691. * @param {number} fromIndex The index to search from.
  20692. * @returns {number} Returns the index of the matched value, else `-1`.
  20693. */
  20694. function baseIndexOf(array, value, fromIndex) {
  20695. return value === value
  20696. ? _strictIndexOf(array, value, fromIndex)
  20697. : _baseFindIndex(array, _baseIsNaN, fromIndex);
  20698. }
  20699. /* harmony default export */ const _baseIndexOf = (baseIndexOf);
  20700. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayIncludes.js
  20701. /**
  20702. * A specialized version of `_.includes` for arrays without support for
  20703. * specifying an index to search from.
  20704. *
  20705. * @private
  20706. * @param {Array} [array] The array to inspect.
  20707. * @param {*} target The value to search for.
  20708. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  20709. */
  20710. function arrayIncludes(array, value) {
  20711. var length = array == null ? 0 : array.length;
  20712. return !!length && _baseIndexOf(array, value, 0) > -1;
  20713. }
  20714. /* harmony default export */ const _arrayIncludes = (arrayIncludes);
  20715. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayIncludesWith.js
  20716. /**
  20717. * This function is like `arrayIncludes` except that it accepts a comparator.
  20718. *
  20719. * @private
  20720. * @param {Array} [array] The array to inspect.
  20721. * @param {*} target The value to search for.
  20722. * @param {Function} comparator The comparator invoked per element.
  20723. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  20724. */
  20725. function arrayIncludesWith(array, value, comparator) {
  20726. var index = -1,
  20727. length = array == null ? 0 : array.length;
  20728. while (++index < length) {
  20729. if (comparator(value, array[index])) {
  20730. return true;
  20731. }
  20732. }
  20733. return false;
  20734. }
  20735. /* harmony default export */ const _arrayIncludesWith = (arrayIncludesWith);
  20736. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseDifference.js
  20737. /** Used as the size to enable large array optimizations. */
  20738. var _baseDifference_LARGE_ARRAY_SIZE = 200;
  20739. /**
  20740. * The base implementation of methods like `_.difference` without support
  20741. * for excluding multiple arrays or iteratee shorthands.
  20742. *
  20743. * @private
  20744. * @param {Array} array The array to inspect.
  20745. * @param {Array} values The values to exclude.
  20746. * @param {Function} [iteratee] The iteratee invoked per element.
  20747. * @param {Function} [comparator] The comparator invoked per element.
  20748. * @returns {Array} Returns the new array of filtered values.
  20749. */
  20750. function baseDifference(array, values, iteratee, comparator) {
  20751. var index = -1,
  20752. includes = _arrayIncludes,
  20753. isCommon = true,
  20754. length = array.length,
  20755. result = [],
  20756. valuesLength = values.length;
  20757. if (!length) {
  20758. return result;
  20759. }
  20760. if (iteratee) {
  20761. values = _arrayMap(values, _baseUnary(iteratee));
  20762. }
  20763. if (comparator) {
  20764. includes = _arrayIncludesWith;
  20765. isCommon = false;
  20766. }
  20767. else if (values.length >= _baseDifference_LARGE_ARRAY_SIZE) {
  20768. includes = _cacheHas;
  20769. isCommon = false;
  20770. values = new _SetCache(values);
  20771. }
  20772. outer:
  20773. while (++index < length) {
  20774. var value = array[index],
  20775. computed = iteratee == null ? value : iteratee(value);
  20776. value = (comparator || value !== 0) ? value : 0;
  20777. if (isCommon && computed === computed) {
  20778. var valuesIndex = valuesLength;
  20779. while (valuesIndex--) {
  20780. if (values[valuesIndex] === computed) {
  20781. continue outer;
  20782. }
  20783. }
  20784. result.push(value);
  20785. }
  20786. else if (!includes(values, computed, comparator)) {
  20787. result.push(value);
  20788. }
  20789. }
  20790. return result;
  20791. }
  20792. /* harmony default export */ const _baseDifference = (baseDifference);
  20793. ;// CONCATENATED MODULE: ./node_modules/lodash-es/difference.js
  20794. /**
  20795. * Creates an array of `array` values not included in the other given arrays
  20796. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20797. * for equality comparisons. The order and references of result values are
  20798. * determined by the first array.
  20799. *
  20800. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  20801. *
  20802. * @static
  20803. * @memberOf _
  20804. * @since 0.1.0
  20805. * @category Array
  20806. * @param {Array} array The array to inspect.
  20807. * @param {...Array} [values] The values to exclude.
  20808. * @returns {Array} Returns the new array of filtered values.
  20809. * @see _.without, _.xor
  20810. * @example
  20811. *
  20812. * _.difference([2, 1], [2, 3]);
  20813. * // => [1]
  20814. */
  20815. var difference = _baseRest(function(array, values) {
  20816. return lodash_es_isArrayLikeObject(array)
  20817. ? _baseDifference(array, _baseFlatten(values, 1, lodash_es_isArrayLikeObject, true))
  20818. : [];
  20819. });
  20820. /* harmony default export */ const lodash_es_difference = (difference);
  20821. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_arrayEvery.js
  20822. /**
  20823. * A specialized version of `_.every` for arrays without support for
  20824. * iteratee shorthands.
  20825. *
  20826. * @private
  20827. * @param {Array} [array] The array to iterate over.
  20828. * @param {Function} predicate The function invoked per iteration.
  20829. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20830. * else `false`.
  20831. */
  20832. function arrayEvery(array, predicate) {
  20833. var index = -1,
  20834. length = array == null ? 0 : array.length;
  20835. while (++index < length) {
  20836. if (!predicate(array[index], index, array)) {
  20837. return false;
  20838. }
  20839. }
  20840. return true;
  20841. }
  20842. /* harmony default export */ const _arrayEvery = (arrayEvery);
  20843. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseEvery.js
  20844. /**
  20845. * The base implementation of `_.every` without support for iteratee shorthands.
  20846. *
  20847. * @private
  20848. * @param {Array|Object} collection The collection to iterate over.
  20849. * @param {Function} predicate The function invoked per iteration.
  20850. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20851. * else `false`
  20852. */
  20853. function baseEvery(collection, predicate) {
  20854. var result = true;
  20855. _baseEach(collection, function(value, index, collection) {
  20856. result = !!predicate(value, index, collection);
  20857. return result;
  20858. });
  20859. return result;
  20860. }
  20861. /* harmony default export */ const _baseEvery = (baseEvery);
  20862. ;// CONCATENATED MODULE: ./node_modules/lodash-es/every.js
  20863. /**
  20864. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  20865. * Iteration is stopped once `predicate` returns falsey. The predicate is
  20866. * invoked with three arguments: (value, index|key, collection).
  20867. *
  20868. * **Note:** This method returns `true` for
  20869. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  20870. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  20871. * elements of empty collections.
  20872. *
  20873. * @static
  20874. * @memberOf _
  20875. * @since 0.1.0
  20876. * @category Collection
  20877. * @param {Array|Object} collection The collection to iterate over.
  20878. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20879. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20880. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20881. * else `false`.
  20882. * @example
  20883. *
  20884. * _.every([true, 1, null, 'yes'], Boolean);
  20885. * // => false
  20886. *
  20887. * var users = [
  20888. * { 'user': 'barney', 'age': 36, 'active': false },
  20889. * { 'user': 'fred', 'age': 40, 'active': false }
  20890. * ];
  20891. *
  20892. * // The `_.matches` iteratee shorthand.
  20893. * _.every(users, { 'user': 'barney', 'active': false });
  20894. * // => false
  20895. *
  20896. * // The `_.matchesProperty` iteratee shorthand.
  20897. * _.every(users, ['active', false]);
  20898. * // => true
  20899. *
  20900. * // The `_.property` iteratee shorthand.
  20901. * _.every(users, 'active');
  20902. * // => false
  20903. */
  20904. function every(collection, predicate, guard) {
  20905. var func = lodash_es_isArray(collection) ? _arrayEvery : _baseEvery;
  20906. if (guard && _isIterateeCall(collection, predicate, guard)) {
  20907. predicate = undefined;
  20908. }
  20909. return func(collection, _baseIteratee(predicate, 3));
  20910. }
  20911. /* harmony default export */ const lodash_es_every = (every);
  20912. ;// CONCATENATED MODULE: ./node_modules/lodash-es/findIndex.js
  20913. /* Built-in method references for those with the same name as other `lodash` methods. */
  20914. var findIndex_nativeMax = Math.max;
  20915. /**
  20916. * This method is like `_.find` except that it returns the index of the first
  20917. * element `predicate` returns truthy for instead of the element itself.
  20918. *
  20919. * @static
  20920. * @memberOf _
  20921. * @since 1.1.0
  20922. * @category Array
  20923. * @param {Array} array The array to inspect.
  20924. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20925. * @param {number} [fromIndex=0] The index to search from.
  20926. * @returns {number} Returns the index of the found element, else `-1`.
  20927. * @example
  20928. *
  20929. * var users = [
  20930. * { 'user': 'barney', 'active': false },
  20931. * { 'user': 'fred', 'active': false },
  20932. * { 'user': 'pebbles', 'active': true }
  20933. * ];
  20934. *
  20935. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  20936. * // => 0
  20937. *
  20938. * // The `_.matches` iteratee shorthand.
  20939. * _.findIndex(users, { 'user': 'fred', 'active': false });
  20940. * // => 1
  20941. *
  20942. * // The `_.matchesProperty` iteratee shorthand.
  20943. * _.findIndex(users, ['active', false]);
  20944. * // => 0
  20945. *
  20946. * // The `_.property` iteratee shorthand.
  20947. * _.findIndex(users, 'active');
  20948. * // => 2
  20949. */
  20950. function findIndex(array, predicate, fromIndex) {
  20951. var length = array == null ? 0 : array.length;
  20952. if (!length) {
  20953. return -1;
  20954. }
  20955. var index = fromIndex == null ? 0 : lodash_es_toInteger(fromIndex);
  20956. if (index < 0) {
  20957. index = findIndex_nativeMax(length + index, 0);
  20958. }
  20959. return _baseFindIndex(array, _baseIteratee(predicate, 3), index);
  20960. }
  20961. /* harmony default export */ const lodash_es_findIndex = (findIndex);
  20962. ;// CONCATENATED MODULE: ./node_modules/lodash-es/findLastIndex.js
  20963. /* Built-in method references for those with the same name as other `lodash` methods. */
  20964. var findLastIndex_nativeMax = Math.max,
  20965. findLastIndex_nativeMin = Math.min;
  20966. /**
  20967. * This method is like `_.findIndex` except that it iterates over elements
  20968. * of `collection` from right to left.
  20969. *
  20970. * @static
  20971. * @memberOf _
  20972. * @since 2.0.0
  20973. * @category Array
  20974. * @param {Array} array The array to inspect.
  20975. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20976. * @param {number} [fromIndex=array.length-1] The index to search from.
  20977. * @returns {number} Returns the index of the found element, else `-1`.
  20978. * @example
  20979. *
  20980. * var users = [
  20981. * { 'user': 'barney', 'active': true },
  20982. * { 'user': 'fred', 'active': false },
  20983. * { 'user': 'pebbles', 'active': false }
  20984. * ];
  20985. *
  20986. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  20987. * // => 2
  20988. *
  20989. * // The `_.matches` iteratee shorthand.
  20990. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  20991. * // => 0
  20992. *
  20993. * // The `_.matchesProperty` iteratee shorthand.
  20994. * _.findLastIndex(users, ['active', false]);
  20995. * // => 2
  20996. *
  20997. * // The `_.property` iteratee shorthand.
  20998. * _.findLastIndex(users, 'active');
  20999. * // => 0
  21000. */
  21001. function findLastIndex(array, predicate, fromIndex) {
  21002. var length = array == null ? 0 : array.length;
  21003. if (!length) {
  21004. return -1;
  21005. }
  21006. var index = length - 1;
  21007. if (fromIndex !== undefined) {
  21008. index = lodash_es_toInteger(fromIndex);
  21009. index = fromIndex < 0
  21010. ? findLastIndex_nativeMax(length + index, 0)
  21011. : findLastIndex_nativeMin(index, length - 1);
  21012. }
  21013. return _baseFindIndex(array, _baseIteratee(predicate, 3), index, true);
  21014. }
  21015. /* harmony default export */ const lodash_es_findLastIndex = (findLastIndex);
  21016. ;// CONCATENATED MODULE: ./node_modules/lodash-es/groupBy.js
  21017. /** Used for built-in method references. */
  21018. var groupBy_objectProto = Object.prototype;
  21019. /** Used to check objects for own properties. */
  21020. var groupBy_hasOwnProperty = groupBy_objectProto.hasOwnProperty;
  21021. /**
  21022. * Creates an object composed of keys generated from the results of running
  21023. * each element of `collection` thru `iteratee`. The order of grouped values
  21024. * is determined by the order they occur in `collection`. The corresponding
  21025. * value of each key is an array of elements responsible for generating the
  21026. * key. The iteratee is invoked with one argument: (value).
  21027. *
  21028. * @static
  21029. * @memberOf _
  21030. * @since 0.1.0
  21031. * @category Collection
  21032. * @param {Array|Object} collection The collection to iterate over.
  21033. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  21034. * @returns {Object} Returns the composed aggregate object.
  21035. * @example
  21036. *
  21037. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  21038. * // => { '4': [4.2], '6': [6.1, 6.3] }
  21039. *
  21040. * // The `_.property` iteratee shorthand.
  21041. * _.groupBy(['one', 'two', 'three'], 'length');
  21042. * // => { '3': ['one', 'two'], '5': ['three'] }
  21043. */
  21044. var groupBy = _createAggregator(function(result, value, key) {
  21045. if (groupBy_hasOwnProperty.call(result, key)) {
  21046. result[key].push(value);
  21047. } else {
  21048. _baseAssignValue(result, key, [value]);
  21049. }
  21050. });
  21051. /* harmony default export */ const lodash_es_groupBy = (groupBy);
  21052. ;// CONCATENATED MODULE: ./node_modules/lodash-es/indexOf.js
  21053. /* Built-in method references for those with the same name as other `lodash` methods. */
  21054. var indexOf_nativeMax = Math.max;
  21055. /**
  21056. * Gets the index at which the first occurrence of `value` is found in `array`
  21057. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21058. * for equality comparisons. If `fromIndex` is negative, it's used as the
  21059. * offset from the end of `array`.
  21060. *
  21061. * @static
  21062. * @memberOf _
  21063. * @since 0.1.0
  21064. * @category Array
  21065. * @param {Array} array The array to inspect.
  21066. * @param {*} value The value to search for.
  21067. * @param {number} [fromIndex=0] The index to search from.
  21068. * @returns {number} Returns the index of the matched value, else `-1`.
  21069. * @example
  21070. *
  21071. * _.indexOf([1, 2, 1, 2], 2);
  21072. * // => 1
  21073. *
  21074. * // Search from the `fromIndex`.
  21075. * _.indexOf([1, 2, 1, 2], 2, 2);
  21076. * // => 3
  21077. */
  21078. function indexOf(array, value, fromIndex) {
  21079. var length = array == null ? 0 : array.length;
  21080. if (!length) {
  21081. return -1;
  21082. }
  21083. var index = fromIndex == null ? 0 : lodash_es_toInteger(fromIndex);
  21084. if (index < 0) {
  21085. index = indexOf_nativeMax(length + index, 0);
  21086. }
  21087. return _baseIndexOf(array, value, index);
  21088. }
  21089. /* harmony default export */ const lodash_es_indexOf = (indexOf);
  21090. ;// CONCATENATED MODULE: ./node_modules/lodash-es/keyBy.js
  21091. /**
  21092. * Creates an object composed of keys generated from the results of running
  21093. * each element of `collection` thru `iteratee`. The corresponding value of
  21094. * each key is the last element responsible for generating the key. The
  21095. * iteratee is invoked with one argument: (value).
  21096. *
  21097. * @static
  21098. * @memberOf _
  21099. * @since 4.0.0
  21100. * @category Collection
  21101. * @param {Array|Object} collection The collection to iterate over.
  21102. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  21103. * @returns {Object} Returns the composed aggregate object.
  21104. * @example
  21105. *
  21106. * var array = [
  21107. * { 'dir': 'left', 'code': 97 },
  21108. * { 'dir': 'right', 'code': 100 }
  21109. * ];
  21110. *
  21111. * _.keyBy(array, function(o) {
  21112. * return String.fromCharCode(o.code);
  21113. * });
  21114. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  21115. *
  21116. * _.keyBy(array, 'dir');
  21117. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  21118. */
  21119. var keyBy = _createAggregator(function(result, value, key) {
  21120. _baseAssignValue(result, key, value);
  21121. });
  21122. /* harmony default export */ const lodash_es_keyBy = (keyBy);
  21123. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_strictLastIndexOf.js
  21124. /**
  21125. * A specialized version of `_.lastIndexOf` which performs strict equality
  21126. * comparisons of values, i.e. `===`.
  21127. *
  21128. * @private
  21129. * @param {Array} array The array to inspect.
  21130. * @param {*} value The value to search for.
  21131. * @param {number} fromIndex The index to search from.
  21132. * @returns {number} Returns the index of the matched value, else `-1`.
  21133. */
  21134. function strictLastIndexOf(array, value, fromIndex) {
  21135. var index = fromIndex + 1;
  21136. while (index--) {
  21137. if (array[index] === value) {
  21138. return index;
  21139. }
  21140. }
  21141. return index;
  21142. }
  21143. /* harmony default export */ const _strictLastIndexOf = (strictLastIndexOf);
  21144. ;// CONCATENATED MODULE: ./node_modules/lodash-es/lastIndexOf.js
  21145. /* Built-in method references for those with the same name as other `lodash` methods. */
  21146. var lastIndexOf_nativeMax = Math.max,
  21147. lastIndexOf_nativeMin = Math.min;
  21148. /**
  21149. * This method is like `_.indexOf` except that it iterates over elements of
  21150. * `array` from right to left.
  21151. *
  21152. * @static
  21153. * @memberOf _
  21154. * @since 0.1.0
  21155. * @category Array
  21156. * @param {Array} array The array to inspect.
  21157. * @param {*} value The value to search for.
  21158. * @param {number} [fromIndex=array.length-1] The index to search from.
  21159. * @returns {number} Returns the index of the matched value, else `-1`.
  21160. * @example
  21161. *
  21162. * _.lastIndexOf([1, 2, 1, 2], 2);
  21163. * // => 3
  21164. *
  21165. * // Search from the `fromIndex`.
  21166. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  21167. * // => 1
  21168. */
  21169. function lastIndexOf(array, value, fromIndex) {
  21170. var length = array == null ? 0 : array.length;
  21171. if (!length) {
  21172. return -1;
  21173. }
  21174. var index = length;
  21175. if (fromIndex !== undefined) {
  21176. index = lodash_es_toInteger(fromIndex);
  21177. index = index < 0 ? lastIndexOf_nativeMax(length + index, 0) : lastIndexOf_nativeMin(index, length - 1);
  21178. }
  21179. return value === value
  21180. ? _strictLastIndexOf(array, value, index)
  21181. : _baseFindIndex(array, _baseIsNaN, index, true);
  21182. }
  21183. /* harmony default export */ const lodash_es_lastIndexOf = (lastIndexOf);
  21184. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseMap.js
  21185. /**
  21186. * The base implementation of `_.map` without support for iteratee shorthands.
  21187. *
  21188. * @private
  21189. * @param {Array|Object} collection The collection to iterate over.
  21190. * @param {Function} iteratee The function invoked per iteration.
  21191. * @returns {Array} Returns the new mapped array.
  21192. */
  21193. function baseMap(collection, iteratee) {
  21194. var index = -1,
  21195. result = lodash_es_isArrayLike(collection) ? Array(collection.length) : [];
  21196. _baseEach(collection, function(value, key, collection) {
  21197. result[++index] = iteratee(value, key, collection);
  21198. });
  21199. return result;
  21200. }
  21201. /* harmony default export */ const _baseMap = (baseMap);
  21202. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSortBy.js
  21203. /**
  21204. * The base implementation of `_.sortBy` which uses `comparer` to define the
  21205. * sort order of `array` and replaces criteria objects with their corresponding
  21206. * values.
  21207. *
  21208. * @private
  21209. * @param {Array} array The array to sort.
  21210. * @param {Function} comparer The function to define sort order.
  21211. * @returns {Array} Returns `array`.
  21212. */
  21213. function baseSortBy(array, comparer) {
  21214. var length = array.length;
  21215. array.sort(comparer);
  21216. while (length--) {
  21217. array[length] = array[length].value;
  21218. }
  21219. return array;
  21220. }
  21221. /* harmony default export */ const _baseSortBy = (baseSortBy);
  21222. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_compareAscending.js
  21223. /**
  21224. * Compares values to sort them in ascending order.
  21225. *
  21226. * @private
  21227. * @param {*} value The value to compare.
  21228. * @param {*} other The other value to compare.
  21229. * @returns {number} Returns the sort order indicator for `value`.
  21230. */
  21231. function compareAscending(value, other) {
  21232. if (value !== other) {
  21233. var valIsDefined = value !== undefined,
  21234. valIsNull = value === null,
  21235. valIsReflexive = value === value,
  21236. valIsSymbol = lodash_es_isSymbol(value);
  21237. var othIsDefined = other !== undefined,
  21238. othIsNull = other === null,
  21239. othIsReflexive = other === other,
  21240. othIsSymbol = lodash_es_isSymbol(other);
  21241. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21242. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21243. (valIsNull && othIsDefined && othIsReflexive) ||
  21244. (!valIsDefined && othIsReflexive) ||
  21245. !valIsReflexive) {
  21246. return 1;
  21247. }
  21248. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21249. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21250. (othIsNull && valIsDefined && valIsReflexive) ||
  21251. (!othIsDefined && valIsReflexive) ||
  21252. !othIsReflexive) {
  21253. return -1;
  21254. }
  21255. }
  21256. return 0;
  21257. }
  21258. /* harmony default export */ const _compareAscending = (compareAscending);
  21259. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_compareMultiple.js
  21260. /**
  21261. * Used by `_.orderBy` to compare multiple properties of a value to another
  21262. * and stable sort them.
  21263. *
  21264. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21265. * specify an order of "desc" for descending or "asc" for ascending sort order
  21266. * of corresponding values.
  21267. *
  21268. * @private
  21269. * @param {Object} object The object to compare.
  21270. * @param {Object} other The other object to compare.
  21271. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21272. * @returns {number} Returns the sort order indicator for `object`.
  21273. */
  21274. function compareMultiple(object, other, orders) {
  21275. var index = -1,
  21276. objCriteria = object.criteria,
  21277. othCriteria = other.criteria,
  21278. length = objCriteria.length,
  21279. ordersLength = orders.length;
  21280. while (++index < length) {
  21281. var result = _compareAscending(objCriteria[index], othCriteria[index]);
  21282. if (result) {
  21283. if (index >= ordersLength) {
  21284. return result;
  21285. }
  21286. var order = orders[index];
  21287. return result * (order == 'desc' ? -1 : 1);
  21288. }
  21289. }
  21290. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21291. // that causes it, under certain circumstances, to provide the same value for
  21292. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21293. // for more details.
  21294. //
  21295. // This also ensures a stable sort in V8 and other engines.
  21296. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21297. return object.index - other.index;
  21298. }
  21299. /* harmony default export */ const _compareMultiple = (compareMultiple);
  21300. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseOrderBy.js
  21301. /**
  21302. * The base implementation of `_.orderBy` without param guards.
  21303. *
  21304. * @private
  21305. * @param {Array|Object} collection The collection to iterate over.
  21306. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21307. * @param {string[]} orders The sort orders of `iteratees`.
  21308. * @returns {Array} Returns the new sorted array.
  21309. */
  21310. function baseOrderBy(collection, iteratees, orders) {
  21311. if (iteratees.length) {
  21312. iteratees = _arrayMap(iteratees, function(iteratee) {
  21313. if (lodash_es_isArray(iteratee)) {
  21314. return function(value) {
  21315. return _baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  21316. }
  21317. }
  21318. return iteratee;
  21319. });
  21320. } else {
  21321. iteratees = [lodash_es_identity];
  21322. }
  21323. var index = -1;
  21324. iteratees = _arrayMap(iteratees, _baseUnary(_baseIteratee));
  21325. var result = _baseMap(collection, function(value, key, collection) {
  21326. var criteria = _arrayMap(iteratees, function(iteratee) {
  21327. return iteratee(value);
  21328. });
  21329. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21330. });
  21331. return _baseSortBy(result, function(object, other) {
  21332. return _compareMultiple(object, other, orders);
  21333. });
  21334. }
  21335. /* harmony default export */ const _baseOrderBy = (baseOrderBy);
  21336. ;// CONCATENATED MODULE: ./node_modules/lodash-es/sortBy.js
  21337. /**
  21338. * Creates an array of elements, sorted in ascending order by the results of
  21339. * running each element in a collection thru each iteratee. This method
  21340. * performs a stable sort, that is, it preserves the original sort order of
  21341. * equal elements. The iteratees are invoked with one argument: (value).
  21342. *
  21343. * @static
  21344. * @memberOf _
  21345. * @since 0.1.0
  21346. * @category Collection
  21347. * @param {Array|Object} collection The collection to iterate over.
  21348. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  21349. * The iteratees to sort by.
  21350. * @returns {Array} Returns the new sorted array.
  21351. * @example
  21352. *
  21353. * var users = [
  21354. * { 'user': 'fred', 'age': 48 },
  21355. * { 'user': 'barney', 'age': 36 },
  21356. * { 'user': 'fred', 'age': 30 },
  21357. * { 'user': 'barney', 'age': 34 }
  21358. * ];
  21359. *
  21360. * _.sortBy(users, [function(o) { return o.user; }]);
  21361. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  21362. *
  21363. * _.sortBy(users, ['user', 'age']);
  21364. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  21365. */
  21366. var sortBy = _baseRest(function(collection, iteratees) {
  21367. if (collection == null) {
  21368. return [];
  21369. }
  21370. var length = iteratees.length;
  21371. if (length > 1 && _isIterateeCall(collection, iteratees[0], iteratees[1])) {
  21372. iteratees = [];
  21373. } else if (length > 2 && _isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  21374. iteratees = [iteratees[0]];
  21375. }
  21376. return _baseOrderBy(collection, _baseFlatten(iteratees, 1), []);
  21377. });
  21378. /* harmony default export */ const lodash_es_sortBy = (sortBy);
  21379. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/collection.js
  21380. // Backbone.js 1.4.0
  21381. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  21382. // Backbone may be freely distributed under the MIT license.
  21383. // Collection
  21384. // ----------
  21385. // If models tend to represent a single row of data, a Collection is
  21386. // more analogous to a table full of data ... or a small slice or page of that
  21387. // table, or a collection of rows that belong together for a particular reason
  21388. // -- all of the messages in this particular folder, all of the documents
  21389. // belonging to this particular author, and so on. Collections maintain
  21390. // indexes of their models, both in order, and for lookup by `id`.
  21391. const slice = Array.prototype.slice; // Create a new **Collection**, perhaps to contain a specific type of `model`.
  21392. // If a `comparator` is specified, the Collection will maintain
  21393. // its models in sort order, as they're added and removed.
  21394. const Collection = function (models, options) {
  21395. options || (options = {});
  21396. this.preinitialize.apply(this, arguments);
  21397. if (options.model) this.model = options.model;
  21398. if (options.comparator !== undefined) this.comparator = options.comparator;
  21399. this._reset();
  21400. this.initialize.apply(this, arguments);
  21401. if (models) this.reset(models, lodash_es_assignIn({
  21402. silent: true
  21403. }, options));
  21404. };
  21405. Collection.extend = inherits; // Default options for `Collection#set`.
  21406. const setOptions = {
  21407. add: true,
  21408. remove: true,
  21409. merge: true
  21410. };
  21411. const addOptions = {
  21412. add: true,
  21413. remove: false
  21414. }; // Splices `insert` into `array` at index `at`.
  21415. const collection_splice = function (array, insert, at) {
  21416. at = Math.min(Math.max(at, 0), array.length);
  21417. const tail = Array(array.length - at);
  21418. const length = insert.length;
  21419. let i;
  21420. for (i = 0; i < tail.length; i++) tail[i] = array[i + at];
  21421. for (i = 0; i < length; i++) array[i + at] = insert[i];
  21422. for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i];
  21423. }; // Define the Collection's inheritable methods.
  21424. Object.assign(Collection.prototype, Events, {
  21425. // The default model for a collection is just a **Backbone.Model**.
  21426. // This should be overridden in most cases.
  21427. model: Model,
  21428. // preinitialize is an empty function by default. You can override it with a function
  21429. // or object. preinitialize will run before any instantiation logic is run in the Collection.
  21430. preinitialize: function () {},
  21431. // Initialize is an empty function by default. Override it with your own
  21432. // initialization logic.
  21433. initialize: function () {},
  21434. // The JSON representation of a Collection is an array of the
  21435. // models' attributes.
  21436. toJSON: function (options) {
  21437. return this.map(function (model) {
  21438. return model.toJSON(options);
  21439. });
  21440. },
  21441. // Proxy `Backbone.sync` by default.
  21442. sync: function (method, model, options) {
  21443. return getSyncMethod(this)(method, model, options);
  21444. },
  21445. // Add a model, or list of models to the set. `models` may be Backbone
  21446. // Models or raw JavaScript objects to be converted to Models, or any
  21447. // combination of the two.
  21448. add: function (models, options) {
  21449. return this.set(models, lodash_es_assignIn({
  21450. merge: false
  21451. }, options, addOptions));
  21452. },
  21453. // Remove a model, or a list of models from the set.
  21454. remove: function (models, options) {
  21455. options = lodash_es_assignIn({}, options);
  21456. const singular = !Array.isArray(models);
  21457. models = singular ? [models] : models.slice();
  21458. const removed = this._removeModels(models, options);
  21459. if (!options.silent && removed.length) {
  21460. options.changes = {
  21461. added: [],
  21462. merged: [],
  21463. removed: removed
  21464. };
  21465. this.trigger('update', this, options);
  21466. }
  21467. return singular ? removed[0] : removed;
  21468. },
  21469. // Update a collection by `set`-ing a new list of models, adding new ones,
  21470. // removing models that are no longer present, and merging models that
  21471. // already exist in the collection, as necessary. Similar to **Model#set**,
  21472. // the core operation for updating the data contained by the collection.
  21473. set: function (models, options) {
  21474. if (models == null) return;
  21475. options = lodash_es_assignIn({}, setOptions, options);
  21476. if (options.parse && !this._isModel(models)) {
  21477. models = this.parse(models, options) || [];
  21478. }
  21479. const singular = !Array.isArray(models);
  21480. models = singular ? [models] : models.slice();
  21481. let at = options.at;
  21482. if (at != null) at = +at;
  21483. if (at > this.length) at = this.length;
  21484. if (at < 0) at += this.length + 1;
  21485. const set = [];
  21486. const toAdd = [];
  21487. const toMerge = [];
  21488. const toRemove = [];
  21489. const modelMap = {};
  21490. const add = options.add;
  21491. const merge = options.merge;
  21492. const remove = options.remove;
  21493. let sort = false;
  21494. const sortable = this.comparator && at == null && options.sort !== false;
  21495. const sortAttr = lodash_es_isString(this.comparator) ? this.comparator : null; // Turn bare objects into model references, and prevent invalid models
  21496. // from being added.
  21497. let model, i;
  21498. for (i = 0; i < models.length; i++) {
  21499. model = models[i]; // If a duplicate is found, prevent it from being added and
  21500. // optionally merge it into the existing model.
  21501. const existing = this.get(model);
  21502. if (existing) {
  21503. if (merge && model !== existing) {
  21504. let attrs = this._isModel(model) ? model.attributes : model;
  21505. if (options.parse) attrs = existing.parse(attrs, options);
  21506. existing.set(attrs, options);
  21507. toMerge.push(existing);
  21508. if (sortable && !sort) sort = existing.hasChanged(sortAttr);
  21509. }
  21510. if (!modelMap[existing.cid]) {
  21511. modelMap[existing.cid] = true;
  21512. set.push(existing);
  21513. }
  21514. models[i] = existing; // If this is a new, valid model, push it to the `toAdd` list.
  21515. } else if (add) {
  21516. model = models[i] = this._prepareModel(model, options);
  21517. if (model) {
  21518. toAdd.push(model);
  21519. this._addReference(model, options);
  21520. modelMap[model.cid] = true;
  21521. set.push(model);
  21522. }
  21523. }
  21524. } // Remove stale models.
  21525. if (remove) {
  21526. for (i = 0; i < this.length; i++) {
  21527. model = this.models[i];
  21528. if (!modelMap[model.cid]) toRemove.push(model);
  21529. }
  21530. if (toRemove.length) this._removeModels(toRemove, options);
  21531. } // See if sorting is needed, update `length` and splice in new models.
  21532. let orderChanged = false;
  21533. const replace = !sortable && add && remove;
  21534. if (set.length && replace) {
  21535. orderChanged = this.length !== set.length || lodash_es_some(this.models, (m, index) => m !== set[index]);
  21536. this.models.length = 0;
  21537. collection_splice(this.models, set, 0);
  21538. this.length = this.models.length;
  21539. } else if (toAdd.length) {
  21540. if (sortable) sort = true;
  21541. collection_splice(this.models, toAdd, at == null ? this.length : at);
  21542. this.length = this.models.length;
  21543. } // Silently sort the collection if appropriate.
  21544. if (sort) this.sort({
  21545. silent: true
  21546. }); // Unless silenced, it's time to fire all appropriate add/sort/update events.
  21547. if (!options.silent) {
  21548. for (i = 0; i < toAdd.length; i++) {
  21549. if (at != null) options.index = at + i;
  21550. model = toAdd[i];
  21551. model.trigger('add', model, this, options);
  21552. }
  21553. if (sort || orderChanged) this.trigger('sort', this, options);
  21554. if (toAdd.length || toRemove.length || toMerge.length) {
  21555. options.changes = {
  21556. added: toAdd,
  21557. removed: toRemove,
  21558. merged: toMerge
  21559. };
  21560. this.trigger('update', this, options);
  21561. }
  21562. } // Return the added (or merged) model (or models).
  21563. return singular ? models[0] : models;
  21564. },
  21565. clearStore: async function () {
  21566. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  21567. let filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : o => o;
  21568. await Promise.all(this.models.filter(filter).map(m => {
  21569. return new Promise(resolve => {
  21570. m.destroy(Object.assign(options, {
  21571. 'success': resolve,
  21572. 'error': (m, e) => {
  21573. console.error(e);
  21574. resolve();
  21575. }
  21576. }));
  21577. });
  21578. }));
  21579. await this.browserStorage.clear();
  21580. this.reset();
  21581. },
  21582. // When you have more items than you want to add or remove individually,
  21583. // you can reset the entire set with a new list of models, without firing
  21584. // any granular `add` or `remove` events. Fires `reset` when finished.
  21585. // Useful for bulk operations and optimizations.
  21586. reset: function (models, options) {
  21587. options = options ? lodash_es_clone(options) : {};
  21588. for (let i = 0; i < this.models.length; i++) {
  21589. this._removeReference(this.models[i], options);
  21590. }
  21591. options.previousModels = this.models;
  21592. this._reset();
  21593. models = this.add(models, lodash_es_assignIn({
  21594. silent: true
  21595. }, options));
  21596. if (!options.silent) this.trigger('reset', this, options);
  21597. return models;
  21598. },
  21599. // Add a model to the end of the collection.
  21600. push: function (model, options) {
  21601. return this.add(model, lodash_es_assignIn({
  21602. at: this.length
  21603. }, options));
  21604. },
  21605. // Remove a model from the end of the collection.
  21606. pop: function (options) {
  21607. const model = this.at(this.length - 1);
  21608. return this.remove(model, options);
  21609. },
  21610. // Add a model to the beginning of the collection.
  21611. unshift: function (model, options) {
  21612. return this.add(model, lodash_es_assignIn({
  21613. at: 0
  21614. }, options));
  21615. },
  21616. // Remove a model from the beginning of the collection.
  21617. shift: function (options) {
  21618. const model = this.at(0);
  21619. return this.remove(model, options);
  21620. },
  21621. // Slice out a sub-array of models from the collection.
  21622. slice: function () {
  21623. return slice.apply(this.models, arguments);
  21624. },
  21625. filter: function (callback, thisArg) {
  21626. return this.models.filter(lodash_es_isFunction(callback) ? callback : m => m.matches(callback), thisArg);
  21627. },
  21628. every: function (pred) {
  21629. return lodash_es_every(this.models.map(m => m.attributes), pred);
  21630. },
  21631. difference: function (values) {
  21632. return lodash_es_difference(this.models, values);
  21633. },
  21634. max: function () {
  21635. return Math.max.apply(Math, this.models);
  21636. },
  21637. min: function () {
  21638. return Math.min.apply(Math, this.models);
  21639. },
  21640. drop: function () {
  21641. let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  21642. return this.models.slice(n);
  21643. },
  21644. some: function (pred) {
  21645. return lodash_es_some(this.models.map(m => m.attributes), pred);
  21646. },
  21647. sortBy: function (iteratee) {
  21648. return lodash_es_sortBy(this.models, lodash_es_isFunction(iteratee) ? iteratee : m => lodash_es_isString(iteratee) ? m.get(iteratee) : m.matches(iteratee));
  21649. },
  21650. isEmpty: function () {
  21651. return lodash_es_isEmpty(this.models);
  21652. },
  21653. keyBy: function (iteratee) {
  21654. return lodash_es_keyBy(this.models, iteratee);
  21655. },
  21656. each: function (callback, thisArg) {
  21657. return this.forEach(callback, thisArg);
  21658. },
  21659. forEach: function (callback, thisArg) {
  21660. return this.models.forEach(callback, thisArg);
  21661. },
  21662. includes: function (item) {
  21663. return this.models.includes(item);
  21664. },
  21665. size: function () {
  21666. return this.models.length;
  21667. },
  21668. countBy: function (f) {
  21669. return lodash_es_countBy(this.models, lodash_es_isFunction(f) ? f : m => lodash_es_isString(f) ? m.get(f) : m.matches(f));
  21670. },
  21671. groupBy: function (pred) {
  21672. return lodash_es_groupBy(this.models, lodash_es_isFunction(pred) ? pred : m => lodash_es_isString(pred) ? m.get(pred) : m.matches(pred));
  21673. },
  21674. indexOf: function (fromIndex) {
  21675. return lodash_es_indexOf(this.models, fromIndex);
  21676. },
  21677. findLastIndex: function (pred, fromIndex) {
  21678. return lodash_es_findLastIndex(this.models, lodash_es_isFunction(pred) ? pred : m => lodash_es_isString(pred) ? m.get(pred) : m.matches(pred), fromIndex);
  21679. },
  21680. lastIndexOf: function (fromIndex) {
  21681. return lodash_es_lastIndexOf(this.models, fromIndex);
  21682. },
  21683. findIndex: function (pred) {
  21684. return lodash_es_findIndex(this.models, lodash_es_isFunction(pred) ? pred : m => lodash_es_isString(pred) ? m.get(pred) : m.matches(pred));
  21685. },
  21686. last: function () {
  21687. const length = this.models == null ? 0 : this.models.length;
  21688. return length ? this.models[length - 1] : undefined;
  21689. },
  21690. head: function () {
  21691. return this.models[0];
  21692. },
  21693. first: function () {
  21694. return this.head();
  21695. },
  21696. map: function (cb, thisArg) {
  21697. return this.models.map(lodash_es_isFunction(cb) ? cb : m => lodash_es_isString(cb) ? m.get(cb) : m.matches(cb), thisArg);
  21698. },
  21699. reduce: function (callback, initialValue) {
  21700. return this.models.reduce(callback, initialValue || this.models[0]);
  21701. },
  21702. reduceRight: function (callback, initialValue) {
  21703. return this.models.reduceRight(callback, initialValue || this.models[0]);
  21704. },
  21705. toArray: function () {
  21706. return Array.from(this.models);
  21707. },
  21708. // Get a model from the set by id, cid, model object with id or cid
  21709. // properties, or an attributes object that is transformed through modelId.
  21710. get: function (obj) {
  21711. if (obj == null) return undefined;
  21712. return this._byId[obj] || this._byId[this.modelId(this._isModel(obj) ? obj.attributes : obj)] || obj.cid && this._byId[obj.cid];
  21713. },
  21714. // Returns `true` if the model is in the collection.
  21715. has: function (obj) {
  21716. return this.get(obj) != null;
  21717. },
  21718. // Get the model at the given index.
  21719. at: function (index) {
  21720. if (index < 0) index += this.length;
  21721. return this.models[index];
  21722. },
  21723. // Return models with matching attributes. Useful for simple cases of
  21724. // `filter`.
  21725. where: function (attrs, first) {
  21726. return this[first ? 'find' : 'filter'](attrs);
  21727. },
  21728. // Return the first model with matching attributes. Useful for simple cases
  21729. // of `find`.
  21730. findWhere: function (attrs) {
  21731. return this.where(attrs, true);
  21732. },
  21733. find: function (predicate, fromIndex) {
  21734. const pred = lodash_es_isFunction(predicate) ? predicate : m => m.matches(predicate);
  21735. return this.models.find(pred, fromIndex);
  21736. },
  21737. // Force the collection to re-sort itself. You don't need to call this under
  21738. // normal circumstances, as the set will maintain sort order as each item
  21739. // is added.
  21740. sort: function (options) {
  21741. let comparator = this.comparator;
  21742. if (!comparator) throw new Error('Cannot sort a set without a comparator');
  21743. options || (options = {});
  21744. const length = comparator.length;
  21745. if (lodash_es_isFunction(comparator)) comparator = comparator.bind(this); // Run sort based on type of `comparator`.
  21746. if (length === 1 || lodash_es_isString(comparator)) {
  21747. this.models = this.sortBy(comparator);
  21748. } else {
  21749. this.models.sort(comparator);
  21750. }
  21751. if (!options.silent) this.trigger('sort', this, options);
  21752. return this;
  21753. },
  21754. // Pluck an attribute from each model in the collection.
  21755. pluck: function (attr) {
  21756. return this.map(attr + '');
  21757. },
  21758. // Fetch the default set of models for this collection, resetting the
  21759. // collection when they arrive. If `reset: true` is passed, the response
  21760. // data will be passed through the `reset` method instead of `set`.
  21761. fetch: function (options) {
  21762. options = lodash_es_assignIn({
  21763. parse: true
  21764. }, options);
  21765. const success = options.success;
  21766. const collection = this;
  21767. const promise = options.promise && getResolveablePromise();
  21768. options.success = function (resp) {
  21769. const method = options.reset ? 'reset' : 'set';
  21770. collection[method](resp, options);
  21771. if (success) success.call(options.context, collection, resp, options);
  21772. promise && promise.resolve();
  21773. collection.trigger('sync', collection, resp, options);
  21774. };
  21775. wrapError(this, options);
  21776. return promise ? promise : this.sync('read', this, options);
  21777. },
  21778. // Create a new instance of a model in this collection. Add the model to the
  21779. // collection immediately, unless `wait: true` is passed, in which case we
  21780. // wait for the server to agree.
  21781. create: function (model, options) {
  21782. options = options ? lodash_es_clone(options) : {};
  21783. const wait = options.wait;
  21784. const return_promise = options.promise;
  21785. const promise = return_promise && getResolveablePromise();
  21786. model = this._prepareModel(model, options);
  21787. if (!model) return false;
  21788. if (!wait) this.add(model, options);
  21789. const collection = this;
  21790. const success = options.success;
  21791. const error = options.error;
  21792. options.success = function (m, resp, callbackOpts) {
  21793. if (wait) {
  21794. collection.add(m, callbackOpts);
  21795. }
  21796. if (success) {
  21797. success.call(callbackOpts.context, m, resp, callbackOpts);
  21798. }
  21799. if (return_promise) {
  21800. promise.resolve(m);
  21801. }
  21802. };
  21803. options.error = function (model, e, options) {
  21804. error && error.call(options.context, model, e, options);
  21805. return_promise && promise.reject(e);
  21806. };
  21807. model.save(null, Object.assign(options, {
  21808. 'promise': false
  21809. }));
  21810. if (return_promise) {
  21811. return promise;
  21812. } else {
  21813. return model;
  21814. }
  21815. },
  21816. // **parse** converts a response into a list of models to be added to the
  21817. // collection. The default implementation is just to pass it through.
  21818. parse: function (resp, options) {
  21819. return resp;
  21820. },
  21821. // Create a new collection with an identical list of models as this one.
  21822. clone: function () {
  21823. return new this.constructor(this.models, {
  21824. model: this.model,
  21825. comparator: this.comparator
  21826. });
  21827. },
  21828. // Define how to uniquely identify models in the collection.
  21829. modelId: function (attrs) {
  21830. var _this$model$prototype;
  21831. return attrs[((_this$model$prototype = this.model.prototype) === null || _this$model$prototype === void 0 ? void 0 : _this$model$prototype.idAttribute) || 'id'];
  21832. },
  21833. // Get an iterator of all models in this collection.
  21834. values: function () {
  21835. return new CollectionIterator(this, ITERATOR_VALUES);
  21836. },
  21837. // Get an iterator of all model IDs in this collection.
  21838. keys: function () {
  21839. return new CollectionIterator(this, ITERATOR_KEYS);
  21840. },
  21841. // Get an iterator of all [ID, model] tuples in this collection.
  21842. entries: function () {
  21843. return new CollectionIterator(this, ITERATOR_KEYSVALUES);
  21844. },
  21845. // Private method to reset all internal state. Called when the collection
  21846. // is first initialized or reset.
  21847. _reset: function () {
  21848. this.length = 0;
  21849. this.models = [];
  21850. this._byId = {};
  21851. },
  21852. // Prepare a hash of attributes (or other model) to be added to this
  21853. // collection.
  21854. _prepareModel: function (attrs, options) {
  21855. if (this._isModel(attrs)) {
  21856. if (!attrs.collection) attrs.collection = this;
  21857. return attrs;
  21858. }
  21859. options = options ? lodash_es_clone(options) : {};
  21860. options.collection = this;
  21861. const model = new this.model(attrs, options);
  21862. if (!model.validationError) return model;
  21863. this.trigger('invalid', this, model.validationError, options);
  21864. return false;
  21865. },
  21866. // Internal method called by both remove and set.
  21867. _removeModels: function (models, options) {
  21868. const removed = [];
  21869. for (let i = 0; i < models.length; i++) {
  21870. const model = this.get(models[i]);
  21871. if (!model) continue;
  21872. const index = this.indexOf(model);
  21873. this.models.splice(index, 1);
  21874. this.length--; // Remove references before triggering 'remove' event to prevent an
  21875. // infinite loop. #3693
  21876. delete this._byId[model.cid];
  21877. const id = this.modelId(model.attributes);
  21878. if (id != null) delete this._byId[id];
  21879. if (!options.silent) {
  21880. options.index = index;
  21881. model.trigger('remove', model, this, options);
  21882. }
  21883. removed.push(model);
  21884. this._removeReference(model, options);
  21885. }
  21886. return removed;
  21887. },
  21888. // Method for checking whether an object should be considered a model for
  21889. // the purposes of adding to the collection.
  21890. _isModel: function (model) {
  21891. return model instanceof Model;
  21892. },
  21893. // Internal method to create a model's ties to a collection.
  21894. _addReference: function (model, options) {
  21895. this._byId[model.cid] = model;
  21896. const id = this.modelId(model.attributes);
  21897. if (id != null) this._byId[id] = model;
  21898. model.on('all', this._onModelEvent, this);
  21899. },
  21900. // Internal method to sever a model's ties to a collection.
  21901. _removeReference: function (model, options) {
  21902. delete this._byId[model.cid];
  21903. const id = this.modelId(model.attributes);
  21904. if (id != null) delete this._byId[id];
  21905. if (this === model.collection) delete model.collection;
  21906. model.off('all', this._onModelEvent, this);
  21907. },
  21908. // Internal method called every time a model in the set fires an event.
  21909. // Sets need to update their indexes when models change ids. All other
  21910. // events simply proxy through. "add" and "remove" events that originate
  21911. // in other collections are ignored.
  21912. _onModelEvent: function (event, model, collection, options) {
  21913. if (model) {
  21914. if ((event === 'add' || event === 'remove') && collection !== this) return;
  21915. if (event === 'destroy') this.remove(model, options);
  21916. if (event === 'change') {
  21917. const prevId = this.modelId(model.previousAttributes());
  21918. const id = this.modelId(model.attributes);
  21919. if (prevId !== id) {
  21920. if (prevId != null) delete this._byId[prevId];
  21921. if (id != null) this._byId[id] = model;
  21922. }
  21923. }
  21924. }
  21925. this.trigger.apply(this, arguments);
  21926. }
  21927. }); // Defining an @@iterator method implements JavaScript's Iterable protocol.
  21928. // In modern ES2015 browsers, this value is found at Symbol.iterator.
  21929. /* global Symbol */
  21930. const $$iterator = typeof Symbol === 'function' && Symbol.iterator;
  21931. if ($$iterator) {
  21932. Collection.prototype[$$iterator] = Collection.prototype.values;
  21933. } // CollectionIterator
  21934. // ------------------
  21935. // A CollectionIterator implements JavaScript's Iterator protocol, allowing the
  21936. // use of `for of` loops in modern browsers and interoperation between
  21937. // Collection and other JavaScript functions and third-party libraries
  21938. // which can operate on Iterables.
  21939. const CollectionIterator = function (collection, kind) {
  21940. this._collection = collection;
  21941. this._kind = kind;
  21942. this._index = 0;
  21943. }; // This "enum" defines the three possible kinds of values which can be emitted
  21944. // by a CollectionIterator that correspond to the values(), keys() and entries()
  21945. // methods on Collection, respectively.
  21946. const ITERATOR_VALUES = 1;
  21947. const ITERATOR_KEYS = 2;
  21948. const ITERATOR_KEYSVALUES = 3; // All Iterators should themselves be Iterable.
  21949. if ($$iterator) {
  21950. CollectionIterator.prototype[$$iterator] = function () {
  21951. return this;
  21952. };
  21953. }
  21954. CollectionIterator.prototype.next = function () {
  21955. if (this._collection) {
  21956. // Only continue iterating if the iterated collection is long enough.
  21957. if (this._index < this._collection.length) {
  21958. const model = this._collection.at(this._index);
  21959. this._index++; // Construct a value depending on what kind of values should be iterated.
  21960. let value;
  21961. if (this._kind === ITERATOR_VALUES) {
  21962. value = model;
  21963. } else {
  21964. const id = this._collection.modelId(model.attributes);
  21965. if (this._kind === ITERATOR_KEYS) {
  21966. value = id;
  21967. } else {
  21968. // ITERATOR_KEYSVALUES
  21969. value = [id, model];
  21970. }
  21971. }
  21972. return {
  21973. value: value,
  21974. done: false
  21975. };
  21976. } // Once exhausted, remove the reference to the collection so future
  21977. // calls to the next method always return done.
  21978. this._collection = undefined;
  21979. }
  21980. return {
  21981. value: undefined,
  21982. done: true
  21983. };
  21984. };
  21985. ;// CONCATENATED MODULE: ./node_modules/@lit/reactive-element/css-tag.js
  21986. /**
  21987. * @license
  21988. * Copyright 2019 Google LLC
  21989. * SPDX-License-Identifier: BSD-3-Clause
  21990. */
  21991. const css_tag_t=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e=Symbol(),n=new Map;class s{constructor(t,n){if(this._$cssResult$=!0,n!==e)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let e=n.get(this.cssText);return css_tag_t&&void 0===e&&(n.set(this.cssText,e=new CSSStyleSheet),e.replaceSync(this.cssText)),e}toString(){return this.cssText}}const o=t=>new s("string"==typeof t?t:t+"",e),r=(t,...n)=>{const o=1===t.length?t[0]:n.reduce(((e,n,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[s+1]),t[0]);return new s(o,e)},css_tag_i=(e,n)=>{css_tag_t?e.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((t=>{const n=document.createElement("style"),s=window.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=t.cssText,e.appendChild(n)}))},S=css_tag_t?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return o(e)})(t):t;
  21992. //# sourceMappingURL=css-tag.js.map
  21993. ;// CONCATENATED MODULE: ./node_modules/@lit/reactive-element/reactive-element.js
  21994. /**
  21995. * @license
  21996. * Copyright 2017 Google LLC
  21997. * SPDX-License-Identifier: BSD-3-Clause
  21998. */var reactive_element_s;const reactive_element_e=window.trustedTypes,reactive_element_r=reactive_element_e?reactive_element_e.emptyScript:"",h=window.reactiveElementPolyfillSupport,reactive_element_o={toAttribute(t,i){switch(i){case Boolean:t=t?reactive_element_r:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},reactive_element_n=(t,i)=>i!==t&&(i==i||t==t),l={attribute:!0,type:String,converter:reactive_element_o,reflect:!1,hasChanged:reactive_element_n};class a extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var i;null!==(i=this.l)&&void 0!==i||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Eh(s,i);void 0!==e&&(this._$Eu.set(e,s),t.push(e))})),t}static createProperty(t,i=l){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e)}}static getPropertyDescriptor(t,i,s){return{get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||l}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(i){const s=[];if(Array.isArray(i)){const e=new Set(i.flat(1/0).reverse());for(const i of e)s.unshift(S(i))}else void 0!==i&&s.push(S(i));return s}static _$Eh(t,i){const s=i.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var i,s;(null!==(i=this._$Eg)&&void 0!==i?i:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t))}removeController(t){var i;null===(i=this._$Eg)||void 0===i||i.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Et.set(i,this[i]),delete this[i])}))}createRenderRoot(){var t;const s=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return css_tag_i(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}))}attributeChangedCallback(t,i,s){this._$AK(t,s)}_$ES(t,i,s=l){var e,r;const h=this.constructor._$Eh(t,s);if(void 0!==h&&!0===s.reflect){const n=(null!==(r=null===(e=s.converter)||void 0===e?void 0:e.toAttribute)&&void 0!==r?r:reactive_element_o.toAttribute)(i,s.type);this._$Ei=t,null==n?this.removeAttribute(h):this.setAttribute(h,n),this._$Ei=null}}_$AK(t,i){var s,e,r;const h=this.constructor,n=h._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=h.getPropertyOptions(n),l=t.converter,a=null!==(r=null!==(e=null===(s=l)||void 0===s?void 0:s.fromAttribute)&&void 0!==e?e:"function"==typeof l?l:null)&&void 0!==r?r:reactive_element_o.fromAttribute;this._$Ei=n,this[n]=a(i,t.type),this._$Ei=null}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||reactive_element_n)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,i)=>this[i]=t)),this._$Et=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$EU()}catch(t){throw i=!1,this._$EU(),t}i&&this._$AE(s)}willUpdate(t){}_$AE(t){var i;null===(i=this._$Eg)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$ES(i,this[i],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}a.finalized=!0,a.elementProperties=new Map,a.elementStyles=[],a.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:a}),(null!==(reactive_element_s=globalThis.reactiveElementVersions)&&void 0!==reactive_element_s?reactive_element_s:globalThis.reactiveElementVersions=[]).push("1.3.0");
  21999. //# sourceMappingURL=reactive-element.js.map
  22000. ;// CONCATENATED MODULE: ./node_modules/lit-html/lit-html.js
  22001. /**
  22002. * @license
  22003. * Copyright 2017 Google LLC
  22004. * SPDX-License-Identifier: BSD-3-Clause
  22005. */
  22006. var lit_html_t;
  22007. const lit_html_i = globalThis.trustedTypes,
  22008. lit_html_s = lit_html_i ? lit_html_i.createPolicy("lit-html", {
  22009. createHTML: t => t
  22010. }) : void 0,
  22011. lit_html_e = `lit$${(Math.random() + "").slice(9)}$`,
  22012. lit_html_o = "?" + lit_html_e,
  22013. lit_html_n = `<${lit_html_o}>`,
  22014. lit_html_l = document,
  22015. lit_html_h = function () {
  22016. let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  22017. return lit_html_l.createComment(t);
  22018. },
  22019. lit_html_r = t => null === t || "object" != typeof t && "function" != typeof t,
  22020. d = Array.isArray,
  22021. lit_html_u = t => {
  22022. var i;
  22023. return d(t) || "function" == typeof (null === (i = t) || void 0 === i ? void 0 : i[Symbol.iterator]);
  22024. },
  22025. c = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,
  22026. v = /-->/g,
  22027. lit_html_a = />/g,
  22028. f = />|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,
  22029. _ = /'/g,
  22030. m = /"/g,
  22031. g = /^(?:script|style|textarea|title)$/i,
  22032. p = t => function (i) {
  22033. for (var _len = arguments.length, s = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  22034. s[_key - 1] = arguments[_key];
  22035. }
  22036. return {
  22037. _$litType$: t,
  22038. strings: i,
  22039. values: s
  22040. };
  22041. },
  22042. $ = p(1),
  22043. y = p(2),
  22044. b = Symbol.for("lit-noChange"),
  22045. w = Symbol.for("lit-nothing"),
  22046. T = new WeakMap(),
  22047. x = (t, i, s) => {
  22048. var e, o;
  22049. const n = null !== (e = null == s ? void 0 : s.renderBefore) && void 0 !== e ? e : i;
  22050. let l = n._$litPart$;
  22051. if (void 0 === l) {
  22052. const t = null !== (o = null == s ? void 0 : s.renderBefore) && void 0 !== o ? o : null;
  22053. n._$litPart$ = l = new N(i.insertBefore(lit_html_h(), t), t, void 0, null != s ? s : {});
  22054. }
  22055. return l._$AI(t), l;
  22056. },
  22057. A = lit_html_l.createTreeWalker(lit_html_l, 129, null, !1),
  22058. C = (t, i) => {
  22059. const o = t.length - 1,
  22060. l = [];
  22061. let h,
  22062. r = 2 === i ? "<svg>" : "",
  22063. d = c;
  22064. for (let i = 0; i < o; i++) {
  22065. const s = t[i];
  22066. let o,
  22067. u,
  22068. p = -1,
  22069. $ = 0;
  22070. for (; $ < s.length && (d.lastIndex = $, u = d.exec(s), null !== u);) $ = d.lastIndex, d === c ? "!--" === u[1] ? d = v : void 0 !== u[1] ? d = lit_html_a : void 0 !== u[2] ? (g.test(u[2]) && (h = RegExp("</" + u[2], "g")), d = f) : void 0 !== u[3] && (d = f) : d === f ? ">" === u[0] ? (d = null != h ? h : c, p = -1) : void 0 === u[1] ? p = -2 : (p = d.lastIndex - u[2].length, o = u[1], d = void 0 === u[3] ? f : '"' === u[3] ? m : _) : d === m || d === _ ? d = f : d === v || d === lit_html_a ? d = c : (d = f, h = void 0);
  22071. const y = d === f && t[i + 1].startsWith("/>") ? " " : "";
  22072. r += d === c ? s + lit_html_n : p >= 0 ? (l.push(o), s.slice(0, p) + "$lit$" + s.slice(p) + lit_html_e + y) : s + lit_html_e + (-2 === p ? (l.push(void 0), i) : y);
  22073. }
  22074. const u = r + (t[o] || "<?>") + (2 === i ? "</svg>" : "");
  22075. if (!Array.isArray(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array");
  22076. return [void 0 !== lit_html_s ? lit_html_s.createHTML(u) : u, l];
  22077. };
  22078. class E {
  22079. constructor(_ref, n) {
  22080. let {
  22081. strings: t,
  22082. _$litType$: s
  22083. } = _ref;
  22084. let l;
  22085. this.parts = [];
  22086. let r = 0,
  22087. d = 0;
  22088. const u = t.length - 1,
  22089. c = this.parts,
  22090. [v, a] = C(t, s);
  22091. if (this.el = E.createElement(v, n), A.currentNode = this.el.content, 2 === s) {
  22092. const t = this.el.content,
  22093. i = t.firstChild;
  22094. i.remove(), t.append(...i.childNodes);
  22095. }
  22096. for (; null !== (l = A.nextNode()) && c.length < u;) {
  22097. if (1 === l.nodeType) {
  22098. if (l.hasAttributes()) {
  22099. const t = [];
  22100. for (const i of l.getAttributeNames()) if (i.endsWith("$lit$") || i.startsWith(lit_html_e)) {
  22101. const s = a[d++];
  22102. if (t.push(i), void 0 !== s) {
  22103. const t = l.getAttribute(s.toLowerCase() + "$lit$").split(lit_html_e),
  22104. i = /([.?@])?(.*)/.exec(s);
  22105. c.push({
  22106. type: 1,
  22107. index: r,
  22108. name: i[2],
  22109. strings: t,
  22110. ctor: "." === i[1] ? M : "?" === i[1] ? H : "@" === i[1] ? I : lit_html_S
  22111. });
  22112. } else c.push({
  22113. type: 6,
  22114. index: r
  22115. });
  22116. }
  22117. for (const i of t) l.removeAttribute(i);
  22118. }
  22119. if (g.test(l.tagName)) {
  22120. const t = l.textContent.split(lit_html_e),
  22121. s = t.length - 1;
  22122. if (s > 0) {
  22123. l.textContent = lit_html_i ? lit_html_i.emptyScript : "";
  22124. for (let i = 0; i < s; i++) l.append(t[i], lit_html_h()), A.nextNode(), c.push({
  22125. type: 2,
  22126. index: ++r
  22127. });
  22128. l.append(t[s], lit_html_h());
  22129. }
  22130. }
  22131. } else if (8 === l.nodeType) if (l.data === lit_html_o) c.push({
  22132. type: 2,
  22133. index: r
  22134. });else {
  22135. let t = -1;
  22136. for (; -1 !== (t = l.data.indexOf(lit_html_e, t + 1));) c.push({
  22137. type: 7,
  22138. index: r
  22139. }), t += lit_html_e.length - 1;
  22140. }
  22141. r++;
  22142. }
  22143. }
  22144. static createElement(t, i) {
  22145. const s = lit_html_l.createElement("template");
  22146. return s.innerHTML = t, s;
  22147. }
  22148. }
  22149. function P(t, i) {
  22150. let s = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : t;
  22151. let e = arguments.length > 3 ? arguments[3] : undefined;
  22152. var o, n, l, h;
  22153. if (i === b) return i;
  22154. let d = void 0 !== e ? null === (o = s._$Cl) || void 0 === o ? void 0 : o[e] : s._$Cu;
  22155. const u = lit_html_r(i) ? void 0 : i._$litDirective$;
  22156. return (null == d ? void 0 : d.constructor) !== u && (null === (n = null == d ? void 0 : d._$AO) || void 0 === n || n.call(d, !1), void 0 === u ? d = void 0 : (d = new u(t), d._$AT(t, s, e)), void 0 !== e ? (null !== (l = (h = s)._$Cl) && void 0 !== l ? l : h._$Cl = [])[e] = d : s._$Cu = d), void 0 !== d && (i = P(t, d._$AS(t, i.values), d, e)), i;
  22157. }
  22158. class V {
  22159. constructor(t, i) {
  22160. this.v = [], this._$AN = void 0, this._$AD = t, this._$AM = i;
  22161. }
  22162. get parentNode() {
  22163. return this._$AM.parentNode;
  22164. }
  22165. get _$AU() {
  22166. return this._$AM._$AU;
  22167. }
  22168. p(t) {
  22169. var i;
  22170. const {
  22171. el: {
  22172. content: s
  22173. },
  22174. parts: e
  22175. } = this._$AD,
  22176. o = (null !== (i = null == t ? void 0 : t.creationScope) && void 0 !== i ? i : lit_html_l).importNode(s, !0);
  22177. A.currentNode = o;
  22178. let n = A.nextNode(),
  22179. h = 0,
  22180. r = 0,
  22181. d = e[0];
  22182. for (; void 0 !== d;) {
  22183. if (h === d.index) {
  22184. let i;
  22185. 2 === d.type ? i = new N(n, n.nextSibling, this, t) : 1 === d.type ? i = new d.ctor(n, d.name, d.strings, this, t) : 6 === d.type && (i = new L(n, this, t)), this.v.push(i), d = e[++r];
  22186. }
  22187. h !== (null == d ? void 0 : d.index) && (n = A.nextNode(), h++);
  22188. }
  22189. return o;
  22190. }
  22191. m(t) {
  22192. let i = 0;
  22193. for (const s of this.v) void 0 !== s && (void 0 !== s.strings ? (s._$AI(t, s, i), i += s.strings.length - 2) : s._$AI(t[i])), i++;
  22194. }
  22195. }
  22196. class N {
  22197. constructor(t, i, s, e) {
  22198. var o;
  22199. this.type = 2, this._$AH = w, this._$AN = void 0, this._$AA = t, this._$AB = i, this._$AM = s, this.options = e, this._$Cg = null === (o = null == e ? void 0 : e.isConnected) || void 0 === o || o;
  22200. }
  22201. get _$AU() {
  22202. var t, i;
  22203. return null !== (i = null === (t = this._$AM) || void 0 === t ? void 0 : t._$AU) && void 0 !== i ? i : this._$Cg;
  22204. }
  22205. get parentNode() {
  22206. let t = this._$AA.parentNode;
  22207. const i = this._$AM;
  22208. return void 0 !== i && 11 === t.nodeType && (t = i.parentNode), t;
  22209. }
  22210. get startNode() {
  22211. return this._$AA;
  22212. }
  22213. get endNode() {
  22214. return this._$AB;
  22215. }
  22216. _$AI(t) {
  22217. let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  22218. t = P(this, t, i), lit_html_r(t) ? t === w || null == t || "" === t ? (this._$AH !== w && this._$AR(), this._$AH = w) : t !== this._$AH && t !== b && this.$(t) : void 0 !== t._$litType$ ? this.T(t) : void 0 !== t.nodeType ? this.k(t) : lit_html_u(t) ? this.S(t) : this.$(t);
  22219. }
  22220. A(t) {
  22221. let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._$AB;
  22222. return this._$AA.parentNode.insertBefore(t, i);
  22223. }
  22224. k(t) {
  22225. this._$AH !== t && (this._$AR(), this._$AH = this.A(t));
  22226. }
  22227. $(t) {
  22228. this._$AH !== w && lit_html_r(this._$AH) ? this._$AA.nextSibling.data = t : this.k(lit_html_l.createTextNode(t)), this._$AH = t;
  22229. }
  22230. T(t) {
  22231. var i;
  22232. const {
  22233. values: s,
  22234. _$litType$: e
  22235. } = t,
  22236. o = "number" == typeof e ? this._$AC(t) : (void 0 === e.el && (e.el = E.createElement(e.h, this.options)), e);
  22237. if ((null === (i = this._$AH) || void 0 === i ? void 0 : i._$AD) === o) this._$AH.m(s);else {
  22238. const t = new V(o, this),
  22239. i = t.p(this.options);
  22240. t.m(s), this.k(i), this._$AH = t;
  22241. }
  22242. }
  22243. _$AC(t) {
  22244. let i = T.get(t.strings);
  22245. return void 0 === i && T.set(t.strings, i = new E(t)), i;
  22246. }
  22247. S(t) {
  22248. d(this._$AH) || (this._$AH = [], this._$AR());
  22249. const i = this._$AH;
  22250. let s,
  22251. e = 0;
  22252. for (const o of t) e === i.length ? i.push(s = new N(this.A(lit_html_h()), this.A(lit_html_h()), this, this.options)) : s = i[e], s._$AI(o), e++;
  22253. e < i.length && (this._$AR(s && s._$AB.nextSibling, e), i.length = e);
  22254. }
  22255. _$AR() {
  22256. let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._$AA.nextSibling;
  22257. let i = arguments.length > 1 ? arguments[1] : undefined;
  22258. var s;
  22259. for (null === (s = this._$AP) || void 0 === s || s.call(this, !1, !0, i); t && t !== this._$AB;) {
  22260. const i = t.nextSibling;
  22261. t.remove(), t = i;
  22262. }
  22263. }
  22264. setConnected(t) {
  22265. var i;
  22266. void 0 === this._$AM && (this._$Cg = t, null === (i = this._$AP) || void 0 === i || i.call(this, t));
  22267. }
  22268. }
  22269. class lit_html_S {
  22270. constructor(t, i, s, e, o) {
  22271. this.type = 1, this._$AH = w, this._$AN = void 0, this.element = t, this.name = i, this._$AM = e, this.options = o, s.length > 2 || "" !== s[0] || "" !== s[1] ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = w;
  22272. }
  22273. get tagName() {
  22274. return this.element.tagName;
  22275. }
  22276. get _$AU() {
  22277. return this._$AM._$AU;
  22278. }
  22279. _$AI(t) {
  22280. let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  22281. let s = arguments.length > 2 ? arguments[2] : undefined;
  22282. let e = arguments.length > 3 ? arguments[3] : undefined;
  22283. const o = this.strings;
  22284. let n = !1;
  22285. if (void 0 === o) t = P(this, t, i, 0), n = !lit_html_r(t) || t !== this._$AH && t !== b, n && (this._$AH = t);else {
  22286. const e = t;
  22287. let l, h;
  22288. for (t = o[0], l = 0; l < o.length - 1; l++) h = P(this, e[s + l], i, l), h === b && (h = this._$AH[l]), n || (n = !lit_html_r(h) || h !== this._$AH[l]), h === w ? t = w : t !== w && (t += (null != h ? h : "") + o[l + 1]), this._$AH[l] = h;
  22289. }
  22290. n && !e && this.C(t);
  22291. }
  22292. C(t) {
  22293. t === w ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t ? t : "");
  22294. }
  22295. }
  22296. class M extends lit_html_S {
  22297. constructor() {
  22298. super(...arguments), this.type = 3;
  22299. }
  22300. C(t) {
  22301. this.element[this.name] = t === w ? void 0 : t;
  22302. }
  22303. }
  22304. const k = lit_html_i ? lit_html_i.emptyScript : "";
  22305. class H extends lit_html_S {
  22306. constructor() {
  22307. super(...arguments), this.type = 4;
  22308. }
  22309. C(t) {
  22310. t && t !== w ? this.element.setAttribute(this.name, k) : this.element.removeAttribute(this.name);
  22311. }
  22312. }
  22313. class I extends lit_html_S {
  22314. constructor(t, i, s, e, o) {
  22315. super(t, i, s, e, o), this.type = 5;
  22316. }
  22317. _$AI(t) {
  22318. let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  22319. var s;
  22320. if ((t = null !== (s = P(this, t, i, 0)) && void 0 !== s ? s : w) === b) return;
  22321. const e = this._$AH,
  22322. o = t === w && e !== w || t.capture !== e.capture || t.once !== e.once || t.passive !== e.passive,
  22323. n = t !== w && (e === w || o);
  22324. o && this.element.removeEventListener(this.name, this, e), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
  22325. }
  22326. handleEvent(t) {
  22327. var i, s;
  22328. "function" == typeof this._$AH ? this._$AH.call(null !== (s = null === (i = this.options) || void 0 === i ? void 0 : i.host) && void 0 !== s ? s : this.element, t) : this._$AH.handleEvent(t);
  22329. }
  22330. }
  22331. class L {
  22332. constructor(t, i, s) {
  22333. this.element = t, this.type = 6, this._$AN = void 0, this._$AM = i, this.options = s;
  22334. }
  22335. get _$AU() {
  22336. return this._$AM._$AU;
  22337. }
  22338. _$AI(t) {
  22339. P(this, t);
  22340. }
  22341. }
  22342. const R = {
  22343. P: "$lit$",
  22344. L: lit_html_e,
  22345. V: lit_html_o,
  22346. I: 1,
  22347. N: C,
  22348. R: V,
  22349. D: lit_html_u,
  22350. j: P,
  22351. H: N,
  22352. O: lit_html_S,
  22353. F: H,
  22354. B: I,
  22355. W: M,
  22356. Z: L
  22357. },
  22358. z = window.litHtmlPolyfillSupport;
  22359. null == z || z(E, N), (null !== (lit_html_t = globalThis.litHtmlVersions) && void 0 !== lit_html_t ? lit_html_t : globalThis.litHtmlVersions = []).push("2.2.0");
  22360. ;// CONCATENATED MODULE: ./node_modules/lit-element/lit-element.js
  22361. /**
  22362. * @license
  22363. * Copyright 2017 Google LLC
  22364. * SPDX-License-Identifier: BSD-3-Clause
  22365. */var lit_element_l,lit_element_o;const lit_element_r=(/* unused pure expression or super */ null && (t));class lit_element_s extends a{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=x(i,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return b}}lit_element_s.finalized=!0,lit_element_s._$litElement$=!0,null===(lit_element_l=globalThis.litElementHydrateSupport)||void 0===lit_element_l||lit_element_l.call(globalThis,{LitElement:lit_element_s});const lit_element_n=globalThis.litElementPolyfillSupport;null==lit_element_n||lit_element_n({LitElement:lit_element_s});const lit_element_h={_$AK:(t,e,i)=>{t._$AK(e,i)},_$AL:t=>t._$AL};(null!==(lit_element_o=globalThis.litElementVersions)&&void 0!==lit_element_o?lit_element_o:globalThis.litElementVersions=[]).push("3.2.0");
  22366. //# sourceMappingURL=lit-element.js.map
  22367. ;// CONCATENATED MODULE: ./node_modules/lit/index.js
  22368. //# sourceMappingURL=index.js.map
  22369. ;// CONCATENATED MODULE: ./src/headless/core.js
  22370. /**
  22371. * @copyright The Converse.js contributors
  22372. * @license Mozilla Public License (MPLv2)
  22373. */
  22374. dayjs_min_default().extend((advancedFormat_default())); // Add Strophe Namespaces
  22375. Strophe.addNamespace('ACTIVITY', 'http://jabber.org/protocol/activity');
  22376. Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
  22377. Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
  22378. Strophe.addNamespace('CSI', 'urn:xmpp:csi:0');
  22379. Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
  22380. Strophe.addNamespace('EME', 'urn:xmpp:eme:0');
  22381. Strophe.addNamespace('FASTEN', 'urn:xmpp:fasten:0');
  22382. Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
  22383. Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
  22384. Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
  22385. Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
  22386. Strophe.addNamespace('MARKERS', 'urn:xmpp:chat-markers:0');
  22387. Strophe.addNamespace('MENTIONS', 'urn:xmpp:mmn:0');
  22388. Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0');
  22389. Strophe.addNamespace('MODERATE', 'urn:xmpp:message-moderate:0');
  22390. Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
  22391. Strophe.addNamespace('OCCUPANTID', 'urn:xmpp:occupant-id:0');
  22392. Strophe.addNamespace('OMEMO', 'eu.siacs.conversations.axolotl');
  22393. Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob');
  22394. Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
  22395. Strophe.addNamespace('RAI', 'urn:xmpp:rai:0');
  22396. Strophe.addNamespace('RECEIPTS', 'urn:xmpp:receipts');
  22397. Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0');
  22398. Strophe.addNamespace('REGISTER', 'jabber:iq:register');
  22399. Strophe.addNamespace('RETRACT', 'urn:xmpp:message-retract:0');
  22400. Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
  22401. Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
  22402. Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
  22403. Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
  22404. Strophe.addNamespace('STANZAS', 'urn:ietf:params:xml:ns:xmpp-stanzas');
  22405. Strophe.addNamespace('STYLING', 'urn:xmpp:styling:0');
  22406. Strophe.addNamespace('VCARD', 'vcard-temp');
  22407. Strophe.addNamespace('VCARDUPDATE', 'vcard-temp:x:update');
  22408. Strophe.addNamespace('XFORM', 'jabber:x:data');
  22409. Strophe.addNamespace('XHTML', 'http://www.w3.org/1999/xhtml');
  22410. shared_converse.VERSION_NAME = "v9.1.1";
  22411. Object.assign(shared_converse, Events); // Make converse pluggable
  22412. pluggable.enable(shared_converse, '_converse', 'pluggable');
  22413. /**
  22414. * ### The private API
  22415. *
  22416. * The private API methods are only accessible via the closured {@link _converse}
  22417. * object, which is only available to plugins.
  22418. *
  22419. * These methods are kept private (i.e. not global) because they may return
  22420. * sensitive data which should be kept off-limits to other 3rd-party scripts
  22421. * that might be running in the page.
  22422. *
  22423. * @namespace _converse.api
  22424. * @memberOf _converse
  22425. */
  22426. const core_api = shared_converse.api = {
  22427. connection: api,
  22428. settings: settings_api,
  22429. /**
  22430. * Lets you trigger events, which can be listened to via
  22431. * {@link _converse.api.listen.on} or {@link _converse.api.listen.once}
  22432. * (see [_converse.api.listen](http://localhost:8000/docs/html/api/-_converse.api.listen.html)).
  22433. *
  22434. * Some events also double as promises and can be waited on via {@link _converse.api.waitUntil}.
  22435. *
  22436. * @method _converse.api.trigger
  22437. * @param {string} name - The event name
  22438. * @param {...any} [argument] - Argument to be passed to the event handler
  22439. * @param {object} [options]
  22440. * @param {boolean} [options.synchronous] - Whether the event is synchronous or not.
  22441. * When a synchronous event is fired, a promise will be returned
  22442. * by {@link _converse.api.trigger} which resolves once all the
  22443. * event handlers' promises have been resolved.
  22444. */
  22445. async trigger(name) {
  22446. if (!shared_converse._events) {
  22447. return;
  22448. }
  22449. const args = Array.from(arguments);
  22450. const options = args.pop();
  22451. if (options && options.synchronous) {
  22452. const events = shared_converse._events[name] || [];
  22453. const event_args = args.splice(1);
  22454. await Promise.all(events.map(e => e.callback.apply(e.ctx, event_args)));
  22455. } else {
  22456. shared_converse.trigger.apply(shared_converse, arguments);
  22457. }
  22458. const promise = shared_converse.promises[name];
  22459. if (promise !== undefined) {
  22460. promise.resolve();
  22461. }
  22462. },
  22463. /**
  22464. * Triggers a hook which can be intercepted by registered listeners via
  22465. * {@link _converse.api.listen.on} or {@link _converse.api.listen.once}.
  22466. * (see [_converse.api.listen](http://localhost:8000/docs/html/api/-_converse.api.listen.html)).
  22467. * A hook is a special kind of event which allows you to intercept a data
  22468. * structure in order to modify it, before passing it back.
  22469. * @async
  22470. * @param {string} name - The hook name
  22471. * @param {...any} context - The context to which the hook applies (could be for example, a {@link _converse.ChatBox)).
  22472. * @param {...any} data - The data structure to be intercepted and modified by the hook listeners.
  22473. * @returns {Promise<any>} - A promise that resolves with the modified data structure.
  22474. */
  22475. hook(name, context, data) {
  22476. const events = shared_converse._events[name] || [];
  22477. if (events.length) {
  22478. // Create a chain of promises, with each one feeding its output to
  22479. // the next. The first input is a promise with the original data
  22480. // sent to this hook.
  22481. return events.reduce((o, e) => o.then(d => e.callback(context, d)), Promise.resolve(data));
  22482. } else {
  22483. return data;
  22484. }
  22485. },
  22486. /**
  22487. * This grouping collects API functions related to the current logged in user.
  22488. *
  22489. * @namespace _converse.api.user
  22490. * @memberOf _converse.api
  22491. */
  22492. user: {
  22493. settings: user_settings_api,
  22494. /**
  22495. * @method _converse.api.user.jid
  22496. * @returns {string} The current user's full JID (Jabber ID)
  22497. * @example _converse.api.user.jid())
  22498. */
  22499. jid() {
  22500. return shared_converse.connection.jid;
  22501. },
  22502. /**
  22503. * Logs the user in.
  22504. *
  22505. * If called without any parameters, Converse will try
  22506. * to log the user in by calling the `prebind_url` or `credentials_url` depending
  22507. * on whether prebinding is used or not.
  22508. *
  22509. * @method _converse.api.user.login
  22510. * @param {string} [jid]
  22511. * @param {string} [password]
  22512. * @param {boolean} [automatic=false] - An internally used flag that indicates whether
  22513. * this method was called automatically once the connection has been
  22514. * initialized. It's used together with the `auto_login` configuration flag
  22515. * to determine whether Converse should try to log the user in if it
  22516. * fails to restore a previous auth'd session.
  22517. * @returns {void}
  22518. */
  22519. async login(jid, password) {
  22520. var _converse$connection, _api$settings$get;
  22521. let automatic = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  22522. jid = jid || core_api.settings.get('jid');
  22523. if (!((_converse$connection = shared_converse.connection) !== null && _converse$connection !== void 0 && _converse$connection.jid) || jid && !utils_core.isSameDomain(shared_converse.connection.jid, jid)) {
  22524. await shared_converse.initConnection();
  22525. }
  22526. if ((_api$settings$get = core_api.settings.get("connection_options")) !== null && _api$settings$get !== void 0 && _api$settings$get.worker && (await shared_converse.connection.restoreWorkerSession())) {
  22527. return;
  22528. }
  22529. if (jid) {
  22530. jid = await setUserJID(jid);
  22531. } // See whether there is a BOSH session to re-attach to
  22532. const bosh_plugin = shared_converse.pluggable.plugins["converse-bosh"];
  22533. if (bosh_plugin !== null && bosh_plugin !== void 0 && bosh_plugin.enabled()) {
  22534. if (await shared_converse.restoreBOSHSession()) {
  22535. return;
  22536. } else if (core_api.settings.get("authentication") === shared_converse.PREBIND && (!automatic || core_api.settings.get("auto_login"))) {
  22537. return shared_converse.startNewPreboundBOSHSession();
  22538. }
  22539. }
  22540. password = password || core_api.settings.get("password");
  22541. const credentials = jid && password ? {
  22542. jid,
  22543. password
  22544. } : null;
  22545. attemptNonPreboundSession(credentials, automatic);
  22546. },
  22547. /**
  22548. * Logs the user out of the current XMPP session.
  22549. * @method _converse.api.user.logout
  22550. * @example _converse.api.user.logout();
  22551. */
  22552. async logout() {
  22553. /**
  22554. * Triggered before the user is logged out
  22555. * @event _converse#beforeLogout
  22556. */
  22557. await core_api.trigger('beforeLogout', {
  22558. 'synchronous': true
  22559. });
  22560. const promise = getOpenPromise();
  22561. const complete = () => {
  22562. // Recreate all the promises
  22563. Object.keys(shared_converse.promises).forEach(replacePromise);
  22564. delete shared_converse.jid;
  22565. /**
  22566. * Triggered once the user has logged out.
  22567. * @event _converse#logout
  22568. */
  22569. core_api.trigger('logout');
  22570. promise.resolve();
  22571. };
  22572. shared_converse.connection.setDisconnectionCause(shared_converse.LOGOUT, undefined, true);
  22573. if (shared_converse.connection !== undefined) {
  22574. core_api.listen.once('disconnected', () => complete());
  22575. shared_converse.connection.disconnect();
  22576. } else {
  22577. complete();
  22578. }
  22579. return promise;
  22580. }
  22581. },
  22582. /**
  22583. * Converse and its plugins trigger various events which you can listen to via the
  22584. * {@link _converse.api.listen} namespace.
  22585. *
  22586. * Some of these events are also available as [ES2015 Promises](http://es6-features.org/#PromiseUsage)
  22587. * although not all of them could logically act as promises, since some events
  22588. * might be fired multpile times whereas promises are to be resolved (or
  22589. * rejected) only once.
  22590. *
  22591. * Events which are also promises include:
  22592. *
  22593. * * [cachedRoster](/docs/html/events.html#cachedroster)
  22594. * * [chatBoxesFetched](/docs/html/events.html#chatBoxesFetched)
  22595. * * [pluginsInitialized](/docs/html/events.html#pluginsInitialized)
  22596. * * [roster](/docs/html/events.html#roster)
  22597. * * [rosterContactsFetched](/docs/html/events.html#rosterContactsFetched)
  22598. * * [rosterGroupsFetched](/docs/html/events.html#rosterGroupsFetched)
  22599. * * [rosterInitialized](/docs/html/events.html#rosterInitialized)
  22600. *
  22601. * The various plugins might also provide promises, and they do this by using the
  22602. * `promises.add` api method.
  22603. *
  22604. * @namespace _converse.api.promises
  22605. * @memberOf _converse.api
  22606. */
  22607. promises: {
  22608. /**
  22609. * By calling `promises.add`, a new [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
  22610. * is made available for other code or plugins to depend on via the
  22611. * {@link _converse.api.waitUntil} method.
  22612. *
  22613. * Generally, it's the responsibility of the plugin which adds the promise to
  22614. * also resolve it.
  22615. *
  22616. * This is done by calling {@link _converse.api.trigger}, which not only resolves the
  22617. * promise, but also emits an event with the same name (which can be listened to
  22618. * via {@link _converse.api.listen}).
  22619. *
  22620. * @method _converse.api.promises.add
  22621. * @param {string|array} [name|names] The name or an array of names for the promise(s) to be added
  22622. * @param {boolean} [replace=true] Whether this promise should be replaced with a new one when the user logs out.
  22623. * @example _converse.api.promises.add('foo-completed');
  22624. */
  22625. add(promises) {
  22626. let replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  22627. promises = Array.isArray(promises) ? promises : [promises];
  22628. promises.forEach(name => {
  22629. const promise = getOpenPromise();
  22630. promise.replace = replace;
  22631. shared_converse.promises[name] = promise;
  22632. });
  22633. }
  22634. },
  22635. /**
  22636. * Converse emits events to which you can subscribe to.
  22637. *
  22638. * The `listen` namespace exposes methods for creating event listeners
  22639. * (aka handlers) for these events.
  22640. *
  22641. * @namespace _converse.api.listen
  22642. * @memberOf _converse
  22643. */
  22644. listen: {
  22645. /**
  22646. * Lets you listen to an event exactly once.
  22647. * @method _converse.api.listen.once
  22648. * @param {string} name The event's name
  22649. * @param {function} callback The callback method to be called when the event is emitted.
  22650. * @param {object} [context] The value of the `this` parameter for the callback.
  22651. * @example _converse.api.listen.once('message', function (messageXML) { ... });
  22652. */
  22653. once: shared_converse.once.bind(shared_converse),
  22654. /**
  22655. * Lets you subscribe to an event.
  22656. * Every time the event fires, the callback method specified by `callback` will be called.
  22657. * @method _converse.api.listen.on
  22658. * @param {string} name The event's name
  22659. * @param {function} callback The callback method to be called when the event is emitted.
  22660. * @param {object} [context] The value of the `this` parameter for the callback.
  22661. * @example _converse.api.listen.on('message', function (messageXML) { ... });
  22662. */
  22663. on: shared_converse.on.bind(shared_converse),
  22664. /**
  22665. * To stop listening to an event, you can use the `not` method.
  22666. * @method _converse.api.listen.not
  22667. * @param {string} name The event's name
  22668. * @param {function} callback The callback method that is to no longer be called when the event fires
  22669. * @example _converse.api.listen.not('message', function (messageXML);
  22670. */
  22671. not: shared_converse.off.bind(shared_converse),
  22672. /**
  22673. * Subscribe to an incoming stanza
  22674. * Every a matched stanza is received, the callback method specified by
  22675. * `callback` will be called.
  22676. * @method _converse.api.listen.stanza
  22677. * @param {string} name The stanza's name
  22678. * @param {object} options Matching options (e.g. 'ns' for namespace, 'type' for stanza type, also 'id' and 'from');
  22679. * @param {function} handler The callback method to be called when the stanza appears
  22680. */
  22681. stanza(name, options, handler) {
  22682. if (lodash_es_isFunction(options)) {
  22683. handler = options;
  22684. options = {};
  22685. } else {
  22686. options = options || {};
  22687. }
  22688. shared_converse.connection.addHandler(handler, options.ns, name, options.type, options.id, options.from, options);
  22689. }
  22690. },
  22691. /**
  22692. * Wait until a promise is resolved or until the passed in function returns
  22693. * a truthy value.
  22694. * @method _converse.api.waitUntil
  22695. * @param {string|function} condition - The name of the promise to wait for,
  22696. * or a function which should eventually return a truthy value.
  22697. * @returns {Promise}
  22698. */
  22699. waitUntil(condition) {
  22700. if (lodash_es_isFunction(condition)) {
  22701. return utils_core.waitUntil(condition);
  22702. } else {
  22703. const promise = shared_converse.promises[condition];
  22704. if (promise === undefined) {
  22705. return null;
  22706. }
  22707. return promise;
  22708. }
  22709. },
  22710. /**
  22711. * Allows you to send XML stanzas.
  22712. * @method _converse.api.send
  22713. * @param {XMLElement} stanza
  22714. * @return {void}
  22715. * @example
  22716. * const msg = converse.env.$msg({
  22717. * 'from': 'juliet@example.com/balcony',
  22718. * 'to': 'romeo@example.net',
  22719. * 'type':'chat'
  22720. * });
  22721. * _converse.api.send(msg);
  22722. */
  22723. send(stanza) {
  22724. var _stanza;
  22725. if (!core_api.connection.connected()) {
  22726. headless_log.warn("Not sending stanza because we're not connected!");
  22727. headless_log.warn(Strophe.serialize(stanza));
  22728. return;
  22729. }
  22730. if (typeof stanza === 'string') {
  22731. stanza = utils_core.toStanza(stanza);
  22732. } else if ((_stanza = stanza) !== null && _stanza !== void 0 && _stanza.nodeTree) {
  22733. stanza = stanza.nodeTree;
  22734. }
  22735. if (stanza.tagName === 'iq') {
  22736. return core_api.sendIQ(stanza);
  22737. } else {
  22738. shared_converse.connection.send(stanza);
  22739. core_api.trigger('send', stanza);
  22740. }
  22741. },
  22742. /**
  22743. * Send an IQ stanza
  22744. * @method _converse.api.sendIQ
  22745. * @param {XMLElement} stanza
  22746. * @param {Integer} [timeout=_converse.STANZA_TIMEOUT]
  22747. * @param {Boolean} [reject=true] - Whether an error IQ should cause the promise
  22748. * to be rejected. If `false`, the promise will resolve instead of being rejected.
  22749. * @returns {Promise} A promise which resolves (or potentially rejected) once we
  22750. * receive a `result` or `error` stanza or once a timeout is reached.
  22751. * If the IQ stanza being sent is of type `result` or `error`, there's
  22752. * nothing to wait for, so an already resolved promise is returned.
  22753. */
  22754. sendIQ(stanza) {
  22755. var _stanza2;
  22756. let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : shared_converse.STANZA_TIMEOUT;
  22757. let reject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  22758. let promise;
  22759. stanza = ((_stanza2 = stanza) === null || _stanza2 === void 0 ? void 0 : _stanza2.nodeTree) ?? stanza;
  22760. if (['get', 'set'].includes(stanza.getAttribute('type'))) {
  22761. timeout = timeout || shared_converse.STANZA_TIMEOUT;
  22762. if (reject) {
  22763. promise = new Promise((resolve, reject) => shared_converse.connection.sendIQ(stanza, resolve, reject, timeout));
  22764. promise.catch(e => {
  22765. if (e === null) {
  22766. throw new TimeoutError(`Timeout error after ${timeout}ms for the following IQ stanza: ${Strophe.serialize(stanza)}`);
  22767. }
  22768. });
  22769. } else {
  22770. promise = new Promise(resolve => shared_converse.connection.sendIQ(stanza, resolve, resolve, timeout));
  22771. }
  22772. } else {
  22773. shared_converse.connection.sendIQ(stanza);
  22774. promise = Promise.resolve();
  22775. }
  22776. core_api.trigger('send', stanza);
  22777. return promise;
  22778. }
  22779. };
  22780. shared_converse.shouldClearCache = () => !shared_converse.config.get('trusted') || core_api.settings.get('clear_cache_on_logout') || shared_converse.isTestEnv();
  22781. function clearSession() {
  22782. var _converse$session;
  22783. (_converse$session = shared_converse.session) === null || _converse$session === void 0 ? void 0 : _converse$session.destroy();
  22784. delete shared_converse.session;
  22785. shared_converse.shouldClearCache() && shared_converse.api.user.settings.clear();
  22786. /**
  22787. * Synchronouse event triggered once the user session has been cleared,
  22788. * for example when the user has logged out or when Converse has
  22789. * disconnected for some other reason.
  22790. * @event _converse#clearSession
  22791. */
  22792. return shared_converse.api.trigger('clearSession', {
  22793. 'synchronous': true
  22794. });
  22795. }
  22796. shared_converse.initConnection = function () {
  22797. const api = shared_converse.api;
  22798. if (!api.settings.get('bosh_service_url')) {
  22799. if (api.settings.get("authentication") === shared_converse.PREBIND) {
  22800. throw new Error("authentication is set to 'prebind' but we don't have a BOSH connection");
  22801. }
  22802. }
  22803. const XMPPConnection = shared_converse.isTestEnv() ? MockConnection : Connection;
  22804. shared_converse.connection = new XMPPConnection(getConnectionServiceURL(), Object.assign(shared_converse.default_connection_options, api.settings.get("connection_options"), {
  22805. 'keepalive': api.settings.get("keepalive")
  22806. }));
  22807. setUpXMLLogging();
  22808. /**
  22809. * Triggered once the `Connection` constructor has been initialized, which
  22810. * will be responsible for managing the connection to the XMPP server.
  22811. *
  22812. * @event _converse#connectionInitialized
  22813. */
  22814. api.trigger('connectionInitialized');
  22815. };
  22816. function setUpXMLLogging() {
  22817. const lmap = {};
  22818. lmap[Strophe.LogLevel.DEBUG] = 'debug';
  22819. lmap[Strophe.LogLevel.INFO] = 'info';
  22820. lmap[Strophe.LogLevel.WARN] = 'warn';
  22821. lmap[Strophe.LogLevel.ERROR] = 'error';
  22822. lmap[Strophe.LogLevel.FATAL] = 'fatal';
  22823. Strophe.log = (level, msg) => headless_log.log(msg, lmap[level]);
  22824. Strophe.error = msg => headless_log.error(msg);
  22825. shared_converse.connection.xmlInput = body => headless_log.debug(body.outerHTML, 'color: darkgoldenrod');
  22826. shared_converse.connection.xmlOutput = body => headless_log.debug(body.outerHTML, 'color: darkcyan');
  22827. }
  22828. shared_converse.saveWindowState = function (ev) {
  22829. // XXX: eventually we should be able to just use
  22830. // document.visibilityState (when we drop support for older
  22831. // browsers).
  22832. let state;
  22833. const event_map = {
  22834. 'focus': "visible",
  22835. 'focusin': "visible",
  22836. 'pageshow': "visible",
  22837. 'blur': "hidden",
  22838. 'focusout': "hidden",
  22839. 'pagehide': "hidden"
  22840. };
  22841. ev = ev || document.createEvent('Events');
  22842. if (ev.type in event_map) {
  22843. state = event_map[ev.type];
  22844. } else {
  22845. state = document.hidden ? "hidden" : "visible";
  22846. }
  22847. shared_converse.windowState = state;
  22848. /**
  22849. * Triggered when window state has changed.
  22850. * Used to determine when a user left the page and when came back.
  22851. * @event _converse#windowStateChanged
  22852. * @type { object }
  22853. * @property{ string } state - Either "hidden" or "visible"
  22854. * @example _converse.api.listen.on('windowStateChanged', obj => { ... });
  22855. */
  22856. core_api.trigger('windowStateChanged', {
  22857. state
  22858. });
  22859. };
  22860. shared_converse.ConnectionFeedback = Model.extend({
  22861. defaults: {
  22862. 'connection_status': Strophe.Status.DISCONNECTED,
  22863. 'message': ''
  22864. },
  22865. initialize() {
  22866. this.on('change', () => core_api.trigger('connfeedback', shared_converse.connfeedback));
  22867. }
  22868. });
  22869. const core_converse = window.converse || {};
  22870. /**
  22871. * ### The Public API
  22872. *
  22873. * This namespace contains public API methods which are are
  22874. * accessible on the global `converse` object.
  22875. * They are public, because any JavaScript in the
  22876. * page can call them. Public methods therefore don’t expose any sensitive
  22877. * or closured data. To do that, you’ll need to create a plugin, which has
  22878. * access to the private API method.
  22879. *
  22880. * @global
  22881. * @namespace converse
  22882. */
  22883. Object.assign(core_converse, {
  22884. CHAT_STATES: CHAT_STATES,
  22885. keycodes: KEYCODES,
  22886. /**
  22887. * Public API method which initializes Converse.
  22888. * This method must always be called when using Converse.
  22889. * @async
  22890. * @memberOf converse
  22891. * @method initialize
  22892. * @param {object} config A map of [configuration-settings](https://conversejs.org/docs/html/configuration.html#configuration-settings).
  22893. * @example
  22894. * converse.initialize({
  22895. * auto_list_rooms: false,
  22896. * auto_subscribe: false,
  22897. * bosh_service_url: 'https://bind.example.com',
  22898. * hide_muc_server: false,
  22899. * i18n: 'en',
  22900. * play_sounds: true,
  22901. * show_controlbox_by_default: true,
  22902. * debug: false,
  22903. * roster_groups: true
  22904. * });
  22905. */
  22906. async initialize(settings) {
  22907. var _api$elements;
  22908. await cleanup(shared_converse);
  22909. setUnloadEvent();
  22910. initAppSettings(settings);
  22911. shared_converse.strict_plugin_dependencies = settings.strict_plugin_dependencies; // Needed by pluggable.js
  22912. headless_log.setLogLevel(core_api.settings.get("loglevel"));
  22913. if (core_api.settings.get("authentication") === shared_converse.ANONYMOUS) {
  22914. if (core_api.settings.get("auto_login") && !core_api.settings.get('jid')) {
  22915. throw new Error("Config Error: you need to provide the server's " + "domain via the 'jid' option when using anonymous " + "authentication with auto_login.");
  22916. }
  22917. }
  22918. shared_converse.router.route(/^converse\?loglevel=(debug|info|warn|error|fatal)$/, 'loglevel', l => headless_log.setLogLevel(l));
  22919. shared_converse.connfeedback = new shared_converse.ConnectionFeedback();
  22920. /* When reloading the page:
  22921. * For new sessions, we need to send out a presence stanza to notify
  22922. * the server/network that we're online.
  22923. * When re-attaching to an existing session we don't need to again send out a presence stanza,
  22924. * because it's as if "we never left" (see onConnectStatusChanged).
  22925. * https://github.com/conversejs/converse.js/issues/521
  22926. */
  22927. shared_converse.send_initial_presence = true;
  22928. await initSessionStorage(shared_converse);
  22929. await initClientConfig(shared_converse);
  22930. await i18n.initialize();
  22931. initPlugins(shared_converse); // Register all custom elements
  22932. // XXX: api.elements is defined in the UI part of Converse, outside of @converse/headless.
  22933. // This line should probably be moved to the UI code as part of a larger refactoring.
  22934. (_api$elements = core_api.elements) === null || _api$elements === void 0 ? void 0 : _api$elements.register();
  22935. registerGlobalEventHandlers(shared_converse);
  22936. try {
  22937. !History.started && shared_converse.router.history.start();
  22938. } catch (e) {
  22939. headless_log.error(e);
  22940. }
  22941. const plugins = shared_converse.pluggable.plugins;
  22942. if (core_api.settings.get("auto_login") || core_api.settings.get("keepalive") && lodash_es_invoke(plugins['converse-bosh'], 'enabled')) {
  22943. await core_api.user.login(null, null, true);
  22944. }
  22945. /**
  22946. * Triggered once converse.initialize has finished.
  22947. * @event _converse#initialized
  22948. */
  22949. core_api.trigger('initialized');
  22950. if (shared_converse.isTestEnv()) {
  22951. return shared_converse;
  22952. }
  22953. },
  22954. /**
  22955. * Exposes methods for adding and removing plugins. You'll need to write a plugin
  22956. * if you want to have access to the private API methods defined further down below.
  22957. *
  22958. * For more information on plugins, read the documentation on [writing a plugin](/docs/html/plugin_development.html).
  22959. * @namespace plugins
  22960. * @memberOf converse
  22961. */
  22962. plugins: {
  22963. /**
  22964. * Registers a new plugin.
  22965. * @method converse.plugins.add
  22966. * @param {string} name The name of the plugin
  22967. * @param {object} plugin The plugin object
  22968. * @example
  22969. * const plugin = {
  22970. * initialize: function () {
  22971. * // Gets called as soon as the plugin has been loaded.
  22972. *
  22973. * // Inside this method, you have access to the private
  22974. * // API via `_covnerse.api`.
  22975. *
  22976. * // The private _converse object contains the core logic
  22977. * // and data-structures of Converse.
  22978. * }
  22979. * }
  22980. * converse.plugins.add('myplugin', plugin);
  22981. */
  22982. add(name, plugin) {
  22983. plugin.__name__ = name;
  22984. if (shared_converse.pluggable.plugins[name] !== undefined) {
  22985. throw new TypeError(`Error: plugin with name "${name}" has already been ` + 'registered!');
  22986. } else {
  22987. shared_converse.pluggable.plugins[name] = plugin;
  22988. }
  22989. }
  22990. },
  22991. /**
  22992. * Utility methods and globals from bundled 3rd party libraries.
  22993. * @typedef ConverseEnv
  22994. * @property {function} converse.env.$build - Creates a Strophe.Builder, for creating stanza objects.
  22995. * @property {function} converse.env.$iq - Creates a Strophe.Builder with an <iq/> element as the root.
  22996. * @property {function} converse.env.$msg - Creates a Strophe.Builder with an <message/> element as the root.
  22997. * @property {function} converse.env.$pres - Creates a Strophe.Builder with an <presence/> element as the root.
  22998. * @property {function} converse.env.Promise - The Promise implementation used by Converse.
  22999. * @property {function} converse.env.Strophe - The [Strophe](http://strophe.im/strophejs) XMPP library used by Converse.
  23000. * @property {function} converse.env.f - And instance of Lodash with its methods wrapped to produce immutable auto-curried iteratee-first data-last methods.
  23001. * @property {function} converse.env.sizzle - [Sizzle](https://sizzlejs.com) CSS selector engine.
  23002. * @property {function} converse.env.sprintf
  23003. * @property {object} converse.env._ - The instance of [lodash-es](http://lodash.com) used by Converse.
  23004. * @property {object} converse.env.dayjs - [DayJS](https://github.com/iamkun/dayjs) date manipulation library.
  23005. * @property {object} converse.env.utils - Module containing common utility methods used by Converse.
  23006. * @memberOf converse
  23007. */
  23008. 'env': {
  23009. $build: $build,
  23010. $iq: $iq,
  23011. $msg: $msg,
  23012. $pres: $pres,
  23013. 'utils': utils_core,
  23014. Collection: Collection,
  23015. Model: Model,
  23016. Promise,
  23017. Strophe: Strophe,
  23018. URI: (URI_default()),
  23019. dayjs: (dayjs_min_default()),
  23020. html: $,
  23021. log: headless_log,
  23022. sizzle: (sizzle_default()),
  23023. sprintf: sprintf.sprintf,
  23024. u: utils_core
  23025. }
  23026. });
  23027. ;// CONCATENATED MODULE: ./src/headless/shared/actions.js
  23028. const actions_u = core_converse.env.utils;
  23029. function rejectMessage(stanza, text) {
  23030. // Reject an incoming message by replying with an error message of type "cancel".
  23031. core_api.send($msg({
  23032. 'to': stanza.getAttribute('from'),
  23033. 'type': 'error',
  23034. 'id': stanza.getAttribute('id')
  23035. }).c('error', {
  23036. 'type': 'cancel'
  23037. }).c('not-allowed', {
  23038. xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'
  23039. }).up().c('text', {
  23040. xmlns: 'urn:ietf:params:xml:ns:xmpp-stanzas'
  23041. }).t(text));
  23042. headless_log.warn(`Rejecting message stanza with the following reason: ${text}`);
  23043. headless_log.warn(stanza);
  23044. }
  23045. /**
  23046. * Send out a XEP-0333 chat marker
  23047. * @param { String } to_jid
  23048. * @param { String } id - The id of the message being marked
  23049. * @param { String } type - The marker type
  23050. * @param { String } msg_type
  23051. */
  23052. function sendMarker(to_jid, id, type, msg_type) {
  23053. const stanza = $msg({
  23054. 'from': shared_converse.connection.jid,
  23055. 'id': actions_u.getUniqueId(),
  23056. 'to': to_jid,
  23057. 'type': msg_type ? msg_type : 'chat'
  23058. }).c(type, {
  23059. 'xmlns': Strophe.NS.MARKERS,
  23060. 'id': id
  23061. });
  23062. core_api.send(stanza);
  23063. }
  23064. ;// CONCATENATED MODULE: ./src/headless/utils/url.js
  23065. const {
  23066. u: url_u
  23067. } = core_converse.env;
  23068. /**
  23069. * Given a url, check whether the protocol being used is allowed for rendering
  23070. * the media in the chat (as opposed to just rendering a URL hyperlink).
  23071. * @param { String } url
  23072. * @returns { Boolean }
  23073. */
  23074. function isAllowedProtocolForMedia(url) {
  23075. const uri = getURI(url);
  23076. const {
  23077. protocol
  23078. } = window.location;
  23079. if (['chrome-extension:', 'file:'].includes(protocol)) {
  23080. return true;
  23081. }
  23082. return protocol === 'http:' || protocol === 'https:' && ['https', 'aesgcm'].includes(uri.protocol().toLowerCase());
  23083. }
  23084. function getURI(url) {
  23085. try {
  23086. return url instanceof (URI_default()) ? url : new (URI_default())(url);
  23087. } catch (error) {
  23088. headless_log.debug(error);
  23089. return null;
  23090. }
  23091. }
  23092. /**
  23093. * Given the an array of file extensions, check whether a URL points to a file
  23094. * ending in one of them.
  23095. * @param { String[] } types - An array of file extensions
  23096. * @param { String } url
  23097. * @returns { Boolean }
  23098. * @example
  23099. * checkFileTypes(['.gif'], 'https://conversejs.org/cat.gif?foo=bar');
  23100. */
  23101. function checkFileTypes(types, url) {
  23102. const uri = getURI(url);
  23103. if (uri === null) {
  23104. throw new Error(`checkFileTypes: could not parse url ${url}`);
  23105. }
  23106. const filename = uri.filename().toLowerCase();
  23107. return !!types.filter(ext => filename.endsWith(ext)).length;
  23108. }
  23109. function isDomainWhitelisted(whitelist, url) {
  23110. const uri = getURI(url);
  23111. const subdomain = uri.subdomain();
  23112. const domain = uri.domain();
  23113. const fulldomain = `${subdomain ? `${subdomain}.` : ''}${domain}`;
  23114. return whitelist.includes(domain) || whitelist.includes(fulldomain);
  23115. }
  23116. function shouldRenderMediaFromURL(url_text, type) {
  23117. if (!isAllowedProtocolForMedia(url_text)) {
  23118. return false;
  23119. }
  23120. const may_render = core_api.settings.get('render_media');
  23121. const is_domain_allowed = isDomainAllowed(url_text, `allowed_${type}_domains`);
  23122. if (Array.isArray(may_render)) {
  23123. return is_domain_allowed && isDomainWhitelisted(may_render, url_text);
  23124. } else {
  23125. return is_domain_allowed && may_render;
  23126. }
  23127. }
  23128. function filterQueryParamsFromURL(url) {
  23129. const paramsArray = core_api.settings.get('filter_url_query_params');
  23130. if (!paramsArray) return url;
  23131. const parsed_uri = getURI(url);
  23132. return parsed_uri.removeQuery(paramsArray).toString();
  23133. }
  23134. function isDomainAllowed(url, setting) {
  23135. const allowed_domains = core_api.settings.get(setting);
  23136. if (!Array.isArray(allowed_domains)) {
  23137. return true;
  23138. }
  23139. try {
  23140. return isDomainWhitelisted(allowed_domains, url);
  23141. } catch (error) {
  23142. headless_log.debug(error);
  23143. return false;
  23144. }
  23145. }
  23146. /**
  23147. * Accepts a {@link MediaURL} object and then checks whether its domain is
  23148. * allowed for rendering in the chat.
  23149. * @param { MediaURL } o
  23150. * @returns { Bool }
  23151. */
  23152. function isMediaURLDomainAllowed(o) {
  23153. return o.is_audio && isDomainAllowed(o.url, 'allowed_audio_domains') || o.is_video && isDomainAllowed(o.url, 'allowed_video_domains') || o.is_image && isDomainAllowed(o.url, 'allowed_image_domains');
  23154. }
  23155. function isURLWithImageExtension(url) {
  23156. return checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url);
  23157. }
  23158. function isGIFURL(url) {
  23159. return checkFileTypes(['.gif'], url);
  23160. }
  23161. function isAudioURL(url) {
  23162. return checkFileTypes(['.ogg', '.mp3', '.m4a'], url);
  23163. }
  23164. function isVideoURL(url) {
  23165. return checkFileTypes(['.mp4', '.webm'], url);
  23166. }
  23167. function isImageURL(url) {
  23168. const regex = core_api.settings.get('image_urls_regex');
  23169. return (regex === null || regex === void 0 ? void 0 : regex.test(url)) || isURLWithImageExtension(url);
  23170. }
  23171. function isEncryptedFileURL(url) {
  23172. return url.startsWith('aesgcm://');
  23173. }
  23174. Object.assign(url_u, {
  23175. isAudioURL,
  23176. isGIFURL,
  23177. isVideoURL,
  23178. isImageURL,
  23179. isURLWithImageExtension,
  23180. checkFileTypes,
  23181. getURI,
  23182. shouldRenderMediaFromURL,
  23183. isAllowedProtocolForMedia
  23184. });
  23185. ;// CONCATENATED MODULE: ./src/headless/shared/parsers.js
  23186. const {
  23187. NS
  23188. } = Strophe;
  23189. class StanzaParseError extends Error {
  23190. constructor(message, stanza) {
  23191. super(message, stanza);
  23192. this.name = 'StanzaParseError';
  23193. this.stanza = stanza;
  23194. }
  23195. }
  23196. /**
  23197. * Extract the XEP-0359 stanza IDs from the passed in stanza
  23198. * and return a map containing them.
  23199. * @private
  23200. * @param { XMLElement } stanza - The message stanza
  23201. * @returns { Object }
  23202. */
  23203. function getStanzaIDs(stanza, original_stanza) {
  23204. const attrs = {}; // Store generic stanza ids
  23205. const sids = sizzle_default()(`stanza-id[xmlns="${Strophe.NS.SID}"]`, stanza);
  23206. const sid_attrs = sids.reduce((acc, s) => {
  23207. acc[`stanza_id ${s.getAttribute('by')}`] = s.getAttribute('id');
  23208. return acc;
  23209. }, {});
  23210. Object.assign(attrs, sid_attrs); // Store the archive id
  23211. const result = sizzle_default()(`message > result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).pop();
  23212. if (result) {
  23213. const by_jid = original_stanza.getAttribute('from') || shared_converse.bare_jid;
  23214. attrs[`stanza_id ${by_jid}`] = result.getAttribute('id');
  23215. } // Store the origin id
  23216. const origin_id = sizzle_default()(`origin-id[xmlns="${Strophe.NS.SID}"]`, stanza).pop();
  23217. if (origin_id) {
  23218. attrs['origin_id'] = origin_id.getAttribute('id');
  23219. }
  23220. return attrs;
  23221. }
  23222. function getEncryptionAttributes(stanza) {
  23223. const eme_tag = sizzle_default()(`encryption[xmlns="${Strophe.NS.EME}"]`, stanza).pop();
  23224. const namespace = eme_tag === null || eme_tag === void 0 ? void 0 : eme_tag.getAttribute('namespace');
  23225. const attrs = {};
  23226. if (namespace) {
  23227. attrs.is_encrypted = true;
  23228. attrs.encryption_namespace = namespace;
  23229. } else if (sizzle_default()(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, stanza).pop()) {
  23230. attrs.is_encrypted = true;
  23231. attrs.encryption_namespace = Strophe.NS.OMEMO;
  23232. }
  23233. return attrs;
  23234. }
  23235. /**
  23236. * @private
  23237. * @param { XMLElement } stanza - The message stanza
  23238. * @param { XMLElement } original_stanza - The original stanza, that contains the
  23239. * message stanza, if it was contained, otherwise it's the message stanza itself.
  23240. * @returns { Object }
  23241. */
  23242. function getRetractionAttributes(stanza, original_stanza) {
  23243. const fastening = sizzle_default()(`> apply-to[xmlns="${Strophe.NS.FASTEN}"]`, stanza).pop();
  23244. if (fastening) {
  23245. const applies_to_id = fastening.getAttribute('id');
  23246. const retracted = sizzle_default()(`> retract[xmlns="${Strophe.NS.RETRACT}"]`, fastening).pop();
  23247. if (retracted) {
  23248. const delay = sizzle_default()(`delay[xmlns="${Strophe.NS.DELAY}"]`, original_stanza).pop();
  23249. const time = delay ? dayjs_min_default()(delay.getAttribute('stamp')).toISOString() : new Date().toISOString();
  23250. return {
  23251. 'editable': false,
  23252. 'retracted': time,
  23253. 'retracted_id': applies_to_id
  23254. };
  23255. }
  23256. } else {
  23257. const tombstone = sizzle_default()(`> retracted[xmlns="${Strophe.NS.RETRACT}"]`, stanza).pop();
  23258. if (tombstone) {
  23259. return {
  23260. 'editable': false,
  23261. 'is_tombstone': true,
  23262. 'retracted': tombstone.getAttribute('stamp')
  23263. };
  23264. }
  23265. }
  23266. return {};
  23267. }
  23268. function getCorrectionAttributes(stanza, original_stanza) {
  23269. const el = sizzle_default()(`replace[xmlns="${Strophe.NS.MESSAGE_CORRECT}"]`, stanza).pop();
  23270. if (el) {
  23271. const replace_id = el.getAttribute('id');
  23272. if (replace_id) {
  23273. const delay = sizzle_default()(`delay[xmlns="${Strophe.NS.DELAY}"]`, original_stanza).pop();
  23274. const time = delay ? dayjs_min_default()(delay.getAttribute('stamp')).toISOString() : new Date().toISOString();
  23275. return {
  23276. replace_id,
  23277. 'edited': time
  23278. };
  23279. }
  23280. }
  23281. return {};
  23282. }
  23283. function getOpenGraphMetadata(stanza) {
  23284. const fastening = sizzle_default()(`> apply-to[xmlns="${Strophe.NS.FASTEN}"]`, stanza).pop();
  23285. if (fastening) {
  23286. const applies_to_id = fastening.getAttribute('id');
  23287. const meta = sizzle_default()(`> meta[xmlns="${Strophe.NS.XHTML}"]`, fastening);
  23288. if (meta.length) {
  23289. const msg_limit = core_api.settings.get('message_limit');
  23290. const data = meta.reduce((acc, el) => {
  23291. const property = el.getAttribute('property');
  23292. if (property) {
  23293. let value = decodeHTMLEntities(el.getAttribute('content') || '');
  23294. if (msg_limit && property === 'og:description' && value.length >= msg_limit) {
  23295. value = `${value.slice(0, msg_limit)}${decodeHTMLEntities('&#8230;')}`;
  23296. }
  23297. acc[property] = value;
  23298. }
  23299. return acc;
  23300. }, {
  23301. 'ogp_for_id': applies_to_id
  23302. });
  23303. if ("og:description" in data || "og:title" in data || "og:image" in data) {
  23304. return data;
  23305. }
  23306. }
  23307. }
  23308. return {};
  23309. }
  23310. function getMediaURLsMetadata(text) {
  23311. let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  23312. const objs = [];
  23313. if (!text) {
  23314. return {};
  23315. }
  23316. try {
  23317. URI_default().withinString(text, (url, start, end) => {
  23318. if (url.startsWith('_')) {
  23319. url = url.slice(1);
  23320. start += 1;
  23321. }
  23322. if (url.endsWith('_')) {
  23323. url = url.slice(0, url.length - 1);
  23324. end -= 1;
  23325. }
  23326. objs.push({
  23327. url,
  23328. 'start': start + offset,
  23329. 'end': end + offset
  23330. });
  23331. return url;
  23332. }, URL_PARSE_OPTIONS);
  23333. } catch (error) {
  23334. headless_log.debug(error);
  23335. }
  23336. /**
  23337. * @typedef { Object } MediaURLMetadata
  23338. * An object representing the metadata of a URL found in a chat message
  23339. * The actual URL is not saved, it can be extracted via the `start` and `end` indexes.
  23340. * @property { Boolean } is_audio
  23341. * @property { Boolean } is_image
  23342. * @property { Boolean } is_video
  23343. * @property { String } end
  23344. * @property { String } start
  23345. */
  23346. const media_urls = objs.map(o => ({
  23347. 'end': o.end,
  23348. 'is_audio': isAudioURL(o.url),
  23349. 'is_image': isImageURL(o.url),
  23350. 'is_video': isVideoURL(o.url),
  23351. 'is_encrypted': isEncryptedFileURL(o.url),
  23352. 'start': o.start
  23353. }));
  23354. return media_urls.length ? {
  23355. media_urls
  23356. } : {};
  23357. }
  23358. function getSpoilerAttributes(stanza) {
  23359. const spoiler = sizzle_default()(`spoiler[xmlns="${Strophe.NS.SPOILER}"]`, stanza).pop();
  23360. return {
  23361. 'is_spoiler': !!spoiler,
  23362. 'spoiler_hint': spoiler === null || spoiler === void 0 ? void 0 : spoiler.textContent
  23363. };
  23364. }
  23365. function getOutOfBandAttributes(stanza) {
  23366. const xform = sizzle_default()(`x[xmlns="${Strophe.NS.OUTOFBAND}"]`, stanza).pop();
  23367. if (xform) {
  23368. var _xform$querySelector, _xform$querySelector2;
  23369. return {
  23370. 'oob_url': (_xform$querySelector = xform.querySelector('url')) === null || _xform$querySelector === void 0 ? void 0 : _xform$querySelector.textContent,
  23371. 'oob_desc': (_xform$querySelector2 = xform.querySelector('desc')) === null || _xform$querySelector2 === void 0 ? void 0 : _xform$querySelector2.textContent
  23372. };
  23373. }
  23374. return {};
  23375. }
  23376. /**
  23377. * Returns the human readable error message contained in a `groupchat` message stanza of type `error`.
  23378. * @private
  23379. * @param { XMLElement } stanza - The message stanza
  23380. */
  23381. function getErrorAttributes(stanza) {
  23382. if (stanza.getAttribute('type') === 'error') {
  23383. const error = stanza.querySelector('error');
  23384. const text = sizzle_default()(`text[xmlns="${Strophe.NS.STANZAS}"]`, error).pop();
  23385. return {
  23386. 'is_error': true,
  23387. 'error_text': text === null || text === void 0 ? void 0 : text.textContent,
  23388. 'error_type': error.getAttribute('type'),
  23389. 'error_condition': error.firstElementChild.nodeName
  23390. };
  23391. }
  23392. return {};
  23393. }
  23394. function getReferences(stanza) {
  23395. return sizzle_default()(`reference[xmlns="${Strophe.NS.REFERENCE}"]`, stanza).map(ref => {
  23396. var _stanza$querySelector;
  23397. const anchor = ref.getAttribute('anchor');
  23398. const text = (_stanza$querySelector = stanza.querySelector(anchor ? `#${anchor}` : 'body')) === null || _stanza$querySelector === void 0 ? void 0 : _stanza$querySelector.textContent;
  23399. if (!text) {
  23400. headless_log.warn(`Could not find referenced text for ${ref}`);
  23401. return null;
  23402. }
  23403. const begin = ref.getAttribute('begin');
  23404. const end = ref.getAttribute('end');
  23405. return {
  23406. 'begin': begin,
  23407. 'end': end,
  23408. 'type': ref.getAttribute('type'),
  23409. 'value': text.slice(begin, end),
  23410. 'uri': ref.getAttribute('uri')
  23411. };
  23412. }).filter(r => r);
  23413. }
  23414. function getReceiptId(stanza) {
  23415. const receipt = sizzle_default()(`received[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).pop();
  23416. return receipt === null || receipt === void 0 ? void 0 : receipt.getAttribute('id');
  23417. }
  23418. /**
  23419. * Determines whether the passed in stanza is a XEP-0280 Carbon
  23420. * @private
  23421. * @param { XMLElement } stanza - The message stanza
  23422. * @returns { Boolean }
  23423. */
  23424. function isCarbon(stanza) {
  23425. const xmlns = Strophe.NS.CARBONS;
  23426. return sizzle_default()(`message > received[xmlns="${xmlns}"]`, stanza).length > 0 || sizzle_default()(`message > sent[xmlns="${xmlns}"]`, stanza).length > 0;
  23427. }
  23428. /**
  23429. * Returns the XEP-0085 chat state contained in a message stanza
  23430. * @private
  23431. * @param { XMLElement } stanza - The message stanza
  23432. */
  23433. function getChatState(stanza) {
  23434. var _sizzle$pop;
  23435. return (_sizzle$pop = sizzle_default()(`
  23436. composing[xmlns="${NS.CHATSTATES}"],
  23437. paused[xmlns="${NS.CHATSTATES}"],
  23438. inactive[xmlns="${NS.CHATSTATES}"],
  23439. active[xmlns="${NS.CHATSTATES}"],
  23440. gone[xmlns="${NS.CHATSTATES}"]`, stanza).pop()) === null || _sizzle$pop === void 0 ? void 0 : _sizzle$pop.nodeName;
  23441. }
  23442. function isValidReceiptRequest(stanza, attrs) {
  23443. return attrs.sender !== 'me' && !attrs.is_carbon && !attrs.is_archived && sizzle_default()(`request[xmlns="${Strophe.NS.RECEIPTS}"]`, stanza).length;
  23444. }
  23445. /**
  23446. * Check whether the passed-in stanza is a forwarded message that is "bare",
  23447. * i.e. it's not forwarded as part of a larger protocol, like MAM.
  23448. * @param { XMLElement } stanza
  23449. */
  23450. function throwErrorIfInvalidForward(stanza) {
  23451. const bare_forward = sizzle_default()(`message > forwarded[xmlns="${Strophe.NS.FORWARD}"]`, stanza).length;
  23452. if (bare_forward) {
  23453. rejectMessage(stanza, 'Forwarded messages not part of an encapsulating protocol are not supported');
  23454. const from_jid = stanza.getAttribute('from');
  23455. throw new StanzaParseError(`Ignoring unencapsulated forwarded message from ${from_jid}`, stanza);
  23456. }
  23457. }
  23458. /**
  23459. * Determines whether the passed in stanza is a XEP-0333 Chat Marker
  23460. * @private
  23461. * @method getChatMarker
  23462. * @param { XMLElement } stanza - The message stanza
  23463. * @returns { Boolean }
  23464. */
  23465. function getChatMarker(stanza) {
  23466. // If we receive more than one marker (which shouldn't happen), we take
  23467. // the highest level of acknowledgement.
  23468. return sizzle_default()(`
  23469. acknowledged[xmlns="${Strophe.NS.MARKERS}"],
  23470. displayed[xmlns="${Strophe.NS.MARKERS}"],
  23471. received[xmlns="${Strophe.NS.MARKERS}"]`, stanza).pop();
  23472. }
  23473. function isHeadline(stanza) {
  23474. return stanza.getAttribute('type') === 'headline';
  23475. }
  23476. function isServerMessage(stanza) {
  23477. if (sizzle_default()(`mentions[xmlns="${Strophe.NS.MENTIONS}"]`, stanza).pop()) {
  23478. return false;
  23479. }
  23480. const from_jid = stanza.getAttribute('from');
  23481. if (stanza.getAttribute('type') !== 'error' && from_jid && !from_jid.includes('@')) {
  23482. // Some servers (e.g. Prosody) don't set the stanza
  23483. // type to "headline" when sending server messages.
  23484. // For now we check if an @ signal is included, and if not,
  23485. // we assume it's a headline stanza.
  23486. return true;
  23487. }
  23488. return false;
  23489. }
  23490. /**
  23491. * Determines whether the passed in stanza is a XEP-0313 MAM stanza
  23492. * @private
  23493. * @method isArchived
  23494. * @param { XMLElement } stanza - The message stanza
  23495. * @returns { Boolean }
  23496. */
  23497. function isArchived(original_stanza) {
  23498. return !!sizzle_default()(`message > result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).pop();
  23499. }
  23500. /**
  23501. * Returns an object containing all attribute names and values for a particular element.
  23502. * @method getAttributes
  23503. * @param { XMLElement } stanza
  23504. * @returns { Object }
  23505. */
  23506. function getAttributes(stanza) {
  23507. return stanza.getAttributeNames().reduce((acc, name) => {
  23508. acc[name] = Strophe.xmlunescape(stanza.getAttribute(name));
  23509. return acc;
  23510. }, {});
  23511. }
  23512. ;// CONCATENATED MODULE: ./src/headless/plugins/adhoc.js
  23513. const {
  23514. Strophe: adhoc_Strophe
  23515. } = core_converse.env;
  23516. let adhoc_converse, adhoc_api;
  23517. adhoc_Strophe.addNamespace('ADHOC', 'http://jabber.org/protocol/commands');
  23518. function parseForCommands(stanza) {
  23519. const items = sizzle_default()(`query[xmlns="${adhoc_Strophe.NS.DISCO_ITEMS}"][node="${adhoc_Strophe.NS.ADHOC}"] item`, stanza);
  23520. return items.map(getAttributes);
  23521. }
  23522. const adhoc_adhoc_api = {
  23523. /**
  23524. * The XEP-0050 Ad-Hoc Commands API
  23525. *
  23526. * This API lets you discover ad-hoc commands available for an entity in the XMPP network.
  23527. *
  23528. * @namespace api.adhoc
  23529. * @memberOf api
  23530. */
  23531. adhoc: {
  23532. /**
  23533. * @method api.adhoc.getCommands
  23534. * @param { String } to_jid
  23535. */
  23536. async getCommands(to_jid) {
  23537. let commands = [];
  23538. try {
  23539. commands = parseForCommands(await adhoc_api.disco.items(to_jid, adhoc_Strophe.NS.ADHOC));
  23540. } catch (e) {
  23541. if (e === null) {
  23542. headless_log.error(`Error: timeout while fetching ad-hoc commands for ${to_jid}`);
  23543. } else {
  23544. headless_log.error(`Error while fetching ad-hoc commands for ${to_jid}`);
  23545. headless_log.error(e);
  23546. }
  23547. }
  23548. return commands;
  23549. }
  23550. }
  23551. };
  23552. core_converse.plugins.add('converse-adhoc', {
  23553. dependencies: ["converse-disco"],
  23554. initialize() {
  23555. adhoc_converse = this._converse;
  23556. adhoc_api = adhoc_converse.api;
  23557. Object.assign(adhoc_api, adhoc_adhoc_api);
  23558. }
  23559. });
  23560. /* harmony default export */ const adhoc = ((/* unused pure expression or super */ null && (adhoc_adhoc_api)));
  23561. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/model-with-contact.js
  23562. const ModelWithContact = Model.extend({
  23563. initialize() {
  23564. this.rosterContactAdded = getOpenPromise();
  23565. },
  23566. async setRosterContact(jid) {
  23567. const contact = await core_api.contacts.get(jid);
  23568. if (contact) {
  23569. this.contact = contact;
  23570. this.set('nickname', contact.get('nickname'));
  23571. this.rosterContactAdded.resolve();
  23572. }
  23573. }
  23574. });
  23575. /* harmony default export */ const model_with_contact = (ModelWithContact);
  23576. // EXTERNAL MODULE: ./node_modules/filesize/lib/filesize.min.js
  23577. var filesize_min = __webpack_require__(6755);
  23578. var filesize_min_default = /*#__PURE__*/__webpack_require__.n(filesize_min);
  23579. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isMatch.js
  23580. /**
  23581. * Performs a partial deep comparison between `object` and `source` to
  23582. * determine if `object` contains equivalent property values.
  23583. *
  23584. * **Note:** This method is equivalent to `_.matches` when `source` is
  23585. * partially applied.
  23586. *
  23587. * Partial comparisons will match empty array and empty object `source`
  23588. * values against any array or object value, respectively. See `_.isEqual`
  23589. * for a list of supported value comparisons.
  23590. *
  23591. * @static
  23592. * @memberOf _
  23593. * @since 3.0.0
  23594. * @category Lang
  23595. * @param {Object} object The object to inspect.
  23596. * @param {Object} source The object of property values to match.
  23597. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  23598. * @example
  23599. *
  23600. * var object = { 'a': 1, 'b': 2 };
  23601. *
  23602. * _.isMatch(object, { 'b': 2 });
  23603. * // => true
  23604. *
  23605. * _.isMatch(object, { 'b': 1 });
  23606. * // => false
  23607. */
  23608. function isMatch(object, source) {
  23609. return object === source || _baseIsMatch(object, source, _getMatchData(source));
  23610. }
  23611. /* harmony default export */ const lodash_es_isMatch = (isMatch);
  23612. ;// CONCATENATED MODULE: ./src/headless/shared/chat/utils.js
  23613. const {
  23614. u: utils_u
  23615. } = core_converse.env;
  23616. function pruneHistory(model) {
  23617. const max_history = core_api.settings.get('prune_messages_above');
  23618. if (max_history && typeof max_history === 'number') {
  23619. if (model.messages.length > max_history) {
  23620. const non_empty_messages = model.messages.filter(m => !utils_u.isEmptyMessage(m));
  23621. if (non_empty_messages.length > max_history) {
  23622. while (non_empty_messages.length > max_history) {
  23623. non_empty_messages.shift().destroy();
  23624. }
  23625. /**
  23626. * Triggered once the message history has been pruned, i.e.
  23627. * once older messages have been removed to keep the
  23628. * number of messages below the value set in `prune_messages_above`.
  23629. * @event _converse#historyPruned
  23630. * @type { _converse.ChatBox | _converse.ChatRoom }
  23631. * @example _converse.api.listen.on('historyPruned', this => { ... });
  23632. */
  23633. core_api.trigger('historyPruned', model);
  23634. }
  23635. }
  23636. }
  23637. }
  23638. /**
  23639. * Given an array of {@link MediaURLMetadata} objects and text, return an
  23640. * array of {@link MediaURL} objects.
  23641. * @param { Array<MediaURLMetadata> } arr
  23642. * @param { String } text
  23643. * @returns{ Array<MediaURL> }
  23644. */
  23645. function getMediaURLs(arr, text) {
  23646. let offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  23647. /**
  23648. * @typedef { Object } MediaURLData
  23649. * An object representing a URL found in a chat message
  23650. * @property { Boolean } is_audio
  23651. * @property { Boolean } is_image
  23652. * @property { Boolean } is_video
  23653. * @property { String } end
  23654. * @property { String } start
  23655. * @property { String } url
  23656. */
  23657. return arr.map(o => {
  23658. const start = o.start - offset;
  23659. const end = o.end - offset;
  23660. if (start < 0 || start >= text.length) {
  23661. return null;
  23662. }
  23663. return Object.assign({}, o, {
  23664. start,
  23665. end,
  23666. 'url': text.substring(o.start - offset, o.end - offset)
  23667. });
  23668. }).filter(o => o);
  23669. }
  23670. const debouncedPruneHistory = lodash_es_debounce(pruneHistory, 500);
  23671. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/parsers.js
  23672. const {
  23673. Strophe: parsers_Strophe,
  23674. sizzle: parsers_sizzle
  23675. } = core_converse.env;
  23676. /**
  23677. * Parses a passed in message stanza and returns an object of attributes.
  23678. * @method st#parseMessage
  23679. * @param { XMLElement } stanza - The message stanza
  23680. * @param { _converse } _converse
  23681. * @returns { (MessageAttributes|Error) }
  23682. */
  23683. async function parseMessage(stanza) {
  23684. var _stanza$querySelector, _stanza$querySelector2, _contact, _contact$attributes, _stanza$querySelector3, _stanza$querySelector4;
  23685. throwErrorIfInvalidForward(stanza);
  23686. let to_jid = stanza.getAttribute('to');
  23687. const to_resource = parsers_Strophe.getResourceFromJid(to_jid);
  23688. if (core_api.settings.get('filter_by_resource') && to_resource && to_resource !== shared_converse.resource) {
  23689. return new StanzaParseError(`Ignoring incoming message intended for a different resource: ${to_jid}`, stanza);
  23690. }
  23691. const original_stanza = stanza;
  23692. let from_jid = stanza.getAttribute('from') || shared_converse.bare_jid;
  23693. if (isCarbon(stanza)) {
  23694. if (from_jid === shared_converse.bare_jid) {
  23695. const selector = `[xmlns="${parsers_Strophe.NS.CARBONS}"] > forwarded[xmlns="${parsers_Strophe.NS.FORWARD}"] > message`;
  23696. stanza = parsers_sizzle(selector, stanza).pop();
  23697. to_jid = stanza.getAttribute('to');
  23698. from_jid = stanza.getAttribute('from');
  23699. } else {
  23700. // Prevent message forging via carbons: https://xmpp.org/extensions/xep-0280.html#security
  23701. rejectMessage(stanza, 'Rejecting carbon from invalid JID');
  23702. return new StanzaParseError(`Rejecting carbon from invalid JID ${to_jid}`, stanza);
  23703. }
  23704. }
  23705. const is_archived = isArchived(stanza);
  23706. if (is_archived) {
  23707. if (from_jid === shared_converse.bare_jid) {
  23708. const selector = `[xmlns="${parsers_Strophe.NS.MAM}"] > forwarded[xmlns="${parsers_Strophe.NS.FORWARD}"] > message`;
  23709. stanza = parsers_sizzle(selector, stanza).pop();
  23710. to_jid = stanza.getAttribute('to');
  23711. from_jid = stanza.getAttribute('from');
  23712. } else {
  23713. return new StanzaParseError(`Invalid Stanza: alleged MAM message from ${stanza.getAttribute('from')}`, stanza);
  23714. }
  23715. }
  23716. const from_bare_jid = parsers_Strophe.getBareJidFromJid(from_jid);
  23717. const is_me = from_bare_jid === shared_converse.bare_jid;
  23718. if (is_me && to_jid === null) {
  23719. return new StanzaParseError(`Don't know how to handle message stanza without 'to' attribute. ${stanza.outerHTML}`, stanza);
  23720. }
  23721. const is_headline = isHeadline(stanza);
  23722. const is_server_message = isServerMessage(stanza);
  23723. let contact, contact_jid;
  23724. if (!is_headline && !is_server_message) {
  23725. contact_jid = is_me ? parsers_Strophe.getBareJidFromJid(to_jid) : from_bare_jid;
  23726. contact = await core_api.contacts.get(contact_jid);
  23727. if (contact === undefined && !core_api.settings.get('allow_non_roster_messaging')) {
  23728. headless_log.error(stanza);
  23729. return new StanzaParseError(`Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.`, stanza);
  23730. }
  23731. }
  23732. /**
  23733. * @typedef { Object } MessageAttributes
  23734. * The object which {@link parseMessage} returns
  23735. * @property { ('me'|'them') } sender - Whether the message was sent by the current user or someone else
  23736. * @property { Array<Object> } references - A list of objects representing XEP-0372 references
  23737. * @property { Boolean } editable - Is this message editable via XEP-0308?
  23738. * @property { Boolean } is_archived - Is this message from a XEP-0313 MAM archive?
  23739. * @property { Boolean } is_carbon - Is this message a XEP-0280 Carbon?
  23740. * @property { Boolean } is_delayed - Was delivery of this message was delayed as per XEP-0203?
  23741. * @property { Boolean } is_encrypted - Is this message XEP-0384 encrypted?
  23742. * @property { Boolean } is_error - Whether an error was received for this message
  23743. * @property { Boolean } is_headline - Is this a "headline" message?
  23744. * @property { Boolean } is_markable - Can this message be marked with a XEP-0333 chat marker?
  23745. * @property { Boolean } is_marker - Is this message a XEP-0333 Chat Marker?
  23746. * @property { Boolean } is_only_emojis - Does the message body contain only emojis?
  23747. * @property { Boolean } is_spoiler - Is this a XEP-0382 spoiler message?
  23748. * @property { Boolean } is_tombstone - Is this a XEP-0424 tombstone?
  23749. * @property { Boolean } is_unstyled - Whether XEP-0393 styling hints should be ignored
  23750. * @property { Boolean } is_valid_receipt_request - Does this message request a XEP-0184 receipt (and is not from us or a carbon or archived message)
  23751. * @property { Object } encrypted - XEP-0384 encryption payload attributes
  23752. * @property { String } body - The contents of the <body> tag of the message stanza
  23753. * @property { String } chat_state - The XEP-0085 chat state notification contained in this message
  23754. * @property { String } contact_jid - The JID of the other person or entity
  23755. * @property { String } edited - An ISO8601 string recording the time that the message was edited per XEP-0308
  23756. * @property { String } error_condition - The defined error condition
  23757. * @property { String } error_text - The error text received from the server
  23758. * @property { String } error_type - The type of error received from the server
  23759. * @property { String } from - The sender JID
  23760. * @property { String } fullname - The full name of the sender
  23761. * @property { String } marker - The XEP-0333 Chat Marker value
  23762. * @property { String } marker_id - The `id` attribute of a XEP-0333 chat marker
  23763. * @property { String } msgid - The root `id` attribute of the stanza
  23764. * @property { String } nick - The roster nickname of the sender
  23765. * @property { String } oob_desc - The description of the XEP-0066 out of band data
  23766. * @property { String } oob_url - The URL of the XEP-0066 out of band data
  23767. * @property { String } origin_id - The XEP-0359 Origin ID
  23768. * @property { String } receipt_id - The `id` attribute of a XEP-0184 <receipt> element
  23769. * @property { String } received - An ISO8601 string recording the time that the message was received
  23770. * @property { String } replace_id - The `id` attribute of a XEP-0308 <replace> element
  23771. * @property { String } retracted - An ISO8601 string recording the time that the message was retracted
  23772. * @property { String } retracted_id - The `id` attribute of a XEP-424 <retracted> element
  23773. * @property { String } spoiler_hint The XEP-0382 spoiler hint
  23774. * @property { String } stanza_id - The XEP-0359 Stanza ID. Note: the key is actualy `stanza_id ${by_jid}` and there can be multiple.
  23775. * @property { String } subject - The <subject> element value
  23776. * @property { String } thread - The <thread> element value
  23777. * @property { String } time - The time (in ISO8601 format), either given by the XEP-0203 <delay> element, or of receipt.
  23778. * @property { String } to - The recipient JID
  23779. * @property { String } type - The type of message
  23780. */
  23781. const delay = parsers_sizzle(`delay[xmlns="${parsers_Strophe.NS.DELAY}"]`, original_stanza).pop();
  23782. const marker = getChatMarker(stanza);
  23783. const now = new Date().toISOString();
  23784. let attrs = Object.assign({
  23785. contact_jid,
  23786. is_archived,
  23787. is_headline,
  23788. is_server_message,
  23789. 'body': (_stanza$querySelector = stanza.querySelector('body')) === null || _stanza$querySelector === void 0 ? void 0 : (_stanza$querySelector2 = _stanza$querySelector.textContent) === null || _stanza$querySelector2 === void 0 ? void 0 : _stanza$querySelector2.trim(),
  23790. 'chat_state': getChatState(stanza),
  23791. 'from': parsers_Strophe.getBareJidFromJid(stanza.getAttribute('from')),
  23792. 'is_carbon': isCarbon(original_stanza),
  23793. 'is_delayed': !!delay,
  23794. 'is_markable': !!parsers_sizzle(`markable[xmlns="${parsers_Strophe.NS.MARKERS}"]`, stanza).length,
  23795. 'is_marker': !!marker,
  23796. 'is_unstyled': !!parsers_sizzle(`unstyled[xmlns="${parsers_Strophe.NS.STYLING}"]`, stanza).length,
  23797. 'marker_id': marker && marker.getAttribute('id'),
  23798. 'msgid': stanza.getAttribute('id') || original_stanza.getAttribute('id'),
  23799. 'nick': (_contact = contact) === null || _contact === void 0 ? void 0 : (_contact$attributes = _contact.attributes) === null || _contact$attributes === void 0 ? void 0 : _contact$attributes.nickname,
  23800. 'receipt_id': getReceiptId(stanza),
  23801. 'received': new Date().toISOString(),
  23802. 'references': getReferences(stanza),
  23803. 'sender': is_me ? 'me' : 'them',
  23804. 'subject': (_stanza$querySelector3 = stanza.querySelector('subject')) === null || _stanza$querySelector3 === void 0 ? void 0 : _stanza$querySelector3.textContent,
  23805. 'thread': (_stanza$querySelector4 = stanza.querySelector('thread')) === null || _stanza$querySelector4 === void 0 ? void 0 : _stanza$querySelector4.textContent,
  23806. 'time': delay ? dayjs_min_default()(delay.getAttribute('stamp')).toISOString() : now,
  23807. 'to': stanza.getAttribute('to'),
  23808. 'type': stanza.getAttribute('type')
  23809. }, getErrorAttributes(stanza), getOutOfBandAttributes(stanza), getSpoilerAttributes(stanza), getCorrectionAttributes(stanza, original_stanza), getStanzaIDs(stanza, original_stanza), getRetractionAttributes(stanza, original_stanza), getEncryptionAttributes(stanza, shared_converse));
  23810. if (attrs.is_archived) {
  23811. const from = original_stanza.getAttribute('from');
  23812. if (from && from !== shared_converse.bare_jid) {
  23813. return new StanzaParseError(`Invalid Stanza: Forged MAM message from ${from}`, stanza);
  23814. }
  23815. }
  23816. await core_api.emojis.initialize();
  23817. attrs = Object.assign({
  23818. 'message': attrs.body || attrs.error,
  23819. // TODO: Remove and use body and error attributes instead
  23820. 'is_only_emojis': attrs.body ? utils_core.isOnlyEmojis(attrs.body) : false,
  23821. 'is_valid_receipt_request': isValidReceiptRequest(stanza, attrs)
  23822. }, attrs); // We prefer to use one of the XEP-0359 unique and stable stanza IDs
  23823. // as the Model id, to avoid duplicates.
  23824. attrs['id'] = attrs['origin_id'] || attrs[`stanza_id ${attrs.from}`] || utils_core.getUniqueId();
  23825. /**
  23826. * *Hook* which allows plugins to add additional parsing
  23827. * @event _converse#parseMessage
  23828. */
  23829. attrs = await core_api.hook('parseMessage', stanza, attrs); // We call this after the hook, to allow plugins (like omemo) to decrypt encrypted
  23830. // messages, since we need to parse the message text to determine whether
  23831. // there are media urls.
  23832. return Object.assign(attrs, getMediaURLsMetadata(attrs.is_encrypted ? attrs.plaintext : attrs.body));
  23833. }
  23834. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/model.js
  23835. const {
  23836. Strophe: model_Strophe,
  23837. $msg: model_$msg
  23838. } = core_converse.env;
  23839. const model_u = core_converse.env.utils;
  23840. /**
  23841. * Represents an open/ongoing chat conversation.
  23842. *
  23843. * @class
  23844. * @namespace _converse.ChatBox
  23845. * @memberOf _converse
  23846. */
  23847. const ChatBox = model_with_contact.extend({
  23848. defaults() {
  23849. return {
  23850. 'bookmarked': false,
  23851. 'chat_state': undefined,
  23852. 'hidden': isUniView() && !core_api.settings.get('singleton'),
  23853. 'message_type': 'chat',
  23854. 'nickname': undefined,
  23855. 'num_unread': 0,
  23856. 'time_opened': this.get('time_opened') || new Date().getTime(),
  23857. 'time_sent': new Date(0).toISOString(),
  23858. 'type': shared_converse.PRIVATE_CHAT_TYPE,
  23859. 'url': ''
  23860. };
  23861. },
  23862. async initialize() {
  23863. this.initialized = getOpenPromise();
  23864. model_with_contact.prototype.initialize.apply(this, arguments);
  23865. const jid = this.get('jid');
  23866. if (!jid) {
  23867. // XXX: The `validate` method will prevent this model
  23868. // from being persisted if there's no jid, but that gets
  23869. // called after model instantiation, so we have to deal
  23870. // with invalid models here also.
  23871. // This happens when the controlbox is in browser storage,
  23872. // but we're in embedded mode.
  23873. return;
  23874. }
  23875. this.set({
  23876. 'box_id': `box-${jid}`
  23877. });
  23878. this.initNotifications();
  23879. this.initUI();
  23880. this.initMessages();
  23881. if (this.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  23882. this.presence = shared_converse.presences.get(jid) || shared_converse.presences.create({
  23883. jid
  23884. });
  23885. await this.setRosterContact(jid);
  23886. this.presence.on('change:show', item => this.onPresenceChanged(item));
  23887. }
  23888. this.on('change:chat_state', this.sendChatState, this);
  23889. this.ui.on('change:scrolled', this.onScrolledChanged, this);
  23890. await this.fetchMessages();
  23891. /**
  23892. * Triggered once a {@link _converse.ChatBox} has been created and initialized.
  23893. * @event _converse#chatBoxInitialized
  23894. * @type { _converse.ChatBox}
  23895. * @example _converse.api.listen.on('chatBoxInitialized', model => { ... });
  23896. */
  23897. await core_api.trigger('chatBoxInitialized', this, {
  23898. 'Synchronous': true
  23899. });
  23900. this.initialized.resolve();
  23901. },
  23902. getMessagesCollection() {
  23903. return new shared_converse.Messages();
  23904. },
  23905. getMessagesCacheKey() {
  23906. return `converse.messages-${this.get('jid')}-${shared_converse.bare_jid}`;
  23907. },
  23908. initMessages() {
  23909. this.messages = this.getMessagesCollection();
  23910. this.messages.fetched = getOpenPromise();
  23911. this.messages.fetched.then(() => {
  23912. this.pruneHistoryWhenScrolledDown();
  23913. /**
  23914. * Triggered whenever a { @link _converse.ChatBox } or ${ @link _converse.ChatRoom }
  23915. * has fetched its messages from the local cache.
  23916. * @event _converse#afterMessagesFetched
  23917. * @type { _converse.ChatBox| _converse.ChatRoom }
  23918. * @example _converse.api.listen.on('afterMessagesFetched', (chat) => { ... });
  23919. */
  23920. core_api.trigger('afterMessagesFetched', this);
  23921. });
  23922. this.messages.chatbox = this;
  23923. initStorage(this.messages, this.getMessagesCacheKey());
  23924. this.listenTo(this.messages, 'change:upload', this.onMessageUploadChanged, this);
  23925. this.listenTo(this.messages, 'add', this.onMessageAdded, this);
  23926. },
  23927. initUI() {
  23928. this.ui = new Model();
  23929. },
  23930. initNotifications() {
  23931. this.notifications = new Model();
  23932. },
  23933. getNotificationsText() {
  23934. var _this$notifications, _this$notifications2, _this$notifications3;
  23935. const {
  23936. __
  23937. } = shared_converse;
  23938. if (((_this$notifications = this.notifications) === null || _this$notifications === void 0 ? void 0 : _this$notifications.get('chat_state')) === shared_converse.COMPOSING) {
  23939. return __('%1$s is typing', this.getDisplayName());
  23940. } else if (((_this$notifications2 = this.notifications) === null || _this$notifications2 === void 0 ? void 0 : _this$notifications2.get('chat_state')) === shared_converse.PAUSED) {
  23941. return __('%1$s has stopped typing', this.getDisplayName());
  23942. } else if (((_this$notifications3 = this.notifications) === null || _this$notifications3 === void 0 ? void 0 : _this$notifications3.get('chat_state')) === shared_converse.GONE) {
  23943. return __('%1$s has gone away', this.getDisplayName());
  23944. } else {
  23945. return '';
  23946. }
  23947. },
  23948. afterMessagesFetched() {
  23949. /**
  23950. * Triggered whenever a `_converse.ChatBox` instance has fetched its messages from
  23951. * `sessionStorage` but **NOT** from the server.
  23952. * @event _converse#afterMessagesFetched
  23953. * @type {_converse.ChatBox | _converse.ChatRoom}
  23954. * @example _converse.api.listen.on('afterMessagesFetched', view => { ... });
  23955. */
  23956. core_api.trigger('afterMessagesFetched', this);
  23957. },
  23958. fetchMessages() {
  23959. if (this.messages.fetched_flag) {
  23960. headless_log.info(`Not re-fetching messages for ${this.get('jid')}`);
  23961. return;
  23962. }
  23963. this.messages.fetched_flag = true;
  23964. const resolve = this.messages.fetched.resolve;
  23965. this.messages.fetch({
  23966. 'add': true,
  23967. 'success': msgs => {
  23968. this.afterMessagesFetched(msgs);
  23969. resolve();
  23970. },
  23971. 'error': () => {
  23972. this.afterMessagesFetched();
  23973. resolve();
  23974. }
  23975. });
  23976. return this.messages.fetched;
  23977. },
  23978. async handleErrorMessageStanza(stanza) {
  23979. const {
  23980. __
  23981. } = shared_converse;
  23982. const attrs = await parseMessage(stanza, shared_converse);
  23983. if (!(await this.shouldShowErrorMessage(attrs))) {
  23984. return;
  23985. }
  23986. const message = this.getMessageReferencedByError(attrs);
  23987. if (message) {
  23988. const new_attrs = {
  23989. 'error': attrs.error,
  23990. 'error_condition': attrs.error_condition,
  23991. 'error_text': attrs.error_text,
  23992. 'error_type': attrs.error_type,
  23993. 'editable': false
  23994. };
  23995. if (attrs.msgid === message.get('retraction_id')) {
  23996. // The error message refers to a retraction
  23997. new_attrs.retraction_id = undefined;
  23998. if (!attrs.error) {
  23999. if (attrs.error_condition === 'forbidden') {
  24000. new_attrs.error = __("You're not allowed to retract your message.");
  24001. } else {
  24002. new_attrs.error = __('Sorry, an error occurred while trying to retract your message.');
  24003. }
  24004. }
  24005. } else if (!attrs.error) {
  24006. if (attrs.error_condition === 'forbidden') {
  24007. new_attrs.error = __("You're not allowed to send a message.");
  24008. } else {
  24009. new_attrs.error = __('Sorry, an error occurred while trying to send your message.');
  24010. }
  24011. }
  24012. message.save(new_attrs);
  24013. } else {
  24014. this.createMessage(attrs);
  24015. }
  24016. },
  24017. /**
  24018. * Queue an incoming `chat` message stanza for processing.
  24019. * @async
  24020. * @private
  24021. * @method _converse.ChatBox#queueMessage
  24022. * @param { Promise<MessageAttributes> } attrs - A promise which resolves to the message attributes
  24023. */
  24024. queueMessage(attrs) {
  24025. this.msg_chain = (this.msg_chain || this.messages.fetched).then(() => this.onMessage(attrs)).catch(e => headless_log.error(e));
  24026. return this.msg_chain;
  24027. },
  24028. /**
  24029. * @async
  24030. * @private
  24031. * @method _converse.ChatBox#onMessage
  24032. * @param { MessageAttributes } attrs_promse - A promise which resolves to the message attributes.
  24033. */
  24034. async onMessage(attrs) {
  24035. attrs = await attrs;
  24036. if (model_u.isErrorObject(attrs)) {
  24037. attrs.stanza && headless_log.error(attrs.stanza);
  24038. return headless_log.error(attrs.message);
  24039. }
  24040. const message = this.getDuplicateMessage(attrs);
  24041. if (message) {
  24042. this.updateMessage(message, attrs);
  24043. } else if (!this.handleReceipt(attrs) && !this.handleChatMarker(attrs) && !(await this.handleRetraction(attrs))) {
  24044. this.setEditable(attrs, attrs.time);
  24045. if (attrs['chat_state'] && attrs.sender === 'them') {
  24046. this.notifications.set('chat_state', attrs.chat_state);
  24047. }
  24048. if (model_u.shouldCreateMessage(attrs)) {
  24049. const msg = this.handleCorrection(attrs) || (await this.createMessage(attrs));
  24050. this.notifications.set({
  24051. 'chat_state': null
  24052. });
  24053. this.handleUnreadMessage(msg);
  24054. }
  24055. }
  24056. },
  24057. async onMessageUploadChanged(message) {
  24058. if (message.get('upload') === shared_converse.SUCCESS) {
  24059. const attrs = {
  24060. 'body': message.get('body'),
  24061. 'spoiler_hint': message.get('spoiler_hint'),
  24062. 'oob_url': message.get('oob_url')
  24063. };
  24064. await this.sendMessage(attrs);
  24065. message.destroy();
  24066. }
  24067. },
  24068. onMessageAdded(message) {
  24069. if (core_api.settings.get('prune_messages_above') && (core_api.settings.get('pruning_behavior') === 'scrolled' || !this.ui.get('scrolled')) && !model_u.isEmptyMessage(message)) {
  24070. debouncedPruneHistory(this);
  24071. }
  24072. },
  24073. async clearMessages() {
  24074. try {
  24075. await this.messages.clearStore();
  24076. } catch (e) {
  24077. this.messages.trigger('reset');
  24078. headless_log.error(e);
  24079. } finally {
  24080. // No point in fetching messages from the cache if it's been cleared.
  24081. // Make sure to resolve the fetched promise to avoid freezes.
  24082. this.messages.fetched.resolve();
  24083. }
  24084. },
  24085. async close() {
  24086. if (core_api.connection.connected()) {
  24087. // Immediately sending the chat state, because the
  24088. // model is going to be destroyed afterwards.
  24089. this.setChatState(shared_converse.INACTIVE);
  24090. this.sendChatState();
  24091. }
  24092. try {
  24093. await new Promise((success, reject) => {
  24094. return this.destroy({
  24095. success,
  24096. 'error': (m, e) => reject(e)
  24097. });
  24098. });
  24099. } catch (e) {
  24100. headless_log.error(e);
  24101. } finally {
  24102. if (core_api.settings.get('clear_messages_on_reconnection')) {
  24103. await this.clearMessages();
  24104. }
  24105. }
  24106. /**
  24107. * Triggered once a chatbox has been closed.
  24108. * @event _converse#chatBoxClosed
  24109. * @type {_converse.ChatBox | _converse.ChatRoom}
  24110. * @example _converse.api.listen.on('chatBoxClosed', chat => { ... });
  24111. */
  24112. core_api.trigger('chatBoxClosed', this);
  24113. },
  24114. announceReconnection() {
  24115. /**
  24116. * Triggered whenever a `_converse.ChatBox` instance has reconnected after an outage
  24117. * @event _converse#onChatReconnected
  24118. * @type {_converse.ChatBox | _converse.ChatRoom}
  24119. * @example _converse.api.listen.on('onChatReconnected', chat => { ... });
  24120. */
  24121. core_api.trigger('chatReconnected', this);
  24122. },
  24123. async onReconnection() {
  24124. if (core_api.settings.get('clear_messages_on_reconnection')) {
  24125. await this.clearMessages();
  24126. }
  24127. this.announceReconnection();
  24128. },
  24129. onPresenceChanged(item) {
  24130. const {
  24131. __
  24132. } = shared_converse;
  24133. const show = item.get('show');
  24134. const fullname = this.getDisplayName();
  24135. let text;
  24136. if (show === 'offline') {
  24137. text = __('%1$s has gone offline', fullname);
  24138. } else if (show === 'away') {
  24139. text = __('%1$s has gone away', fullname);
  24140. } else if (show === 'dnd') {
  24141. text = __('%1$s is busy', fullname);
  24142. } else if (show === 'online') {
  24143. text = __('%1$s is online', fullname);
  24144. }
  24145. text && this.createMessage({
  24146. 'message': text,
  24147. 'type': 'info'
  24148. });
  24149. },
  24150. onScrolledChanged() {
  24151. if (!this.ui.get('scrolled')) {
  24152. this.clearUnreadMsgCounter();
  24153. this.pruneHistoryWhenScrolledDown();
  24154. }
  24155. },
  24156. pruneHistoryWhenScrolledDown() {
  24157. if (core_api.settings.get('prune_messages_above') && core_api.settings.get('pruning_behavior') === 'unscrolled' && !this.ui.get('scrolled')) {
  24158. debouncedPruneHistory(this);
  24159. }
  24160. },
  24161. validate(attrs) {
  24162. if (!attrs.jid) {
  24163. return 'Ignored ChatBox without JID';
  24164. }
  24165. const room_jids = core_api.settings.get('auto_join_rooms').map(s => lodash_es_isObject(s) ? s.jid : s);
  24166. const auto_join = core_api.settings.get('auto_join_private_chats').concat(room_jids);
  24167. if (core_api.settings.get("singleton") && !auto_join.includes(attrs.jid) && !core_api.settings.get('auto_join_on_invite')) {
  24168. const msg = `${attrs.jid} is not allowed because singleton is true and it's not being auto_joined`;
  24169. headless_log.warn(msg);
  24170. return msg;
  24171. }
  24172. },
  24173. getDisplayName() {
  24174. if (this.contact) {
  24175. return this.contact.getDisplayName();
  24176. } else if (this.vcard) {
  24177. return this.vcard.getDisplayName();
  24178. } else {
  24179. return this.get('jid');
  24180. }
  24181. },
  24182. async createMessageFromError(error) {
  24183. if (error instanceof shared_converse.TimeoutError) {
  24184. const msg = await this.createMessage({
  24185. 'type': 'error',
  24186. 'message': error.message,
  24187. 'retry_event_id': error.retry_event_id,
  24188. 'is_ephemeral': 30000
  24189. });
  24190. msg.error = error;
  24191. }
  24192. },
  24193. editEarlierMessage() {
  24194. let message;
  24195. let idx = this.messages.findLastIndex('correcting');
  24196. if (idx >= 0) {
  24197. this.messages.at(idx).save('correcting', false);
  24198. while (idx > 0) {
  24199. idx -= 1;
  24200. const candidate = this.messages.at(idx);
  24201. if (candidate.get('editable')) {
  24202. message = candidate;
  24203. break;
  24204. }
  24205. }
  24206. }
  24207. message = message || this.messages.filter({
  24208. 'sender': 'me'
  24209. }).reverse().find(m => m.get('editable'));
  24210. if (message) {
  24211. message.save('correcting', true);
  24212. }
  24213. },
  24214. editLaterMessage() {
  24215. let message;
  24216. let idx = this.messages.findLastIndex('correcting');
  24217. if (idx >= 0) {
  24218. this.messages.at(idx).save('correcting', false);
  24219. while (idx < this.messages.length - 1) {
  24220. idx += 1;
  24221. const candidate = this.messages.at(idx);
  24222. if (candidate.get('editable')) {
  24223. message = candidate;
  24224. message.save('correcting', true);
  24225. break;
  24226. }
  24227. }
  24228. }
  24229. return message;
  24230. },
  24231. getOldestMessage() {
  24232. for (let i = 0; i < this.messages.length; i++) {
  24233. const message = this.messages.at(i);
  24234. if (message.get('type') === this.get('message_type')) {
  24235. return message;
  24236. }
  24237. }
  24238. },
  24239. getMostRecentMessage() {
  24240. for (let i = this.messages.length - 1; i >= 0; i--) {
  24241. const message = this.messages.at(i);
  24242. if (message.get('type') === this.get('message_type')) {
  24243. return message;
  24244. }
  24245. }
  24246. },
  24247. getUpdatedMessageAttributes(message, attrs) {
  24248. if (!attrs.error_type && message.get('error_type') === 'Decryption') {
  24249. // Looks like we have a failed decrypted message stored, and now
  24250. // we have a properly decrypted version of the same message.
  24251. // See issue: https://github.com/conversejs/converse.js/issues/2733#issuecomment-1035493594
  24252. return Object.assign({}, attrs, {
  24253. error_condition: undefined,
  24254. error_message: undefined,
  24255. error_text: undefined,
  24256. error_type: undefined,
  24257. is_archived: attrs.is_archived,
  24258. is_ephemeral: false,
  24259. is_error: false
  24260. });
  24261. } else {
  24262. return {
  24263. is_archived: attrs.is_archived
  24264. };
  24265. }
  24266. },
  24267. updateMessage(message, attrs) {
  24268. const new_attrs = this.getUpdatedMessageAttributes(message, attrs);
  24269. new_attrs && message.save(new_attrs);
  24270. },
  24271. /**
  24272. * Mutator for setting the chat state of this chat session.
  24273. * Handles clearing of any chat state notification timeouts and
  24274. * setting new ones if necessary.
  24275. * Timeouts are set when the state being set is COMPOSING or PAUSED.
  24276. * After the timeout, COMPOSING will become PAUSED and PAUSED will become INACTIVE.
  24277. * See XEP-0085 Chat State Notifications.
  24278. * @private
  24279. * @method _converse.ChatBox#setChatState
  24280. * @param { string } state - The chat state (consts ACTIVE, COMPOSING, PAUSED, INACTIVE, GONE)
  24281. */
  24282. setChatState(state, options) {
  24283. if (this.chat_state_timeout !== undefined) {
  24284. window.clearTimeout(this.chat_state_timeout);
  24285. delete this.chat_state_timeout;
  24286. }
  24287. if (state === shared_converse.COMPOSING) {
  24288. this.chat_state_timeout = window.setTimeout(this.setChatState.bind(this), shared_converse.TIMEOUTS.PAUSED, shared_converse.PAUSED);
  24289. } else if (state === shared_converse.PAUSED) {
  24290. this.chat_state_timeout = window.setTimeout(this.setChatState.bind(this), shared_converse.TIMEOUTS.INACTIVE, shared_converse.INACTIVE);
  24291. }
  24292. this.set('chat_state', state, options);
  24293. return this;
  24294. },
  24295. /**
  24296. * Given an error `<message>` stanza's attributes, find the saved message model which is
  24297. * referenced by that error.
  24298. * @param { Object } attrs
  24299. */
  24300. getMessageReferencedByError(attrs) {
  24301. const id = attrs.msgid;
  24302. return id && this.messages.models.find(m => [m.get('msgid'), m.get('retraction_id')].includes(id));
  24303. },
  24304. /**
  24305. * @private
  24306. * @method _converse.ChatBox#shouldShowErrorMessage
  24307. * @returns {boolean}
  24308. */
  24309. shouldShowErrorMessage(attrs) {
  24310. const msg = this.getMessageReferencedByError(attrs);
  24311. if (!msg && attrs.chat_state) {
  24312. // If the error refers to a message not included in our store,
  24313. // and it has a chat state tag, we assume that this was a
  24314. // CSI message (which we don't store).
  24315. // See https://github.com/conversejs/converse.js/issues/1317
  24316. return;
  24317. } // Gets overridden in ChatRoom
  24318. return true;
  24319. },
  24320. isSameUser(jid1, jid2) {
  24321. return model_u.isSameBareJID(jid1, jid2);
  24322. },
  24323. /**
  24324. * Looks whether we already have a retraction for this
  24325. * incoming message. If so, it's considered "dangling" because it
  24326. * probably hasn't been applied to anything yet, given that the
  24327. * relevant message is only coming in now.
  24328. * @private
  24329. * @method _converse.ChatBox#findDanglingRetraction
  24330. * @param { object } attrs - Attributes representing a received
  24331. * message, as returned by {@link parseMessage}
  24332. * @returns { _converse.Message }
  24333. */
  24334. findDanglingRetraction(attrs) {
  24335. if (!attrs.origin_id || !this.messages.length) {
  24336. return null;
  24337. } // Only look for dangling retractions if there are newer
  24338. // messages than this one, since retractions come after.
  24339. if (this.messages.last().get('time') > attrs.time) {
  24340. // Search from latest backwards
  24341. const messages = Array.from(this.messages.models);
  24342. messages.reverse();
  24343. return messages.find(_ref => {
  24344. let {
  24345. attributes
  24346. } = _ref;
  24347. return attributes.retracted_id === attrs.origin_id && attributes.from === attrs.from && !attributes.moderated_by;
  24348. });
  24349. }
  24350. },
  24351. /**
  24352. * Handles message retraction based on the passed in attributes.
  24353. * @private
  24354. * @method _converse.ChatBox#handleRetraction
  24355. * @param { object } attrs - Attributes representing a received
  24356. * message, as returned by {@link parseMessage}
  24357. * @returns { Boolean } Returns `true` or `false` depending on
  24358. * whether a message was retracted or not.
  24359. */
  24360. async handleRetraction(attrs) {
  24361. const RETRACTION_ATTRIBUTES = ['retracted', 'retracted_id', 'editable'];
  24362. if (attrs.retracted) {
  24363. if (attrs.is_tombstone) {
  24364. return false;
  24365. }
  24366. const message = this.messages.findWhere({
  24367. 'origin_id': attrs.retracted_id,
  24368. 'from': attrs.from
  24369. });
  24370. if (!message) {
  24371. attrs['dangling_retraction'] = true;
  24372. await this.createMessage(attrs);
  24373. return true;
  24374. }
  24375. message.save(lodash_es_pick(attrs, RETRACTION_ATTRIBUTES));
  24376. return true;
  24377. } else {
  24378. // Check if we have dangling retraction
  24379. const message = this.findDanglingRetraction(attrs);
  24380. if (message) {
  24381. const retraction_attrs = lodash_es_pick(message.attributes, RETRACTION_ATTRIBUTES);
  24382. const new_attrs = Object.assign({
  24383. 'dangling_retraction': false
  24384. }, attrs, retraction_attrs);
  24385. delete new_attrs['id']; // Delete id, otherwise a new cache entry gets created
  24386. message.save(new_attrs);
  24387. return true;
  24388. }
  24389. }
  24390. return false;
  24391. },
  24392. /**
  24393. * Determines whether the passed in message attributes represent a
  24394. * message which corrects a previously received message, or an
  24395. * older message which has already been corrected.
  24396. * In both cases, update the corrected message accordingly.
  24397. * @private
  24398. * @method _converse.ChatBox#handleCorrection
  24399. * @param { object } attrs - Attributes representing a received
  24400. * message, as returned by {@link parseMessage}
  24401. * @returns { _converse.Message|undefined } Returns the corrected
  24402. * message or `undefined` if not applicable.
  24403. */
  24404. handleCorrection(attrs) {
  24405. if (!attrs.replace_id || !attrs.from) {
  24406. return;
  24407. }
  24408. const message = this.messages.findWhere({
  24409. 'msgid': attrs.replace_id,
  24410. 'from': attrs.from
  24411. });
  24412. if (!message) {
  24413. return;
  24414. }
  24415. const older_versions = message.get('older_versions') || {};
  24416. if (attrs.time < message.get('time') && message.get('edited')) {
  24417. // This is an older message which has been corrected afterwards
  24418. older_versions[attrs.time] = attrs['message'];
  24419. message.save({
  24420. 'older_versions': older_versions
  24421. });
  24422. } else {
  24423. // This is a correction of an earlier message we already received
  24424. if (Object.keys(older_versions).length) {
  24425. older_versions[message.get('edited')] = message.getMessageText();
  24426. } else {
  24427. older_versions[message.get('time')] = message.getMessageText();
  24428. }
  24429. attrs = Object.assign(attrs, {
  24430. older_versions
  24431. });
  24432. delete attrs['msgid']; // We want to keep the msgid of the original message
  24433. delete attrs['id']; // Delete id, otherwise a new cache entry gets created
  24434. attrs['time'] = message.get('time');
  24435. message.save(attrs);
  24436. }
  24437. return message;
  24438. },
  24439. /**
  24440. * Returns an already cached message (if it exists) based on the
  24441. * passed in attributes map.
  24442. * @private
  24443. * @method _converse.ChatBox#getDuplicateMessage
  24444. * @param { object } attrs - Attributes representing a received
  24445. * message, as returned by {@link parseMessage}
  24446. * @returns {Promise<_converse.Message>}
  24447. */
  24448. getDuplicateMessage(attrs) {
  24449. const queries = [...this.getStanzaIdQueryAttrs(attrs), this.getOriginIdQueryAttrs(attrs), this.getMessageBodyQueryAttrs(attrs)].filter(s => s);
  24450. const msgs = this.messages.models;
  24451. return msgs.find(m => queries.reduce((out, q) => out || lodash_es_isMatch(m.attributes, q), false));
  24452. },
  24453. getOriginIdQueryAttrs(attrs) {
  24454. return attrs.origin_id && {
  24455. 'origin_id': attrs.origin_id,
  24456. 'from': attrs.from
  24457. };
  24458. },
  24459. getStanzaIdQueryAttrs(attrs) {
  24460. const keys = Object.keys(attrs).filter(k => k.startsWith('stanza_id '));
  24461. return keys.map(key => {
  24462. const by_jid = key.replace(/^stanza_id /, '');
  24463. const query = {};
  24464. query[`stanza_id ${by_jid}`] = attrs[key];
  24465. return query;
  24466. });
  24467. },
  24468. getMessageBodyQueryAttrs(attrs) {
  24469. if (attrs.msgid) {
  24470. const query = {
  24471. 'from': attrs.from,
  24472. 'msgid': attrs.msgid
  24473. }; // XXX: Need to take XEP-428 <fallback> into consideration
  24474. if (!attrs.is_encrypted && attrs.body) {
  24475. // We can't match the message if it's a reflected
  24476. // encrypted message (e.g. via MAM or in a MUC)
  24477. query['body'] = attrs.body;
  24478. }
  24479. return query;
  24480. }
  24481. },
  24482. /**
  24483. * Retract one of your messages in this chat
  24484. * @private
  24485. * @method _converse.ChatBoxView#retractOwnMessage
  24486. * @param { _converse.Message } message - The message which we're retracting.
  24487. */
  24488. retractOwnMessage(message) {
  24489. this.sendRetractionMessage(message);
  24490. message.save({
  24491. 'retracted': new Date().toISOString(),
  24492. 'retracted_id': message.get('origin_id'),
  24493. 'retraction_id': message.get('id'),
  24494. 'is_ephemeral': true,
  24495. 'editable': false
  24496. });
  24497. },
  24498. /**
  24499. * Sends a message stanza to retract a message in this chat
  24500. * @private
  24501. * @method _converse.ChatBox#sendRetractionMessage
  24502. * @param { _converse.Message } message - The message which we're retracting.
  24503. */
  24504. sendRetractionMessage(message) {
  24505. const origin_id = message.get('origin_id');
  24506. if (!origin_id) {
  24507. throw new Error("Can't retract message without a XEP-0359 Origin ID");
  24508. }
  24509. const msg = model_$msg({
  24510. 'id': model_u.getUniqueId(),
  24511. 'to': this.get('jid'),
  24512. 'type': "chat"
  24513. }).c('store', {
  24514. xmlns: model_Strophe.NS.HINTS
  24515. }).up().c("apply-to", {
  24516. 'id': origin_id,
  24517. 'xmlns': model_Strophe.NS.FASTEN
  24518. }).c('retract', {
  24519. xmlns: model_Strophe.NS.RETRACT
  24520. });
  24521. return shared_converse.connection.send(msg);
  24522. },
  24523. /**
  24524. * Finds the last eligible message and then sends a XEP-0333 chat marker for it.
  24525. * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
  24526. * @param { Boolean } force - Whether a marker should be sent for the
  24527. * message, even if it didn't include a `markable` element.
  24528. */
  24529. sendMarkerForLastMessage() {
  24530. let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'displayed';
  24531. let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  24532. const msgs = Array.from(this.messages.models);
  24533. msgs.reverse();
  24534. const msg = msgs.find(m => m.get('sender') === 'them' && (force || m.get('is_markable')));
  24535. msg && this.sendMarkerForMessage(msg, type, force);
  24536. },
  24537. /**
  24538. * Given the passed in message object, send a XEP-0333 chat marker.
  24539. * @param { _converse.Message } msg
  24540. * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
  24541. * @param { Boolean } force - Whether a marker should be sent for the
  24542. * message, even if it didn't include a `markable` element.
  24543. */
  24544. sendMarkerForMessage(msg) {
  24545. let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'displayed';
  24546. let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  24547. if (!msg || !core_api.settings.get('send_chat_markers').includes(type)) {
  24548. return;
  24549. }
  24550. if (msg !== null && msg !== void 0 && msg.get('is_markable') || force) {
  24551. const from_jid = model_Strophe.getBareJidFromJid(msg.get('from'));
  24552. sendMarker(from_jid, msg.get('msgid'), type, msg.get('type'));
  24553. }
  24554. },
  24555. handleChatMarker(attrs) {
  24556. const to_bare_jid = model_Strophe.getBareJidFromJid(attrs.to);
  24557. if (to_bare_jid !== shared_converse.bare_jid) {
  24558. return false;
  24559. }
  24560. if (attrs.is_markable) {
  24561. if (this.contact && !attrs.is_archived && !attrs.is_carbon) {
  24562. sendMarker(attrs.from, attrs.msgid, 'received');
  24563. }
  24564. return false;
  24565. } else if (attrs.marker_id) {
  24566. const message = this.messages.findWhere({
  24567. 'msgid': attrs.marker_id
  24568. });
  24569. const field_name = `marker_${attrs.marker}`;
  24570. if (message && !message.get(field_name)) {
  24571. message.save({
  24572. field_name: new Date().toISOString()
  24573. });
  24574. }
  24575. return true;
  24576. }
  24577. },
  24578. sendReceiptStanza(to_jid, id) {
  24579. const receipt_stanza = model_$msg({
  24580. 'from': shared_converse.connection.jid,
  24581. 'id': model_u.getUniqueId(),
  24582. 'to': to_jid,
  24583. 'type': 'chat'
  24584. }).c('received', {
  24585. 'xmlns': model_Strophe.NS.RECEIPTS,
  24586. 'id': id
  24587. }).up().c('store', {
  24588. 'xmlns': model_Strophe.NS.HINTS
  24589. }).up();
  24590. core_api.send(receipt_stanza);
  24591. },
  24592. handleReceipt(attrs) {
  24593. if (attrs.sender === 'them') {
  24594. if (attrs.is_valid_receipt_request) {
  24595. this.sendReceiptStanza(attrs.from, attrs.msgid);
  24596. } else if (attrs.receipt_id) {
  24597. const message = this.messages.findWhere({
  24598. 'msgid': attrs.receipt_id
  24599. });
  24600. if (message && !message.get('received')) {
  24601. message.save({
  24602. 'received': new Date().toISOString()
  24603. });
  24604. }
  24605. return true;
  24606. }
  24607. }
  24608. return false;
  24609. },
  24610. /**
  24611. * Given a {@link _converse.Message} return the XML stanza that represents it.
  24612. * @private
  24613. * @method _converse.ChatBox#createMessageStanza
  24614. * @param { _converse.Message } message - The message object
  24615. */
  24616. async createMessageStanza(message) {
  24617. const stanza = model_$msg({
  24618. 'from': shared_converse.connection.jid,
  24619. 'to': this.get('jid'),
  24620. 'type': this.get('message_type'),
  24621. 'id': message.get('edited') && model_u.getUniqueId() || message.get('msgid')
  24622. }).c('body').t(message.get('body')).up().c(shared_converse.ACTIVE, {
  24623. 'xmlns': model_Strophe.NS.CHATSTATES
  24624. }).root();
  24625. if (message.get('type') === 'chat') {
  24626. stanza.c('request', {
  24627. 'xmlns': model_Strophe.NS.RECEIPTS
  24628. }).root();
  24629. }
  24630. if (!message.get('is_encrypted')) {
  24631. if (message.get('is_spoiler')) {
  24632. if (message.get('spoiler_hint')) {
  24633. stanza.c('spoiler', {
  24634. 'xmlns': model_Strophe.NS.SPOILER
  24635. }, message.get('spoiler_hint')).root();
  24636. } else {
  24637. stanza.c('spoiler', {
  24638. 'xmlns': model_Strophe.NS.SPOILER
  24639. }).root();
  24640. }
  24641. }
  24642. (message.get('references') || []).forEach(reference => {
  24643. const attrs = {
  24644. 'xmlns': model_Strophe.NS.REFERENCE,
  24645. 'begin': reference.begin,
  24646. 'end': reference.end,
  24647. 'type': reference.type
  24648. };
  24649. if (reference.uri) {
  24650. attrs.uri = reference.uri;
  24651. }
  24652. stanza.c('reference', attrs).root();
  24653. });
  24654. if (message.get('oob_url')) {
  24655. stanza.c('x', {
  24656. 'xmlns': model_Strophe.NS.OUTOFBAND
  24657. }).c('url').t(message.get('oob_url')).root();
  24658. }
  24659. }
  24660. if (message.get('edited')) {
  24661. stanza.c('replace', {
  24662. 'xmlns': model_Strophe.NS.MESSAGE_CORRECT,
  24663. 'id': message.get('msgid')
  24664. }).root();
  24665. }
  24666. if (message.get('origin_id')) {
  24667. stanza.c('origin-id', {
  24668. 'xmlns': model_Strophe.NS.SID,
  24669. 'id': message.get('origin_id')
  24670. }).root();
  24671. }
  24672. stanza.root();
  24673. /**
  24674. * *Hook* which allows plugins to update an outgoing message stanza
  24675. * @event _converse#createMessageStanza
  24676. * @param { _converse.ChatBox | _converse.ChatRoom } - The chat from
  24677. * which this message stanza is being sent.
  24678. * @param { Object } data - Message data
  24679. * @param { _converse.Message | _converse.ChatRoomMessage } data.message
  24680. * The message object from which the stanza is created and which gets persisted to storage.
  24681. * @param { Strophe.Builder } data.stanza
  24682. * The stanza that will be sent out, as a Strophe.Builder object.
  24683. * You can use the Strophe.Builder functions to extend the stanza.
  24684. * See http://strophe.im/strophejs/doc/1.4.3/files/strophe-umd-js.html#Strophe.Builder.Functions
  24685. */
  24686. const data = await core_api.hook('createMessageStanza', this, {
  24687. message,
  24688. stanza
  24689. });
  24690. return data.stanza;
  24691. },
  24692. async getOutgoingMessageAttributes(attrs) {
  24693. var _attrs;
  24694. const is_spoiler = !!this.get('composing_spoiler');
  24695. const origin_id = model_u.getUniqueId();
  24696. const text = (_attrs = attrs) === null || _attrs === void 0 ? void 0 : _attrs.body;
  24697. const body = text ? model_u.httpToGeoUri(model_u.shortnamesToUnicode(text), shared_converse) : undefined;
  24698. attrs = Object.assign({}, attrs, {
  24699. 'from': shared_converse.bare_jid,
  24700. 'fullname': shared_converse.xmppstatus.get('fullname'),
  24701. 'id': origin_id,
  24702. 'is_only_emojis': text ? model_u.isOnlyEmojis(text) : false,
  24703. 'jid': this.get('jid'),
  24704. 'message': body,
  24705. 'msgid': origin_id,
  24706. 'nickname': this.get('nickname'),
  24707. 'sender': 'me',
  24708. 'time': new Date().toISOString(),
  24709. 'type': this.get('message_type'),
  24710. body,
  24711. is_spoiler,
  24712. origin_id
  24713. }, getMediaURLsMetadata(text));
  24714. /**
  24715. * *Hook* which allows plugins to update the attributes of an outgoing message.
  24716. * These attributes get set on the { @link _converse.Message } or
  24717. * { @link _converse.ChatRoomMessage } and persisted to storage.
  24718. * @event _converse#getOutgoingMessageAttributes
  24719. * @param { _converse.ChatBox | _converse.ChatRoom } chat
  24720. * The chat from which this message will be sent.
  24721. * @param { MessageAttributes } attrs
  24722. * The message attributes, from which the stanza will be created.
  24723. */
  24724. attrs = await core_api.hook('getOutgoingMessageAttributes', this, attrs);
  24725. return attrs;
  24726. },
  24727. /**
  24728. * Responsible for setting the editable attribute of messages.
  24729. * If api.settings.get('allow_message_corrections') is "last", then only the last
  24730. * message sent from me will be editable. If set to "all" all messages
  24731. * will be editable. Otherwise no messages will be editable.
  24732. * @method _converse.ChatBox#setEditable
  24733. * @memberOf _converse.ChatBox
  24734. * @param { Object } attrs An object containing message attributes.
  24735. * @param { String } send_time - time when the message was sent
  24736. */
  24737. setEditable(attrs, send_time) {
  24738. if (attrs.is_headline || model_u.isEmptyMessage(attrs) || attrs.sender !== 'me') {
  24739. return;
  24740. }
  24741. if (core_api.settings.get('allow_message_corrections') === 'all') {
  24742. attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs);
  24743. } else if (core_api.settings.get('allow_message_corrections') === 'last' && send_time > this.get('time_sent')) {
  24744. this.set({
  24745. 'time_sent': send_time
  24746. });
  24747. const msg = this.messages.findWhere({
  24748. 'editable': true
  24749. });
  24750. if (msg) {
  24751. msg.save({
  24752. 'editable': false
  24753. });
  24754. }
  24755. attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs);
  24756. }
  24757. },
  24758. /**
  24759. * Queue the creation of a message, to make sure that we don't run
  24760. * into a race condition whereby we're creating a new message
  24761. * before the collection has been fetched.
  24762. * @async
  24763. * @private
  24764. * @method _converse.ChatBox#createMessage
  24765. * @param { Object } attrs
  24766. */
  24767. async createMessage(attrs, options) {
  24768. attrs.time = attrs.time || new Date().toISOString();
  24769. await this.messages.fetched;
  24770. return this.messages.create(attrs, options);
  24771. },
  24772. /**
  24773. * Responsible for sending off a text message inside an ongoing chat conversation.
  24774. * @private
  24775. * @method _converse.ChatBox#sendMessage
  24776. * @memberOf _converse.ChatBox
  24777. * @param { Object } [attrs] - A map of attributes to be saved on the message
  24778. * @returns { _converse.Message }
  24779. * @example
  24780. * const chat = api.chats.get('buddy1@example.org');
  24781. * chat.sendMessage({'body': 'hello world'});
  24782. */
  24783. async sendMessage(attrs) {
  24784. attrs = await this.getOutgoingMessageAttributes(attrs);
  24785. let message = this.messages.findWhere('correcting');
  24786. if (message) {
  24787. const older_versions = message.get('older_versions') || {};
  24788. const edited_time = message.get('edited') || message.get('time');
  24789. older_versions[edited_time] = message.getMessageText();
  24790. const plaintext = attrs.is_encrypted ? attrs.message : undefined;
  24791. message.save({
  24792. 'body': attrs.body,
  24793. 'message': attrs.body,
  24794. 'correcting': false,
  24795. 'edited': new Date().toISOString(),
  24796. 'is_only_emojis': attrs.is_only_emojis,
  24797. 'origin_id': model_u.getUniqueId(),
  24798. 'received': undefined,
  24799. 'references': attrs.references,
  24800. older_versions,
  24801. plaintext
  24802. });
  24803. } else {
  24804. this.setEditable(attrs, new Date().toISOString());
  24805. message = await this.createMessage(attrs);
  24806. }
  24807. try {
  24808. const stanza = await this.createMessageStanza(message);
  24809. core_api.send(stanza);
  24810. } catch (e) {
  24811. message.destroy();
  24812. headless_log.error(e);
  24813. return;
  24814. }
  24815. /**
  24816. * Triggered when a message is being sent out
  24817. * @event _converse#sendMessage
  24818. * @type { Object }
  24819. * @param { Object } data
  24820. * @property { (_converse.ChatBox | _converse.ChatRoom) } data.chatbox
  24821. * @property { (_converse.Message | _converse.ChatRoomMessage) } data.message
  24822. */
  24823. core_api.trigger('sendMessage', {
  24824. 'chatbox': this,
  24825. message
  24826. });
  24827. return message;
  24828. },
  24829. /**
  24830. * Sends a message with the current XEP-0085 chat state of the user
  24831. * as taken from the `chat_state` attribute of the {@link _converse.ChatBox}.
  24832. * @private
  24833. * @method _converse.ChatBox#sendChatState
  24834. */
  24835. sendChatState() {
  24836. if (core_api.settings.get('send_chat_state_notifications') && this.get('chat_state')) {
  24837. const allowed = core_api.settings.get('send_chat_state_notifications');
  24838. if (Array.isArray(allowed) && !allowed.includes(this.get('chat_state'))) {
  24839. return;
  24840. }
  24841. core_api.send(model_$msg({
  24842. 'id': model_u.getUniqueId(),
  24843. 'to': this.get('jid'),
  24844. 'type': 'chat'
  24845. }).c(this.get('chat_state'), {
  24846. 'xmlns': model_Strophe.NS.CHATSTATES
  24847. }).up().c('no-store', {
  24848. 'xmlns': model_Strophe.NS.HINTS
  24849. }).up().c('no-permanent-store', {
  24850. 'xmlns': model_Strophe.NS.HINTS
  24851. }));
  24852. }
  24853. },
  24854. async sendFiles(files) {
  24855. var _maxFileSize;
  24856. const {
  24857. __
  24858. } = shared_converse;
  24859. const result = await core_api.disco.features.get(model_Strophe.NS.HTTPUPLOAD, shared_converse.domain);
  24860. const item = result.pop();
  24861. if (!item) {
  24862. this.createMessage({
  24863. 'message': __("Sorry, looks like file upload is not supported by your server."),
  24864. 'type': 'error',
  24865. 'is_ephemeral': true
  24866. });
  24867. return;
  24868. }
  24869. const data = item.dataforms.where({
  24870. 'FORM_TYPE': {
  24871. 'value': model_Strophe.NS.HTTPUPLOAD,
  24872. 'type': "hidden"
  24873. }
  24874. }).pop();
  24875. const max_file_size = window.parseInt((_maxFileSize = ((data === null || data === void 0 ? void 0 : data.attributes) || {})['max-file-size']) === null || _maxFileSize === void 0 ? void 0 : _maxFileSize.value);
  24876. const slot_request_url = item === null || item === void 0 ? void 0 : item.id;
  24877. if (!slot_request_url) {
  24878. this.createMessage({
  24879. 'message': __("Sorry, looks like file upload is not supported by your server."),
  24880. 'type': 'error',
  24881. 'is_ephemeral': true
  24882. });
  24883. return;
  24884. }
  24885. Array.from(files).forEach(async file => {
  24886. /**
  24887. * *Hook* which allows plugins to transform files before they'll be
  24888. * uploaded. The main use-case is to encrypt the files.
  24889. * @event _converse#beforeFileUpload
  24890. * @param { _converse.ChatBox | _converse.ChatRoom } chat
  24891. * The chat from which this file will be uploaded.
  24892. * @param { File } file
  24893. * The file that will be uploaded
  24894. */
  24895. file = await core_api.hook('beforeFileUpload', this, file);
  24896. if (!window.isNaN(max_file_size) && window.parseInt(file.size) > max_file_size) {
  24897. return this.createMessage({
  24898. 'message': __('The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.', file.name, filesize_min_default()(max_file_size)),
  24899. 'type': 'error',
  24900. 'is_ephemeral': true
  24901. });
  24902. } else {
  24903. const initial_attrs = await this.getOutgoingMessageAttributes();
  24904. const attrs = Object.assign(initial_attrs, {
  24905. 'file': true,
  24906. 'progress': 0,
  24907. 'slot_request_url': slot_request_url
  24908. });
  24909. this.setEditable(attrs, new Date().toISOString());
  24910. const message = await this.createMessage(attrs, {
  24911. 'silent': true
  24912. });
  24913. message.file = file;
  24914. this.messages.trigger('add', message);
  24915. message.getRequestSlotURL();
  24916. }
  24917. });
  24918. },
  24919. maybeShow(force) {
  24920. if (isUniView()) {
  24921. const filter = c => !c.get('hidden') && c.get('jid') !== this.get('jid') && c.get('id') !== 'controlbox';
  24922. const other_chats = shared_converse.chatboxes.filter(filter);
  24923. if (force || other_chats.length === 0) {
  24924. // We only have one chat visible at any one time.
  24925. // So before opening a chat, we make sure all other chats are hidden.
  24926. other_chats.forEach(c => model_u.safeSave(c, {
  24927. 'hidden': true
  24928. }));
  24929. model_u.safeSave(this, {
  24930. 'hidden': false
  24931. });
  24932. }
  24933. return;
  24934. }
  24935. model_u.safeSave(this, {
  24936. 'hidden': false
  24937. });
  24938. this.trigger('show');
  24939. return this;
  24940. },
  24941. /**
  24942. * Indicates whether the chat is hidden and therefore
  24943. * whether a newly received message will be visible
  24944. * to the user or not.
  24945. * @returns {boolean}
  24946. */
  24947. isHidden() {
  24948. // Note: This methods gets overridden by converse-minimize
  24949. return this.get('hidden') || this.isScrolledUp() || shared_converse.windowState === 'hidden';
  24950. },
  24951. /**
  24952. * Given a newly received {@link _converse.Message} instance,
  24953. * update the unread counter if necessary.
  24954. * @private
  24955. * @method _converse.ChatBox#handleUnreadMessage
  24956. * @param {_converse.Message} message
  24957. */
  24958. handleUnreadMessage(message) {
  24959. if (!(message !== null && message !== void 0 && message.get('body'))) {
  24960. return;
  24961. }
  24962. if (model_u.isNewMessage(message)) {
  24963. if (message.get('sender') === 'me') {
  24964. // We remove the "scrolled" flag so that the chat area
  24965. // gets scrolled down. We always want to scroll down
  24966. // when the user writes a message as opposed to when a
  24967. // message is received.
  24968. this.ui.set('scrolled', false);
  24969. } else if (this.isHidden()) {
  24970. this.incrementUnreadMsgsCounter(message);
  24971. } else {
  24972. this.sendMarkerForMessage(message);
  24973. }
  24974. }
  24975. },
  24976. incrementUnreadMsgsCounter(message) {
  24977. const settings = {
  24978. 'num_unread': this.get('num_unread') + 1
  24979. };
  24980. if (this.get('num_unread') === 0) {
  24981. settings['first_unread_id'] = message.get('id');
  24982. }
  24983. this.save(settings);
  24984. },
  24985. clearUnreadMsgCounter() {
  24986. if (this.get('num_unread') > 0) {
  24987. this.sendMarkerForMessage(this.messages.last());
  24988. }
  24989. model_u.safeSave(this, {
  24990. 'num_unread': 0
  24991. });
  24992. },
  24993. isScrolledUp() {
  24994. return this.ui.get('scrolled');
  24995. }
  24996. });
  24997. /* harmony default export */ const model = (ChatBox);
  24998. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/message.js
  24999. const {
  25000. Strophe: message_Strophe,
  25001. sizzle: message_sizzle,
  25002. u: message_u
  25003. } = core_converse.env;
  25004. /**
  25005. * Mixin which turns a `ModelWithContact` model into a non-MUC message. These can be either `chat` messages or `headline` messages.
  25006. * @mixin
  25007. * @namespace _converse.Message
  25008. * @memberOf _converse
  25009. * @example const msg = new _converse.Message({'message': 'hello world!'});
  25010. */
  25011. const MessageMixin = {
  25012. defaults() {
  25013. return {
  25014. 'msgid': message_u.getUniqueId(),
  25015. 'time': new Date().toISOString(),
  25016. 'is_ephemeral': false
  25017. };
  25018. },
  25019. async initialize() {
  25020. if (!this.checkValidity()) {
  25021. return;
  25022. }
  25023. this.initialized = getOpenPromise();
  25024. if (this.get('file')) {
  25025. this.on('change:put', () => this.uploadFile());
  25026. } // If `type` changes from `error` to `chat`, we want to set the contact. See #2733
  25027. this.on('change:type', () => this.setContact());
  25028. this.on('change:is_ephemeral', () => this.setTimerForEphemeralMessage());
  25029. await this.setContact();
  25030. this.setTimerForEphemeralMessage();
  25031. /**
  25032. * Triggered once a {@link _converse.Message} has been created and initialized.
  25033. * @event _converse#messageInitialized
  25034. * @type { _converse.Message}
  25035. * @example _converse.api.listen.on('messageInitialized', model => { ... });
  25036. */
  25037. await core_api.trigger('messageInitialized', this, {
  25038. 'Synchronous': true
  25039. });
  25040. this.initialized.resolve();
  25041. },
  25042. setContact() {
  25043. if (this.get('type') === 'chat') {
  25044. model_with_contact.prototype.initialize.apply(this, arguments);
  25045. this.setRosterContact(message_Strophe.getBareJidFromJid(this.get('from')));
  25046. }
  25047. },
  25048. /**
  25049. * Sets an auto-destruct timer for this message, if it's is_ephemeral.
  25050. * @private
  25051. * @method _converse.Message#setTimerForEphemeralMessage
  25052. */
  25053. setTimerForEphemeralMessage() {
  25054. if (this.ephemeral_timer) {
  25055. clearTimeout(this.ephemeral_timer);
  25056. }
  25057. const is_ephemeral = this.isEphemeral();
  25058. if (is_ephemeral) {
  25059. const timeout = typeof is_ephemeral === "number" ? is_ephemeral : 10000;
  25060. this.ephemeral_timer = window.setTimeout(() => this.safeDestroy(), timeout);
  25061. }
  25062. },
  25063. checkValidity() {
  25064. if (Object.keys(this.attributes).length === 3) {
  25065. // XXX: This is an empty message with only the 3 default values.
  25066. // This seems to happen when saving a newly created message
  25067. // fails for some reason.
  25068. // TODO: This is likely fixable by setting `wait` when
  25069. // creating messages. See the wait-for-messages branch.
  25070. this.validationError = 'Empty message';
  25071. this.safeDestroy();
  25072. return false;
  25073. }
  25074. return true;
  25075. },
  25076. /**
  25077. * Determines whether this messsage may be retracted by the current user.
  25078. * @private
  25079. * @method _converse.Messages#mayBeRetracted
  25080. * @returns { Boolean }
  25081. */
  25082. mayBeRetracted() {
  25083. const is_own_message = this.get('sender') === 'me';
  25084. const not_canceled = this.get('error_type') !== 'cancel';
  25085. return is_own_message && not_canceled && ['all', 'own'].includes(core_api.settings.get('allow_message_retraction'));
  25086. },
  25087. safeDestroy() {
  25088. try {
  25089. this.destroy();
  25090. } catch (e) {
  25091. headless_log.warn(`safeDestroy: ${e}`);
  25092. }
  25093. },
  25094. /**
  25095. * Returns a boolean indicating whether this message is ephemeral,
  25096. * meaning it will get automatically removed after ten seconds.
  25097. * @returns { boolean }
  25098. */
  25099. isEphemeral() {
  25100. return this.get('is_ephemeral');
  25101. },
  25102. /**
  25103. * Returns a boolean indicating whether this message is a XEP-0245 /me command.
  25104. * @returns { boolean }
  25105. */
  25106. isMeCommand() {
  25107. const text = this.getMessageText();
  25108. if (!text) {
  25109. return false;
  25110. }
  25111. return text.startsWith('/me ');
  25112. },
  25113. /**
  25114. * Returns a boolean indicating whether this message is considered a followup
  25115. * message from the previous one. Followup messages are shown grouped together
  25116. * under one author heading.
  25117. * A message is considered a followup of it's predecessor when it's a chat
  25118. * message from the same author, within 10 minutes.
  25119. * @returns { boolean }
  25120. */
  25121. isFollowup() {
  25122. const messages = this.collection.models;
  25123. const idx = messages.indexOf(this);
  25124. const prev_model = idx ? messages[idx - 1] : null;
  25125. if (prev_model === null) {
  25126. return false;
  25127. }
  25128. const date = dayjs_min_default()(this.get('time'));
  25129. return this.get('from') === prev_model.get('from') && !this.isMeCommand() && !prev_model.isMeCommand() && this.get('type') !== 'info' && prev_model.get('type') !== 'info' && date.isBefore(dayjs_min_default()(prev_model.get('time')).add(10, 'minutes')) && !!this.get('is_encrypted') === !!prev_model.get('is_encrypted');
  25130. },
  25131. getDisplayName() {
  25132. if (this.contact) {
  25133. return this.contact.getDisplayName();
  25134. } else if (this.vcard) {
  25135. return this.vcard.getDisplayName();
  25136. } else {
  25137. return this.get('from');
  25138. }
  25139. },
  25140. getMessageText() {
  25141. if (this.get('is_encrypted')) {
  25142. const {
  25143. __
  25144. } = shared_converse;
  25145. return this.get('plaintext') || this.get('body') || __('Undecryptable OMEMO message');
  25146. } else if (['groupchat', 'chat'].includes(this.get('type'))) {
  25147. return this.get('body');
  25148. } else {
  25149. return this.get('message');
  25150. }
  25151. },
  25152. /**
  25153. * Send out an IQ stanza to request a file upload slot.
  25154. * https://xmpp.org/extensions/xep-0363.html#request
  25155. * @private
  25156. * @method _converse.Message#sendSlotRequestStanza
  25157. */
  25158. sendSlotRequestStanza() {
  25159. if (!this.file) {
  25160. return Promise.reject(new Error('file is undefined'));
  25161. }
  25162. const iq = core_converse.env.$iq({
  25163. 'from': shared_converse.jid,
  25164. 'to': this.get('slot_request_url'),
  25165. 'type': 'get'
  25166. }).c('request', {
  25167. 'xmlns': message_Strophe.NS.HTTPUPLOAD,
  25168. 'filename': this.file.name,
  25169. 'size': this.file.size,
  25170. 'content-type': this.file.type
  25171. });
  25172. return core_api.sendIQ(iq);
  25173. },
  25174. getUploadRequestMetadata(stanza) {
  25175. const headers = message_sizzle(`slot[xmlns="${message_Strophe.NS.HTTPUPLOAD}"] put header`, stanza); // https://xmpp.org/extensions/xep-0363.html#request
  25176. // TODO: Can't set the Cookie header in JavaScipt, instead cookies need
  25177. // to be manually set via document.cookie, so we're leaving it out here.
  25178. return {
  25179. 'headers': headers.map(h => ({
  25180. 'name': h.getAttribute('name'),
  25181. 'value': h.textContent
  25182. })).filter(h => ['Authorization', 'Expires'].includes(h.name))
  25183. };
  25184. },
  25185. async getRequestSlotURL() {
  25186. const {
  25187. __
  25188. } = shared_converse;
  25189. let stanza;
  25190. try {
  25191. stanza = await this.sendSlotRequestStanza();
  25192. } catch (e) {
  25193. headless_log.error(e);
  25194. return this.save({
  25195. 'type': 'error',
  25196. 'message': __('Sorry, could not determine upload URL.'),
  25197. 'is_ephemeral': true
  25198. });
  25199. }
  25200. const slot = message_sizzle(`slot[xmlns="${message_Strophe.NS.HTTPUPLOAD}"]`, stanza).pop();
  25201. if (slot) {
  25202. this.upload_metadata = this.getUploadRequestMetadata(stanza);
  25203. this.save({
  25204. 'get': slot.querySelector('get').getAttribute('url'),
  25205. 'put': slot.querySelector('put').getAttribute('url')
  25206. });
  25207. } else {
  25208. return this.save({
  25209. 'type': 'error',
  25210. 'message': __('Sorry, could not determine file upload URL.'),
  25211. 'is_ephemeral': true
  25212. });
  25213. }
  25214. },
  25215. uploadFile() {
  25216. var _this$upload_metadata;
  25217. const xhr = new XMLHttpRequest();
  25218. xhr.onreadystatechange = async () => {
  25219. if (xhr.readyState === XMLHttpRequest.DONE) {
  25220. headless_log.info('Status: ' + xhr.status);
  25221. if (xhr.status === 200 || xhr.status === 201) {
  25222. let attrs = {
  25223. 'upload': shared_converse.SUCCESS,
  25224. 'oob_url': this.get('get'),
  25225. 'message': this.get('get'),
  25226. 'body': this.get('get')
  25227. };
  25228. /**
  25229. * *Hook* which allows plugins to change the attributes
  25230. * saved on the message once a file has been uploaded.
  25231. * @event _converse#afterFileUploaded
  25232. */
  25233. attrs = await core_api.hook('afterFileUploaded', this, attrs);
  25234. this.save(attrs);
  25235. } else {
  25236. xhr.onerror();
  25237. }
  25238. }
  25239. };
  25240. xhr.upload.addEventListener('progress', evt => {
  25241. if (evt.lengthComputable) {
  25242. this.set('progress', evt.loaded / evt.total);
  25243. }
  25244. }, false);
  25245. xhr.onerror = () => {
  25246. const {
  25247. __
  25248. } = shared_converse;
  25249. let message;
  25250. if (xhr.responseText) {
  25251. message = __('Sorry, could not succesfully upload your file. Your server’s response: "%1$s"', xhr.responseText);
  25252. } else {
  25253. message = __('Sorry, could not succesfully upload your file.');
  25254. }
  25255. this.save({
  25256. 'type': 'error',
  25257. 'upload': shared_converse.FAILURE,
  25258. 'message': message,
  25259. 'is_ephemeral': true
  25260. });
  25261. };
  25262. xhr.open('PUT', this.get('put'), true);
  25263. xhr.setRequestHeader('Content-type', this.file.type);
  25264. (_this$upload_metadata = this.upload_metadata.headers) === null || _this$upload_metadata === void 0 ? void 0 : _this$upload_metadata.forEach(h => xhr.setRequestHeader(h.name, h.value));
  25265. xhr.send(this.file);
  25266. }
  25267. };
  25268. /* harmony default export */ const message = (MessageMixin);
  25269. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/api.js
  25270. /* harmony default export */ const chat_api = ({
  25271. /**
  25272. * The "chats" namespace (used for one-on-one chats)
  25273. *
  25274. * @namespace api.chats
  25275. * @memberOf api
  25276. */
  25277. chats: {
  25278. /**
  25279. * @method api.chats.create
  25280. * @param {string|string[]} jid|jids An jid or array of jids
  25281. * @param {object} [attrs] An object containing configuration attributes.
  25282. */
  25283. async create(jids, attrs) {
  25284. if (typeof jids === 'string') {
  25285. if (attrs && !(attrs !== null && attrs !== void 0 && attrs.fullname)) {
  25286. var _contact$attributes;
  25287. const contact = await core_api.contacts.get(jids);
  25288. attrs.fullname = contact === null || contact === void 0 ? void 0 : (_contact$attributes = contact.attributes) === null || _contact$attributes === void 0 ? void 0 : _contact$attributes.fullname;
  25289. }
  25290. const chatbox = core_api.chats.get(jids, attrs, true);
  25291. if (!chatbox) {
  25292. headless_log.error("Could not open chatbox for JID: " + jids);
  25293. return;
  25294. }
  25295. return chatbox;
  25296. }
  25297. if (Array.isArray(jids)) {
  25298. return Promise.all(jids.forEach(async jid => {
  25299. var _contact$attributes2;
  25300. const contact = await core_api.contacts.get(jids);
  25301. attrs.fullname = contact === null || contact === void 0 ? void 0 : (_contact$attributes2 = contact.attributes) === null || _contact$attributes2 === void 0 ? void 0 : _contact$attributes2.fullname;
  25302. return core_api.chats.get(jid, attrs, true).maybeShow();
  25303. }));
  25304. }
  25305. headless_log.error("chats.create: You need to provide at least one JID");
  25306. return null;
  25307. },
  25308. /**
  25309. * Opens a new one-on-one chat.
  25310. *
  25311. * @method api.chats.open
  25312. * @param {String|string[]} name - e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']
  25313. * @param {Object} [attrs] - Attributes to be set on the _converse.ChatBox model.
  25314. * @param {Boolean} [attrs.minimized] - Should the chat be created in minimized state.
  25315. * @param {Boolean} [force=false] - By default, a minimized
  25316. * chat won't be maximized (in `overlayed` view mode) and in
  25317. * `fullscreen` view mode a newly opened chat won't replace
  25318. * another chat already in the foreground.
  25319. * Set `force` to `true` if you want to force the chat to be
  25320. * maximized or shown.
  25321. * @returns {Promise} Promise which resolves with the
  25322. * _converse.ChatBox representing the chat.
  25323. *
  25324. * @example
  25325. * // To open a single chat, provide the JID of the contact you're chatting with in that chat:
  25326. * converse.plugins.add('myplugin', {
  25327. * initialize: function() {
  25328. * const _converse = this._converse;
  25329. * // Note, buddy@example.org must be in your contacts roster!
  25330. * api.chats.open('buddy@example.com').then(chat => {
  25331. * // Now you can do something with the chat model
  25332. * });
  25333. * }
  25334. * });
  25335. *
  25336. * @example
  25337. * // To open an array of chats, provide an array of JIDs:
  25338. * converse.plugins.add('myplugin', {
  25339. * initialize: function () {
  25340. * const _converse = this._converse;
  25341. * // Note, these users must first be in your contacts roster!
  25342. * api.chats.open(['buddy1@example.com', 'buddy2@example.com']).then(chats => {
  25343. * // Now you can do something with the chat models
  25344. * });
  25345. * }
  25346. * });
  25347. */
  25348. async open(jids, attrs, force) {
  25349. if (typeof jids === 'string') {
  25350. const chat = await core_api.chats.get(jids, attrs, true);
  25351. if (chat) {
  25352. return chat.maybeShow(force);
  25353. }
  25354. return chat;
  25355. } else if (Array.isArray(jids)) {
  25356. return Promise.all(jids.map(j => core_api.chats.get(j, attrs, true).then(c => c && c.maybeShow(force))).filter(c => c));
  25357. }
  25358. const err_msg = "chats.open: You need to provide at least one JID";
  25359. headless_log.error(err_msg);
  25360. throw new Error(err_msg);
  25361. },
  25362. /**
  25363. * Retrieves a chat or all chats.
  25364. *
  25365. * @method api.chats.get
  25366. * @param {String|string[]} jids - e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']
  25367. * @param {Object} [attrs] - Attributes to be set on the _converse.ChatBox model.
  25368. * @param {Boolean} [create=false] - Whether the chat should be created if it's not found.
  25369. * @returns { Promise<_converse.ChatBox> }
  25370. *
  25371. * @example
  25372. * // To return a single chat, provide the JID of the contact you're chatting with in that chat:
  25373. * const model = await api.chats.get('buddy@example.com');
  25374. *
  25375. * @example
  25376. * // To return an array of chats, provide an array of JIDs:
  25377. * const models = await api.chats.get(['buddy1@example.com', 'buddy2@example.com']);
  25378. *
  25379. * @example
  25380. * // To return all open chats, call the method without any parameters::
  25381. * const models = await api.chats.get();
  25382. *
  25383. */
  25384. async get(jids) {
  25385. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  25386. let create = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  25387. await core_api.waitUntil('chatBoxesFetched');
  25388. async function _get(jid) {
  25389. let model = await core_api.chatboxes.get(jid);
  25390. if (!model && create) {
  25391. model = await core_api.chatboxes.create(jid, attrs, shared_converse.ChatBox);
  25392. } else {
  25393. model = model && model.get('type') === shared_converse.PRIVATE_CHAT_TYPE ? model : null;
  25394. if (model && Object.keys(attrs).length) {
  25395. model.save(attrs);
  25396. }
  25397. }
  25398. return model;
  25399. }
  25400. if (jids === undefined) {
  25401. const chats = await core_api.chatboxes.get();
  25402. return chats.filter(c => c.get('type') === shared_converse.PRIVATE_CHAT_TYPE);
  25403. } else if (typeof jids === 'string') {
  25404. return _get(jids);
  25405. }
  25406. return Promise.all(jids.map(jid => _get(jid)));
  25407. }
  25408. }
  25409. });
  25410. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/utils.js
  25411. const {
  25412. Strophe: utils_Strophe,
  25413. sizzle: utils_sizzle,
  25414. u: chat_utils_u
  25415. } = core_converse.env;
  25416. function openChat(jid) {
  25417. if (!chat_utils_u.isValidJID(jid)) {
  25418. return headless_log.warn(`Invalid JID "${jid}" provided in URL fragment`);
  25419. }
  25420. core_api.chats.open(jid);
  25421. }
  25422. async function onClearSession() {
  25423. if (shared_converse.shouldClearCache()) {
  25424. await Promise.all(shared_converse.chatboxes.map(c => c.messages && c.messages.clearStore({
  25425. 'silent': true
  25426. })));
  25427. const filter = o => o.get('type') !== shared_converse.CONTROLBOX_TYPE;
  25428. shared_converse.chatboxes.clearStore({
  25429. 'silent': true
  25430. }, filter);
  25431. }
  25432. }
  25433. async function handleErrorMessage(stanza) {
  25434. const from_jid = utils_Strophe.getBareJidFromJid(stanza.getAttribute('from'));
  25435. if (chat_utils_u.isSameBareJID(from_jid, shared_converse.bare_jid)) {
  25436. return;
  25437. }
  25438. const chatbox = await core_api.chatboxes.get(from_jid);
  25439. if (chatbox.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  25440. chatbox === null || chatbox === void 0 ? void 0 : chatbox.handleErrorMessageStanza(stanza);
  25441. }
  25442. }
  25443. function autoJoinChats() {
  25444. // Automatically join private chats, based on the
  25445. // "auto_join_private_chats" configuration setting.
  25446. core_api.settings.get('auto_join_private_chats').forEach(jid => {
  25447. if (shared_converse.chatboxes.where({
  25448. 'jid': jid
  25449. }).length) {
  25450. return;
  25451. }
  25452. if (typeof jid === 'string') {
  25453. core_api.chats.open(jid);
  25454. } else {
  25455. headless_log.error('Invalid jid criteria specified for "auto_join_private_chats"');
  25456. }
  25457. });
  25458. /**
  25459. * Triggered once any private chats have been automatically joined as
  25460. * specified by the `auto_join_private_chats` setting.
  25461. * See: https://conversejs.org/docs/html/configuration.html#auto-join-private-chats
  25462. * @event _converse#privateChatsAutoJoined
  25463. * @example _converse.api.listen.on('privateChatsAutoJoined', () => { ... });
  25464. * @example _converse.api.waitUntil('privateChatsAutoJoined').then(() => { ... });
  25465. */
  25466. core_api.trigger('privateChatsAutoJoined');
  25467. }
  25468. function registerMessageHandlers() {
  25469. shared_converse.connection.addHandler(stanza => {
  25470. if (utils_sizzle(`message > result[xmlns="${utils_Strophe.NS.MAM}"]`, stanza).pop()) {
  25471. // MAM messages are handled in converse-mam.
  25472. // We shouldn't get MAM messages here because
  25473. // they shouldn't have a `type` attribute.
  25474. headless_log.warn(`Received a MAM message with type "chat".`);
  25475. return true;
  25476. }
  25477. shared_converse.handleMessageStanza(stanza);
  25478. return true;
  25479. }, null, 'message', 'chat');
  25480. shared_converse.connection.addHandler(stanza => {
  25481. // Message receipts are usually without the `type` attribute. See #1353
  25482. if (stanza.getAttribute('type') !== null) {
  25483. // TODO: currently Strophe has no way to register a handler
  25484. // for stanzas without a `type` attribute.
  25485. // We could update it to accept null to mean no attribute,
  25486. // but that would be a backward-incompatible change
  25487. return true; // Gets handled above.
  25488. }
  25489. shared_converse.handleMessageStanza(stanza);
  25490. return true;
  25491. }, utils_Strophe.NS.RECEIPTS, 'message');
  25492. shared_converse.connection.addHandler(stanza => {
  25493. handleErrorMessage(stanza);
  25494. return true;
  25495. }, null, 'message', 'error');
  25496. }
  25497. /**
  25498. * Handler method for all incoming single-user chat "message" stanzas.
  25499. * @private
  25500. * @param { MessageAttributes } attrs - The message attributes
  25501. */
  25502. async function handleMessageStanza(stanza) {
  25503. if (isServerMessage(stanza)) {
  25504. // Prosody sends headline messages with type `chat`, so we need to filter them out here.
  25505. const from = stanza.getAttribute('from');
  25506. return headless_log.info(`handleMessageStanza: Ignoring incoming server message from JID: ${from}`);
  25507. }
  25508. let attrs;
  25509. try {
  25510. attrs = await parseMessage(stanza, shared_converse);
  25511. } catch (e) {
  25512. return headless_log.error(e);
  25513. }
  25514. if (chat_utils_u.isErrorObject(attrs)) {
  25515. attrs.stanza && headless_log.error(attrs.stanza);
  25516. return headless_log.error(attrs.message);
  25517. } // XXX: Need to take XEP-428 <fallback> into consideration
  25518. const has_body = !!(attrs.body || attrs.plaintext);
  25519. const chatbox = await core_api.chats.get(attrs.contact_jid, {
  25520. 'nickname': attrs.nick
  25521. }, has_body);
  25522. await (chatbox === null || chatbox === void 0 ? void 0 : chatbox.queueMessage(attrs));
  25523. /**
  25524. * @typedef { Object } MessageData
  25525. * An object containing the original message stanza, as well as the
  25526. * parsed attributes.
  25527. * @property { XMLElement } stanza
  25528. * @property { MessageAttributes } stanza
  25529. * @property { ChatBox } chatbox
  25530. */
  25531. const data = {
  25532. stanza,
  25533. attrs,
  25534. chatbox
  25535. };
  25536. /**
  25537. * Triggered when a message stanza is been received and processed.
  25538. * @event _converse#message
  25539. * @type { object }
  25540. * @property { module:converse-chat~MessageData } data
  25541. */
  25542. core_api.trigger('message', data);
  25543. }
  25544. ;// CONCATENATED MODULE: ./src/headless/plugins/chat/index.js
  25545. /**
  25546. * @copyright 2022, the Converse.js contributors
  25547. * @license Mozilla Public License (MPLv2)
  25548. */
  25549. core_converse.plugins.add('converse-chat', {
  25550. /* Optional dependencies are other plugins which might be
  25551. * overridden or relied upon, and therefore need to be loaded before
  25552. * this plugin. They are called "optional" because they might not be
  25553. * available, in which case any overrides applicable to them will be
  25554. * ignored.
  25555. *
  25556. * It's possible however to make optional dependencies non-optional.
  25557. * If the setting "strict_plugin_dependencies" is set to true,
  25558. * an error will be raised if the plugin is not found.
  25559. *
  25560. * NB: These plugins need to have already been loaded via require.js.
  25561. */
  25562. dependencies: ['converse-chatboxes', 'converse-disco'],
  25563. initialize() {
  25564. // Configuration values for this plugin
  25565. // ====================================
  25566. // Refer to docs/source/configuration.rst for explanations of these
  25567. // configuration settings.
  25568. core_api.settings.extend({
  25569. 'allow_message_corrections': 'all',
  25570. 'allow_message_retraction': 'all',
  25571. 'allow_message_styling': true,
  25572. 'auto_join_private_chats': [],
  25573. 'clear_messages_on_reconnection': false,
  25574. 'filter_by_resource': false,
  25575. 'prune_messages_above': undefined,
  25576. 'pruning_behavior': 'unscrolled',
  25577. 'send_chat_markers': ["received", "displayed", "acknowledged"],
  25578. 'send_chat_state_notifications': true
  25579. });
  25580. shared_converse.Message = model_with_contact.extend(message);
  25581. shared_converse.Messages = Collection.extend({
  25582. model: shared_converse.Message,
  25583. comparator: 'time'
  25584. });
  25585. Object.assign(shared_converse, {
  25586. ChatBox: model,
  25587. handleMessageStanza: handleMessageStanza
  25588. });
  25589. Object.assign(core_api, chat_api);
  25590. shared_converse.router.route('converse/chat?jid=:jid', openChat);
  25591. core_api.listen.on('chatBoxesFetched', autoJoinChats);
  25592. core_api.listen.on('presencesInitialized', registerMessageHandlers);
  25593. core_api.listen.on('clearSession', onClearSession);
  25594. }
  25595. });
  25596. ;// CONCATENATED MODULE: ./src/headless/plugins/disco/entity.js
  25597. const {
  25598. Strophe: entity_Strophe
  25599. } = core_converse.env;
  25600. /**
  25601. * @class
  25602. * @namespace _converse.DiscoEntity
  25603. * @memberOf _converse
  25604. *
  25605. * A Disco Entity is a JID addressable entity that can be queried for features.
  25606. *
  25607. * See XEP-0030: https://xmpp.org/extensions/xep-0030.html
  25608. */
  25609. const DiscoEntity = Model.extend({
  25610. idAttribute: 'jid',
  25611. async initialize(_, options) {
  25612. this.waitUntilFeaturesDiscovered = getOpenPromise();
  25613. this.dataforms = new Collection();
  25614. let id = `converse.dataforms-${this.get('jid')}`;
  25615. this.dataforms.browserStorage = shared_converse.createStore(id, 'session');
  25616. this.features = new Collection();
  25617. id = `converse.features-${this.get('jid')}`;
  25618. this.features.browserStorage = shared_converse.createStore(id, 'session');
  25619. this.listenTo(this.features, 'add', this.onFeatureAdded);
  25620. this.fields = new Collection();
  25621. id = `converse.fields-${this.get('jid')}`;
  25622. this.fields.browserStorage = shared_converse.createStore(id, 'session');
  25623. this.listenTo(this.fields, 'add', this.onFieldAdded);
  25624. this.items = new shared_converse.DiscoEntities();
  25625. id = `converse.disco-items-${this.get('jid')}`;
  25626. this.items.browserStorage = shared_converse.createStore(id, 'session');
  25627. await new Promise(f => this.items.fetch({
  25628. 'success': f,
  25629. 'error': f
  25630. }));
  25631. this.identities = new Collection();
  25632. id = `converse.identities-${this.get('jid')}`;
  25633. this.identities.browserStorage = shared_converse.createStore(id, 'session');
  25634. this.fetchFeatures(options);
  25635. },
  25636. /**
  25637. * Returns a Promise which resolves with a map indicating
  25638. * whether a given identity is provided by this entity.
  25639. * @private
  25640. * @method _converse.DiscoEntity#getIdentity
  25641. * @param { String } category - The identity category
  25642. * @param { String } type - The identity type
  25643. */
  25644. async getIdentity(category, type) {
  25645. await this.waitUntilFeaturesDiscovered;
  25646. return this.identities.findWhere({
  25647. 'category': category,
  25648. 'type': type
  25649. });
  25650. },
  25651. /**
  25652. * Returns a Promise which resolves with a map indicating
  25653. * whether a given feature is supported.
  25654. * @private
  25655. * @method _converse.DiscoEntity#hasFeature
  25656. * @param { String } feature - The feature that might be supported.
  25657. */
  25658. async hasFeature(feature) {
  25659. await this.waitUntilFeaturesDiscovered;
  25660. if (this.features.findWhere({
  25661. 'var': feature
  25662. })) {
  25663. return this;
  25664. }
  25665. },
  25666. onFeatureAdded(feature) {
  25667. feature.entity = this;
  25668. /**
  25669. * Triggered when Converse has learned of a service provided by the XMPP server.
  25670. * See XEP-0030.
  25671. * @event _converse#serviceDiscovered
  25672. * @type { Model }
  25673. * @example _converse.api.listen.on('featuresDiscovered', feature => { ... });
  25674. */
  25675. core_api.trigger('serviceDiscovered', feature);
  25676. },
  25677. onFieldAdded(field) {
  25678. field.entity = this;
  25679. /**
  25680. * Triggered when Converse has learned of a disco extension field.
  25681. * See XEP-0030.
  25682. * @event _converse#discoExtensionFieldDiscovered
  25683. * @example _converse.api.listen.on('discoExtensionFieldDiscovered', () => { ... });
  25684. */
  25685. core_api.trigger('discoExtensionFieldDiscovered', field);
  25686. },
  25687. async fetchFeatures(options) {
  25688. if (options.ignore_cache) {
  25689. this.queryInfo();
  25690. } else {
  25691. const store_id = this.features.browserStorage.name;
  25692. const result = await this.features.browserStorage.store.getItem(store_id);
  25693. if (result && result.length === 0 || result === null) {
  25694. this.queryInfo();
  25695. } else {
  25696. this.features.fetch({
  25697. add: true,
  25698. success: () => {
  25699. this.waitUntilFeaturesDiscovered.resolve(this);
  25700. this.trigger('featuresDiscovered');
  25701. }
  25702. });
  25703. this.identities.fetch({
  25704. add: true
  25705. });
  25706. }
  25707. }
  25708. },
  25709. async queryInfo() {
  25710. let stanza;
  25711. try {
  25712. stanza = await core_api.disco.info(this.get('jid'), null);
  25713. } catch (iq) {
  25714. iq === null ? headless_log.error(`Timeout for disco#info query for ${this.get('jid')}`) : headless_log.error(iq);
  25715. this.waitUntilFeaturesDiscovered.resolve(this);
  25716. return;
  25717. }
  25718. this.onInfo(stanza);
  25719. },
  25720. onDiscoItems(stanza) {
  25721. sizzle_default()(`query[xmlns="${entity_Strophe.NS.DISCO_ITEMS}"] item`, stanza).forEach(item => {
  25722. if (item.getAttribute("node")) {
  25723. // XXX: Ignore nodes for now.
  25724. // See: https://xmpp.org/extensions/xep-0030.html#items-nodes
  25725. return;
  25726. }
  25727. const jid = item.getAttribute('jid');
  25728. if (this.items.get(jid) === undefined) {
  25729. const entities = shared_converse.disco_entities;
  25730. const entity = entities.get(jid) || entities.create({
  25731. jid,
  25732. name: item.getAttribute('name')
  25733. });
  25734. this.items.add(entity);
  25735. }
  25736. });
  25737. },
  25738. async queryForItems() {
  25739. if (this.identities.where({
  25740. 'category': 'server'
  25741. }).length === 0) {
  25742. // Don't fetch features and items if this is not a
  25743. // server or a conference component.
  25744. return;
  25745. }
  25746. const stanza = await core_api.disco.items(this.get('jid'));
  25747. this.onDiscoItems(stanza);
  25748. },
  25749. onInfo(stanza) {
  25750. Array.from(stanza.querySelectorAll('identity')).forEach(identity => {
  25751. this.identities.create({
  25752. 'category': identity.getAttribute('category'),
  25753. 'type': identity.getAttribute('type'),
  25754. 'name': identity.getAttribute('name')
  25755. });
  25756. });
  25757. sizzle_default()(`x[type="result"][xmlns="${entity_Strophe.NS.XFORM}"]`, stanza).forEach(form => {
  25758. const data = {};
  25759. sizzle_default()('field', form).forEach(field => {
  25760. var _field$querySelector;
  25761. data[field.getAttribute('var')] = {
  25762. 'value': (_field$querySelector = field.querySelector('value')) === null || _field$querySelector === void 0 ? void 0 : _field$querySelector.textContent,
  25763. 'type': field.getAttribute('type')
  25764. };
  25765. });
  25766. this.dataforms.create(data);
  25767. });
  25768. if (stanza.querySelector(`feature[var="${entity_Strophe.NS.DISCO_ITEMS}"]`)) {
  25769. this.queryForItems();
  25770. }
  25771. Array.from(stanza.querySelectorAll('feature')).forEach(feature => {
  25772. this.features.create({
  25773. 'var': feature.getAttribute('var'),
  25774. 'from': stanza.getAttribute('from')
  25775. });
  25776. }); // XEP-0128 Service Discovery Extensions
  25777. sizzle_default()('x[type="result"][xmlns="jabber:x:data"] field', stanza).forEach(field => {
  25778. var _field$querySelector2;
  25779. this.fields.create({
  25780. 'var': field.getAttribute('var'),
  25781. 'value': (_field$querySelector2 = field.querySelector('value')) === null || _field$querySelector2 === void 0 ? void 0 : _field$querySelector2.textContent,
  25782. 'from': stanza.getAttribute('from')
  25783. });
  25784. });
  25785. this.waitUntilFeaturesDiscovered.resolve(this);
  25786. this.trigger('featuresDiscovered');
  25787. }
  25788. });
  25789. /* harmony default export */ const entity = (DiscoEntity);
  25790. ;// CONCATENATED MODULE: ./src/headless/plugins/disco/entities.js
  25791. const DiscoEntities = Collection.extend({
  25792. model: entity,
  25793. fetchEntities() {
  25794. return new Promise((resolve, reject) => {
  25795. this.fetch({
  25796. add: true,
  25797. success: resolve,
  25798. error(_m, e) {
  25799. headless_log.error(e);
  25800. reject(new Error("Could not fetch disco entities"));
  25801. }
  25802. });
  25803. });
  25804. }
  25805. });
  25806. /* harmony default export */ const entities = (DiscoEntities);
  25807. ;// CONCATENATED MODULE: ./src/headless/plugins/disco/utils.js
  25808. const {
  25809. Strophe: disco_utils_Strophe,
  25810. $iq: utils_$iq
  25811. } = core_converse.env;
  25812. function onDiscoInfoRequest(stanza) {
  25813. const node = stanza.getElementsByTagName('query')[0].getAttribute('node');
  25814. const attrs = {
  25815. xmlns: disco_utils_Strophe.NS.DISCO_INFO
  25816. };
  25817. if (node) {
  25818. attrs.node = node;
  25819. }
  25820. const iqresult = utils_$iq({
  25821. 'type': 'result',
  25822. 'id': stanza.getAttribute('id')
  25823. });
  25824. const from = stanza.getAttribute('from');
  25825. if (from !== null) {
  25826. iqresult.attrs({
  25827. 'to': from
  25828. });
  25829. }
  25830. iqresult.c('query', attrs);
  25831. shared_converse.disco._identities.forEach(identity => {
  25832. const attrs = {
  25833. 'category': identity.category,
  25834. 'type': identity.type
  25835. };
  25836. if (identity.name) {
  25837. attrs.name = identity.name;
  25838. }
  25839. if (identity.lang) {
  25840. attrs['xml:lang'] = identity.lang;
  25841. }
  25842. iqresult.c('identity', attrs).up();
  25843. });
  25844. shared_converse.disco._features.forEach(f => iqresult.c('feature', {
  25845. 'var': f
  25846. }).up());
  25847. core_api.send(iqresult.tree());
  25848. return true;
  25849. }
  25850. function addClientFeatures() {
  25851. // See https://xmpp.org/registrar/disco-categories.html
  25852. core_api.disco.own.identities.add('client', 'web', 'Converse');
  25853. core_api.disco.own.features.add(disco_utils_Strophe.NS.CHATSTATES);
  25854. core_api.disco.own.features.add(disco_utils_Strophe.NS.DISCO_INFO);
  25855. core_api.disco.own.features.add(disco_utils_Strophe.NS.ROSTERX); // Limited support
  25856. if (core_api.settings.get("message_carbons")) {
  25857. core_api.disco.own.features.add(disco_utils_Strophe.NS.CARBONS);
  25858. }
  25859. /**
  25860. * Triggered in converse-disco once the core disco features of
  25861. * Converse have been added.
  25862. * @event _converse#addClientFeatures
  25863. * @example _converse.api.listen.on('addClientFeatures', () => { ... });
  25864. */
  25865. core_api.trigger('addClientFeatures');
  25866. return this;
  25867. }
  25868. async function initializeDisco() {
  25869. addClientFeatures();
  25870. shared_converse.connection.addHandler(stanza => onDiscoInfoRequest(stanza), disco_utils_Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
  25871. shared_converse.disco_entities = new shared_converse.DiscoEntities();
  25872. const id = `converse.disco-entities-${shared_converse.bare_jid}`;
  25873. shared_converse.disco_entities.browserStorage = shared_converse.createStore(id, 'session');
  25874. const collection = await shared_converse.disco_entities.fetchEntities();
  25875. if (collection.length === 0 || !collection.get(shared_converse.domain)) {
  25876. // If we don't have an entity for our own XMPP server, create one.
  25877. shared_converse.disco_entities.create({
  25878. 'jid': shared_converse.domain
  25879. });
  25880. }
  25881. /**
  25882. * Triggered once the `converse-disco` plugin has been initialized and the
  25883. * `_converse.disco_entities` collection will be available and populated with at
  25884. * least the service discovery features of the user's own server.
  25885. * @event _converse#discoInitialized
  25886. * @example _converse.api.listen.on('discoInitialized', () => { ... });
  25887. */
  25888. core_api.trigger('discoInitialized');
  25889. }
  25890. function initStreamFeatures() {
  25891. // Initialize the stream_features collection, and if we're
  25892. // re-attaching to a pre-existing BOSH session, we restore the
  25893. // features from cache.
  25894. // Otherwise the features will be created once we've received them
  25895. // from the server (see populateStreamFeatures).
  25896. if (!shared_converse.stream_features) {
  25897. const bare_jid = disco_utils_Strophe.getBareJidFromJid(shared_converse.jid);
  25898. const id = `converse.stream-features-${bare_jid}`;
  25899. core_api.promises.add('streamFeaturesAdded');
  25900. shared_converse.stream_features = new Collection();
  25901. shared_converse.stream_features.browserStorage = shared_converse.createStore(id, "session");
  25902. }
  25903. }
  25904. function notifyStreamFeaturesAdded() {
  25905. /**
  25906. * Triggered as soon as the stream features are known.
  25907. * If you want to check whether a stream feature is supported before proceeding,
  25908. * then you'll first want to wait for this event.
  25909. * @event _converse#streamFeaturesAdded
  25910. * @example _converse.api.listen.on('streamFeaturesAdded', () => { ... });
  25911. */
  25912. core_api.trigger('streamFeaturesAdded');
  25913. }
  25914. function populateStreamFeatures() {
  25915. // Strophe.js sets the <stream:features> element on the
  25916. // Strophe.Connection instance (_converse.connection).
  25917. //
  25918. // Once this is we populate the _converse.stream_features collection
  25919. // and trigger streamFeaturesAdded.
  25920. initStreamFeatures();
  25921. Array.from(shared_converse.connection.features.childNodes).forEach(feature => {
  25922. shared_converse.stream_features.create({
  25923. 'name': feature.nodeName,
  25924. 'xmlns': feature.getAttribute('xmlns')
  25925. });
  25926. });
  25927. notifyStreamFeaturesAdded();
  25928. }
  25929. function utils_clearSession() {
  25930. var _converse$disco_entit, _converse$disco_entit2, _converse$disco_entit3, _converse$disco_entit4, _converse$disco_entit5;
  25931. (_converse$disco_entit = shared_converse.disco_entities) === null || _converse$disco_entit === void 0 ? void 0 : _converse$disco_entit.forEach(e => e.features.clearStore());
  25932. (_converse$disco_entit2 = shared_converse.disco_entities) === null || _converse$disco_entit2 === void 0 ? void 0 : _converse$disco_entit2.forEach(e => e.identities.clearStore());
  25933. (_converse$disco_entit3 = shared_converse.disco_entities) === null || _converse$disco_entit3 === void 0 ? void 0 : _converse$disco_entit3.forEach(e => e.dataforms.clearStore());
  25934. (_converse$disco_entit4 = shared_converse.disco_entities) === null || _converse$disco_entit4 === void 0 ? void 0 : _converse$disco_entit4.forEach(e => e.fields.clearStore());
  25935. (_converse$disco_entit5 = shared_converse.disco_entities) === null || _converse$disco_entit5 === void 0 ? void 0 : _converse$disco_entit5.clearStore();
  25936. delete shared_converse.disco_entities;
  25937. }
  25938. ;// CONCATENATED MODULE: ./src/headless/plugins/disco/api.js
  25939. const {
  25940. Strophe: api_Strophe,
  25941. $iq: api_$iq
  25942. } = core_converse.env;
  25943. /* harmony default export */ const disco_api = ({
  25944. /**
  25945. * The XEP-0030 service discovery API
  25946. *
  25947. * This API lets you discover information about entities on the
  25948. * XMPP network.
  25949. *
  25950. * @namespace api.disco
  25951. * @memberOf api
  25952. */
  25953. disco: {
  25954. /**
  25955. * @namespace api.disco.stream
  25956. * @memberOf api.disco
  25957. */
  25958. stream: {
  25959. /**
  25960. * @method api.disco.stream.getFeature
  25961. * @param {String} name The feature name
  25962. * @param {String} xmlns The XML namespace
  25963. * @example _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver')
  25964. */
  25965. async getFeature(name, xmlns) {
  25966. await core_api.waitUntil('streamFeaturesAdded');
  25967. if (!name || !xmlns) {
  25968. throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature");
  25969. }
  25970. if (shared_converse.stream_features === undefined && !core_api.connection.connected()) {
  25971. // Happens during tests when disco lookups happen asynchronously after teardown.
  25972. const msg = `Tried to get feature ${name} ${xmlns} but _converse.stream_features has been torn down`;
  25973. headless_log.warn(msg);
  25974. return;
  25975. }
  25976. return shared_converse.stream_features.findWhere({
  25977. 'name': name,
  25978. 'xmlns': xmlns
  25979. });
  25980. }
  25981. },
  25982. /**
  25983. * @namespace api.disco.own
  25984. * @memberOf api.disco
  25985. */
  25986. own: {
  25987. /**
  25988. * @namespace api.disco.own.identities
  25989. * @memberOf api.disco.own
  25990. */
  25991. identities: {
  25992. /**
  25993. * Lets you add new identities for this client (i.e. instance of Converse)
  25994. * @method api.disco.own.identities.add
  25995. *
  25996. * @param {String} category - server, client, gateway, directory, etc.
  25997. * @param {String} type - phone, pc, web, etc.
  25998. * @param {String} name - "Converse"
  25999. * @param {String} lang - en, el, de, etc.
  26000. *
  26001. * @example _converse.api.disco.own.identities.clear();
  26002. */
  26003. add(category, type, name, lang) {
  26004. for (var i = 0; i < shared_converse.disco._identities.length; i++) {
  26005. if (shared_converse.disco._identities[i].category == category && shared_converse.disco._identities[i].type == type && shared_converse.disco._identities[i].name == name && shared_converse.disco._identities[i].lang == lang) {
  26006. return false;
  26007. }
  26008. }
  26009. shared_converse.disco._identities.push({
  26010. category: category,
  26011. type: type,
  26012. name: name,
  26013. lang: lang
  26014. });
  26015. },
  26016. /**
  26017. * Clears all previously registered identities.
  26018. * @method api.disco.own.identities.clear
  26019. * @example _converse.api.disco.own.identities.clear();
  26020. */
  26021. clear() {
  26022. shared_converse.disco._identities = [];
  26023. },
  26024. /**
  26025. * Returns all of the identities registered for this client
  26026. * (i.e. instance of Converse).
  26027. * @method api.disco.identities.get
  26028. * @example const identities = api.disco.own.identities.get();
  26029. */
  26030. get() {
  26031. return shared_converse.disco._identities;
  26032. }
  26033. },
  26034. /**
  26035. * @namespace api.disco.own.features
  26036. * @memberOf api.disco.own
  26037. */
  26038. features: {
  26039. /**
  26040. * Lets you register new disco features for this client (i.e. instance of Converse)
  26041. * @method api.disco.own.features.add
  26042. * @param {String} name - e.g. http://jabber.org/protocol/caps
  26043. * @example _converse.api.disco.own.features.add("http://jabber.org/protocol/caps");
  26044. */
  26045. add(name) {
  26046. for (var i = 0; i < shared_converse.disco._features.length; i++) {
  26047. if (shared_converse.disco._features[i] == name) {
  26048. return false;
  26049. }
  26050. }
  26051. shared_converse.disco._features.push(name);
  26052. },
  26053. /**
  26054. * Clears all previously registered features.
  26055. * @method api.disco.own.features.clear
  26056. * @example _converse.api.disco.own.features.clear();
  26057. */
  26058. clear() {
  26059. shared_converse.disco._features = [];
  26060. },
  26061. /**
  26062. * Returns all of the features registered for this client (i.e. instance of Converse).
  26063. * @method api.disco.own.features.get
  26064. * @example const features = api.disco.own.features.get();
  26065. */
  26066. get() {
  26067. return shared_converse.disco._features;
  26068. }
  26069. }
  26070. },
  26071. /**
  26072. * Query for information about an XMPP entity
  26073. *
  26074. * @method api.disco.info
  26075. * @param {string} jid The Jabber ID of the entity to query
  26076. * @param {string} [node] A specific node identifier associated with the JID
  26077. * @returns {promise} Promise which resolves once we have a result from the server.
  26078. */
  26079. info(jid, node) {
  26080. const attrs = {
  26081. xmlns: api_Strophe.NS.DISCO_INFO
  26082. };
  26083. if (node) {
  26084. attrs.node = node;
  26085. }
  26086. const info = api_$iq({
  26087. 'from': shared_converse.connection.jid,
  26088. 'to': jid,
  26089. 'type': 'get'
  26090. }).c('query', attrs);
  26091. return core_api.sendIQ(info);
  26092. },
  26093. /**
  26094. * Query for items associated with an XMPP entity
  26095. *
  26096. * @method api.disco.items
  26097. * @param {string} jid The Jabber ID of the entity to query for items
  26098. * @param {string} [node] A specific node identifier associated with the JID
  26099. * @returns {promise} Promise which resolves once we have a result from the server.
  26100. */
  26101. items(jid, node) {
  26102. const attrs = {
  26103. 'xmlns': api_Strophe.NS.DISCO_ITEMS
  26104. };
  26105. if (node) {
  26106. attrs.node = node;
  26107. }
  26108. return core_api.sendIQ(api_$iq({
  26109. 'from': shared_converse.connection.jid,
  26110. 'to': jid,
  26111. 'type': 'get'
  26112. }).c('query', attrs));
  26113. },
  26114. /**
  26115. * Namespace for methods associated with disco entities
  26116. *
  26117. * @namespace api.disco.entities
  26118. * @memberOf api.disco
  26119. */
  26120. entities: {
  26121. /**
  26122. * Get the corresponding `DiscoEntity` instance.
  26123. *
  26124. * @method api.disco.entities.get
  26125. * @param {string} jid The Jabber ID of the entity
  26126. * @param {boolean} [create] Whether the entity should be created if it doesn't exist.
  26127. * @example _converse.api.disco.entities.get(jid);
  26128. */
  26129. async get(jid) {
  26130. let create = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  26131. await core_api.waitUntil('discoInitialized');
  26132. if (!jid) {
  26133. return shared_converse.disco_entities;
  26134. }
  26135. if (shared_converse.disco_entities === undefined) {
  26136. // Happens during tests when disco lookups happen asynchronously after teardown.
  26137. const msg = `Tried to look up entity ${jid} but _converse.disco_entities has been torn down`;
  26138. headless_log.warn(msg);
  26139. return;
  26140. }
  26141. const entity = shared_converse.disco_entities.get(jid);
  26142. if (entity || !create) {
  26143. return entity;
  26144. }
  26145. return core_api.disco.entities.create(jid);
  26146. },
  26147. /**
  26148. * Create a new disco entity. It's identity and features
  26149. * will automatically be fetched from cache or from the
  26150. * XMPP server.
  26151. *
  26152. * Fetching from cache can be disabled by passing in
  26153. * `ignore_cache: true` in the options parameter.
  26154. *
  26155. * @method api.disco.entities.create
  26156. * @param {string} jid The Jabber ID of the entity
  26157. * @param {object} [options] Additional options
  26158. * @param {boolean} [options.ignore_cache]
  26159. * If true, fetch all features from the XMPP server instead of restoring them from cache
  26160. * @example _converse.api.disco.entities.create(jid, {'ignore_cache': true});
  26161. */
  26162. create(jid, options) {
  26163. return shared_converse.disco_entities.create({
  26164. 'jid': jid
  26165. }, options);
  26166. }
  26167. },
  26168. /**
  26169. * @namespace api.disco.features
  26170. * @memberOf api.disco
  26171. */
  26172. features: {
  26173. /**
  26174. * Return a given feature of a disco entity
  26175. *
  26176. * @method api.disco.features.get
  26177. * @param {string} feature The feature that might be
  26178. * supported. In the XML stanza, this is the `var`
  26179. * attribute of the `<feature>` element. For
  26180. * example: `http://jabber.org/protocol/muc`
  26181. * @param {string} jid The JID of the entity
  26182. * (and its associated items) which should be queried
  26183. * @returns {promise} A promise which resolves with a list containing
  26184. * _converse.Entity instances representing the entity
  26185. * itself or those items associated with the entity if
  26186. * they support the given feature.
  26187. * @example
  26188. * api.disco.features.get(Strophe.NS.MAM, _converse.bare_jid);
  26189. */
  26190. async get(feature, jid) {
  26191. if (!jid) {
  26192. throw new TypeError('You need to provide an entity JID');
  26193. }
  26194. await core_api.waitUntil('discoInitialized');
  26195. let entity = await core_api.disco.entities.get(jid, true);
  26196. if (shared_converse.disco_entities === undefined && !core_api.connection.connected()) {
  26197. // Happens during tests when disco lookups happen asynchronously after teardown.
  26198. const msg = `Tried to get feature ${feature} for ${jid} but _converse.disco_entities has been torn down`;
  26199. headless_log.warn(msg);
  26200. return;
  26201. }
  26202. entity = await entity.waitUntilFeaturesDiscovered;
  26203. const promises = [...entity.items.map(i => i.hasFeature(feature)), entity.hasFeature(feature)];
  26204. const result = await Promise.all(promises);
  26205. return result.filter(lodash_es_isObject);
  26206. }
  26207. },
  26208. /**
  26209. * Used to determine whether an entity supports a given feature.
  26210. *
  26211. * @method api.disco.supports
  26212. * @param {string} feature The feature that might be
  26213. * supported. In the XML stanza, this is the `var`
  26214. * attribute of the `<feature>` element. For
  26215. * example: `http://jabber.org/protocol/muc`
  26216. * @param {string} jid The JID of the entity
  26217. * (and its associated items) which should be queried
  26218. * @returns {promise} A promise which resolves with `true` or `false`.
  26219. * @example
  26220. * if (await api.disco.supports(Strophe.NS.MAM, _converse.bare_jid)) {
  26221. * // The feature is supported
  26222. * } else {
  26223. * // The feature is not supported
  26224. * }
  26225. */
  26226. async supports(feature, jid) {
  26227. const features = (await core_api.disco.features.get(feature, jid)) || [];
  26228. return features.length > 0;
  26229. },
  26230. /**
  26231. * Refresh the features, fields and identities associated with a
  26232. * disco entity by refetching them from the server
  26233. * @method api.disco.refresh
  26234. * @param {string} jid The JID of the entity whose features are refreshed.
  26235. * @returns {promise} A promise which resolves once the features have been refreshed
  26236. * @example
  26237. * await api.disco.refresh('room@conference.example.org');
  26238. */
  26239. async refresh(jid) {
  26240. if (!jid) {
  26241. throw new TypeError('api.disco.refresh: You need to provide an entity JID');
  26242. }
  26243. await core_api.waitUntil('discoInitialized');
  26244. let entity = await core_api.disco.entities.get(jid);
  26245. if (entity) {
  26246. entity.features.reset();
  26247. entity.fields.reset();
  26248. entity.identities.reset();
  26249. if (!entity.waitUntilFeaturesDiscovered.isPending) {
  26250. entity.waitUntilFeaturesDiscovered = getOpenPromise();
  26251. }
  26252. entity.queryInfo();
  26253. } else {
  26254. // Create it if it doesn't exist
  26255. entity = await core_api.disco.entities.create(jid, {
  26256. 'ignore_cache': true
  26257. });
  26258. }
  26259. return entity.waitUntilFeaturesDiscovered;
  26260. },
  26261. /**
  26262. * @deprecated Use {@link api.disco.refresh} instead.
  26263. * @method api.disco.refreshFeatures
  26264. */
  26265. refreshFeatures(jid) {
  26266. return core_api.refresh(jid);
  26267. },
  26268. /**
  26269. * Return all the features associated with a disco entity
  26270. *
  26271. * @method api.disco.getFeatures
  26272. * @param {string} jid The JID of the entity whose features are returned.
  26273. * @returns {promise} A promise which resolves with the returned features
  26274. * @example
  26275. * const features = await api.disco.getFeatures('room@conference.example.org');
  26276. */
  26277. async getFeatures(jid) {
  26278. if (!jid) {
  26279. throw new TypeError('api.disco.getFeatures: You need to provide an entity JID');
  26280. }
  26281. await core_api.waitUntil('discoInitialized');
  26282. let entity = await core_api.disco.entities.get(jid, true);
  26283. entity = await entity.waitUntilFeaturesDiscovered;
  26284. return entity.features;
  26285. },
  26286. /**
  26287. * Return all the service discovery extensions fields
  26288. * associated with an entity.
  26289. *
  26290. * See [XEP-0129: Service Discovery Extensions](https://xmpp.org/extensions/xep-0128.html)
  26291. *
  26292. * @method api.disco.getFields
  26293. * @param {string} jid The JID of the entity whose fields are returned.
  26294. * @example
  26295. * const fields = await api.disco.getFields('room@conference.example.org');
  26296. */
  26297. async getFields(jid) {
  26298. if (!jid) {
  26299. throw new TypeError('api.disco.getFields: You need to provide an entity JID');
  26300. }
  26301. await core_api.waitUntil('discoInitialized');
  26302. let entity = await core_api.disco.entities.get(jid, true);
  26303. entity = await entity.waitUntilFeaturesDiscovered;
  26304. return entity.fields;
  26305. },
  26306. /**
  26307. * Get the identity (with the given category and type) for a given disco entity.
  26308. *
  26309. * For example, when determining support for PEP (personal eventing protocol), you
  26310. * want to know whether the user's own JID has an identity with
  26311. * `category='pubsub'` and `type='pep'` as explained in this section of
  26312. * XEP-0163: https://xmpp.org/extensions/xep-0163.html#support
  26313. *
  26314. * @method api.disco.getIdentity
  26315. * @param {string} The identity category.
  26316. * In the XML stanza, this is the `category`
  26317. * attribute of the `<identity>` element.
  26318. * For example: 'pubsub'
  26319. * @param {string} type The identity type.
  26320. * In the XML stanza, this is the `type`
  26321. * attribute of the `<identity>` element.
  26322. * For example: 'pep'
  26323. * @param {string} jid The JID of the entity which might have the identity
  26324. * @returns {promise} A promise which resolves with a map indicating
  26325. * whether an identity with a given type is provided by the entity.
  26326. * @example
  26327. * api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid).then(
  26328. * function (identity) {
  26329. * if (identity) {
  26330. * // The entity DOES have this identity
  26331. * } else {
  26332. * // The entity DOES NOT have this identity
  26333. * }
  26334. * }
  26335. * ).catch(e => log.error(e));
  26336. */
  26337. async getIdentity(category, type, jid) {
  26338. const e = await core_api.disco.entities.get(jid, true);
  26339. if (e === undefined && !core_api.connection.connected()) {
  26340. // Happens during tests when disco lookups happen asynchronously after teardown.
  26341. const msg = `Tried to look up category ${category} for ${jid} but _converse.disco_entities has been torn down`;
  26342. headless_log.warn(msg);
  26343. return;
  26344. }
  26345. return e.getIdentity(category, type);
  26346. }
  26347. }
  26348. });
  26349. ;// CONCATENATED MODULE: ./src/headless/plugins/disco/index.js
  26350. /**
  26351. * @copyright The Converse.js contributors
  26352. * @license Mozilla Public License (MPLv2)
  26353. * @description Converse plugin which add support for XEP-0030: Service Discovery
  26354. */
  26355. const {
  26356. Strophe: disco_Strophe
  26357. } = core_converse.env;
  26358. core_converse.plugins.add('converse-disco', {
  26359. initialize() {
  26360. Object.assign(core_api, disco_api);
  26361. core_api.promises.add('discoInitialized');
  26362. core_api.promises.add('streamFeaturesAdded');
  26363. shared_converse.DiscoEntity = entity;
  26364. shared_converse.DiscoEntities = entities;
  26365. shared_converse.disco = {
  26366. _identities: [],
  26367. _features: []
  26368. };
  26369. core_api.listen.on('userSessionInitialized', async () => {
  26370. initStreamFeatures();
  26371. if (shared_converse.connfeedback.get('connection_status') === disco_Strophe.Status.ATTACHED) {
  26372. // When re-attaching to a BOSH session, we fetch the stream features from the cache.
  26373. await new Promise((success, error) => shared_converse.stream_features.fetch({
  26374. success,
  26375. error
  26376. }));
  26377. notifyStreamFeaturesAdded();
  26378. }
  26379. });
  26380. core_api.listen.on('beforeResourceBinding', populateStreamFeatures);
  26381. core_api.listen.on('reconnected', initializeDisco);
  26382. core_api.listen.on('connected', initializeDisco);
  26383. core_api.listen.on('beforeTearDown', async () => {
  26384. core_api.promises.add('streamFeaturesAdded');
  26385. if (shared_converse.stream_features) {
  26386. await shared_converse.stream_features.clearStore();
  26387. delete shared_converse.stream_features;
  26388. }
  26389. }); // All disco entities stored in sessionStorage and are refetched
  26390. // upon login or reconnection and then stored with new ids, so to
  26391. // avoid sessionStorage filling up, we remove them.
  26392. core_api.listen.on('will-reconnect', utils_clearSession);
  26393. core_api.listen.on('clearSession', utils_clearSession);
  26394. }
  26395. });
  26396. ;// CONCATENATED MODULE: ./src/headless/plugins/emoji/index.js
  26397. /**
  26398. * @module converse-emoji
  26399. * @copyright 2022, the Converse.js contributors
  26400. * @license Mozilla Public License (MPLv2)
  26401. */
  26402. core_converse.emojis = {
  26403. 'initialized': false,
  26404. 'initialized_promise': getOpenPromise()
  26405. };
  26406. core_converse.plugins.add('converse-emoji', {
  26407. initialize() {
  26408. /* The initialize function gets called as soon as the plugin is
  26409. * loaded by converse.js's plugin machinery.
  26410. */
  26411. const {
  26412. ___
  26413. } = shared_converse;
  26414. core_api.settings.extend({
  26415. 'emoji_image_path': 'https://twemoji.maxcdn.com/v/12.1.6/',
  26416. 'emoji_categories': {
  26417. "smileys": ":grinning:",
  26418. "people": ":thumbsup:",
  26419. "activity": ":soccer:",
  26420. "travel": ":motorcycle:",
  26421. "objects": ":bomb:",
  26422. "nature": ":rainbow:",
  26423. "food": ":hotdog:",
  26424. "symbols": ":musical_note:",
  26425. "flags": ":flag_ac:",
  26426. "custom": null
  26427. },
  26428. // We use the triple-underscore method which doesn't actually
  26429. // translate but does signify to gettext that these strings should
  26430. // go into the POT file. The translation then happens in the
  26431. // template. We do this so that users can pass in their own
  26432. // strings via converse.initialize, which is before __ is
  26433. // available.
  26434. 'emoji_category_labels': {
  26435. "smileys": ___("Smileys and emotions"),
  26436. "people": ___("People"),
  26437. "activity": ___("Activities"),
  26438. "travel": ___("Travel"),
  26439. "objects": ___("Objects"),
  26440. "nature": ___("Animals and nature"),
  26441. "food": ___("Food and drink"),
  26442. "symbols": ___("Symbols"),
  26443. "flags": ___("Flags"),
  26444. "custom": ___("Stickers")
  26445. }
  26446. });
  26447. /**
  26448. * Model for storing data related to the Emoji picker widget
  26449. * @class
  26450. * @namespace _converse.EmojiPicker
  26451. * @memberOf _converse
  26452. */
  26453. shared_converse.EmojiPicker = Model.extend({
  26454. defaults: {
  26455. 'current_category': 'smileys',
  26456. 'current_skintone': '',
  26457. 'scroll_position': 0
  26458. }
  26459. }); // We extend the default converse.js API to add methods specific to MUC groupchats.
  26460. Object.assign(core_api, {
  26461. /**
  26462. * @namespace api.emojis
  26463. * @memberOf api
  26464. */
  26465. emojis: {
  26466. /**
  26467. * Initializes Emoji support by downloading the emojis JSON (and any applicable images).
  26468. * @method api.emojis.initialize
  26469. * @returns {Promise}
  26470. */
  26471. async initialize() {
  26472. if (!core_converse.emojis.initialized) {
  26473. core_converse.emojis.initialized = true;
  26474. const {
  26475. default: json
  26476. } = await __webpack_require__.e(/* import() | emojis */ 4610).then(__webpack_require__.t.bind(__webpack_require__, 5175, 19));
  26477. core_converse.emojis.json = json;
  26478. core_converse.emojis.by_sn = Object.keys(json).reduce((result, cat) => Object.assign(result, json[cat]), {});
  26479. core_converse.emojis.list = Object.values(core_converse.emojis.by_sn);
  26480. core_converse.emojis.list.sort((a, b) => a.sn < b.sn ? -1 : a.sn > b.sn ? 1 : 0);
  26481. core_converse.emojis.shortnames = core_converse.emojis.list.map(m => m.sn);
  26482. const getShortNames = () => core_converse.emojis.shortnames.map(s => s.replace(/[+]/g, "\\$&")).join('|');
  26483. core_converse.emojis.shortnames_regex = new RegExp(getShortNames(), "gi");
  26484. core_converse.emojis.initialized_promise.resolve();
  26485. }
  26486. return core_converse.emojis.initialized_promise;
  26487. }
  26488. }
  26489. });
  26490. }
  26491. });
  26492. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/message.js
  26493. /**
  26494. * Mixing that turns a Message model into a ChatRoomMessage model.
  26495. * @class
  26496. * @namespace _converse.ChatRoomMessage
  26497. * @memberOf _converse
  26498. */
  26499. const ChatRoomMessageMixin = {
  26500. initialize() {
  26501. if (!this.checkValidity()) {
  26502. return;
  26503. }
  26504. if (this.get('file')) {
  26505. this.on('change:put', () => this.uploadFile());
  26506. } // If `type` changes from `error` to `groupchat`, we want to set the occupant. See #2733
  26507. this.on('change:type', () => this.setOccupant());
  26508. this.on('change:is_ephemeral', () => this.setTimerForEphemeralMessage());
  26509. this.setTimerForEphemeralMessage();
  26510. this.setOccupant();
  26511. /**
  26512. * Triggered once a { @link _converse.ChatRoomMessage } has been created and initialized.
  26513. * @event _converse#chatRoomMessageInitialized
  26514. * @type { _converse.ChatRoomMessages}
  26515. * @example _converse.api.listen.on('chatRoomMessageInitialized', model => { ... });
  26516. */
  26517. core_api.trigger('chatRoomMessageInitialized', this);
  26518. },
  26519. getDisplayName() {
  26520. var _this$occupant;
  26521. return ((_this$occupant = this.occupant) === null || _this$occupant === void 0 ? void 0 : _this$occupant.getDisplayName()) || this.get('nick');
  26522. },
  26523. /**
  26524. * Determines whether this messsage may be moderated,
  26525. * based on configuration settings and server support.
  26526. * @async
  26527. * @private
  26528. * @method _converse.ChatRoomMessages#mayBeModerated
  26529. * @returns { Boolean }
  26530. */
  26531. mayBeModerated() {
  26532. if (typeof this.get('from_muc') === 'undefined') {
  26533. // If from_muc is not defined, then this message hasn't been
  26534. // reflected yet, which means we won't have a XEP-0359 stanza id.
  26535. return;
  26536. }
  26537. return ['all', 'moderator'].includes(core_api.settings.get('allow_message_retraction')) && this.get(`stanza_id ${this.get('from_muc')}`) && this.collection.chatbox.canModerateMessages();
  26538. },
  26539. checkValidity() {
  26540. const result = shared_converse.Message.prototype.checkValidity.call(this);
  26541. !result && this.collection.chatbox.debouncedRejoin();
  26542. return result;
  26543. },
  26544. onOccupantRemoved() {
  26545. var _this$collection;
  26546. this.stopListening(this.occupant);
  26547. delete this.occupant;
  26548. const chatbox = this === null || this === void 0 ? void 0 : (_this$collection = this.collection) === null || _this$collection === void 0 ? void 0 : _this$collection.chatbox;
  26549. if (!chatbox) {
  26550. return headless_log.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);
  26551. }
  26552. this.listenTo(chatbox.occupants, 'add', this.onOccupantAdded);
  26553. },
  26554. onOccupantAdded(occupant) {
  26555. var _this$collection2;
  26556. if (this.get('occupant_id')) {
  26557. if (occupant.get('occupant_id') !== this.get('occupant_id')) {
  26558. return;
  26559. }
  26560. } else if (occupant.get('nick') !== Strophe.getResourceFromJid(this.get('from'))) {
  26561. return;
  26562. }
  26563. const chatbox = this === null || this === void 0 ? void 0 : (_this$collection2 = this.collection) === null || _this$collection2 === void 0 ? void 0 : _this$collection2.chatbox;
  26564. if (!chatbox) {
  26565. return headless_log.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);
  26566. }
  26567. this.occupant = occupant;
  26568. if (occupant.get('jid')) {
  26569. this.save('from_real_jid', occupant.get('jid'));
  26570. }
  26571. this.trigger('occupantAdded');
  26572. this.listenTo(this.occupant, 'destroy', this.onOccupantRemoved);
  26573. this.stopListening(chatbox.occupants, 'add', this.onOccupantAdded);
  26574. },
  26575. setOccupant() {
  26576. var _this$collection3;
  26577. if (this.get('type') !== 'groupchat' || this.isEphemeral() || this.occupant) {
  26578. return;
  26579. }
  26580. const chatbox = this === null || this === void 0 ? void 0 : (_this$collection3 = this.collection) === null || _this$collection3 === void 0 ? void 0 : _this$collection3.chatbox;
  26581. if (!chatbox) {
  26582. return headless_log.error(`Could not get collection.chatbox for message: ${JSON.stringify(this.toJSON())}`);
  26583. }
  26584. const nick = Strophe.getResourceFromJid(this.get('from'));
  26585. const occupant_id = this.get('occupant_id');
  26586. this.occupant = chatbox.occupants.findOccupant({
  26587. nick,
  26588. occupant_id
  26589. });
  26590. if (!this.occupant && core_api.settings.get('muc_send_probes')) {
  26591. this.occupant = chatbox.occupants.create({
  26592. nick,
  26593. occupant_id,
  26594. 'type': 'unavailable'
  26595. });
  26596. const jid = `${chatbox.get('jid')}/${nick}`;
  26597. core_api.user.presence.send('probe', jid);
  26598. }
  26599. if (this.occupant) {
  26600. this.listenTo(this.occupant, 'destroy', this.onOccupantRemoved);
  26601. } else {
  26602. this.listenTo(chatbox.occupants, 'add', this.onOccupantAdded);
  26603. }
  26604. }
  26605. };
  26606. /* harmony default export */ const muc_message = (ChatRoomMessageMixin);
  26607. ;// CONCATENATED MODULE: ./src/headless/utils/parse-helpers.js
  26608. /**
  26609. * @copyright 2022, the Converse.js contributors
  26610. * @license Mozilla Public License (MPLv2)
  26611. * @description Pure functions to help functionally parse messages.
  26612. * @todo Other parsing helpers can be made more abstract and placed here.
  26613. */
  26614. const helpers = {};
  26615. const escapeRegexChars = (string, char) => string.replace(RegExp('\\' + char, 'ig'), '\\' + char);
  26616. helpers.escapeCharacters = characters => string => characters.split('').reduce(escapeRegexChars, string);
  26617. helpers.escapeRegexString = helpers.escapeCharacters('[\\^$.?*+(){}|'); // `for` is ~25% faster than using `Array.find()`
  26618. helpers.findFirstMatchInArray = array => text => {
  26619. for (let i = 0; i < array.length; i++) {
  26620. if (text.localeCompare(array[i], undefined, {
  26621. sensitivity: 'base'
  26622. }) === 0) {
  26623. return array[i];
  26624. }
  26625. }
  26626. return null;
  26627. };
  26628. const reduceReferences = (_ref, ref, index) => {
  26629. let [text, refs] = _ref;
  26630. let updated_text = text;
  26631. let {
  26632. begin,
  26633. end
  26634. } = ref;
  26635. const {
  26636. value
  26637. } = ref;
  26638. begin = begin - index;
  26639. end = end - index - 1; // -1 to compensate for the removed @
  26640. updated_text = `${updated_text.slice(0, begin)}${value}${updated_text.slice(end + 1)}`;
  26641. return [updated_text, [...refs, { ...ref,
  26642. begin,
  26643. end
  26644. }]];
  26645. };
  26646. helpers.reduceTextFromReferences = (text, refs) => refs.reduce(reduceReferences, [text, []]);
  26647. /* harmony default export */ const parse_helpers = (helpers);
  26648. ;// CONCATENATED MODULE: ./src/headless/utils/form.js
  26649. /**
  26650. * @copyright 2022, the Converse.js contributors
  26651. * @license Mozilla Public License (MPLv2)
  26652. * @description This is the form utilities module.
  26653. */
  26654. /**
  26655. * Takes an HTML DOM and turns it into an XForm field.
  26656. * @private
  26657. * @method u#webForm2xForm
  26658. * @param { DOMElement } field - the field to convert
  26659. */
  26660. utils_core.webForm2xForm = function (field) {
  26661. const name = field.getAttribute('name');
  26662. if (!name) {
  26663. return null; // See #1924
  26664. }
  26665. let value;
  26666. if (field.getAttribute('type') === 'checkbox') {
  26667. value = field.checked && 1 || 0;
  26668. } else if (field.tagName == "TEXTAREA") {
  26669. value = field.value.split('\n').filter(s => s.trim());
  26670. } else if (field.tagName == "SELECT") {
  26671. value = utils_core.getSelectValues(field);
  26672. } else {
  26673. value = field.value;
  26674. }
  26675. return utils_core.toStanza(`
  26676. <field var="${name}">
  26677. ${value.constructor === Array ? value.map(v => `<value>${v}</value>`) : `<value>${value}</value>`}
  26678. </field>`);
  26679. };
  26680. /* harmony default export */ const utils_form = (utils_core);
  26681. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseZipObject.js
  26682. /**
  26683. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  26684. *
  26685. * @private
  26686. * @param {Array} props The property identifiers.
  26687. * @param {Array} values The property values.
  26688. * @param {Function} assignFunc The function to assign values.
  26689. * @returns {Object} Returns the new object.
  26690. */
  26691. function baseZipObject(props, values, assignFunc) {
  26692. var index = -1,
  26693. length = props.length,
  26694. valsLength = values.length,
  26695. result = {};
  26696. while (++index < length) {
  26697. var value = index < valsLength ? values[index] : undefined;
  26698. assignFunc(result, props[index], value);
  26699. }
  26700. return result;
  26701. }
  26702. /* harmony default export */ const _baseZipObject = (baseZipObject);
  26703. ;// CONCATENATED MODULE: ./node_modules/lodash-es/zipObject.js
  26704. /**
  26705. * This method is like `_.fromPairs` except that it accepts two arrays,
  26706. * one of property identifiers and one of corresponding values.
  26707. *
  26708. * @static
  26709. * @memberOf _
  26710. * @since 0.4.0
  26711. * @category Array
  26712. * @param {Array} [props=[]] The property identifiers.
  26713. * @param {Array} [values=[]] The property values.
  26714. * @returns {Object} Returns the new object.
  26715. * @example
  26716. *
  26717. * _.zipObject(['a', 'b'], [1, 2]);
  26718. * // => { 'a': 1, 'b': 2 }
  26719. */
  26720. function zipObject(props, values) {
  26721. return _baseZipObject(props || [], values || [], _assignValue);
  26722. }
  26723. /* harmony default export */ const lodash_es_zipObject = (zipObject);
  26724. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/parsers.js
  26725. const {
  26726. Strophe: muc_parsers_Strophe,
  26727. sizzle: muc_parsers_sizzle,
  26728. u: parsers_u
  26729. } = core_converse.env;
  26730. const {
  26731. NS: parsers_NS
  26732. } = muc_parsers_Strophe;
  26733. /**
  26734. * Parses a message stanza for XEP-0317 MEP notification data
  26735. * @param { XMLElement } stanza - The message stanza
  26736. * @returns { Array } Returns an array of objects representing <activity> elements.
  26737. */
  26738. function getMEPActivities(stanza) {
  26739. const items_el = muc_parsers_sizzle(`items[node="${muc_parsers_Strophe.NS.CONFINFO}"]`, stanza).pop();
  26740. if (!items_el) {
  26741. return null;
  26742. }
  26743. const from = stanza.getAttribute('from');
  26744. const msgid = stanza.getAttribute('id');
  26745. const selector = `item ` + `conference-info[xmlns="${muc_parsers_Strophe.NS.CONFINFO}"] ` + `activity[xmlns="${muc_parsers_Strophe.NS.ACTIVITY}"]`;
  26746. return muc_parsers_sizzle(selector, items_el).map(el => {
  26747. var _el$querySelector;
  26748. const message = (_el$querySelector = el.querySelector('text')) === null || _el$querySelector === void 0 ? void 0 : _el$querySelector.textContent;
  26749. if (message) {
  26750. var _el$querySelector2;
  26751. const references = getReferences(stanza);
  26752. const reason = (_el$querySelector2 = el.querySelector('reason')) === null || _el$querySelector2 === void 0 ? void 0 : _el$querySelector2.textContent;
  26753. return {
  26754. from,
  26755. msgid,
  26756. message,
  26757. reason,
  26758. references,
  26759. 'type': 'mep'
  26760. };
  26761. }
  26762. return {};
  26763. });
  26764. }
  26765. /**
  26766. * Given a MUC stanza, check whether it has extended message information that
  26767. * includes the sender's real JID, as described here:
  26768. * https://xmpp.org/extensions/xep-0313.html#business-storeret-muc-archives
  26769. *
  26770. * If so, parse and return that data and return the user's JID
  26771. *
  26772. * Note, this function doesn't check whether this is actually a MAM archived stanza.
  26773. *
  26774. * @private
  26775. * @param { XMLElement } stanza - The message stanza
  26776. * @returns { Object }
  26777. */
  26778. function getJIDFromMUCUserData(stanza) {
  26779. const item = muc_parsers_sizzle(`x[xmlns="${muc_parsers_Strophe.NS.MUC_USER}"] item`, stanza).pop();
  26780. return item === null || item === void 0 ? void 0 : item.getAttribute('jid');
  26781. }
  26782. /**
  26783. * @private
  26784. * @param { XMLElement } stanza - The message stanza
  26785. * @param { XMLElement } original_stanza - The original stanza, that contains the
  26786. * message stanza, if it was contained, otherwise it's the message stanza itself.
  26787. * @returns { Object }
  26788. */
  26789. function getModerationAttributes(stanza) {
  26790. const fastening = muc_parsers_sizzle(`apply-to[xmlns="${muc_parsers_Strophe.NS.FASTEN}"]`, stanza).pop();
  26791. if (fastening) {
  26792. const applies_to_id = fastening.getAttribute('id');
  26793. const moderated = muc_parsers_sizzle(`moderated[xmlns="${muc_parsers_Strophe.NS.MODERATE}"]`, fastening).pop();
  26794. if (moderated) {
  26795. const retracted = muc_parsers_sizzle(`retract[xmlns="${muc_parsers_Strophe.NS.RETRACT}"]`, moderated).pop();
  26796. if (retracted) {
  26797. var _moderated$querySelec;
  26798. return {
  26799. 'editable': false,
  26800. 'moderated': 'retracted',
  26801. 'moderated_by': moderated.getAttribute('by'),
  26802. 'moderated_id': applies_to_id,
  26803. 'moderation_reason': (_moderated$querySelec = moderated.querySelector('reason')) === null || _moderated$querySelec === void 0 ? void 0 : _moderated$querySelec.textContent
  26804. };
  26805. }
  26806. }
  26807. } else {
  26808. const tombstone = muc_parsers_sizzle(`> moderated[xmlns="${muc_parsers_Strophe.NS.MODERATE}"]`, stanza).pop();
  26809. if (tombstone) {
  26810. const retracted = muc_parsers_sizzle(`retracted[xmlns="${muc_parsers_Strophe.NS.RETRACT}"]`, tombstone).pop();
  26811. if (retracted) {
  26812. var _tombstone$querySelec;
  26813. return {
  26814. 'editable': false,
  26815. 'is_tombstone': true,
  26816. 'moderated_by': tombstone.getAttribute('by'),
  26817. 'retracted': tombstone.getAttribute('stamp'),
  26818. 'moderation_reason': (_tombstone$querySelec = tombstone.querySelector('reason')) === null || _tombstone$querySelec === void 0 ? void 0 : _tombstone$querySelec.textContent
  26819. };
  26820. }
  26821. }
  26822. }
  26823. return {};
  26824. }
  26825. function getOccupantID(stanza, chatbox) {
  26826. if (chatbox.features.get(muc_parsers_Strophe.NS.OCCUPANTID)) {
  26827. var _sizzle$pop;
  26828. return (_sizzle$pop = muc_parsers_sizzle(`occupant-id[xmlns="${muc_parsers_Strophe.NS.OCCUPANTID}"]`, stanza).pop()) === null || _sizzle$pop === void 0 ? void 0 : _sizzle$pop.getAttribute('id');
  26829. }
  26830. }
  26831. /**
  26832. * Parses a passed in message stanza and returns an object of attributes.
  26833. * @param { XMLElement } stanza - The message stanza
  26834. * @param { XMLElement } original_stanza - The original stanza, that contains the
  26835. * message stanza, if it was contained, otherwise it's the message stanza itself.
  26836. * @param { _converse.ChatRoom } chatbox
  26837. * @param { _converse } _converse
  26838. * @returns { Promise<MUCMessageAttributes|Error> }
  26839. */
  26840. async function parseMUCMessage(stanza, chatbox) {
  26841. var _stanza$querySelector, _stanza$querySelector2, _stanza$querySelector3, _stanza$querySelector4, _chatbox$occupants$fi;
  26842. throwErrorIfInvalidForward(stanza);
  26843. const selector = `[xmlns="${parsers_NS.MAM}"] > forwarded[xmlns="${parsers_NS.FORWARD}"] > message`;
  26844. const original_stanza = stanza;
  26845. stanza = muc_parsers_sizzle(selector, stanza).pop() || stanza;
  26846. if (muc_parsers_sizzle(`message > forwarded[xmlns="${muc_parsers_Strophe.NS.FORWARD}"]`, stanza).length) {
  26847. return new StanzaParseError(`Invalid Stanza: Forged MAM groupchat message from ${stanza.getAttribute('from')}`, stanza);
  26848. }
  26849. const delay = muc_parsers_sizzle(`delay[xmlns="${muc_parsers_Strophe.NS.DELAY}"]`, original_stanza).pop();
  26850. const from = stanza.getAttribute('from');
  26851. const from_muc = muc_parsers_Strophe.getBareJidFromJid(from);
  26852. const nick = muc_parsers_Strophe.unescapeNode(muc_parsers_Strophe.getResourceFromJid(from));
  26853. const marker = getChatMarker(stanza);
  26854. const now = new Date().toISOString();
  26855. /**
  26856. * @typedef { Object } MUCMessageAttributes
  26857. * The object which {@link parseMUCMessage} returns
  26858. * @property { ('me'|'them') } sender - Whether the message was sent by the current user or someone else
  26859. * @property { Array<Object> } activities - A list of objects representing XEP-0316 MEP notification data
  26860. * @property { Array<Object> } references - A list of objects representing XEP-0372 references
  26861. * @property { Boolean } editable - Is this message editable via XEP-0308?
  26862. * @property { Boolean } is_archived - Is this message from a XEP-0313 MAM archive?
  26863. * @property { Boolean } is_carbon - Is this message a XEP-0280 Carbon?
  26864. * @property { Boolean } is_delayed - Was delivery of this message was delayed as per XEP-0203?
  26865. * @property { Boolean } is_encrypted - Is this message XEP-0384 encrypted?
  26866. * @property { Boolean } is_error - Whether an error was received for this message
  26867. * @property { Boolean } is_headline - Is this a "headline" message?
  26868. * @property { Boolean } is_markable - Can this message be marked with a XEP-0333 chat marker?
  26869. * @property { Boolean } is_marker - Is this message a XEP-0333 Chat Marker?
  26870. * @property { Boolean } is_only_emojis - Does the message body contain only emojis?
  26871. * @property { Boolean } is_spoiler - Is this a XEP-0382 spoiler message?
  26872. * @property { Boolean } is_tombstone - Is this a XEP-0424 tombstone?
  26873. * @property { Boolean } is_unstyled - Whether XEP-0393 styling hints should be ignored
  26874. * @property { Boolean } is_valid_receipt_request - Does this message request a XEP-0184 receipt (and is not from us or a carbon or archived message)
  26875. * @property { Object } encrypted - XEP-0384 encryption payload attributes
  26876. * @property { String } body - The contents of the <body> tag of the message stanza
  26877. * @property { String } chat_state - The XEP-0085 chat state notification contained in this message
  26878. * @property { String } edited - An ISO8601 string recording the time that the message was edited per XEP-0308
  26879. * @property { String } error_condition - The defined error condition
  26880. * @property { String } error_text - The error text received from the server
  26881. * @property { String } error_type - The type of error received from the server
  26882. * @property { String } from - The sender JID (${muc_jid}/${nick})
  26883. * @property { String } from_muc - The JID of the MUC from which this message was sent
  26884. * @property { String } from_real_jid - The real JID of the sender, if available
  26885. * @property { String } fullname - The full name of the sender
  26886. * @property { String } marker - The XEP-0333 Chat Marker value
  26887. * @property { String } marker_id - The `id` attribute of a XEP-0333 chat marker
  26888. * @property { String } moderated - The type of XEP-0425 moderation (if any) that was applied
  26889. * @property { String } moderated_by - The JID of the user that moderated this message
  26890. * @property { String } moderated_id - The XEP-0359 Stanza ID of the message that this one moderates
  26891. * @property { String } moderation_reason - The reason provided why this message moderates another
  26892. * @property { String } msgid - The root `id` attribute of the stanza
  26893. * @property { String } nick - The MUC nickname of the sender
  26894. * @property { String } occupant_id - The XEP-0421 occupant ID
  26895. * @property { String } oob_desc - The description of the XEP-0066 out of band data
  26896. * @property { String } oob_url - The URL of the XEP-0066 out of band data
  26897. * @property { String } origin_id - The XEP-0359 Origin ID
  26898. * @property { String } receipt_id - The `id` attribute of a XEP-0184 <receipt> element
  26899. * @property { String } received - An ISO8601 string recording the time that the message was received
  26900. * @property { String } replace_id - The `id` attribute of a XEP-0308 <replace> element
  26901. * @property { String } retracted - An ISO8601 string recording the time that the message was retracted
  26902. * @property { String } retracted_id - The `id` attribute of a XEP-424 <retracted> element
  26903. * @property { String } spoiler_hint The XEP-0382 spoiler hint
  26904. * @property { String } stanza_id - The XEP-0359 Stanza ID. Note: the key is actualy `stanza_id ${by_jid}` and there can be multiple.
  26905. * @property { String } subject - The <subject> element value
  26906. * @property { String } thread - The <thread> element value
  26907. * @property { String } time - The time (in ISO8601 format), either given by the XEP-0203 <delay> element, or of receipt.
  26908. * @property { String } to - The recipient JID
  26909. * @property { String } type - The type of message
  26910. */
  26911. let attrs = Object.assign({
  26912. from,
  26913. from_muc,
  26914. nick,
  26915. 'is_forwarded': !!stanza.querySelector('forwarded'),
  26916. 'activities': getMEPActivities(stanza),
  26917. 'body': (_stanza$querySelector = stanza.querySelector('body')) === null || _stanza$querySelector === void 0 ? void 0 : (_stanza$querySelector2 = _stanza$querySelector.textContent) === null || _stanza$querySelector2 === void 0 ? void 0 : _stanza$querySelector2.trim(),
  26918. 'chat_state': getChatState(stanza),
  26919. 'is_archived': isArchived(original_stanza),
  26920. 'is_carbon': isCarbon(original_stanza),
  26921. 'is_delayed': !!delay,
  26922. 'is_headline': isHeadline(stanza),
  26923. 'is_markable': !!muc_parsers_sizzle(`markable[xmlns="${muc_parsers_Strophe.NS.MARKERS}"]`, stanza).length,
  26924. 'is_marker': !!marker,
  26925. 'is_unstyled': !!muc_parsers_sizzle(`unstyled[xmlns="${muc_parsers_Strophe.NS.STYLING}"]`, stanza).length,
  26926. 'marker_id': marker && marker.getAttribute('id'),
  26927. 'msgid': stanza.getAttribute('id') || original_stanza.getAttribute('id'),
  26928. 'occupant_id': getOccupantID(stanza, chatbox),
  26929. 'receipt_id': getReceiptId(stanza),
  26930. 'received': new Date().toISOString(),
  26931. 'references': getReferences(stanza),
  26932. 'subject': (_stanza$querySelector3 = stanza.querySelector('subject')) === null || _stanza$querySelector3 === void 0 ? void 0 : _stanza$querySelector3.textContent,
  26933. 'thread': (_stanza$querySelector4 = stanza.querySelector('thread')) === null || _stanza$querySelector4 === void 0 ? void 0 : _stanza$querySelector4.textContent,
  26934. 'time': delay ? dayjs_min_default()(delay.getAttribute('stamp')).toISOString() : now,
  26935. 'to': stanza.getAttribute('to'),
  26936. 'type': stanza.getAttribute('type')
  26937. }, getErrorAttributes(stanza), getOutOfBandAttributes(stanza), getSpoilerAttributes(stanza), getCorrectionAttributes(stanza, original_stanza), getStanzaIDs(stanza, original_stanza), getOpenGraphMetadata(stanza), getRetractionAttributes(stanza, original_stanza), getModerationAttributes(stanza), getEncryptionAttributes(stanza, shared_converse));
  26938. await core_api.emojis.initialize();
  26939. const from_real_jid = attrs.is_archived && getJIDFromMUCUserData(stanza, attrs) || ((_chatbox$occupants$fi = chatbox.occupants.findOccupant(attrs)) === null || _chatbox$occupants$fi === void 0 ? void 0 : _chatbox$occupants$fi.get('jid'));
  26940. attrs = Object.assign({
  26941. from_real_jid,
  26942. 'is_only_emojis': attrs.body ? parsers_u.isOnlyEmojis(attrs.body) : false,
  26943. 'is_valid_receipt_request': isValidReceiptRequest(stanza, attrs),
  26944. 'message': attrs.body || attrs.error,
  26945. // TODO: Remove and use body and error attributes instead
  26946. 'sender': attrs.nick === chatbox.get('nick') ? 'me' : 'them'
  26947. }, attrs);
  26948. if (attrs.is_archived && original_stanza.getAttribute('from') !== attrs.from_muc) {
  26949. return new StanzaParseError(`Invalid Stanza: Forged MAM message from ${original_stanza.getAttribute('from')}`, stanza);
  26950. } else if (attrs.is_archived && original_stanza.getAttribute('from') !== chatbox.get('jid')) {
  26951. return new StanzaParseError(`Invalid Stanza: Forged MAM groupchat message from ${stanza.getAttribute('from')}`, stanza);
  26952. } else if (attrs.is_carbon) {
  26953. return new StanzaParseError('Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied', stanza);
  26954. } // We prefer to use one of the XEP-0359 unique and stable stanza IDs as the Model id, to avoid duplicates.
  26955. attrs['id'] = attrs['origin_id'] || attrs[`stanza_id ${attrs.from_muc || attrs.from}`] || parsers_u.getUniqueId();
  26956. /**
  26957. * *Hook* which allows plugins to add additional parsing
  26958. * @event _converse#parseMUCMessage
  26959. */
  26960. attrs = await core_api.hook('parseMUCMessage', stanza, attrs); // We call this after the hook, to allow plugins to decrypt encrypted
  26961. // messages, since we need to parse the message text to determine whether
  26962. // there are media urls.
  26963. return Object.assign(attrs, getMediaURLsMetadata(attrs.is_encrypted ? attrs.plaintext : attrs.body));
  26964. }
  26965. /**
  26966. * Given an IQ stanza with a member list, create an array of objects containing
  26967. * known member data (e.g. jid, nick, role, affiliation).
  26968. * @private
  26969. * @method muc_utils#parseMemberListIQ
  26970. * @returns { MemberListItem[] }
  26971. */
  26972. function parseMemberListIQ(iq) {
  26973. return muc_parsers_sizzle(`query[xmlns="${muc_parsers_Strophe.NS.MUC_ADMIN}"] item`, iq).map(item => {
  26974. /**
  26975. * @typedef {Object} MemberListItem
  26976. * Either the JID or the nickname (or both) will be available.
  26977. * @property {string} affiliation
  26978. * @property {string} [role]
  26979. * @property {string} [jid]
  26980. * @property {string} [nick]
  26981. */
  26982. const data = {
  26983. 'affiliation': item.getAttribute('affiliation')
  26984. };
  26985. const jid = item.getAttribute('jid');
  26986. if (parsers_u.isValidJID(jid)) {
  26987. data['jid'] = jid;
  26988. } else {
  26989. // XXX: Prosody sends nick for the jid attribute value
  26990. // Perhaps for anonymous room?
  26991. data['nick'] = jid;
  26992. }
  26993. const nick = item.getAttribute('nick');
  26994. if (nick) {
  26995. data['nick'] = nick;
  26996. }
  26997. const role = item.getAttribute('role');
  26998. if (role) {
  26999. data['role'] = nick;
  27000. }
  27001. return data;
  27002. });
  27003. }
  27004. /**
  27005. * Parses a passed in MUC presence stanza and returns an object of attributes.
  27006. * @method parseMUCPresence
  27007. * @param { XMLElement } stanza - The presence stanza
  27008. * @param { _converse.ChatRoom } chatbox
  27009. * @returns { MUCPresenceAttributes }
  27010. */
  27011. function parseMUCPresence(stanza, chatbox) {
  27012. /**
  27013. * @typedef { Object } MUCPresenceAttributes
  27014. * The object which {@link parseMUCPresence} returns
  27015. * @property { ("offline|online") } show
  27016. * @property { Array<MUCHat> } hats - An array of XEP-0317 hats
  27017. * @property { Array<string> } states
  27018. * @property { String } from - The sender JID (${muc_jid}/${nick})
  27019. * @property { String } nick - The nickname of the sender
  27020. * @property { String } occupant_id - The XEP-0421 occupant ID
  27021. * @property { String } type - The type of presence
  27022. */
  27023. const from = stanza.getAttribute('from');
  27024. const type = stanza.getAttribute('type');
  27025. const data = {
  27026. 'from': from,
  27027. 'occupant_id': getOccupantID(stanza, chatbox),
  27028. 'nick': muc_parsers_Strophe.getResourceFromJid(from),
  27029. 'type': type,
  27030. 'states': [],
  27031. 'hats': [],
  27032. 'show': type !== 'unavailable' ? 'online' : 'offline'
  27033. };
  27034. Array.from(stanza.children).forEach(child => {
  27035. if (child.matches('status')) {
  27036. data.status = child.textContent || null;
  27037. } else if (child.matches('show')) {
  27038. data.show = child.textContent || 'online';
  27039. } else if (child.matches('x') && child.getAttribute('xmlns') === muc_parsers_Strophe.NS.MUC_USER) {
  27040. Array.from(child.children).forEach(item => {
  27041. if (item.nodeName === 'item') {
  27042. data.affiliation = item.getAttribute('affiliation');
  27043. data.role = item.getAttribute('role');
  27044. data.jid = item.getAttribute('jid');
  27045. data.nick = item.getAttribute('nick') || data.nick;
  27046. } else if (item.nodeName == 'status' && item.getAttribute('code')) {
  27047. data.states.push(item.getAttribute('code'));
  27048. }
  27049. });
  27050. } else if (child.matches('x') && child.getAttribute('xmlns') === muc_parsers_Strophe.NS.VCARDUPDATE) {
  27051. var _child$querySelector;
  27052. data.image_hash = (_child$querySelector = child.querySelector('photo')) === null || _child$querySelector === void 0 ? void 0 : _child$querySelector.textContent;
  27053. } else if (child.matches('hats') && child.getAttribute('xmlns') === muc_parsers_Strophe.NS.MUC_HATS) {
  27054. /**
  27055. * @typedef { Object } MUCHat
  27056. * Object representing a XEP-0371 Hat
  27057. * @property { String } title
  27058. * @property { String } uri
  27059. */
  27060. data['hats'] = Array.from(child.children).map(c => c.matches('hat') && {
  27061. 'title': c.getAttribute('title'),
  27062. 'uri': c.getAttribute('uri')
  27063. });
  27064. }
  27065. });
  27066. return data;
  27067. }
  27068. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/affiliations/utils.js
  27069. /**
  27070. * @copyright The Converse.js contributors
  27071. * @license Mozilla Public License (MPLv2)
  27072. */
  27073. const {
  27074. Strophe: affiliations_utils_Strophe,
  27075. $iq: affiliations_utils_$iq,
  27076. u: affiliations_utils_u
  27077. } = core_converse.env;
  27078. /**
  27079. * Sends an IQ stanza to the server, asking it for the relevant affiliation list .
  27080. * Returns an array of {@link MemberListItem} objects, representing occupants
  27081. * that have the given affiliation.
  27082. * See: https://xmpp.org/extensions/xep-0045.html#modifymember
  27083. * @param { ("admin"|"owner"|"member") } affiliation
  27084. * @param { String } muc_jid - The JID of the MUC for which the affiliation list should be fetched
  27085. * @returns { Promise<MemberListItem[]> }
  27086. */
  27087. async function getAffiliationList(affiliation, muc_jid) {
  27088. const {
  27089. __
  27090. } = shared_converse;
  27091. const iq = affiliations_utils_$iq({
  27092. 'to': muc_jid,
  27093. 'type': 'get'
  27094. }).c('query', {
  27095. xmlns: affiliations_utils_Strophe.NS.MUC_ADMIN
  27096. }).c('item', {
  27097. 'affiliation': affiliation
  27098. });
  27099. const result = await core_api.sendIQ(iq, null, false);
  27100. if (result === null) {
  27101. const err_msg = __('Error: timeout while fetching %1s list for MUC %2s', affiliation, muc_jid);
  27102. const err = new Error(err_msg);
  27103. headless_log.warn(err_msg);
  27104. return err;
  27105. }
  27106. if (affiliations_utils_u.isErrorStanza(result)) {
  27107. const err_msg = __('Error: not allowed to fetch %1s list for MUC %2s', affiliation, muc_jid);
  27108. const err = new Error(err_msg);
  27109. headless_log.warn(err_msg);
  27110. headless_log.warn(result);
  27111. return err;
  27112. }
  27113. return parseMemberListIQ(result).filter(p => p).sort((a, b) => a.nick < b.nick ? -1 : a.nick > b.nick ? 1 : 0);
  27114. }
  27115. /**
  27116. * Given an occupant model, see which affiliations may be assigned to that user.
  27117. * @param { Model } occupant
  27118. * @returns { Array<('owner'|'admin'|'member'|'outcast'|'none')> } - An array of assignable affiliations
  27119. */
  27120. function getAssignableAffiliations(occupant) {
  27121. let disabled = core_api.settings.get('modtools_disable_assign');
  27122. if (!Array.isArray(disabled)) {
  27123. disabled = disabled ? AFFILIATIONS : [];
  27124. }
  27125. if (occupant.get('affiliation') === 'owner') {
  27126. return AFFILIATIONS.filter(a => !disabled.includes(a));
  27127. } else if (occupant.get('affiliation') === 'admin') {
  27128. return AFFILIATIONS.filter(a => !['owner', 'admin', ...disabled].includes(a));
  27129. } else {
  27130. return [];
  27131. }
  27132. } // Necessary for tests
  27133. shared_converse.getAssignableAffiliations = getAssignableAffiliations;
  27134. /**
  27135. * Send IQ stanzas to the server to modify affiliations for users in this groupchat.
  27136. * See: https://xmpp.org/extensions/xep-0045.html#modifymember
  27137. * @param { Array<Object> } users
  27138. * @param { string } users[].jid - The JID of the user whose affiliation will change
  27139. * @param { Array } users[].affiliation - The new affiliation for this user
  27140. * @param { string } [users[].reason] - An optional reason for the affiliation change
  27141. * @returns { Promise }
  27142. */
  27143. function setAffiliations(muc_jid, users) {
  27144. const affiliations = [...new Set(users.map(u => u.affiliation))];
  27145. return Promise.all(affiliations.map(a => setAffiliation(a, muc_jid, users)));
  27146. }
  27147. /**
  27148. * Send IQ stanzas to the server to set an affiliation for
  27149. * the provided JIDs.
  27150. * See: https://xmpp.org/extensions/xep-0045.html#modifymember
  27151. *
  27152. * Prosody doesn't accept multiple JIDs' affiliations
  27153. * being set in one IQ stanza, so as a workaround we send
  27154. * a separate stanza for each JID.
  27155. * Related ticket: https://issues.prosody.im/345
  27156. *
  27157. * @param { ('outcast'|'member'|'admin'|'owner') } affiliation - The affiliation to be set
  27158. * @param { String|Array<String> } jids - The JID(s) of the MUCs in which the
  27159. * affiliations need to be set.
  27160. * @param { object } members - A map of jids, affiliations and
  27161. * optionally reasons. Only those entries with the
  27162. * same affiliation as being currently set will be considered.
  27163. * @returns { Promise } A promise which resolves and fails depending on the XMPP server response.
  27164. */
  27165. function setAffiliation(affiliation, muc_jids, members) {
  27166. if (!Array.isArray(muc_jids)) {
  27167. muc_jids = [muc_jids];
  27168. }
  27169. members = members.filter(m => [undefined, affiliation].includes(m.affiliation));
  27170. return Promise.all(muc_jids.reduce((acc, jid) => [...acc, ...members.map(m => sendAffiliationIQ(affiliation, jid, m))], []));
  27171. }
  27172. /**
  27173. * Send an IQ stanza specifying an affiliation change.
  27174. * @private
  27175. * @param { String } affiliation: affiliation (could also be stored on the member object).
  27176. * @param { String } muc_jid: The JID of the MUC in which the affiliation should be set.
  27177. * @param { Object } member: Map containing the member's jid and optionally a reason and affiliation.
  27178. */
  27179. function sendAffiliationIQ(affiliation, muc_jid, member) {
  27180. const iq = affiliations_utils_$iq({
  27181. to: muc_jid,
  27182. type: 'set'
  27183. }).c('query', {
  27184. xmlns: affiliations_utils_Strophe.NS.MUC_ADMIN
  27185. }).c('item', {
  27186. 'affiliation': member.affiliation || affiliation,
  27187. 'nick': member.nick,
  27188. 'jid': member.jid
  27189. });
  27190. if (member.reason !== undefined) {
  27191. iq.c('reason', member.reason);
  27192. }
  27193. return core_api.sendIQ(iq);
  27194. }
  27195. /**
  27196. * Given two lists of objects with 'jid', 'affiliation' and
  27197. * 'reason' properties, return a new list containing
  27198. * those objects that are new, changed or removed
  27199. * (depending on the 'remove_absentees' boolean).
  27200. *
  27201. * The affiliations for new and changed members stay the
  27202. * same, for removed members, the affiliation is set to 'none'.
  27203. *
  27204. * The 'reason' property is not taken into account when
  27205. * comparing whether affiliations have been changed.
  27206. * @param { boolean } exclude_existing - Indicates whether JIDs from
  27207. * the new list which are also in the old list
  27208. * (regardless of affiliation) should be excluded
  27209. * from the delta. One reason to do this
  27210. * would be when you want to add a JID only if it
  27211. * doesn't have *any* existing affiliation at all.
  27212. * @param { boolean } remove_absentees - Indicates whether JIDs
  27213. * from the old list which are not in the new list
  27214. * should be considered removed and therefore be
  27215. * included in the delta with affiliation set
  27216. * to 'none'.
  27217. * @param { array } new_list - Array containing the new affiliations
  27218. * @param { array } old_list - Array containing the old affiliations
  27219. * @returns { array }
  27220. */
  27221. function computeAffiliationsDelta(exclude_existing, remove_absentees, new_list, old_list) {
  27222. const new_jids = new_list.map(o => o.jid);
  27223. const old_jids = old_list.map(o => o.jid); // Get the new affiliations
  27224. let delta = lodash_es_difference(new_jids, old_jids).map(jid => new_list[lodash_es_indexOf(new_jids, jid)]);
  27225. if (!exclude_existing) {
  27226. // Get the changed affiliations
  27227. delta = delta.concat(new_list.filter(item => {
  27228. const idx = lodash_es_indexOf(old_jids, item.jid);
  27229. return idx >= 0 ? item.affiliation !== old_list[idx].affiliation : false;
  27230. }));
  27231. }
  27232. if (remove_absentees) {
  27233. // Get the removed affiliations
  27234. delta = delta.concat(lodash_es_difference(old_jids, new_jids).map(jid => ({
  27235. 'jid': jid,
  27236. 'affiliation': 'none'
  27237. })));
  27238. }
  27239. return delta;
  27240. }
  27241. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/muc.js
  27242. const OWNER_COMMANDS = ['owner'];
  27243. const ADMIN_COMMANDS = ['admin', 'ban', 'deop', 'destroy', 'member', 'op', 'revoke'];
  27244. const MODERATOR_COMMANDS = ['kick', 'mute', 'voice', 'modtools'];
  27245. const VISITOR_COMMANDS = ['nick'];
  27246. const METADATA_ATTRIBUTES = ["og:article:author", "og:article:published_time", "og:description", "og:image", "og:image:height", "og:image:width", "og:site_name", "og:title", "og:type", "og:url", "og:video:height", "og:video:secure_url", "og:video:tag", "og:video:type", "og:video:url", "og:video:width"];
  27247. const ACTION_INFO_CODES = ['301', '303', '333', '307', '321', '322'];
  27248. const MUCSession = Model.extend({
  27249. defaults() {
  27250. return {
  27251. 'connection_status': core_converse.ROOMSTATUS.DISCONNECTED
  27252. };
  27253. }
  27254. });
  27255. /**
  27256. * Represents an open/ongoing groupchat conversation.
  27257. * @mixin
  27258. * @namespace _converse.ChatRoom
  27259. * @memberOf _converse
  27260. */
  27261. const ChatRoomMixin = {
  27262. defaults() {
  27263. return {
  27264. 'bookmarked': false,
  27265. 'chat_state': undefined,
  27266. 'has_activity': false,
  27267. // XEP-437
  27268. 'hidden': isUniView() && !core_api.settings.get('singleton'),
  27269. 'hidden_occupants': !!core_api.settings.get('hide_muc_participants'),
  27270. 'message_type': 'groupchat',
  27271. 'name': '',
  27272. // For group chats, we distinguish between generally unread
  27273. // messages and those ones that specifically mention the
  27274. // user.
  27275. //
  27276. // To keep things simple, we reuse `num_unread` from
  27277. // _converse.ChatBox to indicate unread messages which
  27278. // mention the user and `num_unread_general` to indicate
  27279. // generally unread messages (which *includes* mentions!).
  27280. 'num_unread_general': 0,
  27281. 'num_unread': 0,
  27282. 'roomconfig': {},
  27283. 'time_opened': this.get('time_opened') || new Date().getTime(),
  27284. 'time_sent': new Date(0).toISOString(),
  27285. 'type': shared_converse.CHATROOMS_TYPE
  27286. };
  27287. },
  27288. async initialize() {
  27289. this.initialized = getOpenPromise();
  27290. this.debouncedRejoin = lodash_es_debounce(this.rejoin, 250);
  27291. this.set('box_id', `box-${this.get('jid')}`);
  27292. this.initNotifications();
  27293. this.initMessages();
  27294. this.initUI();
  27295. this.initOccupants();
  27296. this.initDiscoModels(); // sendChatState depends on this.features
  27297. this.registerHandlers();
  27298. this.on('change:chat_state', this.sendChatState, this);
  27299. this.on('change:hidden', this.onHiddenChange, this);
  27300. this.on('destroy', this.removeHandlers, this);
  27301. this.ui.on('change:scrolled', this.onScrolledChanged, this);
  27302. await this.restoreSession();
  27303. this.session.on('change:connection_status', this.onConnectionStatusChanged, this);
  27304. this.listenTo(this.occupants, 'add', this.onOccupantAdded);
  27305. this.listenTo(this.occupants, 'remove', this.onOccupantRemoved);
  27306. this.listenTo(this.occupants, 'change:show', this.onOccupantShowChanged);
  27307. this.listenTo(this.occupants, 'change:affiliation', this.createAffiliationChangeMessage);
  27308. this.listenTo(this.occupants, 'change:role', this.createRoleChangeMessage);
  27309. const restored = await this.restoreFromCache();
  27310. if (!restored) {
  27311. this.join();
  27312. }
  27313. /**
  27314. * Triggered once a {@link _converse.ChatRoom} has been created and initialized.
  27315. * @event _converse#chatRoomInitialized
  27316. * @type { _converse.ChatRoom }
  27317. * @example _converse.api.listen.on('chatRoomInitialized', model => { ... });
  27318. */
  27319. await core_api.trigger('chatRoomInitialized', this, {
  27320. 'Synchronous': true
  27321. });
  27322. this.initialized.resolve();
  27323. },
  27324. isEntered() {
  27325. return this.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED;
  27326. },
  27327. /**
  27328. * Checks whether we're still joined and if so, restores the MUC state from cache.
  27329. * @private
  27330. * @method _converse.ChatRoom#restoreFromCache
  27331. * @returns { Boolean } Returns `true` if we're still joined, otherwise returns `false`.
  27332. */
  27333. async restoreFromCache() {
  27334. if (this.isEntered() && (await this.isJoined())) {
  27335. // We've restored the room from cache and we're still joined.
  27336. await new Promise(r => this.features.fetch({
  27337. 'success': r,
  27338. 'error': r
  27339. }));
  27340. await new Promise(r => this.config.fetch({
  27341. 'success': r,
  27342. 'error': r
  27343. }));
  27344. await this.fetchOccupants().catch(e => headless_log.error(e));
  27345. await this.fetchMessages().catch(e => headless_log.error(e));
  27346. return true;
  27347. } else {
  27348. this.session.save('connection_status', core_converse.ROOMSTATUS.DISCONNECTED);
  27349. this.clearOccupantsCache();
  27350. return false;
  27351. }
  27352. },
  27353. /**
  27354. * Join the MUC
  27355. * @private
  27356. * @method _converse.ChatRoom#join
  27357. * @param { String } nick - The user's nickname
  27358. * @param { String } [password] - Optional password, if required by the groupchat.
  27359. * Will fall back to the `password` value stored in the room
  27360. * model (if available).
  27361. */
  27362. async join(nick, password) {
  27363. if (this.isEntered()) {
  27364. // We have restored a groupchat from session storage,
  27365. // so we don't send out a presence stanza again.
  27366. return this;
  27367. } // Set this early, so we don't rejoin in onHiddenChange
  27368. this.session.save('connection_status', core_converse.ROOMSTATUS.CONNECTING);
  27369. await this.refreshDiscoInfo();
  27370. nick = await this.getAndPersistNickname(nick);
  27371. if (!nick) {
  27372. safeSave(this.session, {
  27373. 'connection_status': core_converse.ROOMSTATUS.NICKNAME_REQUIRED
  27374. });
  27375. if (core_api.settings.get('muc_show_logs_before_join')) {
  27376. await this.fetchMessages();
  27377. }
  27378. return this;
  27379. }
  27380. core_api.send(await this.constructJoinPresence(password));
  27381. return this;
  27382. },
  27383. /**
  27384. * Clear stale cache and re-join a MUC we've been in before.
  27385. * @private
  27386. * @method _converse.ChatRoom#rejoin
  27387. */
  27388. rejoin() {
  27389. this.session.save('connection_status', core_converse.ROOMSTATUS.DISCONNECTED);
  27390. this.registerHandlers();
  27391. this.clearOccupantsCache();
  27392. return this.join();
  27393. },
  27394. async constructJoinPresence(password) {
  27395. let stanza = $pres({
  27396. 'id': getUniqueId(),
  27397. 'from': shared_converse.connection.jid,
  27398. 'to': this.getRoomJIDAndNick()
  27399. }).c('x', {
  27400. 'xmlns': Strophe.NS.MUC
  27401. }).c('history', {
  27402. 'maxstanzas': this.features.get('mam_enabled') ? 0 : core_api.settings.get('muc_history_max_stanzas')
  27403. }).up();
  27404. password = password || this.get('password');
  27405. if (password) {
  27406. stanza.cnode(Strophe.xmlElement('password', [], password));
  27407. }
  27408. stanza.up(); // Go one level up, out of the `x` element.
  27409. /**
  27410. * *Hook* which allows plugins to update an outgoing MUC join presence stanza
  27411. * @event _converse#constructedMUCPresence
  27412. * @param { _converse.ChatRoom } - The MUC from which this message stanza is being sent.
  27413. * @param { XMLElement } stanza - The stanza which will be sent out
  27414. */
  27415. stanza = await core_api.hook('constructedMUCPresence', this, stanza);
  27416. return stanza;
  27417. },
  27418. clearOccupantsCache() {
  27419. if (this.occupants.length) {
  27420. // Remove non-members when reconnecting
  27421. this.occupants.filter(o => !o.isMember()).forEach(o => o.destroy());
  27422. } else {
  27423. // Looks like we haven't restored occupants from cache, so we clear it.
  27424. this.occupants.clearStore();
  27425. }
  27426. },
  27427. /**
  27428. * Given the passed in MUC message, send a XEP-0333 chat marker.
  27429. * @param { _converse.MUCMessage } msg
  27430. * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
  27431. * @param { Boolean } force - Whether a marker should be sent for the
  27432. * message, even if it didn't include a `markable` element.
  27433. */
  27434. sendMarkerForMessage(msg) {
  27435. let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'displayed';
  27436. let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  27437. if (!msg || !core_api.settings.get('send_chat_markers').includes(type) || (msg === null || msg === void 0 ? void 0 : msg.get('type')) !== 'groupchat') {
  27438. return;
  27439. }
  27440. if (msg !== null && msg !== void 0 && msg.get('is_markable') || force) {
  27441. const key = `stanza_id ${this.get('jid')}`;
  27442. const id = msg.get(key);
  27443. if (!id) {
  27444. headless_log.error(`Can't send marker for message without stanza ID: ${key}`);
  27445. return;
  27446. }
  27447. const from_jid = Strophe.getBareJidFromJid(msg.get('from'));
  27448. sendMarker(from_jid, id, type, msg.get('type'));
  27449. }
  27450. },
  27451. /**
  27452. * Ensures that the user is subscribed to XEP-0437 Room Activity Indicators
  27453. * if `muc_subscribe_to_rai` is set to `true`.
  27454. * Only affiliated users can subscribe to RAI, but this method doesn't
  27455. * check whether the current user is affiliated because it's intended to be
  27456. * called after the MUC has been left and we don't have that information
  27457. * anymore.
  27458. * @private
  27459. * @method _converse.ChatRoom#enableRAI
  27460. */
  27461. enableRAI() {
  27462. if (core_api.settings.get('muc_subscribe_to_rai')) {
  27463. const muc_domain = Strophe.getDomainFromJid(this.get('jid'));
  27464. core_api.user.presence.send(null, muc_domain, null, $build('rai', {
  27465. 'xmlns': Strophe.NS.RAI
  27466. }));
  27467. }
  27468. },
  27469. /**
  27470. * Handler that gets called when the 'hidden' flag is toggled.
  27471. * @private
  27472. * @method _converse.ChatRoom#onHiddenChange
  27473. */
  27474. async onHiddenChange() {
  27475. const roomstatus = core_converse.ROOMSTATUS;
  27476. const conn_status = this.session.get('connection_status');
  27477. if (this.get('hidden')) {
  27478. if (conn_status === roomstatus.ENTERED && core_api.settings.get('muc_subscribe_to_rai') && this.getOwnAffiliation() !== 'none') {
  27479. this.sendMarkerForLastMessage('received', true);
  27480. await this.leave();
  27481. this.enableRAI();
  27482. }
  27483. } else {
  27484. if (conn_status === roomstatus.DISCONNECTED) {
  27485. this.rejoin();
  27486. }
  27487. this.clearUnreadMsgCounter();
  27488. }
  27489. },
  27490. onOccupantAdded(occupant) {
  27491. if (shared_converse.isInfoVisible(core_converse.MUC_TRAFFIC_STATES.ENTERED) && this.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED && occupant.get('show') === 'online') {
  27492. this.updateNotifications(occupant.get('nick'), core_converse.MUC_TRAFFIC_STATES.ENTERED);
  27493. }
  27494. },
  27495. onOccupantRemoved(occupant) {
  27496. if (shared_converse.isInfoVisible(core_converse.MUC_TRAFFIC_STATES.EXITED) && this.isEntered() && occupant.get('show') === 'online') {
  27497. this.updateNotifications(occupant.get('nick'), core_converse.MUC_TRAFFIC_STATES.EXITED);
  27498. }
  27499. },
  27500. onOccupantShowChanged(occupant) {
  27501. if (occupant.get('states').includes('303')) {
  27502. return;
  27503. }
  27504. if (occupant.get('show') === 'offline' && shared_converse.isInfoVisible(core_converse.MUC_TRAFFIC_STATES.EXITED)) {
  27505. this.updateNotifications(occupant.get('nick'), core_converse.MUC_TRAFFIC_STATES.EXITED);
  27506. } else if (occupant.get('show') === 'online' && shared_converse.isInfoVisible(core_converse.MUC_TRAFFIC_STATES.ENTERED)) {
  27507. this.updateNotifications(occupant.get('nick'), core_converse.MUC_TRAFFIC_STATES.ENTERED);
  27508. }
  27509. },
  27510. async onRoomEntered() {
  27511. await this.occupants.fetchMembers();
  27512. if (core_api.settings.get('clear_messages_on_reconnection')) {
  27513. await this.clearMessages();
  27514. } else {
  27515. await this.fetchMessages();
  27516. }
  27517. /**
  27518. * Triggered when the user has entered a new MUC
  27519. * @event _converse#enteredNewRoom
  27520. * @type { _converse.ChatRoom}
  27521. * @example _converse.api.listen.on('enteredNewRoom', model => { ... });
  27522. */
  27523. core_api.trigger('enteredNewRoom', this);
  27524. if (core_api.settings.get('auto_register_muc_nickname') && (await core_api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid')))) {
  27525. this.registerNickname();
  27526. }
  27527. },
  27528. async onConnectionStatusChanged() {
  27529. if (this.isEntered()) {
  27530. if (this.get('hidden') && core_api.settings.get('muc_subscribe_to_rai') && this.getOwnAffiliation() !== 'none') {
  27531. try {
  27532. await this.leave();
  27533. } catch (e) {
  27534. headless_log.error(e);
  27535. }
  27536. this.enableRAI();
  27537. } else {
  27538. await this.onRoomEntered();
  27539. }
  27540. }
  27541. },
  27542. async onReconnection() {
  27543. await this.rejoin();
  27544. this.announceReconnection();
  27545. },
  27546. getMessagesCollection() {
  27547. return new shared_converse.ChatRoomMessages();
  27548. },
  27549. restoreSession() {
  27550. const id = `muc.session-${shared_converse.bare_jid}-${this.get('jid')}`;
  27551. this.session = new MUCSession({
  27552. id
  27553. });
  27554. initStorage(this.session, id, 'session');
  27555. return new Promise(r => this.session.fetch({
  27556. 'success': r,
  27557. 'error': r
  27558. }));
  27559. },
  27560. initDiscoModels() {
  27561. let id = `converse.muc-features-${shared_converse.bare_jid}-${this.get('jid')}`;
  27562. this.features = new Model(Object.assign({
  27563. id
  27564. }, lodash_es_zipObject(core_converse.ROOM_FEATURES, core_converse.ROOM_FEATURES.map(() => false))));
  27565. this.features.browserStorage = shared_converse.createStore(id, 'session');
  27566. this.features.listenTo(shared_converse, 'beforeLogout', () => this.features.browserStorage.flush());
  27567. id = `converse.muc-config-${shared_converse.bare_jid}-${this.get('jid')}`;
  27568. this.config = new Model({
  27569. id
  27570. });
  27571. this.config.browserStorage = shared_converse.createStore(id, 'session');
  27572. this.config.listenTo(shared_converse, 'beforeLogout', () => this.config.browserStorage.flush());
  27573. },
  27574. initOccupants() {
  27575. this.occupants = new shared_converse.ChatRoomOccupants();
  27576. const id = `converse.occupants-${shared_converse.bare_jid}${this.get('jid')}`;
  27577. this.occupants.browserStorage = shared_converse.createStore(id, 'session');
  27578. this.occupants.chatroom = this;
  27579. this.occupants.listenTo(shared_converse, 'beforeLogout', () => this.occupants.browserStorage.flush());
  27580. },
  27581. fetchOccupants() {
  27582. this.occupants.fetched = new Promise(resolve => {
  27583. this.occupants.fetch({
  27584. 'add': true,
  27585. 'silent': true,
  27586. 'success': resolve,
  27587. 'error': resolve
  27588. });
  27589. });
  27590. return this.occupants.fetched;
  27591. },
  27592. handleAffiliationChangedMessage(stanza) {
  27593. const item = sizzle_default()(`x[xmlns="${Strophe.NS.MUC_USER}"] item`, stanza).pop();
  27594. if (item) {
  27595. const from = stanza.getAttribute('from');
  27596. const type = stanza.getAttribute('type');
  27597. const affiliation = item.getAttribute('affiliation');
  27598. const jid = item.getAttribute('jid');
  27599. const data = {
  27600. from,
  27601. type,
  27602. affiliation,
  27603. 'states': [],
  27604. 'show': type == 'unavailable' ? 'offline' : 'online',
  27605. 'role': item.getAttribute('role'),
  27606. 'jid': Strophe.getBareJidFromJid(jid),
  27607. 'resource': Strophe.getResourceFromJid(jid)
  27608. };
  27609. const occupant = this.occupants.findOccupant({
  27610. 'jid': data.jid
  27611. });
  27612. if (occupant) {
  27613. occupant.save(data);
  27614. } else {
  27615. this.occupants.create(data);
  27616. }
  27617. }
  27618. },
  27619. async handleErrorMessageStanza(stanza) {
  27620. const {
  27621. __
  27622. } = shared_converse;
  27623. const attrs = await parseMUCMessage(stanza, this, shared_converse);
  27624. if (!(await this.shouldShowErrorMessage(attrs))) {
  27625. return;
  27626. }
  27627. const message = this.getMessageReferencedByError(attrs);
  27628. if (message) {
  27629. const new_attrs = {
  27630. 'error': attrs.error,
  27631. 'error_condition': attrs.error_condition,
  27632. 'error_text': attrs.error_text,
  27633. 'error_type': attrs.error_type,
  27634. 'editable': false
  27635. };
  27636. if (attrs.msgid === message.get('retraction_id')) {
  27637. // The error message refers to a retraction
  27638. new_attrs.retracted = undefined;
  27639. new_attrs.retraction_id = undefined;
  27640. new_attrs.retracted_id = undefined;
  27641. if (!attrs.error) {
  27642. if (attrs.error_condition === 'forbidden') {
  27643. new_attrs.error = __("You're not allowed to retract your message.");
  27644. } else if (attrs.error_condition === 'not-acceptable') {
  27645. new_attrs.error = __("Your retraction was not delivered because you're not present in the groupchat.");
  27646. } else {
  27647. new_attrs.error = __('Sorry, an error occurred while trying to retract your message.');
  27648. }
  27649. }
  27650. } else if (!attrs.error) {
  27651. if (attrs.error_condition === 'forbidden') {
  27652. new_attrs.error = __("Your message was not delivered because you weren't allowed to send it.");
  27653. } else if (attrs.error_condition === 'not-acceptable') {
  27654. new_attrs.error = __("Your message was not delivered because you're not present in the groupchat.");
  27655. } else {
  27656. new_attrs.error = __('Sorry, an error occurred while trying to send your message.');
  27657. }
  27658. }
  27659. message.save(new_attrs);
  27660. } else {
  27661. this.createMessage(attrs);
  27662. }
  27663. },
  27664. /**
  27665. * Handles incoming message stanzas from the service that hosts this MUC
  27666. * @private
  27667. * @method _converse.ChatRoom#handleMessageFromMUCHost
  27668. * @param { XMLElement } stanza
  27669. */
  27670. handleMessageFromMUCHost(stanza) {
  27671. if (this.isEntered()) {
  27672. // We're not interested in activity indicators when already joined to the room
  27673. return;
  27674. }
  27675. const rai = sizzle_default()(`rai[xmlns="${Strophe.NS.RAI}"]`, stanza).pop();
  27676. const active_mucs = Array.from((rai === null || rai === void 0 ? void 0 : rai.querySelectorAll('activity')) || []).map(m => m.textContent);
  27677. if (active_mucs.includes(this.get('jid'))) {
  27678. this.save({
  27679. 'has_activity': true,
  27680. 'num_unread_general': 0 // Either/or between activity and unreads
  27681. });
  27682. }
  27683. },
  27684. /**
  27685. * Handles XEP-0452 MUC Mention Notification messages
  27686. * @private
  27687. * @method _converse.ChatRoom#handleForwardedMentions
  27688. * @param { XMLElement } stanza
  27689. */
  27690. handleForwardedMentions(stanza) {
  27691. if (this.isEntered()) {
  27692. // Avoid counting mentions twice
  27693. return;
  27694. }
  27695. const msgs = sizzle_default()(`mentions[xmlns="${Strophe.NS.MENTIONS}"] forwarded[xmlns="${Strophe.NS.FORWARD}"] message[type="groupchat"]`, stanza);
  27696. const muc_jid = this.get('jid');
  27697. const mentions = msgs.filter(m => Strophe.getBareJidFromJid(m.getAttribute('from')) === muc_jid);
  27698. if (mentions.length) {
  27699. this.save({
  27700. 'has_activity': true,
  27701. 'num_unread': this.get('num_unread') + mentions.length
  27702. });
  27703. mentions.forEach(async stanza => {
  27704. const attrs = await parseMUCMessage(stanza, this, shared_converse);
  27705. const data = {
  27706. stanza,
  27707. attrs,
  27708. 'chatbox': this
  27709. };
  27710. core_api.trigger('message', data);
  27711. });
  27712. }
  27713. },
  27714. /**
  27715. * Parses an incoming message stanza and queues it for processing.
  27716. * @private
  27717. * @method _converse.ChatRoom#handleMessageStanza
  27718. * @param { XMLElement } stanza
  27719. */
  27720. async handleMessageStanza(stanza) {
  27721. const type = stanza.getAttribute('type');
  27722. if (type === 'error') {
  27723. return this.handleErrorMessageStanza(stanza);
  27724. }
  27725. if (type === 'groupchat') {
  27726. if (isArchived(stanza)) {
  27727. // MAM messages are handled in converse-mam.
  27728. // We shouldn't get MAM messages here because
  27729. // they shouldn't have a `type` attribute.
  27730. return headless_log.warn(`Received a MAM message with type "groupchat"`);
  27731. }
  27732. this.createInfoMessages(stanza);
  27733. this.fetchFeaturesIfConfigurationChanged(stanza);
  27734. } else if (!type) {
  27735. return this.handleForwardedMentions(stanza);
  27736. }
  27737. /**
  27738. * @typedef { Object } MUCMessageData
  27739. * An object containing the parsed {@link MUCMessageAttributes} and
  27740. * current {@link ChatRoom}.
  27741. * @property { MUCMessageAttributes } attrs
  27742. * @property { ChatRoom } chatbox
  27743. */
  27744. let attrs;
  27745. try {
  27746. attrs = await parseMUCMessage(stanza, this, shared_converse);
  27747. } catch (e) {
  27748. return headless_log.error(e);
  27749. }
  27750. const data = {
  27751. stanza,
  27752. attrs,
  27753. 'chatbox': this
  27754. };
  27755. /**
  27756. * Triggered when a groupchat message stanza has been received and parsed.
  27757. * @event _converse#message
  27758. * @type { object }
  27759. * @property { module:converse-muc~MUCMessageData } data
  27760. */
  27761. core_api.trigger('message', data);
  27762. return attrs && this.queueMessage(attrs);
  27763. },
  27764. /**
  27765. * Register presence and message handlers relevant to this groupchat
  27766. * @private
  27767. * @method _converse.ChatRoom#registerHandlers
  27768. */
  27769. registerHandlers() {
  27770. const muc_jid = this.get('jid');
  27771. const muc_domain = Strophe.getDomainFromJid(muc_jid);
  27772. this.removeHandlers();
  27773. this.presence_handler = shared_converse.connection.addHandler(stanza => this.onPresence(stanza) || true, null, 'presence', null, null, muc_jid, {
  27774. 'ignoreNamespaceFragment': true,
  27775. 'matchBareFromJid': true
  27776. });
  27777. this.domain_presence_handler = shared_converse.connection.addHandler(stanza => this.onPresenceFromMUCHost(stanza) || true, null, 'presence', null, null, muc_domain);
  27778. this.message_handler = shared_converse.connection.addHandler(stanza => !!this.handleMessageStanza(stanza) || true, null, 'message', null, null, muc_jid, {
  27779. 'matchBareFromJid': true
  27780. });
  27781. this.domain_message_handler = shared_converse.connection.addHandler(stanza => this.handleMessageFromMUCHost(stanza) || true, null, 'message', null, null, muc_domain);
  27782. this.affiliation_message_handler = shared_converse.connection.addHandler(stanza => this.handleAffiliationChangedMessage(stanza) || true, Strophe.NS.MUC_USER, 'message', null, null, muc_jid);
  27783. },
  27784. removeHandlers() {
  27785. // Remove the presence and message handlers that were
  27786. // registered for this groupchat.
  27787. if (this.message_handler) {
  27788. shared_converse.connection && shared_converse.connection.deleteHandler(this.message_handler);
  27789. delete this.message_handler;
  27790. }
  27791. if (this.domain_message_handler) {
  27792. shared_converse.connection && shared_converse.connection.deleteHandler(this.domain_message_handler);
  27793. delete this.domain_message_handler;
  27794. }
  27795. if (this.presence_handler) {
  27796. shared_converse.connection && shared_converse.connection.deleteHandler(this.presence_handler);
  27797. delete this.presence_handler;
  27798. }
  27799. if (this.domain_presence_handler) {
  27800. shared_converse.connection && shared_converse.connection.deleteHandler(this.domain_presence_handler);
  27801. delete this.domain_presence_handler;
  27802. }
  27803. if (this.affiliation_message_handler) {
  27804. shared_converse.connection && shared_converse.connection.deleteHandler(this.affiliation_message_handler);
  27805. delete this.affiliation_message_handler;
  27806. }
  27807. return this;
  27808. },
  27809. invitesAllowed() {
  27810. return core_api.settings.get('allow_muc_invitations') && (this.features.get('open') || this.getOwnAffiliation() === 'owner');
  27811. },
  27812. getDisplayName() {
  27813. const name = this.get('name');
  27814. if (name) {
  27815. return name;
  27816. } else if (core_api.settings.get('locked_muc_domain') === 'hidden') {
  27817. return Strophe.getNodeFromJid(this.get('jid'));
  27818. } else {
  27819. return this.get('jid');
  27820. }
  27821. },
  27822. /**
  27823. * Sends a message stanza to the XMPP server and expects a reflection
  27824. * or error message within a specific timeout period.
  27825. * @private
  27826. * @method _converse.ChatRoom#sendTimedMessage
  27827. * @param { _converse.Message|XMLElement } message
  27828. * @returns { Promise<XMLElement>|Promise<_converse.TimeoutError> } Returns a promise
  27829. * which resolves with the reflected message stanza or with an error stanza or {@link _converse.TimeoutError}.
  27830. */
  27831. sendTimedMessage(el) {
  27832. if (typeof el.tree === 'function') {
  27833. el = el.tree();
  27834. }
  27835. let id = el.getAttribute('id');
  27836. if (!id) {
  27837. // inject id if not found
  27838. id = this.getUniqueId('sendIQ');
  27839. el.setAttribute('id', id);
  27840. }
  27841. const promise = getOpenPromise();
  27842. const timeoutHandler = shared_converse.connection.addTimedHandler(shared_converse.STANZA_TIMEOUT, () => {
  27843. shared_converse.connection.deleteHandler(handler);
  27844. const err = new shared_converse.TimeoutError('Timeout Error: No response from server');
  27845. promise.resolve(err);
  27846. return false;
  27847. });
  27848. const handler = shared_converse.connection.addHandler(stanza => {
  27849. timeoutHandler && shared_converse.connection.deleteTimedHandler(timeoutHandler);
  27850. promise.resolve(stanza);
  27851. }, null, 'message', ['error', 'groupchat'], id);
  27852. core_api.send(el);
  27853. return promise;
  27854. },
  27855. /**
  27856. * Retract one of your messages in this groupchat
  27857. * @private
  27858. * @method _converse.ChatRoom#retractOwnMessage
  27859. * @param { _converse.Message } message - The message which we're retracting.
  27860. */
  27861. async retractOwnMessage(message) {
  27862. const __ = shared_converse.__;
  27863. const origin_id = message.get('origin_id');
  27864. if (!origin_id) {
  27865. throw new Error("Can't retract message without a XEP-0359 Origin ID");
  27866. }
  27867. const editable = message.get('editable');
  27868. const stanza = $msg({
  27869. 'id': getUniqueId(),
  27870. 'to': this.get('jid'),
  27871. 'type': 'groupchat'
  27872. }).c('store', {
  27873. xmlns: Strophe.NS.HINTS
  27874. }).up().c('apply-to', {
  27875. 'id': origin_id,
  27876. 'xmlns': Strophe.NS.FASTEN
  27877. }).c('retract', {
  27878. xmlns: Strophe.NS.RETRACT
  27879. }); // Optimistic save
  27880. message.set({
  27881. 'retracted': new Date().toISOString(),
  27882. 'retracted_id': origin_id,
  27883. 'retraction_id': stanza.nodeTree.getAttribute('id'),
  27884. 'editable': false
  27885. });
  27886. const result = await this.sendTimedMessage(stanza);
  27887. if (utils_form.isErrorStanza(result)) {
  27888. headless_log.error(result);
  27889. } else if (result instanceof shared_converse.TimeoutError) {
  27890. headless_log.error(result);
  27891. message.save({
  27892. editable,
  27893. 'error_type': 'timeout',
  27894. 'error': __('A timeout happened while while trying to retract your message.'),
  27895. 'retracted': undefined,
  27896. 'retracted_id': undefined,
  27897. 'retraction_id': undefined
  27898. });
  27899. }
  27900. },
  27901. /**
  27902. * Retract someone else's message in this groupchat.
  27903. * @private
  27904. * @method _converse.ChatRoom#retractOtherMessage
  27905. * @param { _converse.Message } message - The message which we're retracting.
  27906. * @param { string } [reason] - The reason for retracting the message.
  27907. * @example
  27908. * const room = await api.rooms.get(jid);
  27909. * const message = room.messages.findWhere({'body': 'Get rich quick!'});
  27910. * room.retractOtherMessage(message, 'spam');
  27911. */
  27912. async retractOtherMessage(message, reason) {
  27913. const editable = message.get('editable'); // Optimistic save
  27914. message.save({
  27915. 'moderated': 'retracted',
  27916. 'moderated_by': shared_converse.bare_jid,
  27917. 'moderated_id': message.get('msgid'),
  27918. 'moderation_reason': reason,
  27919. 'editable': false
  27920. });
  27921. const result = await this.sendRetractionIQ(message, reason);
  27922. if (result === null || utils_form.isErrorStanza(result)) {
  27923. // Undo the save if something went wrong
  27924. message.save({
  27925. editable,
  27926. 'moderated': undefined,
  27927. 'moderated_by': undefined,
  27928. 'moderated_id': undefined,
  27929. 'moderation_reason': undefined
  27930. });
  27931. }
  27932. return result;
  27933. },
  27934. /**
  27935. * Sends an IQ stanza to the XMPP server to retract a message in this groupchat.
  27936. * @private
  27937. * @method _converse.ChatRoom#sendRetractionIQ
  27938. * @param { _converse.Message } message - The message which we're retracting.
  27939. * @param { string } [reason] - The reason for retracting the message.
  27940. */
  27941. sendRetractionIQ(message, reason) {
  27942. const iq = $iq({
  27943. 'to': this.get('jid'),
  27944. 'type': 'set'
  27945. }).c('apply-to', {
  27946. 'id': message.get(`stanza_id ${this.get('jid')}`),
  27947. 'xmlns': Strophe.NS.FASTEN
  27948. }).c('moderate', {
  27949. xmlns: Strophe.NS.MODERATE
  27950. }).c('retract', {
  27951. xmlns: Strophe.NS.RETRACT
  27952. }).up().c('reason').t(reason || '');
  27953. return core_api.sendIQ(iq, null, false);
  27954. },
  27955. /**
  27956. * Sends an IQ stanza to the XMPP server to destroy this groupchat. Not
  27957. * to be confused with the {@link _converse.ChatRoom#destroy}
  27958. * method, which simply removes the room from the local browser storage cache.
  27959. * @private
  27960. * @method _converse.ChatRoom#sendDestroyIQ
  27961. * @param { string } [reason] - The reason for destroying the groupchat.
  27962. * @param { string } [new_jid] - The JID of the new groupchat which replaces this one.
  27963. */
  27964. sendDestroyIQ(reason, new_jid) {
  27965. const destroy = $build('destroy');
  27966. if (new_jid) {
  27967. destroy.attrs({
  27968. 'jid': new_jid
  27969. });
  27970. }
  27971. const iq = $iq({
  27972. 'to': this.get('jid'),
  27973. 'type': 'set'
  27974. }).c('query', {
  27975. 'xmlns': Strophe.NS.MUC_OWNER
  27976. }).cnode(destroy.node);
  27977. if (reason && reason.length > 0) {
  27978. iq.c('reason', reason);
  27979. }
  27980. return core_api.sendIQ(iq);
  27981. },
  27982. /**
  27983. * Leave the groupchat.
  27984. * @private
  27985. * @method _converse.ChatRoom#leave
  27986. * @param { string } [exit_msg] - Message to indicate your reason for leaving
  27987. */
  27988. async leave(exit_msg) {
  27989. var _converse$disco_entit;
  27990. core_api.connection.connected() && core_api.user.presence.send('unavailable', this.getRoomJIDAndNick(), exit_msg); // Delete the features model
  27991. if (this.features) {
  27992. await new Promise(resolve => this.features.destroy({
  27993. 'success': resolve,
  27994. 'error': (_, e) => {
  27995. headless_log.error(e);
  27996. resolve();
  27997. }
  27998. }));
  27999. } // Delete disco entity
  28000. const disco_entity = (_converse$disco_entit = shared_converse.disco_entities) === null || _converse$disco_entit === void 0 ? void 0 : _converse$disco_entit.get(this.get('jid'));
  28001. if (disco_entity) {
  28002. await new Promise(resolve => disco_entity.destroy({
  28003. 'success': resolve,
  28004. 'error': (_, e) => {
  28005. headless_log.error(e);
  28006. resolve();
  28007. }
  28008. }));
  28009. }
  28010. safeSave(this.session, {
  28011. 'connection_status': core_converse.ROOMSTATUS.DISCONNECTED
  28012. });
  28013. },
  28014. async close(ev) {
  28015. safeSave(this.session, {
  28016. 'connection_status': core_converse.ROOMSTATUS.CLOSING
  28017. });
  28018. this.sendMarkerForLastMessage('received', true);
  28019. await this.unregisterNickname();
  28020. await this.leave();
  28021. this.occupants.clearStore();
  28022. if ((ev === null || ev === void 0 ? void 0 : ev.name) !== 'closeAllChatBoxes' && core_api.settings.get('muc_clear_messages_on_leave')) {
  28023. this.clearMessages();
  28024. } // Delete the session model
  28025. await new Promise(resolve => this.session.destroy({
  28026. 'success': resolve,
  28027. 'error': (_, e) => {
  28028. headless_log.error(e);
  28029. resolve();
  28030. }
  28031. }));
  28032. return shared_converse.ChatBox.prototype.close.call(this);
  28033. },
  28034. canModerateMessages() {
  28035. const self = this.getOwnOccupant();
  28036. return self && self.isModerator() && core_api.disco.supports(Strophe.NS.MODERATE, this.get('jid'));
  28037. },
  28038. /**
  28039. * Return an array of unique nicknames based on all occupants and messages in this MUC.
  28040. * @private
  28041. * @method _converse.ChatRoom#getAllKnownNicknames
  28042. * @returns { String[] }
  28043. */
  28044. getAllKnownNicknames() {
  28045. return [...new Set([...this.occupants.map(o => o.get('nick')), ...this.messages.map(m => m.get('nick'))])].filter(n => n);
  28046. },
  28047. getAllKnownNicknamesRegex() {
  28048. const longNickString = this.getAllKnownNicknames().map(n => parse_helpers.escapeRegexString(n)).join('|');
  28049. return RegExp(`(?:\\p{P}|\\p{Z}|^)@(${longNickString})(?![\\w@-])`, 'uig');
  28050. },
  28051. getOccupantByJID(jid) {
  28052. return this.occupants.findOccupant({
  28053. jid
  28054. });
  28055. },
  28056. getOccupantByNickname(nick) {
  28057. return this.occupants.findOccupant({
  28058. nick
  28059. });
  28060. },
  28061. /**
  28062. * Given a text message, look for `@` mentions and turn them into
  28063. * XEP-0372 references
  28064. * @param { String } text
  28065. */
  28066. parseTextForReferences(text) {
  28067. const mentions_regex = /(\p{P}|\p{Z}|^)([@][\w_-]+(?:\.\w+)*)/giu;
  28068. if (!text || !mentions_regex.test(text)) {
  28069. return [text, []];
  28070. }
  28071. const getMatchingNickname = parse_helpers.findFirstMatchInArray(this.getAllKnownNicknames());
  28072. const uriFromNickname = nickname => {
  28073. const jid = this.get('jid');
  28074. const occupant = this.getOccupant(nickname) || this.getOccupant(jid);
  28075. const uri = this.features.get('nonanonymous') && (occupant === null || occupant === void 0 ? void 0 : occupant.get('jid')) || `${jid}/${nickname}`;
  28076. return encodeURI(`xmpp:${uri}`);
  28077. };
  28078. const matchToReference = match => {
  28079. let at_sign_index = match[0].indexOf('@');
  28080. if (match[0][at_sign_index + 1] === '@') {
  28081. // edge-case
  28082. at_sign_index += 1;
  28083. }
  28084. const begin = match.index + at_sign_index;
  28085. const end = begin + match[0].length - at_sign_index;
  28086. const value = getMatchingNickname(match[1]);
  28087. const type = 'mention';
  28088. const uri = uriFromNickname(value);
  28089. return {
  28090. begin,
  28091. end,
  28092. value,
  28093. type,
  28094. uri
  28095. };
  28096. };
  28097. const regex = this.getAllKnownNicknamesRegex();
  28098. const mentions = [...text.matchAll(regex)].filter(m => !m[0].startsWith('/'));
  28099. const references = mentions.map(matchToReference);
  28100. const [updated_message, updated_references] = parse_helpers.reduceTextFromReferences(text, references);
  28101. return [updated_message, updated_references];
  28102. },
  28103. async getOutgoingMessageAttributes(attrs) {
  28104. var _attrs;
  28105. const is_spoiler = this.get('composing_spoiler');
  28106. let text = '',
  28107. references;
  28108. if ((_attrs = attrs) !== null && _attrs !== void 0 && _attrs.body) {
  28109. [text, references] = this.parseTextForReferences(attrs.body);
  28110. }
  28111. const origin_id = getUniqueId();
  28112. const body = text ? utils_form.httpToGeoUri(utils_form.shortnamesToUnicode(text), shared_converse) : undefined;
  28113. attrs = Object.assign({}, attrs, {
  28114. body,
  28115. is_spoiler,
  28116. origin_id,
  28117. references,
  28118. 'id': origin_id,
  28119. 'msgid': origin_id,
  28120. 'from': `${this.get('jid')}/${this.get('nick')}`,
  28121. 'fullname': this.get('nick'),
  28122. 'is_only_emojis': text ? utils_form.isOnlyEmojis(text) : false,
  28123. 'message': body,
  28124. 'nick': this.get('nick'),
  28125. 'sender': 'me',
  28126. 'type': 'groupchat'
  28127. }, getMediaURLsMetadata(text));
  28128. /**
  28129. * *Hook* which allows plugins to update the attributes of an outgoing
  28130. * message.
  28131. * @event _converse#getOutgoingMessageAttributes
  28132. */
  28133. attrs = await core_api.hook('getOutgoingMessageAttributes', this, attrs);
  28134. return attrs;
  28135. },
  28136. /**
  28137. * Utility method to construct the JID for the current user as occupant of the groupchat.
  28138. * @private
  28139. * @method _converse.ChatRoom#getRoomJIDAndNick
  28140. * @returns {string} - The groupchat JID with the user's nickname added at the end.
  28141. * @example groupchat@conference.example.org/nickname
  28142. */
  28143. getRoomJIDAndNick() {
  28144. const nick = this.get('nick');
  28145. const jid = Strophe.getBareJidFromJid(this.get('jid'));
  28146. return jid + (nick !== null ? `/${nick}` : '');
  28147. },
  28148. /**
  28149. * Sends a message with the current XEP-0085 chat state of the user
  28150. * as taken from the `chat_state` attribute of the {@link _converse.ChatRoom}.
  28151. * @private
  28152. * @method _converse.ChatRoom#sendChatState
  28153. */
  28154. sendChatState() {
  28155. if (!core_api.settings.get('send_chat_state_notifications') || !this.get('chat_state') || !this.isEntered() || this.features.get('moderated') && this.getOwnRole() === 'visitor') {
  28156. return;
  28157. }
  28158. const allowed = core_api.settings.get('send_chat_state_notifications');
  28159. if (Array.isArray(allowed) && !allowed.includes(this.get('chat_state'))) {
  28160. return;
  28161. }
  28162. const chat_state = this.get('chat_state');
  28163. if (chat_state === shared_converse.GONE) {
  28164. // <gone/> is not applicable within MUC context
  28165. return;
  28166. }
  28167. core_api.send($msg({
  28168. 'to': this.get('jid'),
  28169. 'type': 'groupchat'
  28170. }).c(chat_state, {
  28171. 'xmlns': Strophe.NS.CHATSTATES
  28172. }).up().c('no-store', {
  28173. 'xmlns': Strophe.NS.HINTS
  28174. }).up().c('no-permanent-store', {
  28175. 'xmlns': Strophe.NS.HINTS
  28176. }));
  28177. },
  28178. /**
  28179. * Send a direct invitation as per XEP-0249
  28180. * @private
  28181. * @method _converse.ChatRoom#directInvite
  28182. * @param { String } recipient - JID of the person being invited
  28183. * @param { String } [reason] - Reason for the invitation
  28184. */
  28185. directInvite(recipient, reason) {
  28186. if (this.features.get('membersonly')) {
  28187. // When inviting to a members-only groupchat, we first add
  28188. // the person to the member list by giving them an
  28189. // affiliation of 'member' otherwise they won't be able to join.
  28190. this.updateMemberLists([{
  28191. 'jid': recipient,
  28192. 'affiliation': 'member',
  28193. 'reason': reason
  28194. }]);
  28195. }
  28196. const attrs = {
  28197. 'xmlns': 'jabber:x:conference',
  28198. 'jid': this.get('jid')
  28199. };
  28200. if (reason !== null) {
  28201. attrs.reason = reason;
  28202. }
  28203. if (this.get('password')) {
  28204. attrs.password = this.get('password');
  28205. }
  28206. const invitation = $msg({
  28207. 'from': shared_converse.connection.jid,
  28208. 'to': recipient,
  28209. 'id': getUniqueId()
  28210. }).c('x', attrs);
  28211. core_api.send(invitation);
  28212. /**
  28213. * After the user has sent out a direct invitation (as per XEP-0249),
  28214. * to a roster contact, asking them to join a room.
  28215. * @event _converse#chatBoxMaximized
  28216. * @type {object}
  28217. * @property {_converse.ChatRoom} room
  28218. * @property {string} recipient - The JID of the person being invited
  28219. * @property {string} reason - The original reason for the invitation
  28220. * @example _converse.api.listen.on('chatBoxMaximized', view => { ... });
  28221. */
  28222. core_api.trigger('roomInviteSent', {
  28223. 'room': this,
  28224. 'recipient': recipient,
  28225. 'reason': reason
  28226. });
  28227. },
  28228. /**
  28229. * Refresh the disco identity, features and fields for this {@link _converse.ChatRoom}.
  28230. * *features* are stored on the features {@link Model} attribute on this {@link _converse.ChatRoom}.
  28231. * *fields* are stored on the config {@link Model} attribute on this {@link _converse.ChatRoom}.
  28232. * @private
  28233. * @returns {Promise}
  28234. */
  28235. refreshDiscoInfo() {
  28236. return core_api.disco.refresh(this.get('jid')).then(() => this.getDiscoInfo()).catch(e => headless_log.error(e));
  28237. },
  28238. /**
  28239. * Fetch the *extended* MUC info from the server and cache it locally
  28240. * https://xmpp.org/extensions/xep-0045.html#disco-roominfo
  28241. * @private
  28242. * @method _converse.ChatRoom#getDiscoInfo
  28243. * @returns {Promise}
  28244. */
  28245. getDiscoInfo() {
  28246. return core_api.disco.getIdentity('conference', 'text', this.get('jid')).then(identity => this.save({
  28247. 'name': identity === null || identity === void 0 ? void 0 : identity.get('name')
  28248. })).then(() => this.getDiscoInfoFields()).then(() => this.getDiscoInfoFeatures()).catch(e => headless_log.error(e));
  28249. },
  28250. /**
  28251. * Fetch the *extended* MUC info fields from the server and store them locally
  28252. * in the `config` {@link Model} attribute.
  28253. * See: https://xmpp.org/extensions/xep-0045.html#disco-roominfo
  28254. * @private
  28255. * @method _converse.ChatRoom#getDiscoInfoFields
  28256. * @returns {Promise}
  28257. */
  28258. async getDiscoInfoFields() {
  28259. const fields = await core_api.disco.getFields(this.get('jid'));
  28260. const config = fields.reduce((config, f) => {
  28261. const name = f.get('var');
  28262. if (name !== null && name !== void 0 && name.startsWith('muc#roominfo_')) {
  28263. config[name.replace('muc#roominfo_', '')] = f.get('value');
  28264. }
  28265. return config;
  28266. }, {});
  28267. this.config.save(config);
  28268. },
  28269. /**
  28270. * Use converse-disco to populate the features {@link Model} which
  28271. * is stored as an attibute on this {@link _converse.ChatRoom}.
  28272. * The results may be cached. If you want to force fetching the features from the
  28273. * server, call {@link _converse.ChatRoom#refreshDiscoInfo} instead.
  28274. * @private
  28275. * @returns {Promise}
  28276. */
  28277. async getDiscoInfoFeatures() {
  28278. const features = await core_api.disco.getFeatures(this.get('jid'));
  28279. const attrs = Object.assign(lodash_es_zipObject(core_converse.ROOM_FEATURES, core_converse.ROOM_FEATURES.map(() => false)), {
  28280. 'fetched': new Date().toISOString()
  28281. });
  28282. features.each(feature => {
  28283. const fieldname = feature.get('var');
  28284. if (!fieldname.startsWith('muc_')) {
  28285. if (fieldname === Strophe.NS.MAM) {
  28286. attrs.mam_enabled = true;
  28287. } else {
  28288. attrs[fieldname] = true;
  28289. }
  28290. return;
  28291. }
  28292. attrs[fieldname.replace('muc_', '')] = true;
  28293. });
  28294. this.features.save(attrs);
  28295. },
  28296. /**
  28297. * Given a <field> element, return a copy with a <value> child if
  28298. * we can find a value for it in this rooms config.
  28299. * @private
  28300. * @method _converse.ChatRoom#addFieldValue
  28301. * @returns { Element }
  28302. */
  28303. addFieldValue(field) {
  28304. const type = field.getAttribute('type');
  28305. if (type === 'fixed') {
  28306. return field;
  28307. }
  28308. const fieldname = field.getAttribute('var').replace('muc#roomconfig_', '');
  28309. const config = this.get('roomconfig');
  28310. if (fieldname in config) {
  28311. let values;
  28312. switch (type) {
  28313. case 'boolean':
  28314. values = [config[fieldname] ? 1 : 0];
  28315. break;
  28316. case 'list-multi':
  28317. values = config[fieldname];
  28318. break;
  28319. default:
  28320. values = [config[fieldname]];
  28321. }
  28322. field.innerHTML = values.map(v => $build('value').t(v)).join('');
  28323. }
  28324. return field;
  28325. },
  28326. /**
  28327. * Automatically configure the groupchat based on this model's
  28328. * 'roomconfig' data.
  28329. * @private
  28330. * @method _converse.ChatRoom#autoConfigureChatRoom
  28331. * @returns { Promise<XMLElement> }
  28332. * Returns a promise which resolves once a response IQ has
  28333. * been received.
  28334. */
  28335. async autoConfigureChatRoom() {
  28336. const stanza = await this.fetchRoomConfiguration();
  28337. const fields = sizzle_default()('field', stanza);
  28338. const configArray = fields.map(f => this.addFieldValue(f));
  28339. if (configArray.length) {
  28340. return this.sendConfiguration(configArray);
  28341. }
  28342. },
  28343. /**
  28344. * Send an IQ stanza to fetch the groupchat configuration data.
  28345. * Returns a promise which resolves once the response IQ
  28346. * has been received.
  28347. * @private
  28348. * @method _converse.ChatRoom#fetchRoomConfiguration
  28349. * @returns { Promise<XMLElement> }
  28350. */
  28351. fetchRoomConfiguration() {
  28352. return core_api.sendIQ($iq({
  28353. 'to': this.get('jid'),
  28354. 'type': 'get'
  28355. }).c('query', {
  28356. xmlns: Strophe.NS.MUC_OWNER
  28357. }));
  28358. },
  28359. /**
  28360. * Sends an IQ stanza with the groupchat configuration.
  28361. * @private
  28362. * @method _converse.ChatRoom#sendConfiguration
  28363. * @param { Array } config - The groupchat configuration
  28364. * @returns { Promise<XMLElement> } - A promise which resolves with
  28365. * the `result` stanza received from the XMPP server.
  28366. */
  28367. sendConfiguration() {
  28368. let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  28369. const iq = $iq({
  28370. to: this.get('jid'),
  28371. type: 'set'
  28372. }).c('query', {
  28373. xmlns: Strophe.NS.MUC_OWNER
  28374. }).c('x', {
  28375. xmlns: Strophe.NS.XFORM,
  28376. type: 'submit'
  28377. });
  28378. config.forEach(node => iq.cnode(node).up());
  28379. return core_api.sendIQ(iq);
  28380. },
  28381. onCommandError(err) {
  28382. const {
  28383. __
  28384. } = shared_converse;
  28385. headless_log.fatal(err);
  28386. const message = __('Sorry, an error happened while running the command.') + ' ' + __("Check your browser's developer console for details.");
  28387. this.createMessage({
  28388. message,
  28389. 'type': 'error'
  28390. });
  28391. },
  28392. getNickOrJIDFromCommandArgs(args) {
  28393. const {
  28394. __
  28395. } = shared_converse;
  28396. if (utils_form.isValidJID(args.trim())) {
  28397. return args.trim();
  28398. }
  28399. if (!args.startsWith('@')) {
  28400. args = '@' + args;
  28401. }
  28402. const [text, references] = this.parseTextForReferences(args); // eslint-disable-line no-unused-vars
  28403. if (!references.length) {
  28404. const message = __("Error: couldn't find a groupchat participant based on your arguments");
  28405. this.createMessage({
  28406. message,
  28407. 'type': 'error'
  28408. });
  28409. return;
  28410. }
  28411. if (references.length > 1) {
  28412. const message = __('Error: found multiple groupchat participant based on your arguments');
  28413. this.createMessage({
  28414. message,
  28415. 'type': 'error'
  28416. });
  28417. return;
  28418. }
  28419. const nick_or_jid = references.pop().value;
  28420. const reason = args.split(nick_or_jid, 2)[1];
  28421. if (reason && !reason.startsWith(' ')) {
  28422. const message = __("Error: couldn't find a groupchat participant based on your arguments");
  28423. this.createMessage({
  28424. message,
  28425. 'type': 'error'
  28426. });
  28427. return;
  28428. }
  28429. return nick_or_jid;
  28430. },
  28431. validateRoleOrAffiliationChangeArgs(command, args) {
  28432. const {
  28433. __
  28434. } = shared_converse;
  28435. if (!args) {
  28436. const message = __('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.', command);
  28437. this.createMessage({
  28438. message,
  28439. 'type': 'error'
  28440. });
  28441. return false;
  28442. }
  28443. return true;
  28444. },
  28445. getAllowedCommands() {
  28446. let allowed_commands = ['clear', 'help', 'me', 'nick', 'register'];
  28447. if (this.config.get('changesubject') || ['owner', 'admin'].includes(this.getOwnAffiliation())) {
  28448. allowed_commands = [...allowed_commands, ...['subject', 'topic']];
  28449. }
  28450. const occupant = this.occupants.findWhere({
  28451. 'jid': shared_converse.bare_jid
  28452. });
  28453. if (this.verifyAffiliations(['owner'], occupant, false)) {
  28454. allowed_commands = allowed_commands.concat(OWNER_COMMANDS).concat(ADMIN_COMMANDS);
  28455. } else if (this.verifyAffiliations(['admin'], occupant, false)) {
  28456. allowed_commands = allowed_commands.concat(ADMIN_COMMANDS);
  28457. }
  28458. if (this.verifyRoles(['moderator'], occupant, false)) {
  28459. allowed_commands = allowed_commands.concat(MODERATOR_COMMANDS).concat(VISITOR_COMMANDS);
  28460. } else if (!this.verifyRoles(['visitor', 'participant', 'moderator'], occupant, false)) {
  28461. allowed_commands = allowed_commands.concat(VISITOR_COMMANDS);
  28462. }
  28463. allowed_commands.sort();
  28464. if (Array.isArray(core_api.settings.get('muc_disable_slash_commands'))) {
  28465. return allowed_commands.filter(c => !core_api.settings.get('muc_disable_slash_commands').includes(c));
  28466. } else {
  28467. return allowed_commands;
  28468. }
  28469. },
  28470. verifyAffiliations(affiliations, occupant) {
  28471. let show_error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  28472. const {
  28473. __
  28474. } = shared_converse;
  28475. if (!Array.isArray(affiliations)) {
  28476. throw new TypeError('affiliations must be an Array');
  28477. }
  28478. if (!affiliations.length) {
  28479. return true;
  28480. }
  28481. occupant = occupant || this.occupants.findWhere({
  28482. 'jid': shared_converse.bare_jid
  28483. });
  28484. if (occupant) {
  28485. const a = occupant.get('affiliation');
  28486. if (affiliations.includes(a)) {
  28487. return true;
  28488. }
  28489. }
  28490. if (show_error) {
  28491. const message = __('Forbidden: you do not have the necessary affiliation in order to do that.');
  28492. this.createMessage({
  28493. message,
  28494. 'type': 'error'
  28495. });
  28496. }
  28497. return false;
  28498. },
  28499. verifyRoles(roles, occupant) {
  28500. let show_error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  28501. const {
  28502. __
  28503. } = shared_converse;
  28504. if (!Array.isArray(roles)) {
  28505. throw new TypeError('roles must be an Array');
  28506. }
  28507. if (!roles.length) {
  28508. return true;
  28509. }
  28510. occupant = occupant || this.occupants.findWhere({
  28511. 'jid': shared_converse.bare_jid
  28512. });
  28513. if (occupant) {
  28514. const role = occupant.get('role');
  28515. if (roles.includes(role)) {
  28516. return true;
  28517. }
  28518. }
  28519. if (show_error) {
  28520. const message = __('Forbidden: you do not have the necessary role in order to do that.');
  28521. this.createMessage({
  28522. message,
  28523. 'type': 'error',
  28524. 'is_ephemeral': 20000
  28525. });
  28526. }
  28527. return false;
  28528. },
  28529. /**
  28530. * Returns the `role` which the current user has in this MUC
  28531. * @private
  28532. * @method _converse.ChatRoom#getOwnRole
  28533. * @returns { ('none'|'visitor'|'participant'|'moderator') }
  28534. */
  28535. getOwnRole() {
  28536. var _this$getOwnOccupant, _this$getOwnOccupant$;
  28537. return (_this$getOwnOccupant = this.getOwnOccupant()) === null || _this$getOwnOccupant === void 0 ? void 0 : (_this$getOwnOccupant$ = _this$getOwnOccupant.attributes) === null || _this$getOwnOccupant$ === void 0 ? void 0 : _this$getOwnOccupant$.role;
  28538. },
  28539. /**
  28540. * Returns the `affiliation` which the current user has in this MUC
  28541. * @private
  28542. * @method _converse.ChatRoom#getOwnAffiliation
  28543. * @returns { ('none'|'outcast'|'member'|'admin'|'owner') }
  28544. */
  28545. getOwnAffiliation() {
  28546. var _this$getOwnOccupant2, _this$getOwnOccupant3;
  28547. return ((_this$getOwnOccupant2 = this.getOwnOccupant()) === null || _this$getOwnOccupant2 === void 0 ? void 0 : (_this$getOwnOccupant3 = _this$getOwnOccupant2.attributes) === null || _this$getOwnOccupant3 === void 0 ? void 0 : _this$getOwnOccupant3.affiliation) || 'none';
  28548. },
  28549. /**
  28550. * Get the {@link _converse.ChatRoomOccupant} instance which
  28551. * represents the current user.
  28552. * @method _converse.ChatRoom#getOwnOccupant
  28553. * @returns { _converse.ChatRoomOccupant }
  28554. */
  28555. getOwnOccupant() {
  28556. return this.occupants.getOwnOccupant();
  28557. },
  28558. /**
  28559. * Send a presence stanza to update the user's nickname in this MUC.
  28560. * @param { String } nick
  28561. */
  28562. async setNickname(nick) {
  28563. if (core_api.settings.get('auto_register_muc_nickname') && (await core_api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid')))) {
  28564. const old_nick = this.get('nick');
  28565. this.set({
  28566. nick
  28567. });
  28568. try {
  28569. await this.registerNickname();
  28570. } catch (e) {
  28571. const {
  28572. __
  28573. } = shared_converse;
  28574. headless_log.error(e);
  28575. const message = __("Error: couldn't register new nickname in members only room");
  28576. this.createMessage({
  28577. message,
  28578. 'type': 'error',
  28579. 'is_ephemeral': true
  28580. });
  28581. this.set({
  28582. 'nick': old_nick
  28583. });
  28584. return;
  28585. }
  28586. }
  28587. const jid = Strophe.getBareJidFromJid(this.get('jid'));
  28588. core_api.send($pres({
  28589. 'from': shared_converse.connection.jid,
  28590. 'to': `${jid}/${nick}`,
  28591. 'id': getUniqueId()
  28592. }).tree());
  28593. },
  28594. /**
  28595. * Send an IQ stanza to modify an occupant's role
  28596. * @private
  28597. * @method _converse.ChatRoom#setRole
  28598. * @param { _converse.ChatRoomOccupant } occupant
  28599. * @param { String } role
  28600. * @param { String } reason
  28601. * @param { function } onSuccess - callback for a succesful response
  28602. * @param { function } onError - callback for an error response
  28603. */
  28604. setRole(occupant, role, reason, onSuccess, onError) {
  28605. const item = $build('item', {
  28606. 'nick': occupant.get('nick'),
  28607. role
  28608. });
  28609. const iq = $iq({
  28610. 'to': this.get('jid'),
  28611. 'type': 'set'
  28612. }).c('query', {
  28613. xmlns: Strophe.NS.MUC_ADMIN
  28614. }).cnode(item.node);
  28615. if (reason !== null) {
  28616. iq.c('reason', reason);
  28617. }
  28618. return core_api.sendIQ(iq).then(onSuccess).catch(onError);
  28619. },
  28620. /**
  28621. * @private
  28622. * @method _converse.ChatRoom#getOccupant
  28623. * @param { String } nickname_or_jid - The nickname or JID of the occupant to be returned
  28624. * @returns { _converse.ChatRoomOccupant }
  28625. */
  28626. getOccupant(nickname_or_jid) {
  28627. return utils_form.isValidJID(nickname_or_jid) ? this.getOccupantByJID(nickname_or_jid) : this.getOccupantByNickname(nickname_or_jid);
  28628. },
  28629. /**
  28630. * Return an array of occupant models that have the required role
  28631. * @private
  28632. * @method _converse.ChatRoom#getOccupantsWithRole
  28633. * @param { String } role
  28634. * @returns { _converse.ChatRoomOccupant[] }
  28635. */
  28636. getOccupantsWithRole(role) {
  28637. return this.getOccupantsSortedBy('nick').filter(o => o.get('role') === role).map(item => {
  28638. return {
  28639. 'jid': item.get('jid'),
  28640. 'nick': item.get('nick'),
  28641. 'role': item.get('role')
  28642. };
  28643. });
  28644. },
  28645. /**
  28646. * Return an array of occupant models that have the required affiliation
  28647. * @private
  28648. * @method _converse.ChatRoom#getOccupantsWithAffiliation
  28649. * @param { String } affiliation
  28650. * @returns { _converse.ChatRoomOccupant[] }
  28651. */
  28652. getOccupantsWithAffiliation(affiliation) {
  28653. return this.getOccupantsSortedBy('nick').filter(o => o.get('affiliation') === affiliation).map(item => {
  28654. return {
  28655. 'jid': item.get('jid'),
  28656. 'nick': item.get('nick'),
  28657. 'affiliation': item.get('affiliation')
  28658. };
  28659. });
  28660. },
  28661. /**
  28662. * Return an array of occupant models, sorted according to the passed-in attribute.
  28663. * @private
  28664. * @method _converse.ChatRoom#getOccupantsSortedBy
  28665. * @param { String } attr - The attribute to sort the returned array by
  28666. * @returns { _converse.ChatRoomOccupant[] }
  28667. */
  28668. getOccupantsSortedBy(attr) {
  28669. return Array.from(this.occupants.models).sort((a, b) => a.get(attr) < b.get(attr) ? -1 : a.get(attr) > b.get(attr) ? 1 : 0);
  28670. },
  28671. /**
  28672. * Fetch the lists of users with the given affiliations.
  28673. * Then compute the delta between those users and
  28674. * the passed in members, and if it exists, send the delta
  28675. * to the XMPP server to update the member list.
  28676. * @private
  28677. * @method _converse.ChatRoom#updateMemberLists
  28678. * @param { object } members - Map of member jids and affiliations.
  28679. * @returns { Promise }
  28680. * A promise which is resolved once the list has been
  28681. * updated or once it's been established there's no need
  28682. * to update the list.
  28683. */
  28684. async updateMemberLists(members) {
  28685. const muc_jid = this.get('jid');
  28686. const all_affiliations = ['member', 'admin', 'owner'];
  28687. const aff_lists = await Promise.all(all_affiliations.map(a => getAffiliationList(a, muc_jid)));
  28688. const old_members = aff_lists.reduce((acc, val) => utils_form.isErrorObject(val) ? acc : [...val, ...acc], []);
  28689. await setAffiliations(muc_jid, computeAffiliationsDelta(true, false, members, old_members));
  28690. await this.occupants.fetchMembers();
  28691. },
  28692. /**
  28693. * Given a nick name, save it to the model state, otherwise, look
  28694. * for a server-side reserved nickname or default configured
  28695. * nickname and if found, persist that to the model state.
  28696. * @private
  28697. * @method _converse.ChatRoom#getAndPersistNickname
  28698. * @returns { Promise<string> } A promise which resolves with the nickname
  28699. */
  28700. async getAndPersistNickname(nick) {
  28701. nick = nick || this.get('nick') || (await this.getReservedNick()) || shared_converse.getDefaultMUCNickname();
  28702. if (nick) safeSave(this, {
  28703. nick
  28704. }, {
  28705. 'silent': true
  28706. });
  28707. return nick;
  28708. },
  28709. /**
  28710. * Use service-discovery to ask the XMPP server whether
  28711. * this user has a reserved nickname for this groupchat.
  28712. * If so, we'll use that, otherwise we render the nickname form.
  28713. * @private
  28714. * @method _converse.ChatRoom#getReservedNick
  28715. * @returns { Promise<string> } A promise which resolves with the reserved nick or null
  28716. */
  28717. async getReservedNick() {
  28718. const stanza = $iq({
  28719. 'to': this.get('jid'),
  28720. 'from': shared_converse.connection.jid,
  28721. 'type': 'get'
  28722. }).c('query', {
  28723. 'xmlns': Strophe.NS.DISCO_INFO,
  28724. 'node': 'x-roomuser-item'
  28725. });
  28726. const result = await core_api.sendIQ(stanza, null, false);
  28727. if (utils_form.isErrorObject(result)) {
  28728. throw result;
  28729. } // Result might be undefined due to a timeout
  28730. const identity_el = result === null || result === void 0 ? void 0 : result.querySelector('query[node="x-roomuser-item"] identity');
  28731. return identity_el ? identity_el.getAttribute('name') : null;
  28732. },
  28733. /**
  28734. * Send an IQ stanza to the MUC to register this user's nickname.
  28735. * This sets the user's affiliation to 'member' (if they weren't affiliated
  28736. * before) and reserves the nickname for this user, thereby preventing other
  28737. * users from using it in this MUC.
  28738. * See https://xmpp.org/extensions/xep-0045.html#register
  28739. * @private
  28740. * @method _converse.ChatRoom#registerNickname
  28741. */
  28742. async registerNickname() {
  28743. const {
  28744. __
  28745. } = shared_converse;
  28746. const nick = this.get('nick');
  28747. const jid = this.get('jid');
  28748. let iq, err_msg;
  28749. try {
  28750. iq = await core_api.sendIQ($iq({
  28751. 'to': jid,
  28752. 'type': 'get'
  28753. }).c('query', {
  28754. 'xmlns': Strophe.NS.MUC_REGISTER
  28755. }));
  28756. } catch (e) {
  28757. if (sizzle_default()(`not-allowed[xmlns="${Strophe.NS.STANZAS}"]`, e).length) {
  28758. err_msg = __("You're not allowed to register yourself in this groupchat.");
  28759. } else if (sizzle_default()(`registration-required[xmlns="${Strophe.NS.STANZAS}"]`, e).length) {
  28760. err_msg = __("You're not allowed to register in this groupchat because it's members-only.");
  28761. }
  28762. headless_log.error(e);
  28763. return err_msg;
  28764. }
  28765. const required_fields = sizzle_default()('field required', iq).map(f => f.parentElement);
  28766. if (required_fields.length > 1 && required_fields[0].getAttribute('var') !== 'muc#register_roomnick') {
  28767. return headless_log.error(`Can't register the user register in the groupchat ${jid} due to the required fields`);
  28768. }
  28769. try {
  28770. await core_api.sendIQ($iq({
  28771. 'to': jid,
  28772. 'type': 'set'
  28773. }).c('query', {
  28774. 'xmlns': Strophe.NS.MUC_REGISTER
  28775. }).c('x', {
  28776. 'xmlns': Strophe.NS.XFORM,
  28777. 'type': 'submit'
  28778. }).c('field', {
  28779. 'var': 'FORM_TYPE'
  28780. }).c('value').t('http://jabber.org/protocol/muc#register').up().up().c('field', {
  28781. 'var': 'muc#register_roomnick'
  28782. }).c('value').t(nick));
  28783. } catch (e) {
  28784. if (sizzle_default()(`service-unavailable[xmlns="${Strophe.NS.STANZAS}"]`, e).length) {
  28785. err_msg = __("Can't register your nickname in this groupchat, it doesn't support registration.");
  28786. } else if (sizzle_default()(`bad-request[xmlns="${Strophe.NS.STANZAS}"]`, e).length) {
  28787. err_msg = __("Can't register your nickname in this groupchat, invalid data form supplied.");
  28788. }
  28789. headless_log.error(err_msg);
  28790. headless_log.error(e);
  28791. return err_msg;
  28792. }
  28793. },
  28794. /**
  28795. * Check whether we should unregister the user from this MUC, and if so,
  28796. * call { @link _converse.ChatRoom#sendUnregistrationIQ }
  28797. * @method _converse.ChatRoom#unregisterNickname
  28798. */
  28799. async unregisterNickname() {
  28800. if (core_api.settings.get('auto_register_muc_nickname') === 'unregister') {
  28801. try {
  28802. if (await core_api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) {
  28803. await this.sendUnregistrationIQ();
  28804. }
  28805. } catch (e) {
  28806. headless_log.error(e);
  28807. }
  28808. }
  28809. },
  28810. /**
  28811. * Send an IQ stanza to the MUC to unregister this user's nickname.
  28812. * If the user had a 'member' affiliation, it'll be removed and their
  28813. * nickname will no longer be reserved and can instead be used (and
  28814. * registered) by other users.
  28815. * @method _converse.ChatRoom#sendUnregistrationIQ
  28816. */
  28817. sendUnregistrationIQ() {
  28818. const iq = $iq({
  28819. 'to': this.get('jid'),
  28820. 'type': 'set'
  28821. }).c('query', {
  28822. 'xmlns': Strophe.NS.MUC_REGISTER
  28823. }).c('remove');
  28824. return core_api.sendIQ(iq).catch(e => headless_log.error(e));
  28825. },
  28826. /**
  28827. * Given a presence stanza, update the occupant model based on its contents.
  28828. * @private
  28829. * @method _converse.ChatRoom#updateOccupantsOnPresence
  28830. * @param { XMLElement } pres - The presence stanza
  28831. */
  28832. updateOccupantsOnPresence(pres) {
  28833. var _occupant$attributes, _occupant$attributes2;
  28834. const data = parseMUCPresence(pres, this);
  28835. if (data.type === 'error' || !data.jid && !data.nick && !data.occupant_id) {
  28836. return true;
  28837. }
  28838. const occupant = this.occupants.findOccupant(data); // Destroy an unavailable occupant if this isn't a nick change operation and if they're not affiliated
  28839. if (data.type === 'unavailable' && occupant && !data.states.includes(core_converse.MUC_NICK_CHANGED_CODE) && !['admin', 'owner', 'member'].includes(data['affiliation'])) {
  28840. // Before destroying we set the new data, so that we can show the disconnection message
  28841. occupant.set(data);
  28842. occupant.destroy();
  28843. return;
  28844. }
  28845. const jid = data.jid || '';
  28846. const attributes = { ...data,
  28847. 'jid': Strophe.getBareJidFromJid(jid) || (occupant === null || occupant === void 0 ? void 0 : (_occupant$attributes = occupant.attributes) === null || _occupant$attributes === void 0 ? void 0 : _occupant$attributes.jid),
  28848. 'resource': Strophe.getResourceFromJid(jid) || (occupant === null || occupant === void 0 ? void 0 : (_occupant$attributes2 = occupant.attributes) === null || _occupant$attributes2 === void 0 ? void 0 : _occupant$attributes2.resource)
  28849. };
  28850. if (occupant) {
  28851. occupant.save(attributes);
  28852. } else {
  28853. this.occupants.create(attributes);
  28854. }
  28855. },
  28856. fetchFeaturesIfConfigurationChanged(stanza) {
  28857. // 104: configuration change
  28858. // 170: logging enabled
  28859. // 171: logging disabled
  28860. // 172: room no longer anonymous
  28861. // 173: room now semi-anonymous
  28862. // 174: room now fully anonymous
  28863. const codes = ['104', '170', '171', '172', '173', '174'];
  28864. if (sizzle_default()('status', stanza).filter(e => codes.includes(e.getAttribute('status'))).length) {
  28865. this.refreshDiscoInfo();
  28866. }
  28867. },
  28868. /**
  28869. * Given two JIDs, which can be either user JIDs or MUC occupant JIDs,
  28870. * determine whether they belong to the same user.
  28871. * @private
  28872. * @method _converse.ChatRoom#isSameUser
  28873. * @param { String } jid1
  28874. * @param { String } jid2
  28875. * @returns { Boolean }
  28876. */
  28877. isSameUser(jid1, jid2) {
  28878. const bare_jid1 = Strophe.getBareJidFromJid(jid1);
  28879. const bare_jid2 = Strophe.getBareJidFromJid(jid2);
  28880. const resource1 = Strophe.getResourceFromJid(jid1);
  28881. const resource2 = Strophe.getResourceFromJid(jid2);
  28882. if (utils_form.isSameBareJID(jid1, jid2)) {
  28883. if (bare_jid1 === this.get('jid')) {
  28884. // MUC JIDs
  28885. return resource1 === resource2;
  28886. } else {
  28887. return true;
  28888. }
  28889. } else {
  28890. const occupant1 = bare_jid1 === this.get('jid') ? this.occupants.findOccupant({
  28891. 'nick': resource1
  28892. }) : this.occupants.findOccupant({
  28893. 'jid': bare_jid1
  28894. });
  28895. const occupant2 = bare_jid2 === this.get('jid') ? this.occupants.findOccupant({
  28896. 'nick': resource2
  28897. }) : this.occupants.findOccupant({
  28898. 'jid': bare_jid2
  28899. });
  28900. return occupant1 === occupant2;
  28901. }
  28902. },
  28903. async isSubjectHidden() {
  28904. const jids = await core_api.user.settings.get('mucs_with_hidden_subject', []);
  28905. return jids.includes(this.get('jid'));
  28906. },
  28907. async toggleSubjectHiddenState() {
  28908. const muc_jid = this.get('jid');
  28909. const jids = await core_api.user.settings.get('mucs_with_hidden_subject', []);
  28910. if (jids.includes(this.get('jid'))) {
  28911. core_api.user.settings.set('mucs_with_hidden_subject', jids.filter(jid => jid !== muc_jid));
  28912. } else {
  28913. core_api.user.settings.set('mucs_with_hidden_subject', [...jids, muc_jid]);
  28914. }
  28915. },
  28916. /**
  28917. * Handle a possible subject change and return `true` if so.
  28918. * @private
  28919. * @method _converse.ChatRoom#handleSubjectChange
  28920. * @param { object } attrs - Attributes representing a received
  28921. * message, as returned by {@link parseMUCMessage}
  28922. */
  28923. async handleSubjectChange(attrs) {
  28924. const __ = shared_converse.__;
  28925. if (typeof attrs.subject === 'string' && !attrs.thread && !attrs.message) {
  28926. // https://xmpp.org/extensions/xep-0045.html#subject-mod
  28927. // -----------------------------------------------------
  28928. // The subject is changed by sending a message of type "groupchat" to the <room@service>,
  28929. // where the <message/> MUST contain a <subject/> element that specifies the new subject but
  28930. // MUST NOT contain a <body/> element (or a <thread/> element).
  28931. const subject = attrs.subject;
  28932. const author = attrs.nick;
  28933. safeSave(this, {
  28934. 'subject': {
  28935. author,
  28936. 'text': attrs.subject || ''
  28937. }
  28938. });
  28939. if (!attrs.is_delayed && author) {
  28940. const message = subject ? __('Topic set by %1$s', author) : __('Topic cleared by %1$s', author);
  28941. const prev_msg = this.messages.last();
  28942. if ((prev_msg === null || prev_msg === void 0 ? void 0 : prev_msg.get('nick')) !== attrs.nick || (prev_msg === null || prev_msg === void 0 ? void 0 : prev_msg.get('type')) !== 'info' || (prev_msg === null || prev_msg === void 0 ? void 0 : prev_msg.get('message')) !== message) {
  28943. this.createMessage({
  28944. message,
  28945. 'nick': attrs.nick,
  28946. 'type': 'info',
  28947. 'is_ephemeral': true
  28948. });
  28949. }
  28950. if (await this.isSubjectHidden()) {
  28951. this.toggleSubjectHiddenState();
  28952. }
  28953. }
  28954. return true;
  28955. }
  28956. return false;
  28957. },
  28958. /**
  28959. * Set the subject for this {@link _converse.ChatRoom}
  28960. * @private
  28961. * @method _converse.ChatRoom#setSubject
  28962. * @param { String } value
  28963. */
  28964. setSubject() {
  28965. let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  28966. core_api.send($msg({
  28967. to: this.get('jid'),
  28968. from: shared_converse.connection.jid,
  28969. type: 'groupchat'
  28970. }).c('subject', {
  28971. xmlns: 'jabber:client'
  28972. }).t(value).tree());
  28973. },
  28974. /**
  28975. * Is this a chat state notification that can be ignored,
  28976. * because it's old or because it's from us.
  28977. * @private
  28978. * @method _converse.ChatRoom#ignorableCSN
  28979. * @param { Object } attrs - The message attributes
  28980. */
  28981. ignorableCSN(attrs) {
  28982. return attrs.chat_state && !attrs.body && (attrs.is_delayed || this.isOwnMessage(attrs));
  28983. },
  28984. /**
  28985. * Determines whether the message is from ourselves by checking
  28986. * the `from` attribute. Doesn't check the `type` attribute.
  28987. * @private
  28988. * @method _converse.ChatRoom#isOwnMessage
  28989. * @param { Object|XMLElement|_converse.Message } msg
  28990. * @returns { boolean }
  28991. */
  28992. isOwnMessage(msg) {
  28993. let from;
  28994. if (lodash_es_isElement(msg)) {
  28995. from = msg.getAttribute('from');
  28996. } else if (msg instanceof shared_converse.Message) {
  28997. from = msg.get('from');
  28998. } else {
  28999. from = msg.from;
  29000. }
  29001. return Strophe.getResourceFromJid(from) == this.get('nick');
  29002. },
  29003. getUpdatedMessageAttributes(message, attrs) {
  29004. const new_attrs = shared_converse.ChatBox.prototype.getUpdatedMessageAttributes.call(this, message, attrs);
  29005. new_attrs['from_muc'] = attrs['from_muc'];
  29006. if (this.isOwnMessage(attrs)) {
  29007. const stanza_id_keys = Object.keys(attrs).filter(k => k.startsWith('stanza_id'));
  29008. Object.assign(new_attrs, lodash_es_pick(attrs, stanza_id_keys));
  29009. if (!message.get('received')) {
  29010. new_attrs.received = new Date().toISOString();
  29011. }
  29012. }
  29013. return new_attrs;
  29014. },
  29015. /**
  29016. * Send a MUC-0410 MUC Self-Ping stanza to room to determine
  29017. * whether we're still joined.
  29018. * @async
  29019. * @private
  29020. * @method _converse.ChatRoom#isJoined
  29021. * @returns {Promise<boolean>}
  29022. */
  29023. async isJoined() {
  29024. const jid = this.get('jid');
  29025. const ping = $iq({
  29026. 'to': `${jid}/${this.get('nick')}`,
  29027. 'type': 'get'
  29028. }).c('ping', {
  29029. 'xmlns': Strophe.NS.PING
  29030. });
  29031. try {
  29032. await core_api.sendIQ(ping);
  29033. } catch (e) {
  29034. if (e === null) {
  29035. headless_log.warn(`isJoined: Timeout error while checking whether we're joined to MUC: ${jid}`);
  29036. } else {
  29037. headless_log.warn(`isJoined: Apparently we're no longer connected to MUC: ${jid}`);
  29038. }
  29039. return false;
  29040. }
  29041. return true;
  29042. },
  29043. /**
  29044. * Sends a status update presence (i.e. based on the `<show>` element)
  29045. * @method _converse.ChatRoom#sendStatusPresence
  29046. * @param { String } type
  29047. * @param { String } [status] - An optional status message
  29048. * @param { Element[]|Strophe.Builder[]|Element|Strophe.Builder } [child_nodes]
  29049. * Nodes(s) to be added as child nodes of the `presence` XML element.
  29050. */
  29051. async sendStatusPresence(type, status, child_nodes) {
  29052. if (this.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED) {
  29053. const presence = await shared_converse.xmppstatus.constructPresence(type, this.getRoomJIDAndNick(), status);
  29054. child_nodes === null || child_nodes === void 0 ? void 0 : child_nodes.map(c => (c === null || c === void 0 ? void 0 : c.tree()) ?? c).forEach(c => presence.cnode(c).up());
  29055. core_api.send(presence);
  29056. }
  29057. },
  29058. /**
  29059. * Check whether we're still joined and re-join if not
  29060. * @async
  29061. * @method _converse.ChatRoom#rejoinIfNecessary
  29062. */
  29063. async rejoinIfNecessary() {
  29064. if (!(await this.isJoined())) {
  29065. this.rejoin();
  29066. return true;
  29067. }
  29068. },
  29069. /**
  29070. * @private
  29071. * @method _converse.ChatRoom#shouldShowErrorMessage
  29072. * @returns {Promise<boolean>}
  29073. */
  29074. async shouldShowErrorMessage(attrs) {
  29075. if (attrs.error_type === 'Decryption') {
  29076. if (attrs.error_message === "Message key not found. The counter was repeated or the key was not filled.") {
  29077. // OMEMO message which we already decrypted before
  29078. return false;
  29079. } else if (attrs.error_condition === 'not-encrypted-for-this-device') {
  29080. return false;
  29081. }
  29082. } else if (attrs.error_condition === 'not-acceptable' && (await this.rejoinIfNecessary())) {
  29083. return false;
  29084. }
  29085. return shared_converse.ChatBox.prototype.shouldShowErrorMessage.call(this, attrs);
  29086. },
  29087. /**
  29088. * Looks whether we already have a moderation message for this
  29089. * incoming message. If so, it's considered "dangling" because
  29090. * it probably hasn't been applied to anything yet, given that
  29091. * the relevant message is only coming in now.
  29092. * @private
  29093. * @method _converse.ChatRoom#findDanglingModeration
  29094. * @param { object } attrs - Attributes representing a received
  29095. * message, as returned by {@link parseMUCMessage}
  29096. * @returns { _converse.ChatRoomMessage }
  29097. */
  29098. findDanglingModeration(attrs) {
  29099. if (!this.messages.length) {
  29100. return null;
  29101. } // Only look for dangling moderation if there are newer
  29102. // messages than this one, since moderation come after.
  29103. if (this.messages.last().get('time') > attrs.time) {
  29104. // Search from latest backwards
  29105. const messages = Array.from(this.messages.models);
  29106. const stanza_id = attrs[`stanza_id ${this.get('jid')}`];
  29107. if (!stanza_id) {
  29108. return null;
  29109. }
  29110. messages.reverse();
  29111. return messages.find(_ref => {
  29112. let {
  29113. attributes
  29114. } = _ref;
  29115. return attributes.moderated === 'retracted' && attributes.moderated_id === stanza_id && attributes.moderated_by;
  29116. });
  29117. }
  29118. },
  29119. /**
  29120. * Handles message moderation based on the passed in attributes.
  29121. * @private
  29122. * @method _converse.ChatRoom#handleModeration
  29123. * @param { object } attrs - Attributes representing a received
  29124. * message, as returned by {@link parseMUCMessage}
  29125. * @returns { Boolean } Returns `true` or `false` depending on
  29126. * whether a message was moderated or not.
  29127. */
  29128. async handleModeration(attrs) {
  29129. const MODERATION_ATTRIBUTES = ['editable', 'moderated', 'moderated_by', 'moderated_id', 'moderation_reason'];
  29130. if (attrs.moderated === 'retracted') {
  29131. const query = {};
  29132. const key = `stanza_id ${this.get('jid')}`;
  29133. query[key] = attrs.moderated_id;
  29134. const message = this.messages.findWhere(query);
  29135. if (!message) {
  29136. attrs['dangling_moderation'] = true;
  29137. await this.createMessage(attrs);
  29138. return true;
  29139. }
  29140. message.save(lodash_es_pick(attrs, MODERATION_ATTRIBUTES));
  29141. return true;
  29142. } else {
  29143. // Check if we have dangling moderation message
  29144. const message = this.findDanglingModeration(attrs);
  29145. if (message) {
  29146. const moderation_attrs = lodash_es_pick(message.attributes, MODERATION_ATTRIBUTES);
  29147. const new_attrs = Object.assign({
  29148. 'dangling_moderation': false
  29149. }, attrs, moderation_attrs);
  29150. delete new_attrs['id']; // Delete id, otherwise a new cache entry gets created
  29151. message.save(new_attrs);
  29152. return true;
  29153. }
  29154. }
  29155. return false;
  29156. },
  29157. getNotificationsText() {
  29158. const {
  29159. __
  29160. } = shared_converse;
  29161. const actors_per_state = this.notifications.toJSON();
  29162. const role_changes = core_api.settings.get('muc_show_info_messages').filter(role_change => core_converse.MUC_ROLE_CHANGES_LIST.includes(role_change));
  29163. const join_leave_events = core_api.settings.get('muc_show_info_messages').filter(join_leave_event => core_converse.MUC_TRAFFIC_STATES_LIST.includes(join_leave_event));
  29164. const states = [...core_converse.CHAT_STATES, ...join_leave_events, ...role_changes];
  29165. return states.reduce((result, state) => {
  29166. const existing_actors = actors_per_state[state];
  29167. if (!(existing_actors !== null && existing_actors !== void 0 && existing_actors.length)) {
  29168. return result;
  29169. }
  29170. const actors = existing_actors.map(a => {
  29171. var _this$getOccupant;
  29172. return ((_this$getOccupant = this.getOccupant(a)) === null || _this$getOccupant === void 0 ? void 0 : _this$getOccupant.getDisplayName()) || a;
  29173. });
  29174. if (actors.length === 1) {
  29175. if (state === 'composing') {
  29176. return `${result}${__('%1$s is typing', actors[0])}\n`;
  29177. } else if (state === 'paused') {
  29178. return `${result}${__('%1$s has stopped typing', actors[0])}\n`;
  29179. } else if (state === shared_converse.GONE) {
  29180. return `${result}${__('%1$s has gone away', actors[0])}\n`;
  29181. } else if (state === 'entered') {
  29182. return `${result}${__('%1$s has entered the groupchat', actors[0])}\n`;
  29183. } else if (state === 'exited') {
  29184. return `${result}${__('%1$s has left the groupchat', actors[0])}\n`;
  29185. } else if (state === 'op') {
  29186. return `${result}${__('%1$s is now a moderator', actors[0])}\n`;
  29187. } else if (state === 'deop') {
  29188. return `${result}${__('%1$s is no longer a moderator', actors[0])}\n`;
  29189. } else if (state === 'voice') {
  29190. return `${result}${__('%1$s has been given a voice', actors[0])}\n`;
  29191. } else if (state === 'mute') {
  29192. return `${result}${__('%1$s has been muted', actors[0])}\n`;
  29193. }
  29194. } else if (actors.length > 1) {
  29195. let actors_str;
  29196. if (actors.length > 3) {
  29197. actors_str = `${Array.from(actors).slice(0, 2).join(', ')} and others`;
  29198. } else {
  29199. const last_actor = actors.pop();
  29200. actors_str = __('%1$s and %2$s', actors.join(', '), last_actor);
  29201. }
  29202. if (state === 'composing') {
  29203. return `${result}${__('%1$s are typing', actors_str)}\n`;
  29204. } else if (state === 'paused') {
  29205. return `${result}${__('%1$s have stopped typing', actors_str)}\n`;
  29206. } else if (state === shared_converse.GONE) {
  29207. return `${result}${__('%1$s have gone away', actors_str)}\n`;
  29208. } else if (state === 'entered') {
  29209. return `${result}${__('%1$s have entered the groupchat', actors_str)}\n`;
  29210. } else if (state === 'exited') {
  29211. return `${result}${__('%1$s have left the groupchat', actors_str)}\n`;
  29212. } else if (state === 'op') {
  29213. return `${result}${__('%1$s are now moderators', actors[0])}\n`;
  29214. } else if (state === 'deop') {
  29215. return `${result}${__('%1$s are no longer moderators', actors[0])}\n`;
  29216. } else if (state === 'voice') {
  29217. return `${result}${__('%1$s have been given voices', actors[0])}\n`;
  29218. } else if (state === 'mute') {
  29219. return `${result}${__('%1$s have been muted', actors[0])}\n`;
  29220. }
  29221. }
  29222. return result;
  29223. }, '');
  29224. },
  29225. /**
  29226. * @param {String} actor - The nickname of the actor that caused the notification
  29227. * @param {String|Array<String>} states - The state or states representing the type of notificcation
  29228. */
  29229. removeNotification(actor, states) {
  29230. const actors_per_state = this.notifications.toJSON();
  29231. states = Array.isArray(states) ? states : [states];
  29232. states.forEach(state => {
  29233. const existing_actors = Array.from(actors_per_state[state] || []);
  29234. if (existing_actors.includes(actor)) {
  29235. const idx = existing_actors.indexOf(actor);
  29236. existing_actors.splice(idx, 1);
  29237. this.notifications.set(state, Array.from(existing_actors));
  29238. }
  29239. });
  29240. },
  29241. /**
  29242. * Update the notifications model by adding the passed in nickname
  29243. * to the array of nicknames that all match a particular state.
  29244. *
  29245. * Removes the nickname from any other states it might be associated with.
  29246. *
  29247. * The state can be a XEP-0085 Chat State or a XEP-0045 join/leave
  29248. * state.
  29249. * @param {String} actor - The nickname of the actor that causes the notification
  29250. * @param {String} state - The state representing the type of notificcation
  29251. */
  29252. updateNotifications(actor, state) {
  29253. const actors_per_state = this.notifications.toJSON();
  29254. const existing_actors = actors_per_state[state] || [];
  29255. if (existing_actors.includes(actor)) {
  29256. return;
  29257. }
  29258. const reducer = (out, s) => {
  29259. if (s === state) {
  29260. out[s] = [...existing_actors, actor];
  29261. } else {
  29262. out[s] = (actors_per_state[s] || []).filter(a => a !== actor);
  29263. }
  29264. return out;
  29265. };
  29266. const actors_per_chat_state = core_converse.CHAT_STATES.reduce(reducer, {});
  29267. const actors_per_traffic_state = core_converse.MUC_TRAFFIC_STATES_LIST.reduce(reducer, {});
  29268. const actors_per_role_change = core_converse.MUC_ROLE_CHANGES_LIST.reduce(reducer, {});
  29269. this.notifications.set(Object.assign(actors_per_chat_state, actors_per_traffic_state, actors_per_role_change));
  29270. window.setTimeout(() => this.removeNotification(actor, state), 10000);
  29271. },
  29272. handleMetadataFastening(attrs) {
  29273. if (attrs.ogp_for_id) {
  29274. if (attrs.from !== this.get('jid')) {
  29275. // For now we only allow metadata from the MUC itself and not
  29276. // from individual users who are deemed less trustworthy.
  29277. return false;
  29278. }
  29279. const message = this.messages.findWhere({
  29280. 'origin_id': attrs.ogp_for_id
  29281. });
  29282. if (message) {
  29283. const old_list = message.get('ogp_metadata') || [];
  29284. if (old_list.filter(m => m['og:url'] === attrs['og:url']).length) {
  29285. // Don't add metadata for the same URL again
  29286. return false;
  29287. }
  29288. const list = [...old_list, lodash_es_pick(attrs, METADATA_ATTRIBUTES)];
  29289. message.save('ogp_metadata', list);
  29290. return true;
  29291. }
  29292. }
  29293. return false;
  29294. },
  29295. /**
  29296. * Given {@link MessageAttributes} look for XEP-0316 Room Notifications and create info
  29297. * messages for them.
  29298. * @param { XMLElement } stanza
  29299. */
  29300. handleMEPNotification(attrs) {
  29301. var _attrs$activities;
  29302. if (attrs.from !== this.get('jid') || !attrs.activities) {
  29303. return false;
  29304. }
  29305. (_attrs$activities = attrs.activities) === null || _attrs$activities === void 0 ? void 0 : _attrs$activities.forEach(activity_attrs => {
  29306. const data = Object.assign(attrs, activity_attrs);
  29307. this.createMessage(data); // Trigger so that notifications are shown
  29308. core_api.trigger('message', {
  29309. 'attrs': data,
  29310. 'chatbox': this
  29311. });
  29312. });
  29313. return !!attrs.activities.length;
  29314. },
  29315. /**
  29316. * Returns an already cached message (if it exists) based on the
  29317. * passed in attributes map.
  29318. * @method _converse.ChatRoom#getDuplicateMessage
  29319. * @param { object } attrs - Attributes representing a received
  29320. * message, as returned by {@link parseMUCMessage}
  29321. * @returns {Promise<_converse.Message>}
  29322. */
  29323. getDuplicateMessage(attrs) {
  29324. var _attrs$activities2;
  29325. if ((_attrs$activities2 = attrs.activities) !== null && _attrs$activities2 !== void 0 && _attrs$activities2.length) {
  29326. return this.messages.findWhere({
  29327. 'type': 'mep',
  29328. 'msgid': attrs.msgid
  29329. });
  29330. } else {
  29331. return shared_converse.ChatBox.prototype.getDuplicateMessage.call(this, attrs);
  29332. }
  29333. },
  29334. /**
  29335. * Handler for all MUC messages sent to this groupchat. This method
  29336. * shouldn't be called directly, instead {@link _converse.ChatRoom#queueMessage}
  29337. * should be called.
  29338. * @method _converse.ChatRoom#onMessage
  29339. * @param { MessageAttributes } attrs - A promise which resolves to the message attributes.
  29340. */
  29341. async onMessage(attrs) {
  29342. attrs = await attrs;
  29343. if (utils_form.isErrorObject(attrs)) {
  29344. attrs.stanza && headless_log.error(attrs.stanza);
  29345. return headless_log.error(attrs.message);
  29346. } else if (attrs.type === 'error' && !(await this.shouldShowErrorMessage(attrs))) {
  29347. return;
  29348. }
  29349. const message = this.getDuplicateMessage(attrs);
  29350. if (message) {
  29351. message.get('type') === 'groupchat' && this.updateMessage(message, attrs);
  29352. return;
  29353. } else if (attrs.receipt_id || attrs.is_marker || this.ignorableCSN(attrs)) {
  29354. return;
  29355. }
  29356. if (this.handleMetadataFastening(attrs) || this.handleMEPNotification(attrs) || (await this.handleRetraction(attrs)) || (await this.handleModeration(attrs)) || (await this.handleSubjectChange(attrs))) {
  29357. attrs.nick && this.removeNotification(attrs.nick, ['composing', 'paused']);
  29358. return;
  29359. }
  29360. this.setEditable(attrs, attrs.time);
  29361. if (attrs['chat_state']) {
  29362. this.updateNotifications(attrs.nick, attrs.chat_state);
  29363. }
  29364. if (utils_form.shouldCreateGroupchatMessage(attrs)) {
  29365. const msg = this.handleCorrection(attrs) || (await this.createMessage(attrs));
  29366. this.removeNotification(attrs.nick, ['composing', 'paused']);
  29367. this.handleUnreadMessage(msg);
  29368. }
  29369. },
  29370. handleModifyError(pres) {
  29371. var _pres$querySelector;
  29372. const text = (_pres$querySelector = pres.querySelector('error text')) === null || _pres$querySelector === void 0 ? void 0 : _pres$querySelector.textContent;
  29373. if (text) {
  29374. if (this.session.get('connection_status') === core_converse.ROOMSTATUS.CONNECTING) {
  29375. this.setDisconnectionState(text);
  29376. } else {
  29377. const attrs = {
  29378. 'type': 'error',
  29379. 'message': text,
  29380. 'is_ephemeral': true
  29381. };
  29382. this.createMessage(attrs);
  29383. }
  29384. }
  29385. },
  29386. /**
  29387. * Handle a presence stanza that disconnects the user from the MUC
  29388. * @param { XMLElement } stanza
  29389. */
  29390. handleDisconnection(stanza) {
  29391. var _item$querySelector;
  29392. const is_self = stanza.querySelector("status[code='110']") !== null;
  29393. const x = sizzle_default()(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza).pop();
  29394. if (!x) {
  29395. return;
  29396. }
  29397. const disconnection_codes = Object.keys(shared_converse.muc.disconnect_messages);
  29398. const codes = sizzle_default()('status', x).map(s => s.getAttribute('code')).filter(c => disconnection_codes.includes(c));
  29399. const disconnected = is_self && codes.length > 0;
  29400. if (!disconnected) {
  29401. return;
  29402. } // By using querySelector we assume here there is
  29403. // one <item> per <x xmlns='http://jabber.org/protocol/muc#user'>
  29404. // element. This appears to be a safe assumption, since
  29405. // each <x/> element pertains to a single user.
  29406. const item = x.querySelector('item');
  29407. const reason = item ? (_item$querySelector = item.querySelector('reason')) === null || _item$querySelector === void 0 ? void 0 : _item$querySelector.textContent : undefined;
  29408. const actor = item ? lodash_es_invoke(item.querySelector('actor'), 'getAttribute', 'nick') : undefined;
  29409. const message = shared_converse.muc.disconnect_messages[codes[0]];
  29410. const status = codes.includes('301') ? core_converse.ROOMSTATUS.BANNED : core_converse.ROOMSTATUS.DISCONNECTED;
  29411. this.setDisconnectionState(message, reason, actor, status);
  29412. },
  29413. getActionInfoMessage(code, nick, actor) {
  29414. const __ = shared_converse.__;
  29415. if (code === '301') {
  29416. return actor ? __('%1$s has been banned by %2$s', nick, actor) : __('%1$s has been banned', nick);
  29417. } else if (code === '303') {
  29418. return __("%1$s's nickname has changed", nick);
  29419. } else if (code === '307') {
  29420. return actor ? __('%1$s has been kicked out by %2$s', nick, actor) : __('%1$s has been kicked out', nick);
  29421. } else if (code === '321') {
  29422. return __('%1$s has been removed because of an affiliation change', nick);
  29423. } else if (code === '322') {
  29424. return __('%1$s has been removed for not being a member', nick);
  29425. }
  29426. },
  29427. createAffiliationChangeMessage(occupant) {
  29428. const __ = shared_converse.__;
  29429. const previous_affiliation = occupant._previousAttributes.affiliation;
  29430. if (!previous_affiliation) {
  29431. // If no previous affiliation was set, then we don't
  29432. // interpret this as an affiliation change.
  29433. // For example, if muc_send_probes is true, then occupants
  29434. // are created based on incoming messages, in which case
  29435. // we don't yet know the affiliation
  29436. return;
  29437. }
  29438. const current_affiliation = occupant.get('affiliation');
  29439. if (previous_affiliation === 'admin' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.EXADMIN)) {
  29440. this.createMessage({
  29441. 'type': 'info',
  29442. 'message': __('%1$s is no longer an admin of this groupchat', occupant.get('nick'))
  29443. });
  29444. } else if (previous_affiliation === 'owner' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.EXOWNER)) {
  29445. this.createMessage({
  29446. 'type': 'info',
  29447. 'message': __('%1$s is no longer an owner of this groupchat', occupant.get('nick'))
  29448. });
  29449. } else if (previous_affiliation === 'outcast' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.EXOUTCAST)) {
  29450. this.createMessage({
  29451. 'type': 'info',
  29452. 'message': __('%1$s is no longer banned from this groupchat', occupant.get('nick'))
  29453. });
  29454. }
  29455. if (current_affiliation === 'none' && previous_affiliation === 'member' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.EXMEMBER)) {
  29456. this.createMessage({
  29457. 'type': 'info',
  29458. 'message': __('%1$s is no longer a member of this groupchat', occupant.get('nick'))
  29459. });
  29460. }
  29461. if (current_affiliation === 'member' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.MEMBER)) {
  29462. this.createMessage({
  29463. 'type': 'info',
  29464. 'message': __('%1$s is now a member of this groupchat', occupant.get('nick'))
  29465. });
  29466. } else if (current_affiliation === 'admin' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.ADMIN) || current_affiliation == 'owner' && shared_converse.isInfoVisible(core_converse.AFFILIATION_CHANGES.OWNER)) {
  29467. // For example: AppleJack is now an (admin|owner) of this groupchat
  29468. this.createMessage({
  29469. 'type': 'info',
  29470. 'message': __('%1$s is now an %2$s of this groupchat', occupant.get('nick'), current_affiliation)
  29471. });
  29472. }
  29473. },
  29474. createRoleChangeMessage(occupant, changed) {
  29475. if (changed === 'none' || occupant.changed.affiliation) {
  29476. // We don't inform of role changes if they accompany affiliation changes.
  29477. return;
  29478. }
  29479. const previous_role = occupant._previousAttributes.role;
  29480. if (previous_role === 'moderator' && shared_converse.isInfoVisible(core_converse.MUC_ROLE_CHANGES.DEOP)) {
  29481. this.updateNotifications(occupant.get('nick'), core_converse.MUC_ROLE_CHANGES.DEOP);
  29482. } else if (previous_role === 'visitor' && shared_converse.isInfoVisible(core_converse.MUC_ROLE_CHANGES.VOICE)) {
  29483. this.updateNotifications(occupant.get('nick'), core_converse.MUC_ROLE_CHANGES.VOICE);
  29484. }
  29485. if (occupant.get('role') === 'visitor' && shared_converse.isInfoVisible(core_converse.MUC_ROLE_CHANGES.MUTE)) {
  29486. this.updateNotifications(occupant.get('nick'), core_converse.MUC_ROLE_CHANGES.MUTE);
  29487. } else if (occupant.get('role') === 'moderator') {
  29488. if (!['owner', 'admin'].includes(occupant.get('affiliation')) && shared_converse.isInfoVisible(core_converse.MUC_ROLE_CHANGES.OP)) {
  29489. // Oly show this message if the user isn't already
  29490. // an admin or owner, otherwise this isn't new information.
  29491. this.updateNotifications(occupant.get('nick'), core_converse.MUC_ROLE_CHANGES.OP);
  29492. }
  29493. }
  29494. },
  29495. /**
  29496. * Create an info message based on a received MUC status code
  29497. * @private
  29498. * @method _converse.ChatRoom#createInfoMessage
  29499. * @param { string } code - The MUC status code
  29500. * @param { XMLElement } stanza - The original stanza that contains the code
  29501. * @param { Boolean } is_self - Whether this stanza refers to our own presence
  29502. */
  29503. createInfoMessage(code, stanza, is_self) {
  29504. const __ = shared_converse.__;
  29505. const data = {
  29506. 'type': 'info',
  29507. 'is_ephemeral': true
  29508. };
  29509. if (!shared_converse.isInfoVisible(code)) {
  29510. return;
  29511. }
  29512. if (code === '110' || code === '100' && !is_self) {
  29513. return;
  29514. } else if (code in shared_converse.muc.info_messages) {
  29515. data.message = shared_converse.muc.info_messages[code];
  29516. } else if (!is_self && ACTION_INFO_CODES.includes(code)) {
  29517. var _item$querySelector2, _item$querySelector3;
  29518. const nick = Strophe.getResourceFromJid(stanza.getAttribute('from'));
  29519. const item = sizzle_default()(`x[xmlns="${Strophe.NS.MUC_USER}"] item`, stanza).pop();
  29520. data.actor = item ? (_item$querySelector2 = item.querySelector('actor')) === null || _item$querySelector2 === void 0 ? void 0 : _item$querySelector2.getAttribute('nick') : undefined;
  29521. data.reason = item ? (_item$querySelector3 = item.querySelector('reason')) === null || _item$querySelector3 === void 0 ? void 0 : _item$querySelector3.textContent : undefined;
  29522. data.message = this.getActionInfoMessage(code, nick, data.actor);
  29523. } else if (is_self && code in shared_converse.muc.new_nickname_messages) {
  29524. // XXX: Side-effect of setting the nick. Should ideally be refactored out of this method
  29525. let nick;
  29526. if (is_self && code === '210') {
  29527. nick = Strophe.getResourceFromJid(stanza.getAttribute('from'));
  29528. } else if (is_self && code === '303') {
  29529. nick = sizzle_default()(`x[xmlns="${Strophe.NS.MUC_USER}"] item`, stanza).pop().getAttribute('nick');
  29530. }
  29531. this.save('nick', nick);
  29532. data.message = __(shared_converse.muc.new_nickname_messages[code], nick);
  29533. }
  29534. if (data.message) {
  29535. if (code === '201' && this.messages.findWhere(data)) {
  29536. return;
  29537. }
  29538. this.createMessage(data);
  29539. }
  29540. },
  29541. /**
  29542. * Create info messages based on a received presence or message stanza
  29543. * @private
  29544. * @method _converse.ChatRoom#createInfoMessages
  29545. * @param { XMLElement } stanza
  29546. */
  29547. createInfoMessages(stanza) {
  29548. const codes = sizzle_default()(`x[xmlns="${Strophe.NS.MUC_USER}"] status`, stanza).map(s => s.getAttribute('code'));
  29549. if (codes.includes('333') && codes.includes('307')) {
  29550. // See: https://github.com/xsf/xeps/pull/969/files#diff-ac5113766e59219806793c1f7d967f1bR4966
  29551. codes.splice(codes.indexOf('307'), 1);
  29552. }
  29553. const is_self = codes.includes('110');
  29554. codes.forEach(code => this.createInfoMessage(code, stanza, is_self));
  29555. },
  29556. /**
  29557. * Set parameters regarding disconnection from this room. This helps to
  29558. * communicate to the user why they were disconnected.
  29559. * @param { String } message - The disconnection message, as received from (or
  29560. * implied by) the server.
  29561. * @param { String } reason - The reason provided for the disconnection
  29562. * @param { String } actor - The person (if any) responsible for this disconnection
  29563. * @param { Integer } status - The status code (see `converse.ROOMSTATUS`)
  29564. */
  29565. setDisconnectionState(message, reason, actor) {
  29566. let status = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : core_converse.ROOMSTATUS.DISCONNECTED;
  29567. this.session.save({
  29568. 'connection_status': status,
  29569. 'disconnection_actor': actor,
  29570. 'disconnection_message': message,
  29571. 'disconnection_reason': reason
  29572. });
  29573. },
  29574. onNicknameClash(presence) {
  29575. const __ = shared_converse.__;
  29576. if (core_api.settings.get('muc_nickname_from_jid')) {
  29577. const nick = presence.getAttribute('from').split('/')[1];
  29578. if (nick === shared_converse.getDefaultMUCNickname()) {
  29579. this.join(nick + '-2');
  29580. } else {
  29581. const del = nick.lastIndexOf('-');
  29582. const num = nick.substring(del + 1, nick.length);
  29583. this.join(nick.substring(0, del + 1) + String(Number(num) + 1));
  29584. }
  29585. } else {
  29586. this.save({
  29587. 'nickname_validation_message': __('The nickname you chose is reserved or ' + 'currently in use, please choose a different one.')
  29588. });
  29589. this.session.save({
  29590. 'connection_status': core_converse.ROOMSTATUS.NICKNAME_REQUIRED
  29591. });
  29592. }
  29593. },
  29594. /**
  29595. * Parses a <presence> stanza with type "error" and sets the proper
  29596. * `connection_status` value for this {@link _converse.ChatRoom} as
  29597. * well as any additional output that can be shown to the user.
  29598. * @private
  29599. * @param { XMLElement } stanza - The presence stanza
  29600. */
  29601. onErrorPresence(stanza) {
  29602. var _sizzle$pop;
  29603. const __ = shared_converse.__;
  29604. const error = stanza.querySelector('error');
  29605. const error_type = error.getAttribute('type');
  29606. const reason = (_sizzle$pop = sizzle_default()(`text[xmlns="${Strophe.NS.STANZAS}"]`, error).pop()) === null || _sizzle$pop === void 0 ? void 0 : _sizzle$pop.textContent;
  29607. if (error_type === 'modify') {
  29608. this.handleModifyError(stanza);
  29609. } else if (error_type === 'auth') {
  29610. if (sizzle_default()(`not-authorized[xmlns="${Strophe.NS.STANZAS}"]`, error).length) {
  29611. this.save({
  29612. 'password_validation_message': reason || __('Password incorrect')
  29613. });
  29614. this.session.save({
  29615. 'connection_status': core_converse.ROOMSTATUS.PASSWORD_REQUIRED
  29616. });
  29617. }
  29618. if (error.querySelector('registration-required')) {
  29619. const message = __('You are not on the member list of this groupchat.');
  29620. this.setDisconnectionState(message, reason);
  29621. } else if (error.querySelector('forbidden')) {
  29622. this.setDisconnectionState(shared_converse.muc.disconnect_messages[301], reason, null, core_converse.ROOMSTATUS.BANNED);
  29623. }
  29624. } else if (error_type === 'cancel') {
  29625. if (error.querySelector('not-allowed')) {
  29626. const message = __('You are not allowed to create new groupchats.');
  29627. this.setDisconnectionState(message, reason);
  29628. } else if (error.querySelector('not-acceptable')) {
  29629. const message = __("Your nickname doesn't conform to this groupchat's policies.");
  29630. this.setDisconnectionState(message, reason);
  29631. } else if (sizzle_default()(`gone[xmlns="${Strophe.NS.STANZAS}"]`, error).length) {
  29632. var _sizzle$pop2;
  29633. const moved_jid = (_sizzle$pop2 = sizzle_default()(`gone[xmlns="${Strophe.NS.STANZAS}"]`, error).pop()) === null || _sizzle$pop2 === void 0 ? void 0 : _sizzle$pop2.textContent.replace(/^xmpp:/, '').replace(/\?join$/, '');
  29634. this.save({
  29635. moved_jid,
  29636. 'destroyed_reason': reason
  29637. });
  29638. this.session.save({
  29639. 'connection_status': core_converse.ROOMSTATUS.DESTROYED
  29640. });
  29641. } else if (error.querySelector('conflict')) {
  29642. this.onNicknameClash(stanza);
  29643. } else if (error.querySelector('item-not-found')) {
  29644. const message = __('This groupchat does not (yet) exist.');
  29645. this.setDisconnectionState(message, reason);
  29646. } else if (error.querySelector('service-unavailable')) {
  29647. const message = __('This groupchat has reached its maximum number of participants.');
  29648. this.setDisconnectionState(message, reason);
  29649. } else if (error.querySelector('remote-server-not-found')) {
  29650. const message = __('Remote server not found');
  29651. this.setDisconnectionState(message, reason);
  29652. } else if (error.querySelector('forbidden')) {
  29653. const message = __("You're not allowed to enter this groupchat");
  29654. this.setDisconnectionState(message, reason);
  29655. } else {
  29656. const message = __("An error happened while trying to enter this groupchat");
  29657. this.setDisconnectionState(message, reason);
  29658. }
  29659. }
  29660. },
  29661. /**
  29662. * Listens for incoming presence stanzas from the service that hosts this MUC
  29663. * @private
  29664. * @method _converse.ChatRoom#onPresenceFromMUCHost
  29665. * @param { XMLElement } stanza - The presence stanza
  29666. */
  29667. onPresenceFromMUCHost(stanza) {
  29668. if (stanza.getAttribute('type') === 'error') {
  29669. const error = stanza.querySelector('error');
  29670. if ((error === null || error === void 0 ? void 0 : error.getAttribute('type')) === 'wait' && error !== null && error !== void 0 && error.querySelector('resource-constraint')) {
  29671. // If we get a <resource-constraint> error, we assume it's in context of XEP-0437 RAI.
  29672. // We remove this MUC's host from the list of enabled domains and rejoin the MUC.
  29673. if (this.session.get('connection_status') === core_converse.ROOMSTATUS.DISCONNECTED) {
  29674. this.rejoin();
  29675. }
  29676. }
  29677. }
  29678. },
  29679. /**
  29680. * Handles incoming presence stanzas coming from the MUC
  29681. * @private
  29682. * @method _converse.ChatRoom#onPresence
  29683. * @param { XMLElement } stanza
  29684. */
  29685. onPresence(stanza) {
  29686. if (stanza.getAttribute('type') === 'error') {
  29687. return this.onErrorPresence(stanza);
  29688. }
  29689. this.createInfoMessages(stanza);
  29690. if (stanza.querySelector("status[code='110']")) {
  29691. this.onOwnPresence(stanza);
  29692. if (this.getOwnRole() !== 'none' && this.session.get('connection_status') === core_converse.ROOMSTATUS.CONNECTING) {
  29693. this.session.save('connection_status', core_converse.ROOMSTATUS.CONNECTED);
  29694. }
  29695. } else {
  29696. this.updateOccupantsOnPresence(stanza);
  29697. }
  29698. },
  29699. /**
  29700. * Handles a received presence relating to the current user.
  29701. *
  29702. * For locked groupchats (which are by definition "new"), the
  29703. * groupchat will either be auto-configured or created instantly
  29704. * (with default config) or a configuration groupchat will be
  29705. * rendered.
  29706. *
  29707. * If the groupchat is not locked, then the groupchat will be
  29708. * auto-configured only if applicable and if the current
  29709. * user is the groupchat's owner.
  29710. * @private
  29711. * @method _converse.ChatRoom#onOwnPresence
  29712. * @param { XMLElement } pres - The stanza
  29713. */
  29714. async onOwnPresence(stanza) {
  29715. await this.occupants.fetched;
  29716. const old_status = this.session.get('connection_status');
  29717. if (stanza.getAttribute('type') !== 'unavailable' && old_status !== core_converse.ROOMSTATUS.ENTERED && old_status !== core_converse.ROOMSTATUS.CLOSING) {
  29718. // Set connection_status before creating the occupant, but
  29719. // only trigger afterwards, so that plugins can access the
  29720. // occupant in their event handlers.
  29721. this.session.save('connection_status', core_converse.ROOMSTATUS.ENTERED, {
  29722. 'silent': true
  29723. });
  29724. this.updateOccupantsOnPresence(stanza);
  29725. this.session.trigger('change:connection_status', this.session, old_status);
  29726. } else {
  29727. this.updateOccupantsOnPresence(stanza);
  29728. }
  29729. if (stanza.getAttribute('type') === 'unavailable') {
  29730. this.handleDisconnection(stanza);
  29731. return;
  29732. } else {
  29733. const locked_room = stanza.querySelector("status[code='201']");
  29734. if (locked_room) {
  29735. if (this.get('auto_configure')) {
  29736. this.autoConfigureChatRoom().then(() => this.refreshDiscoInfo());
  29737. } else if (core_api.settings.get('muc_instant_rooms')) {
  29738. // Accept default configuration
  29739. this.sendConfiguration().then(() => this.refreshDiscoInfo());
  29740. } else {
  29741. this.session.save({
  29742. 'view': core_converse.MUC.VIEWS.CONFIG
  29743. });
  29744. return;
  29745. }
  29746. } else if (!this.features.get('fetched')) {
  29747. // The features for this groupchat weren't fetched.
  29748. // That must mean it's a new groupchat without locking
  29749. // (in which case Prosody doesn't send a 201 status),
  29750. // otherwise the features would have been fetched in
  29751. // the "initialize" method already.
  29752. if (this.getOwnAffiliation() === 'owner' && this.get('auto_configure')) {
  29753. this.autoConfigureChatRoom().then(() => this.refreshDiscoInfo());
  29754. } else {
  29755. this.getDiscoInfo();
  29756. }
  29757. }
  29758. }
  29759. },
  29760. /**
  29761. * Returns a boolean to indicate whether the current user
  29762. * was mentioned in a message.
  29763. * @private
  29764. * @method _converse.ChatRoom#isUserMentioned
  29765. * @param { String } - The text message
  29766. */
  29767. isUserMentioned(message) {
  29768. const nick = this.get('nick');
  29769. if (message.get('references').length) {
  29770. const mentions = message.get('references').filter(ref => ref.type === 'mention').map(ref => ref.value);
  29771. return mentions.includes(nick);
  29772. } else {
  29773. return new RegExp(`\\b${nick}\\b`).test(message.get('body'));
  29774. }
  29775. },
  29776. incrementUnreadMsgsCounter(message) {
  29777. const settings = {
  29778. 'num_unread_general': this.get('num_unread_general') + 1
  29779. };
  29780. if (this.get('num_unread_general') === 0) {
  29781. settings['first_unread_id'] = message.get('id');
  29782. }
  29783. if (this.isUserMentioned(message)) {
  29784. settings.num_unread = this.get('num_unread') + 1;
  29785. }
  29786. this.save(settings);
  29787. },
  29788. clearUnreadMsgCounter() {
  29789. if (this.get('num_unread_general') > 0 || this.get('num_unread') > 0 || this.get('has_activity')) {
  29790. this.sendMarkerForMessage(this.messages.last());
  29791. }
  29792. safeSave(this, {
  29793. 'has_activity': false,
  29794. 'num_unread': 0,
  29795. 'num_unread_general': 0
  29796. });
  29797. }
  29798. };
  29799. /* harmony default export */ const muc = (ChatRoomMixin);
  29800. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/occupant.js
  29801. /**
  29802. * Represents a participant in a MUC
  29803. * @class
  29804. * @namespace _converse.ChatRoomOccupant
  29805. * @memberOf _converse
  29806. */
  29807. class ChatRoomOccupant extends Model {
  29808. defaults() {
  29809. // eslint-disable-line class-methods-use-this
  29810. return {
  29811. 'hats': [],
  29812. 'show': 'offline',
  29813. 'states': []
  29814. };
  29815. }
  29816. save(key, val, options) {
  29817. let attrs;
  29818. if (key == null) {
  29819. // eslint-disable-line no-eq-null
  29820. return super.save(key, val, options);
  29821. } else if (typeof key === 'object') {
  29822. attrs = key;
  29823. options = val;
  29824. } else {
  29825. (attrs = {})[key] = val;
  29826. }
  29827. if (attrs.occupant_id) {
  29828. attrs.id = attrs.occupant_id;
  29829. }
  29830. return super.save(attrs, options);
  29831. }
  29832. getDisplayName() {
  29833. return this.get('nick') || this.get('jid');
  29834. }
  29835. isMember() {
  29836. return ['admin', 'owner', 'member'].includes(this.get('affiliation'));
  29837. }
  29838. isModerator() {
  29839. return ['admin', 'owner'].includes(this.get('affiliation')) || this.get('role') === 'moderator';
  29840. }
  29841. isSelf() {
  29842. return this.get('states').includes('110');
  29843. }
  29844. }
  29845. /* harmony default export */ const occupant = (ChatRoomOccupant);
  29846. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/constants.js
  29847. const MUC_ROLE_WEIGHTS = {
  29848. 'moderator': 1,
  29849. 'participant': 2,
  29850. 'visitor': 3,
  29851. 'none': 2
  29852. };
  29853. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/utils.js
  29854. const {
  29855. Strophe: muc_utils_Strophe,
  29856. sizzle: muc_utils_sizzle,
  29857. u: muc_utils_u
  29858. } = core_converse.env;
  29859. function getAutoFetchedAffiliationLists() {
  29860. const affs = core_api.settings.get('muc_fetch_members');
  29861. return Array.isArray(affs) ? affs : affs ? ['member', 'admin', 'owner'] : [];
  29862. }
  29863. /**
  29864. * Given an occupant model, see which roles may be assigned to that user.
  29865. * @param { Model } occupant
  29866. * @returns { Array<('moderator'|'participant'|'visitor')> } - An array of assignable roles
  29867. */
  29868. function getAssignableRoles(occupant) {
  29869. let disabled = core_api.settings.get('modtools_disable_assign');
  29870. if (!Array.isArray(disabled)) {
  29871. disabled = disabled ? ROLES : [];
  29872. }
  29873. if (occupant.get('role') === 'moderator') {
  29874. return ROLES.filter(r => !disabled.includes(r));
  29875. } else {
  29876. return [];
  29877. }
  29878. }
  29879. function registerDirectInvitationHandler() {
  29880. shared_converse.connection.addHandler(message => {
  29881. shared_converse.onDirectMUCInvitation(message);
  29882. return true;
  29883. }, 'jabber:x:conference', 'message');
  29884. }
  29885. function disconnectChatRooms() {
  29886. /* When disconnecting, mark all groupchats as
  29887. * disconnected, so that they will be properly entered again
  29888. * when fetched from session storage.
  29889. */
  29890. return shared_converse.chatboxes.filter(m => m.get('type') === shared_converse.CHATROOMS_TYPE).forEach(m => m.session.save({
  29891. 'connection_status': core_converse.ROOMSTATUS.DISCONNECTED
  29892. }));
  29893. }
  29894. async function onWindowStateChanged(data) {
  29895. if (data.state === 'visible' && core_api.connection.connected()) {
  29896. const rooms = await core_api.rooms.get();
  29897. rooms.forEach(room => room.rejoinIfNecessary());
  29898. }
  29899. }
  29900. async function routeToRoom(jid) {
  29901. if (!muc_utils_u.isValidMUCJID(jid)) {
  29902. return headless_log.warn(`invalid jid "${jid}" provided in url fragment`);
  29903. }
  29904. await core_api.waitUntil('roomsAutoJoined');
  29905. if (core_api.settings.get('allow_bookmarks')) {
  29906. await core_api.waitUntil('bookmarksInitialized');
  29907. }
  29908. core_api.rooms.open(jid);
  29909. }
  29910. /* Opens a groupchat, making sure that certain attributes
  29911. * are correct, for example that the "type" is set to
  29912. * "chatroom".
  29913. */
  29914. async function openChatRoom(jid, settings) {
  29915. settings.type = shared_converse.CHATROOMS_TYPE;
  29916. settings.id = jid;
  29917. const chatbox = await core_api.rooms.get(jid, settings, true);
  29918. chatbox.maybeShow(true);
  29919. return chatbox;
  29920. }
  29921. /**
  29922. * A direct MUC invitation to join a groupchat has been received
  29923. * See XEP-0249: Direct MUC invitations.
  29924. * @private
  29925. * @method _converse.ChatRoom#onDirectMUCInvitation
  29926. * @param { XMLElement } message - The message stanza containing the invitation.
  29927. */
  29928. async function onDirectMUCInvitation(message) {
  29929. const {
  29930. __
  29931. } = shared_converse;
  29932. const x_el = muc_utils_sizzle('x[xmlns="jabber:x:conference"]', message).pop(),
  29933. from = muc_utils_Strophe.getBareJidFromJid(message.getAttribute('from')),
  29934. room_jid = x_el.getAttribute('jid'),
  29935. reason = x_el.getAttribute('reason');
  29936. let result;
  29937. if (core_api.settings.get('auto_join_on_invite')) {
  29938. result = true;
  29939. } else {
  29940. // Invite request might come from someone not your roster list
  29941. let contact = shared_converse.roster.get(from);
  29942. contact = contact ? contact.getDisplayName() : from;
  29943. if (!reason) {
  29944. result = confirm(__('%1$s has invited you to join a groupchat: %2$s', contact, room_jid));
  29945. } else {
  29946. result = confirm(__('%1$s has invited you to join a groupchat: %2$s, and left the following reason: "%3$s"', contact, room_jid, reason));
  29947. }
  29948. }
  29949. if (result === true) {
  29950. const chatroom = await openChatRoom(room_jid, {
  29951. 'password': x_el.getAttribute('password')
  29952. });
  29953. if (chatroom.session.get('connection_status') === core_converse.ROOMSTATUS.DISCONNECTED) {
  29954. shared_converse.chatboxes.get(room_jid).rejoin();
  29955. }
  29956. }
  29957. }
  29958. function getDefaultMUCNickname() {
  29959. // XXX: if anything changes here, update the docs for the
  29960. // locked_muc_nickname setting.
  29961. if (!shared_converse.xmppstatus) {
  29962. throw new Error("Can't call _converse.getDefaultMUCNickname before the statusInitialized has been fired.");
  29963. }
  29964. const nick = shared_converse.xmppstatus.getNickname();
  29965. if (nick) {
  29966. return nick;
  29967. } else if (core_api.settings.get('muc_nickname_from_jid')) {
  29968. return muc_utils_Strophe.unescapeNode(muc_utils_Strophe.getNodeFromJid(shared_converse.bare_jid));
  29969. }
  29970. }
  29971. /**
  29972. * Determines info message visibility based on
  29973. * muc_show_info_messages configuration setting
  29974. * @param {*} code
  29975. * @memberOf _converse
  29976. */
  29977. function isInfoVisible(code) {
  29978. const info_messages = core_api.settings.get('muc_show_info_messages');
  29979. if (info_messages.includes(code)) {
  29980. return true;
  29981. }
  29982. return false;
  29983. }
  29984. /**
  29985. * Automatically join groupchats, based on the
  29986. * "auto_join_rooms" configuration setting, which is an array
  29987. * of strings (groupchat JIDs) or objects (with groupchat JID and other settings).
  29988. */
  29989. async function autoJoinRooms() {
  29990. await Promise.all(core_api.settings.get('auto_join_rooms').map(muc => {
  29991. if (typeof muc === 'string') {
  29992. if (shared_converse.chatboxes.where({
  29993. 'jid': muc
  29994. }).length) {
  29995. return Promise.resolve();
  29996. }
  29997. return core_api.rooms.open(muc);
  29998. } else if (lodash_es_isObject(muc)) {
  29999. return core_api.rooms.open(muc.jid, { ...muc
  30000. });
  30001. } else {
  30002. headless_log.error('Invalid muc criteria specified for "auto_join_rooms"');
  30003. return Promise.resolve();
  30004. }
  30005. }));
  30006. /**
  30007. * Triggered once any rooms that have been configured to be automatically joined,
  30008. * specified via the _`auto_join_rooms` setting, have been entered.
  30009. * @event _converse#roomsAutoJoined
  30010. * @example _converse.api.listen.on('roomsAutoJoined', () => { ... });
  30011. * @example _converse.api.waitUntil('roomsAutoJoined').then(() => { ... });
  30012. */
  30013. core_api.trigger('roomsAutoJoined');
  30014. }
  30015. function onAddClientFeatures() {
  30016. core_api.disco.own.features.add(muc_utils_Strophe.NS.MUC);
  30017. if (core_api.settings.get('allow_muc_invitations')) {
  30018. core_api.disco.own.features.add('jabber:x:conference'); // Invites
  30019. }
  30020. }
  30021. function onBeforeTearDown() {
  30022. shared_converse.chatboxes.where({
  30023. 'type': shared_converse.CHATROOMS_TYPE
  30024. }).forEach(muc => safeSave(muc.session, {
  30025. 'connection_status': core_converse.ROOMSTATUS.DISCONNECTED
  30026. }));
  30027. }
  30028. function onStatusInitialized() {
  30029. window.addEventListener(shared_converse.unloadevent, () => {
  30030. const using_websocket = core_api.connection.isType('websocket');
  30031. if (using_websocket && (!core_api.settings.get('enable_smacks') || !shared_converse.session.get('smacks_stream_id'))) {
  30032. // For non-SMACKS websocket connections, or non-resumeable
  30033. // connections, we disconnect all chatrooms when the page unloads.
  30034. // See issue #1111
  30035. disconnectChatRooms();
  30036. }
  30037. });
  30038. }
  30039. function onBeforeResourceBinding() {
  30040. shared_converse.connection.addHandler(stanza => {
  30041. const muc_jid = muc_utils_Strophe.getBareJidFromJid(stanza.getAttribute('from'));
  30042. if (!shared_converse.chatboxes.get(muc_jid)) {
  30043. core_api.waitUntil('chatBoxesFetched').then(async () => {
  30044. const muc = shared_converse.chatboxes.get(muc_jid);
  30045. if (muc) {
  30046. await muc.initialized;
  30047. muc.message_handler.run(stanza);
  30048. }
  30049. });
  30050. }
  30051. return true;
  30052. }, null, 'message', 'groupchat');
  30053. }
  30054. Object.assign(shared_converse, {
  30055. getAssignableRoles
  30056. });
  30057. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/occupants.js
  30058. function occupants_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  30059. /**
  30060. * A list of {@link _converse.ChatRoomOccupant} instances, representing participants in a MUC.
  30061. * @class
  30062. * @namespace _converse.ChatRoomOccupants
  30063. * @memberOf _converse
  30064. */
  30065. class ChatRoomOccupants extends Collection {
  30066. constructor() {
  30067. super(...arguments);
  30068. occupants_defineProperty(this, "model", occupant);
  30069. }
  30070. comparator(occupant1, occupant2) {
  30071. // eslint-disable-line class-methods-use-this
  30072. const role1 = occupant1.get('role') || 'none';
  30073. const role2 = occupant2.get('role') || 'none';
  30074. if (MUC_ROLE_WEIGHTS[role1] === MUC_ROLE_WEIGHTS[role2]) {
  30075. const nick1 = occupant1.getDisplayName().toLowerCase();
  30076. const nick2 = occupant2.getDisplayName().toLowerCase();
  30077. return nick1 < nick2 ? -1 : nick1 > nick2 ? 1 : 0;
  30078. } else {
  30079. return MUC_ROLE_WEIGHTS[role1] < MUC_ROLE_WEIGHTS[role2] ? -1 : 1;
  30080. }
  30081. }
  30082. create(attrs, options) {
  30083. if (attrs.id || attrs instanceof Model) {
  30084. return super.create(attrs, options);
  30085. }
  30086. attrs.id = attrs.occupant_id || getUniqueId();
  30087. return super.create(attrs, options);
  30088. }
  30089. /**
  30090. * Get the {@link _converse.ChatRoomOccupant} instance which
  30091. * represents the current user.
  30092. * @method _converse.ChatRoomOccupants#getOwnOccupant
  30093. * @returns { _converse.ChatRoomOccupant }
  30094. */
  30095. getOwnOccupant() {
  30096. return this.findWhere({
  30097. 'jid': shared_converse.bare_jid
  30098. });
  30099. }
  30100. async fetchMembers() {
  30101. var _this$getOwnOccupant;
  30102. if (!['member', 'admin', 'owner'].includes((_this$getOwnOccupant = this.getOwnOccupant()) === null || _this$getOwnOccupant === void 0 ? void 0 : _this$getOwnOccupant.get('affiliation'))) {
  30103. // https://xmpp.org/extensions/xep-0045.html#affil-priv
  30104. return;
  30105. }
  30106. const affiliations = getAutoFetchedAffiliationLists();
  30107. if (affiliations.length === 0) {
  30108. return;
  30109. }
  30110. const muc_jid = this.chatroom.get('jid');
  30111. const aff_lists = await Promise.all(affiliations.map(a => getAffiliationList(a, muc_jid)));
  30112. const new_members = aff_lists.reduce((acc, val) => utils_form.isErrorObject(val) ? acc : [...val, ...acc], []);
  30113. const known_affiliations = affiliations.filter(a => !utils_form.isErrorObject(aff_lists[affiliations.indexOf(a)]));
  30114. const new_jids = new_members.map(m => m.jid).filter(m => m !== undefined);
  30115. const new_nicks = new_members.map(m => !m.jid && m.nick || undefined).filter(m => m !== undefined);
  30116. const removed_members = this.filter(m => {
  30117. return known_affiliations.includes(m.get('affiliation')) && !new_nicks.includes(m.get('nick')) && !new_jids.includes(m.get('jid'));
  30118. });
  30119. removed_members.forEach(occupant => {
  30120. if (occupant.get('jid') === shared_converse.bare_jid) {
  30121. return;
  30122. } else if (occupant.get('show') === 'offline') {
  30123. occupant.destroy();
  30124. } else {
  30125. occupant.save('affiliation', null);
  30126. }
  30127. });
  30128. new_members.forEach(attrs => {
  30129. const occupant = this.findOccupant(attrs);
  30130. occupant ? occupant.save(attrs) : this.create(attrs);
  30131. });
  30132. /**
  30133. * Triggered once the member lists for this MUC have been fetched and processed.
  30134. * @event _converse#membersFetched
  30135. * @example _converse.api.listen.on('membersFetched', () => { ... });
  30136. */
  30137. core_api.trigger('membersFetched');
  30138. }
  30139. /**
  30140. * @typedef { Object} OccupantData
  30141. * @property { String } [jid]
  30142. * @property { String } [nick]
  30143. * @property { String } [occupant_id]
  30144. */
  30145. /**
  30146. * Try to find an existing occupant based on the passed in
  30147. * data object.
  30148. *
  30149. * Fetching the user by occupant_id is the quickest, O(1),
  30150. * since it's a dictionary lookup.
  30151. *
  30152. * Fetching by jid or nick is O(n), since it requires traversing an array.
  30153. *
  30154. * Lookup by occupant_id is done first, then jid, and then nick.
  30155. *
  30156. * @method _converse.ChatRoomOccupants#findOccupant
  30157. * @param { OccupantData } data
  30158. */
  30159. findOccupant(data) {
  30160. if (data.occupant_id && this.get(data.occupant_id)) {
  30161. return this.get(data.occupant_id);
  30162. }
  30163. const jid = data.jid && Strophe.getBareJidFromJid(data.jid);
  30164. return jid && this.findWhere({
  30165. jid
  30166. }) || data.nick && this.findWhere({
  30167. 'nick': data.nick
  30168. });
  30169. }
  30170. }
  30171. /* harmony default export */ const occupants = (ChatRoomOccupants);
  30172. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/affiliations/api.js
  30173. /* harmony default export */ const affiliations_api = ({
  30174. /**
  30175. * The "affiliations" namespace groups methods relevant to setting and
  30176. * getting MUC affiliations.
  30177. *
  30178. * @namespace api.rooms.affiliations
  30179. * @memberOf api.rooms
  30180. */
  30181. affiliations: {
  30182. /**
  30183. * Set the given affliation for the given JIDs in the specified MUCs
  30184. *
  30185. * @param { String|Array<String> } muc_jids - The JIDs of the MUCs in
  30186. * which the affiliation should be set.
  30187. * @param { Object[] } users - An array of objects representing users
  30188. * for whom the affiliation is to be set.
  30189. * @param { String } users[].jid - The JID of the user whose affiliation will change
  30190. * @param { ('outcast'|'member'|'admin'|'owner') } users[].affiliation - The new affiliation for this user
  30191. * @param { String } [users[].reason] - An optional reason for the affiliation change
  30192. * @returns { Promise }
  30193. *
  30194. * @example
  30195. * api.rooms.affiliations.set(
  30196. * [
  30197. * 'muc1@muc.example.org',
  30198. * 'muc2@muc.example.org'
  30199. * ], [
  30200. * {
  30201. * 'jid': 'user@example.org',
  30202. * 'affiliation': 'member',
  30203. * 'reason': "You're one of us now!"
  30204. * }
  30205. * ]
  30206. * )
  30207. */
  30208. set(muc_jids, users) {
  30209. users = !Array.isArray(users) ? [users] : users;
  30210. muc_jids = !Array.isArray(muc_jids) ? [muc_jids] : muc_jids;
  30211. return setAffiliations(muc_jids, users);
  30212. }
  30213. }
  30214. });
  30215. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/api.js
  30216. /* harmony default export */ const muc_api = ({
  30217. /**
  30218. * The "rooms" namespace groups methods relevant to chatrooms
  30219. * (aka groupchats).
  30220. *
  30221. * @namespace api.rooms
  30222. * @memberOf api
  30223. */
  30224. rooms: {
  30225. /**
  30226. * Creates a new MUC chatroom (aka groupchat)
  30227. *
  30228. * Similar to {@link api.rooms.open}, but creates
  30229. * the chatroom in the background (i.e. doesn't cause a view to open).
  30230. *
  30231. * @method api.rooms.create
  30232. * @param {(string[]|string)} jid|jids The JID or array of
  30233. * JIDs of the chatroom(s) to create
  30234. * @param {object} [attrs] attrs The room attributes
  30235. * @returns {Promise} Promise which resolves with the Model representing the chat.
  30236. */
  30237. create(jids) {
  30238. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  30239. attrs = typeof attrs === 'string' ? {
  30240. 'nick': attrs
  30241. } : attrs || {};
  30242. if (!attrs.nick && core_api.settings.get('muc_nickname_from_jid')) {
  30243. attrs.nick = Strophe.getNodeFromJid(shared_converse.bare_jid);
  30244. }
  30245. if (jids === undefined) {
  30246. throw new TypeError('rooms.create: You need to provide at least one JID');
  30247. } else if (typeof jids === 'string') {
  30248. return core_api.rooms.get(utils_form.getJIDFromURI(jids), attrs, true);
  30249. }
  30250. return jids.map(jid => core_api.rooms.get(utils_form.getJIDFromURI(jid), attrs, true));
  30251. },
  30252. /**
  30253. * Opens a MUC chatroom (aka groupchat)
  30254. *
  30255. * Similar to {@link api.chats.open}, but for groupchats.
  30256. *
  30257. * @method api.rooms.open
  30258. * @param {string} jid The room JID or JIDs (if not specified, all
  30259. * currently open rooms will be returned).
  30260. * @param {string} attrs A map containing any extra room attributes.
  30261. * @param {string} [attrs.nick] The current user's nickname for the MUC
  30262. * @param {boolean} [attrs.auto_configure] A boolean, indicating
  30263. * whether the room should be configured automatically or not.
  30264. * If set to `true`, then it makes sense to pass in configuration settings.
  30265. * @param {object} [attrs.roomconfig] A map of configuration settings to be used when the room gets
  30266. * configured automatically. Currently it doesn't make sense to specify
  30267. * `roomconfig` values if `auto_configure` is set to `false`.
  30268. * For a list of configuration values that can be passed in, refer to these values
  30269. * in the [XEP-0045 MUC specification](https://xmpp.org/extensions/xep-0045.html#registrar-formtype-owner).
  30270. * The values should be named without the `muc#roomconfig_` prefix.
  30271. * @param {boolean} [attrs.minimized] A boolean, indicating whether the room should be opened minimized or not.
  30272. * @param {boolean} [attrs.bring_to_foreground] A boolean indicating whether the room should be
  30273. * brought to the foreground and therefore replace the currently shown chat.
  30274. * If there is no chat currently open, then this option is ineffective.
  30275. * @param {Boolean} [force=false] - By default, a minimized
  30276. * room won't be maximized (in `overlayed` view mode) and in
  30277. * `fullscreen` view mode a newly opened room won't replace
  30278. * another chat already in the foreground.
  30279. * Set `force` to `true` if you want to force the room to be
  30280. * maximized or shown.
  30281. * @returns {Promise} Promise which resolves with the Model representing the chat.
  30282. *
  30283. * @example
  30284. * api.rooms.open('group@muc.example.com')
  30285. *
  30286. * @example
  30287. * // To return an array of rooms, provide an array of room JIDs:
  30288. * api.rooms.open(['group1@muc.example.com', 'group2@muc.example.com'])
  30289. *
  30290. * @example
  30291. * // To setup a custom nickname when joining the room, provide the optional nick argument:
  30292. * api.rooms.open('group@muc.example.com', {'nick': 'mycustomnick'})
  30293. *
  30294. * @example
  30295. * // For example, opening a room with a specific default configuration:
  30296. * api.rooms.open(
  30297. * 'myroom@conference.example.org',
  30298. * { 'nick': 'coolguy69',
  30299. * 'auto_configure': true,
  30300. * 'roomconfig': {
  30301. * 'changesubject': false,
  30302. * 'membersonly': true,
  30303. * 'persistentroom': true,
  30304. * 'publicroom': true,
  30305. * 'roomdesc': 'Comfy room for hanging out',
  30306. * 'whois': 'anyone'
  30307. * }
  30308. * }
  30309. * );
  30310. */
  30311. async open(jids) {
  30312. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  30313. let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30314. await core_api.waitUntil('chatBoxesFetched');
  30315. if (jids === undefined) {
  30316. const err_msg = 'rooms.open: You need to provide at least one JID';
  30317. headless_log.error(err_msg);
  30318. throw new TypeError(err_msg);
  30319. } else if (typeof jids === 'string') {
  30320. const room = await core_api.rooms.get(jids, attrs, true);
  30321. !attrs.hidden && (room === null || room === void 0 ? void 0 : room.maybeShow(force));
  30322. return room;
  30323. } else {
  30324. const rooms = await Promise.all(jids.map(jid => core_api.rooms.get(jid, attrs, true)));
  30325. rooms.forEach(r => !attrs.hidden && r.maybeShow(force));
  30326. return rooms;
  30327. }
  30328. },
  30329. /**
  30330. * Fetches the object representing a MUC chatroom (aka groupchat)
  30331. *
  30332. * @method api.rooms.get
  30333. * @param { String } [jid] The room JID (if not specified, all rooms will be returned).
  30334. * @param { Object } [attrs] A map containing any extra room attributes
  30335. * to be set if `create` is set to `true`
  30336. * @param { String } [attrs.nick] Specify the nickname
  30337. * @param { String } [attrs.password ] Specify a password if needed to enter a new room
  30338. * @param { Boolean } create A boolean indicating whether the room should be created
  30339. * if not found (default: `false`)
  30340. * @returns { Promise<_converse.ChatRoom> }
  30341. * @example
  30342. * api.waitUntil('roomsAutoJoined').then(() => {
  30343. * const create_if_not_found = true;
  30344. * api.rooms.get(
  30345. * 'group@muc.example.com',
  30346. * {'nick': 'dread-pirate-roberts', 'password': 'secret'},
  30347. * create_if_not_found
  30348. * )
  30349. * });
  30350. */
  30351. async get(jids) {
  30352. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  30353. let create = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30354. await core_api.waitUntil('chatBoxesFetched');
  30355. async function _get(jid) {
  30356. jid = utils_form.getJIDFromURI(jid);
  30357. let model = await core_api.chatboxes.get(jid);
  30358. if (!model && create) {
  30359. model = await core_api.chatboxes.create(jid, attrs, shared_converse.ChatRoom);
  30360. } else {
  30361. model = model && model.get('type') === shared_converse.CHATROOMS_TYPE ? model : null;
  30362. if (model && Object.keys(attrs).length) {
  30363. model.save(attrs);
  30364. }
  30365. }
  30366. return model;
  30367. }
  30368. if (jids === undefined) {
  30369. const chats = await core_api.chatboxes.get();
  30370. return chats.filter(c => c.get('type') === shared_converse.CHATROOMS_TYPE);
  30371. } else if (typeof jids === 'string') {
  30372. return _get(jids);
  30373. }
  30374. return Promise.all(jids.map(jid => _get(jid)));
  30375. }
  30376. }
  30377. });
  30378. ;// CONCATENATED MODULE: ./src/headless/plugins/muc/index.js
  30379. /**
  30380. * @copyright The Converse.js contributors
  30381. * @license Mozilla Public License (MPLv2)
  30382. * @description Implements the non-view logic for XEP-0045 Multi-User Chat
  30383. */
  30384. const ROLES = ['moderator', 'participant', 'visitor'];
  30385. const AFFILIATIONS = ['owner', 'admin', 'member', 'outcast', 'none'];
  30386. core_converse.AFFILIATION_CHANGES = {
  30387. OWNER: 'owner',
  30388. ADMIN: 'admin',
  30389. MEMBER: 'member',
  30390. EXADMIN: 'exadmin',
  30391. EXOWNER: 'exowner',
  30392. EXOUTCAST: 'exoutcast',
  30393. EXMEMBER: 'exmember'
  30394. };
  30395. core_converse.AFFILIATION_CHANGES_LIST = Object.values(core_converse.AFFILIATION_CHANGES);
  30396. core_converse.MUC_TRAFFIC_STATES = {
  30397. ENTERED: 'entered',
  30398. EXITED: 'exited'
  30399. };
  30400. core_converse.MUC_TRAFFIC_STATES_LIST = Object.values(core_converse.MUC_TRAFFIC_STATES);
  30401. core_converse.MUC_ROLE_CHANGES = {
  30402. OP: 'op',
  30403. DEOP: 'deop',
  30404. VOICE: 'voice',
  30405. MUTE: 'mute'
  30406. };
  30407. core_converse.MUC_ROLE_CHANGES_LIST = Object.values(core_converse.MUC_ROLE_CHANGES);
  30408. core_converse.MUC = {};
  30409. core_converse.MUC.INFO_CODES = {
  30410. 'visibility_changes': ['100', '102', '103', '172', '173', '174'],
  30411. 'self': ['110'],
  30412. 'non_privacy_changes': ['104', '201'],
  30413. 'muc_logging_changes': ['170', '171'],
  30414. 'nickname_changes': ['210', '303'],
  30415. 'disconnected': ['301', '307', '321', '322', '332', '333'],
  30416. 'affiliation_changes': [...core_converse.AFFILIATION_CHANGES_LIST],
  30417. 'join_leave_events': [...core_converse.MUC_TRAFFIC_STATES_LIST],
  30418. 'role_changes': [...core_converse.MUC_ROLE_CHANGES_LIST]
  30419. };
  30420. const {
  30421. Strophe: muc_Strophe
  30422. } = core_converse.env; // Add Strophe Namespaces
  30423. muc_Strophe.addNamespace('MUC_ADMIN', muc_Strophe.NS.MUC + '#admin');
  30424. muc_Strophe.addNamespace('MUC_OWNER', muc_Strophe.NS.MUC + '#owner');
  30425. muc_Strophe.addNamespace('MUC_REGISTER', 'jabber:iq:register');
  30426. muc_Strophe.addNamespace('MUC_ROOMCONF', muc_Strophe.NS.MUC + '#roomconfig');
  30427. muc_Strophe.addNamespace('MUC_USER', muc_Strophe.NS.MUC + '#user');
  30428. muc_Strophe.addNamespace('MUC_HATS', 'xmpp:prosody.im/protocol/hats:1');
  30429. muc_Strophe.addNamespace('CONFINFO', 'urn:ietf:params:xml:ns:conference-info');
  30430. core_converse.MUC_NICK_CHANGED_CODE = '303';
  30431. core_converse.ROOM_FEATURES = ['passwordprotected', 'unsecured', 'hidden', 'publicroom', 'membersonly', 'open', 'persistent', 'temporary', 'nonanonymous', 'semianonymous', 'moderated', 'unmoderated', 'mam_enabled']; // No longer used in code, but useful as reference.
  30432. //
  30433. // const ROOM_FEATURES_MAP = {
  30434. // 'passwordprotected': 'unsecured',
  30435. // 'unsecured': 'passwordprotected',
  30436. // 'hidden': 'publicroom',
  30437. // 'publicroom': 'hidden',
  30438. // 'membersonly': 'open',
  30439. // 'open': 'membersonly',
  30440. // 'persistent': 'temporary',
  30441. // 'temporary': 'persistent',
  30442. // 'nonanonymous': 'semianonymous',
  30443. // 'semianonymous': 'nonanonymous',
  30444. // 'moderated': 'unmoderated',
  30445. // 'unmoderated': 'moderated'
  30446. // };
  30447. core_converse.ROOMSTATUS = {
  30448. CONNECTED: 0,
  30449. CONNECTING: 1,
  30450. NICKNAME_REQUIRED: 2,
  30451. PASSWORD_REQUIRED: 3,
  30452. DISCONNECTED: 4,
  30453. ENTERED: 5,
  30454. DESTROYED: 6,
  30455. BANNED: 7,
  30456. CLOSING: 8
  30457. };
  30458. core_converse.plugins.add('converse-muc', {
  30459. /* Optional dependencies are other plugins which might be
  30460. * overridden or relied upon, and therefore need to be loaded before
  30461. * this plugin. They are called "optional" because they might not be
  30462. * available, in which case any overrides applicable to them will be
  30463. * ignored.
  30464. *
  30465. * It's possible however to make optional dependencies non-optional.
  30466. * If the setting "strict_plugin_dependencies" is set to true,
  30467. * an error will be raised if the plugin is not found.
  30468. *
  30469. * NB: These plugins need to have already been loaded via require.js.
  30470. */
  30471. dependencies: ['converse-chatboxes', 'converse-chat', 'converse-disco'],
  30472. overrides: {
  30473. ChatBoxes: {
  30474. model(attrs, options) {
  30475. const {
  30476. _converse
  30477. } = this.__super__;
  30478. if (attrs && attrs.type == _converse.CHATROOMS_TYPE) {
  30479. return new _converse.ChatRoom(attrs, options);
  30480. } else {
  30481. return this.__super__.model.apply(this, arguments);
  30482. }
  30483. }
  30484. }
  30485. },
  30486. initialize() {
  30487. /* The initialize function gets called as soon as the plugin is
  30488. * loaded by converse.js's plugin machinery.
  30489. */
  30490. const {
  30491. __,
  30492. ___
  30493. } = shared_converse; // Configuration values for this plugin
  30494. // ====================================
  30495. // Refer to docs/source/configuration.rst for explanations of these
  30496. // configuration settings.
  30497. core_api.settings.extend({
  30498. 'allow_muc_invitations': true,
  30499. 'auto_join_on_invite': false,
  30500. 'auto_join_rooms': [],
  30501. 'auto_register_muc_nickname': false,
  30502. 'hide_muc_participants': false,
  30503. 'locked_muc_domain': false,
  30504. 'modtools_disable_assign': false,
  30505. 'muc_clear_messages_on_leave': true,
  30506. 'muc_domain': undefined,
  30507. 'muc_fetch_members': true,
  30508. 'muc_history_max_stanzas': undefined,
  30509. 'muc_instant_rooms': true,
  30510. 'muc_nickname_from_jid': false,
  30511. 'muc_send_probes': false,
  30512. 'muc_show_info_messages': [...core_converse.MUC.INFO_CODES.visibility_changes, ...core_converse.MUC.INFO_CODES.self, ...core_converse.MUC.INFO_CODES.non_privacy_changes, ...core_converse.MUC.INFO_CODES.muc_logging_changes, ...core_converse.MUC.INFO_CODES.nickname_changes, ...core_converse.MUC.INFO_CODES.disconnected, ...core_converse.MUC.INFO_CODES.affiliation_changes, ...core_converse.MUC.INFO_CODES.join_leave_events, ...core_converse.MUC.INFO_CODES.role_changes],
  30513. 'muc_show_logs_before_join': false,
  30514. 'muc_subscribe_to_rai': false
  30515. });
  30516. core_api.promises.add(['roomsAutoJoined']);
  30517. if (core_api.settings.get('locked_muc_domain') && typeof core_api.settings.get('muc_domain') !== 'string') {
  30518. throw new Error('Config Error: it makes no sense to set locked_muc_domain ' + 'to true when muc_domain is not set');
  30519. } // This is for tests (at least until we can import modules inside tests)
  30520. core_converse.env.muc_utils = {
  30521. computeAffiliationsDelta: computeAffiliationsDelta
  30522. };
  30523. Object.assign(core_api, muc_api);
  30524. Object.assign(core_api.rooms, affiliations_api);
  30525. /* https://xmpp.org/extensions/xep-0045.html
  30526. * ----------------------------------------
  30527. * 100 message Entering a groupchat Inform user that any occupant is allowed to see the user's full JID
  30528. * 101 message (out of band) Affiliation change Inform user that his or her affiliation changed while not in the groupchat
  30529. * 102 message Configuration change Inform occupants that groupchat now shows unavailable members
  30530. * 103 message Configuration change Inform occupants that groupchat now does not show unavailable members
  30531. * 104 message Configuration change Inform occupants that a non-privacy-related groupchat configuration change has occurred
  30532. * 110 presence Any groupchat presence Inform user that presence refers to one of its own groupchat occupants
  30533. * 170 message or initial presence Configuration change Inform occupants that groupchat logging is now enabled
  30534. * 171 message Configuration change Inform occupants that groupchat logging is now disabled
  30535. * 172 message Configuration change Inform occupants that the groupchat is now non-anonymous
  30536. * 173 message Configuration change Inform occupants that the groupchat is now semi-anonymous
  30537. * 174 message Configuration change Inform occupants that the groupchat is now fully-anonymous
  30538. * 201 presence Entering a groupchat Inform user that a new groupchat has been created
  30539. * 210 presence Entering a groupchat Inform user that the service has assigned or modified the occupant's roomnick
  30540. * 301 presence Removal from groupchat Inform user that he or she has been banned from the groupchat
  30541. * 303 presence Exiting a groupchat Inform all occupants of new groupchat nickname
  30542. * 307 presence Removal from groupchat Inform user that he or she has been kicked from the groupchat
  30543. * 321 presence Removal from groupchat Inform user that he or she is being removed from the groupchat because of an affiliation change
  30544. * 322 presence Removal from groupchat Inform user that he or she is being removed from the groupchat because the groupchat has been changed to members-only and the user is not a member
  30545. * 332 presence Removal from groupchat Inform user that he or she is being removed from the groupchat because of a system shutdown
  30546. */
  30547. shared_converse.muc = {
  30548. info_messages: {
  30549. 100: __('This groupchat is not anonymous'),
  30550. 102: __('This groupchat now shows unavailable members'),
  30551. 103: __('This groupchat does not show unavailable members'),
  30552. 104: __('The groupchat configuration has changed'),
  30553. 170: __('Groupchat logging is now enabled'),
  30554. 171: __('Groupchat logging is now disabled'),
  30555. 172: __('This groupchat is now no longer anonymous'),
  30556. 173: __('This groupchat is now semi-anonymous'),
  30557. 174: __('This groupchat is now fully-anonymous'),
  30558. 201: __('A new groupchat has been created')
  30559. },
  30560. new_nickname_messages: {
  30561. // XXX: Note the triple underscore function and not double underscore.
  30562. 210: ___('Your nickname has been automatically set to %1$s'),
  30563. 303: ___('Your nickname has been changed to %1$s')
  30564. },
  30565. disconnect_messages: {
  30566. 301: __('You have been banned from this groupchat'),
  30567. 333: __('You have exited this groupchat due to a technical problem'),
  30568. 307: __('You have been kicked from this groupchat'),
  30569. 321: __('You have been removed from this groupchat because of an affiliation change'),
  30570. 322: __("You have been removed from this groupchat because the groupchat has changed to members-only and you're not a member"),
  30571. 332: __('You have been removed from this groupchat because the service hosting it is being shut down')
  30572. }
  30573. };
  30574. shared_converse.router.route('converse/room?jid=:jid', routeToRoom);
  30575. shared_converse.ChatRoom = shared_converse.ChatBox.extend(muc);
  30576. shared_converse.ChatRoomMessage = shared_converse.Message.extend(muc_message);
  30577. shared_converse.ChatRoomOccupants = occupants;
  30578. shared_converse.ChatRoomOccupant = occupant;
  30579. /**
  30580. * Collection which stores MUC messages
  30581. * @class
  30582. * @namespace _converse.ChatRoomMessages
  30583. * @memberOf _converse
  30584. */
  30585. shared_converse.ChatRoomMessages = Collection.extend({
  30586. model: shared_converse.ChatRoomMessage,
  30587. comparator: 'time'
  30588. });
  30589. Object.assign(shared_converse, {
  30590. getDefaultMUCNickname: getDefaultMUCNickname,
  30591. isInfoVisible: isInfoVisible,
  30592. onDirectMUCInvitation: onDirectMUCInvitation
  30593. });
  30594. /************************ BEGIN Event Handlers ************************/
  30595. if (core_api.settings.get('allow_muc_invitations')) {
  30596. core_api.listen.on('connected', registerDirectInvitationHandler);
  30597. core_api.listen.on('reconnected', registerDirectInvitationHandler);
  30598. }
  30599. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(`${muc_Strophe.NS.CONFINFO}+notify`));
  30600. core_api.listen.on('addClientFeatures', onAddClientFeatures);
  30601. core_api.listen.on('beforeResourceBinding', onBeforeResourceBinding);
  30602. core_api.listen.on('beforeTearDown', onBeforeTearDown);
  30603. core_api.listen.on('chatBoxesFetched', autoJoinRooms);
  30604. core_api.listen.on('disconnected', disconnectChatRooms);
  30605. core_api.listen.on('statusInitialized', onStatusInitialized);
  30606. core_api.listen.on('windowStateChanged', onWindowStateChanged);
  30607. }
  30608. });
  30609. ;// CONCATENATED MODULE: ./src/headless/plugins/bookmarks/model.js
  30610. const {
  30611. Strophe: bookmarks_model_Strophe
  30612. } = core_converse.env;
  30613. const Bookmark = Model.extend({
  30614. idAttribute: 'jid',
  30615. getDisplayName() {
  30616. return bookmarks_model_Strophe.xmlunescape(this.get('name'));
  30617. }
  30618. });
  30619. /* harmony default export */ const bookmarks_model = (Bookmark);
  30620. ;// CONCATENATED MODULE: ./src/headless/plugins/bookmarks/collection.js
  30621. const {
  30622. Strophe: collection_Strophe,
  30623. $iq: collection_$iq,
  30624. sizzle: collection_sizzle
  30625. } = core_converse.env;
  30626. const Bookmarks = {
  30627. model: bookmarks_model,
  30628. comparator: item => item.get('name').toLowerCase(),
  30629. async initialize() {
  30630. this.on('add', bm => this.openBookmarkedRoom(bm).then(bm => this.markRoomAsBookmarked(bm)).catch(e => headless_log.fatal(e)));
  30631. this.on('remove', this.markRoomAsUnbookmarked, this);
  30632. this.on('remove', this.sendBookmarkStanza, this);
  30633. const cache_key = `converse.room-bookmarks${shared_converse.bare_jid}`;
  30634. this.fetched_flag = cache_key + 'fetched';
  30635. initStorage(this, cache_key);
  30636. await this.fetchBookmarks();
  30637. /**
  30638. * Triggered once the _converse.Bookmarks collection
  30639. * has been created and cached bookmarks have been fetched.
  30640. * @event _converse#bookmarksInitialized
  30641. * @type { _converse.Bookmarks }
  30642. * @example _converse.api.listen.on('bookmarksInitialized', (bookmarks) => { ... });
  30643. */
  30644. core_api.trigger('bookmarksInitialized', this);
  30645. },
  30646. async openBookmarkedRoom(bookmark) {
  30647. if (core_api.settings.get('muc_respect_autojoin') && bookmark.get('autojoin')) {
  30648. const groupchat = await core_api.rooms.create(bookmark.get('jid'), {
  30649. 'nick': bookmark.get('nick')
  30650. });
  30651. groupchat.maybeShow();
  30652. }
  30653. return bookmark;
  30654. },
  30655. fetchBookmarks() {
  30656. const deferred = getOpenPromise();
  30657. if (window.sessionStorage.getItem(this.fetched_flag)) {
  30658. this.fetch({
  30659. 'success': () => deferred.resolve(),
  30660. 'error': () => deferred.resolve()
  30661. });
  30662. } else {
  30663. this.fetchBookmarksFromServer(deferred);
  30664. }
  30665. return deferred;
  30666. },
  30667. createBookmark(options) {
  30668. this.create(options);
  30669. this.sendBookmarkStanza().catch(iq => this.onBookmarkError(iq, options));
  30670. },
  30671. sendBookmarkStanza() {
  30672. const stanza = collection_$iq({
  30673. 'type': 'set',
  30674. 'from': shared_converse.connection.jid
  30675. }).c('pubsub', {
  30676. 'xmlns': collection_Strophe.NS.PUBSUB
  30677. }).c('publish', {
  30678. 'node': collection_Strophe.NS.BOOKMARKS
  30679. }).c('item', {
  30680. 'id': 'current'
  30681. }).c('storage', {
  30682. 'xmlns': collection_Strophe.NS.BOOKMARKS
  30683. });
  30684. this.forEach(model => {
  30685. stanza.c('conference', {
  30686. 'name': model.get('name'),
  30687. 'autojoin': model.get('autojoin'),
  30688. 'jid': model.get('jid')
  30689. }).c('nick').t(model.get('nick')).up().up();
  30690. });
  30691. stanza.up().up().up();
  30692. stanza.c('publish-options').c('x', {
  30693. 'xmlns': collection_Strophe.NS.XFORM,
  30694. 'type': 'submit'
  30695. }).c('field', {
  30696. 'var': 'FORM_TYPE',
  30697. 'type': 'hidden'
  30698. }).c('value').t('http://jabber.org/protocol/pubsub#publish-options').up().up().c('field', {
  30699. 'var': 'pubsub#persist_items'
  30700. }).c('value').t('true').up().up().c('field', {
  30701. 'var': 'pubsub#access_model'
  30702. }).c('value').t('whitelist');
  30703. return core_api.sendIQ(stanza);
  30704. },
  30705. onBookmarkError(iq, options) {
  30706. var _this$get;
  30707. const {
  30708. __
  30709. } = shared_converse;
  30710. headless_log.error("Error while trying to add bookmark");
  30711. headless_log.error(iq);
  30712. core_api.alert('error', __('Error'), [__("Sorry, something went wrong while trying to save your bookmark.")]);
  30713. (_this$get = this.get(options.jid)) === null || _this$get === void 0 ? void 0 : _this$get.destroy();
  30714. },
  30715. fetchBookmarksFromServer(deferred) {
  30716. const stanza = collection_$iq({
  30717. 'from': shared_converse.connection.jid,
  30718. 'type': 'get'
  30719. }).c('pubsub', {
  30720. 'xmlns': collection_Strophe.NS.PUBSUB
  30721. }).c('items', {
  30722. 'node': collection_Strophe.NS.BOOKMARKS
  30723. });
  30724. core_api.sendIQ(stanza).then(iq => this.onBookmarksReceived(deferred, iq)).catch(iq => this.onBookmarksReceivedError(deferred, iq));
  30725. },
  30726. markRoomAsBookmarked(bookmark) {
  30727. const groupchat = shared_converse.chatboxes.get(bookmark.get('jid'));
  30728. groupchat === null || groupchat === void 0 ? void 0 : groupchat.save('bookmarked', true);
  30729. },
  30730. markRoomAsUnbookmarked(bookmark) {
  30731. const groupchat = shared_converse.chatboxes.get(bookmark.get('jid'));
  30732. groupchat === null || groupchat === void 0 ? void 0 : groupchat.save('bookmarked', false);
  30733. },
  30734. createBookmarksFromStanza(stanza) {
  30735. const xmlns = collection_Strophe.NS.BOOKMARKS;
  30736. const sel = `items[node="${xmlns}"] item storage[xmlns="${xmlns}"] conference`;
  30737. collection_sizzle(sel, stanza).forEach(el => {
  30738. var _el$querySelector;
  30739. const jid = el.getAttribute('jid');
  30740. const bookmark = this.get(jid);
  30741. const attrs = {
  30742. 'jid': jid,
  30743. 'name': el.getAttribute('name') || jid,
  30744. 'autojoin': el.getAttribute('autojoin') === 'true',
  30745. 'nick': ((_el$querySelector = el.querySelector('nick')) === null || _el$querySelector === void 0 ? void 0 : _el$querySelector.textContent) || ''
  30746. };
  30747. bookmark ? bookmark.save(attrs) : this.create(attrs);
  30748. });
  30749. },
  30750. onBookmarksReceived(deferred, iq) {
  30751. this.createBookmarksFromStanza(iq);
  30752. window.sessionStorage.setItem(this.fetched_flag, true);
  30753. if (deferred !== undefined) {
  30754. return deferred.resolve();
  30755. }
  30756. },
  30757. onBookmarksReceivedError(deferred, iq) {
  30758. const {
  30759. __
  30760. } = shared_converse;
  30761. if (iq === null) {
  30762. headless_log.error('Error: timeout while fetching bookmarks');
  30763. core_api.alert('error', __('Timeout Error'), [__("The server did not return your bookmarks within the allowed time. " + "You can reload the page to request them again.")]);
  30764. } else if (deferred) {
  30765. if (iq.querySelector('error[type="cancel"] item-not-found')) {
  30766. // Not an exception, the user simply doesn't have any bookmarks.
  30767. window.sessionStorage.setItem(this.fetched_flag, true);
  30768. return deferred.resolve();
  30769. } else {
  30770. headless_log.error('Error while fetching bookmarks');
  30771. headless_log.error(iq);
  30772. return deferred.reject(new Error("Could not fetch bookmarks"));
  30773. }
  30774. } else {
  30775. headless_log.error('Error while fetching bookmarks');
  30776. headless_log.error(iq);
  30777. }
  30778. },
  30779. async getUnopenedBookmarks() {
  30780. await core_api.waitUntil('bookmarksInitialized');
  30781. await core_api.waitUntil('chatBoxesFetched');
  30782. return this.filter(b => !shared_converse.chatboxes.get(b.get('jid')));
  30783. }
  30784. };
  30785. /* harmony default export */ const collection = (Bookmarks);
  30786. ;// CONCATENATED MODULE: ./src/headless/plugins/bookmarks/utils.js
  30787. const {
  30788. Strophe: bookmarks_utils_Strophe,
  30789. sizzle: bookmarks_utils_sizzle
  30790. } = core_converse.env;
  30791. async function checkBookmarksSupport() {
  30792. const identity = await core_api.disco.getIdentity('pubsub', 'pep', shared_converse.bare_jid);
  30793. if (core_api.settings.get('allow_public_bookmarks')) {
  30794. return !!identity;
  30795. } else {
  30796. return core_api.disco.supports(bookmarks_utils_Strophe.NS.PUBSUB + '#publish-options', shared_converse.bare_jid);
  30797. }
  30798. }
  30799. async function initBookmarks() {
  30800. if (!core_api.settings.get('allow_bookmarks')) {
  30801. return;
  30802. }
  30803. if (await checkBookmarksSupport()) {
  30804. shared_converse.bookmarks = new shared_converse.Bookmarks();
  30805. }
  30806. }
  30807. function getNicknameFromBookmark(jid) {
  30808. var _converse$bookmarks, _converse$bookmarks$g;
  30809. if (!core_api.settings.get('allow_bookmarks')) {
  30810. return null;
  30811. }
  30812. return (_converse$bookmarks = shared_converse.bookmarks) === null || _converse$bookmarks === void 0 ? void 0 : (_converse$bookmarks$g = _converse$bookmarks.get(jid)) === null || _converse$bookmarks$g === void 0 ? void 0 : _converse$bookmarks$g.get('nick');
  30813. }
  30814. function handleBookmarksPush(message) {
  30815. if (bookmarks_utils_sizzle(`event[xmlns="${bookmarks_utils_Strophe.NS.PUBSUB}#event"] items[node="${bookmarks_utils_Strophe.NS.BOOKMARKS}"]`, message).length) {
  30816. core_api.waitUntil('bookmarksInitialized').then(() => shared_converse.bookmarks.createBookmarksFromStanza(message)).catch(e => headless_log.fatal(e));
  30817. }
  30818. return true;
  30819. }
  30820. ;// CONCATENATED MODULE: ./src/headless/plugins/bookmarks/index.js
  30821. /**
  30822. * @description
  30823. * Converse.js plugin which adds views for bookmarks specified in XEP-0048.
  30824. * @copyright 2022, the Converse.js contributors
  30825. * @license Mozilla Public License (MPLv2)
  30826. */
  30827. const {
  30828. Strophe: bookmarks_Strophe
  30829. } = core_converse.env;
  30830. bookmarks_Strophe.addNamespace('BOOKMARKS', 'storage:bookmarks');
  30831. core_converse.plugins.add('converse-bookmarks', {
  30832. dependencies: ["converse-chatboxes", "converse-muc"],
  30833. overrides: {
  30834. // Overrides mentioned here will be picked up by converse.js's
  30835. // plugin architecture they will replace existing methods on the
  30836. // relevant objects or classes.
  30837. // New functions which don't exist yet can also be added.
  30838. ChatRoom: {
  30839. getDisplayName() {
  30840. var _converse$bookmarks;
  30841. const {
  30842. _converse,
  30843. getDisplayName
  30844. } = this.__super__;
  30845. const bookmark = this.get('bookmarked') ? (_converse$bookmarks = _converse.bookmarks) === null || _converse$bookmarks === void 0 ? void 0 : _converse$bookmarks.get(this.get('jid')) : null;
  30846. return (bookmark === null || bookmark === void 0 ? void 0 : bookmark.get('name')) || getDisplayName.apply(this, arguments);
  30847. },
  30848. getAndPersistNickname(nick) {
  30849. nick = nick || getNicknameFromBookmark(this.get('jid'));
  30850. return this.__super__.getAndPersistNickname.call(this, nick);
  30851. }
  30852. }
  30853. },
  30854. initialize() {
  30855. // Configuration values for this plugin
  30856. // ====================================
  30857. // Refer to docs/source/configuration.rst for explanations of these
  30858. // configuration settings.
  30859. core_api.settings.extend({
  30860. allow_bookmarks: true,
  30861. allow_public_bookmarks: false,
  30862. muc_respect_autojoin: true
  30863. });
  30864. core_api.promises.add('bookmarksInitialized');
  30865. shared_converse.Bookmark = bookmarks_model;
  30866. shared_converse.Bookmarks = Collection.extend(collection);
  30867. shared_converse.BookmarksList = Model.extend({
  30868. defaults: {
  30869. "toggle-state": shared_converse.OPENED
  30870. }
  30871. });
  30872. core_api.listen.on('addClientFeatures', () => {
  30873. if (core_api.settings.get('allow_bookmarks')) {
  30874. core_api.disco.own.features.add(bookmarks_Strophe.NS.BOOKMARKS + '+notify');
  30875. }
  30876. });
  30877. core_api.listen.on('clearSession', () => {
  30878. if (shared_converse.bookmarks) {
  30879. shared_converse.bookmarks.clearStore({
  30880. 'silent': true
  30881. });
  30882. window.sessionStorage.removeItem(shared_converse.bookmarks.fetched_flag);
  30883. delete shared_converse.bookmarks;
  30884. }
  30885. });
  30886. core_api.listen.on('connected', async () => {
  30887. // Add a handler for bookmarks pushed from other connected clients
  30888. const {
  30889. connection
  30890. } = shared_converse;
  30891. connection.addHandler(handleBookmarksPush, null, 'message', 'headline', null, shared_converse.bare_jid);
  30892. await Promise.all([core_api.waitUntil('chatBoxesFetched')]);
  30893. initBookmarks();
  30894. });
  30895. }
  30896. });
  30897. ;// CONCATENATED MODULE: ./src/headless/plugins/bosh.js
  30898. /**
  30899. * @copyright The Converse.js contributors
  30900. * @license Mozilla Public License (MPLv2)
  30901. * @description Converse.js plugin which add support for XEP-0206: XMPP Over BOSH
  30902. */
  30903. const {
  30904. Strophe: bosh_Strophe
  30905. } = core_converse.env;
  30906. const BOSH_SESSION_ID = 'converse.bosh-session';
  30907. core_converse.plugins.add('converse-bosh', {
  30908. enabled() {
  30909. return !shared_converse.api.settings.get("blacklisted_plugins").includes('converse-bosh');
  30910. },
  30911. initialize() {
  30912. core_api.settings.extend({
  30913. bosh_service_url: undefined,
  30914. prebind_url: null
  30915. });
  30916. async function initBOSHSession() {
  30917. const id = BOSH_SESSION_ID;
  30918. if (!shared_converse.bosh_session) {
  30919. shared_converse.bosh_session = new Model({
  30920. id
  30921. });
  30922. shared_converse.bosh_session.browserStorage = shared_converse.createStore(id, "session");
  30923. await new Promise(resolve => shared_converse.bosh_session.fetch({
  30924. 'success': resolve,
  30925. 'error': resolve
  30926. }));
  30927. }
  30928. if (shared_converse.jid) {
  30929. if (shared_converse.bosh_session.get('jid') !== shared_converse.jid) {
  30930. const jid = await setUserJID(shared_converse.jid);
  30931. shared_converse.bosh_session.clear({
  30932. 'silent': true
  30933. });
  30934. shared_converse.bosh_session.save({
  30935. jid
  30936. });
  30937. }
  30938. } else {
  30939. // Keepalive
  30940. const jid = shared_converse.bosh_session.get('jid');
  30941. jid && (await setUserJID(jid));
  30942. }
  30943. return shared_converse.bosh_session;
  30944. }
  30945. shared_converse.startNewPreboundBOSHSession = function () {
  30946. if (!core_api.settings.get('prebind_url')) {
  30947. throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url");
  30948. }
  30949. const xhr = new XMLHttpRequest();
  30950. xhr.open('GET', core_api.settings.get('prebind_url'), true);
  30951. xhr.setRequestHeader('Accept', 'application/json, text/javascript');
  30952. xhr.onload = async function () {
  30953. if (xhr.status >= 200 && xhr.status < 400) {
  30954. const data = JSON.parse(xhr.responseText);
  30955. const jid = await setUserJID(data.jid);
  30956. shared_converse.connection.attach(jid, data.sid, data.rid, shared_converse.connection.onConnectStatusChanged, BOSH_WAIT);
  30957. } else {
  30958. xhr.onerror();
  30959. }
  30960. };
  30961. xhr.onerror = function () {
  30962. delete shared_converse.connection;
  30963. /**
  30964. * Triggered when fetching prebind tokens failed
  30965. * @event _converse#noResumeableBOSHSession
  30966. * @type { _converse }
  30967. * @example _converse.api.listen.on('noResumeableBOSHSession', _converse => { ... });
  30968. */
  30969. core_api.trigger('noResumeableBOSHSession', shared_converse);
  30970. };
  30971. xhr.send();
  30972. };
  30973. shared_converse.restoreBOSHSession = async function () {
  30974. const jid = (await initBOSHSession()).get('jid');
  30975. if (jid && shared_converse.connection._proto instanceof bosh_Strophe.Bosh) {
  30976. try {
  30977. shared_converse.connection.restore(jid, shared_converse.connection.onConnectStatusChanged);
  30978. return true;
  30979. } catch (e) {
  30980. !shared_converse.isTestEnv() && headless_log.warn("Could not restore session for jid: " + jid + " Error message: " + e.message);
  30981. return false;
  30982. }
  30983. }
  30984. return false;
  30985. };
  30986. /************************ BEGIN Event Handlers ************************/
  30987. core_api.listen.on('clearSession', () => {
  30988. if (shared_converse.bosh_session === undefined) {
  30989. // Remove manually, even if we don't have the corresponding
  30990. // model, to avoid trying to reconnect to a stale BOSH session
  30991. const id = BOSH_SESSION_ID;
  30992. sessionStorage.removeItem(id);
  30993. sessionStorage.removeItem(`${id}-${id}`);
  30994. } else {
  30995. shared_converse.bosh_session.destroy();
  30996. delete shared_converse.bosh_session;
  30997. }
  30998. });
  30999. core_api.listen.on('setUserJID', () => {
  31000. if (shared_converse.bosh_session !== undefined) {
  31001. shared_converse.bosh_session.save({
  31002. 'jid': shared_converse.jid
  31003. });
  31004. }
  31005. });
  31006. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(bosh_Strophe.NS.BOSH));
  31007. /************************ END Event Handlers ************************/
  31008. /************************ BEGIN API ************************/
  31009. Object.assign(core_api, {
  31010. /**
  31011. * This namespace lets you access the BOSH tokens
  31012. *
  31013. * @namespace api.tokens
  31014. * @memberOf api
  31015. */
  31016. tokens: {
  31017. /**
  31018. * @method api.tokens.get
  31019. * @param {string} [id] The type of token to return ('rid' or 'sid').
  31020. * @returns 'string' A token, either the RID or SID token depending on what's asked for.
  31021. * @example _converse.api.tokens.get('rid');
  31022. */
  31023. get(id) {
  31024. if (shared_converse.connection === undefined) {
  31025. return null;
  31026. }
  31027. if (id.toLowerCase() === 'rid') {
  31028. return shared_converse.connection.rid || shared_converse.connection._proto.rid;
  31029. } else if (id.toLowerCase() === 'sid') {
  31030. return shared_converse.connection.sid || shared_converse.connection._proto.sid;
  31031. }
  31032. }
  31033. }
  31034. });
  31035. /************************ end api ************************/
  31036. }
  31037. });
  31038. ;// CONCATENATED MODULE: ./src/headless/plugins/caps/utils.js
  31039. const {
  31040. Strophe: caps_utils_Strophe,
  31041. $build: utils_$build
  31042. } = core_converse.env;
  31043. function propertySort(array, property) {
  31044. return array.sort((a, b) => {
  31045. return a[property] > b[property] ? -1 : 1;
  31046. });
  31047. }
  31048. function generateVerificationString() {
  31049. const identities = shared_converse.api.disco.own.identities.get();
  31050. const features = shared_converse.api.disco.own.features.get();
  31051. if (identities.length > 1) {
  31052. propertySort(identities, "category");
  31053. propertySort(identities, "type");
  31054. propertySort(identities, "lang");
  31055. }
  31056. let S = identities.reduce((result, id) => `${result}${id.category}/${id.type}/${(id === null || id === void 0 ? void 0 : id.lang) ?? ''}/${id.name}<`, "");
  31057. features.sort();
  31058. S = features.reduce((result, feature) => `${result}${feature}<`, S);
  31059. return SHA1.b64_sha1(S);
  31060. }
  31061. function createCapsNode() {
  31062. return utils_$build("c", {
  31063. 'xmlns': caps_utils_Strophe.NS.CAPS,
  31064. 'hash': "sha-1",
  31065. 'node': "https://conversejs.org",
  31066. 'ver': generateVerificationString()
  31067. }).nodeTree;
  31068. }
  31069. ;// CONCATENATED MODULE: ./src/headless/plugins/caps/index.js
  31070. /**
  31071. * @copyright 2022, the Converse.js contributors
  31072. * @license Mozilla Public License (MPLv2)
  31073. */
  31074. const {
  31075. Strophe: caps_Strophe
  31076. } = core_converse.env;
  31077. caps_Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps");
  31078. core_converse.plugins.add('converse-caps', {
  31079. dependencies: ['converse-status'],
  31080. initialize() {
  31081. core_api.listen.on('constructedPresence', (_, p) => p.root().cnode(createCapsNode()).up() && p);
  31082. core_api.listen.on('constructedMUCPresence', (_, p) => p.root().cnode(createCapsNode()).up() && p);
  31083. }
  31084. });
  31085. ;// CONCATENATED MODULE: ./src/headless/plugins/carbons.js
  31086. /**
  31087. * @module converse-carbons
  31088. * @copyright The Converse.js contributors
  31089. * @license Mozilla Public License (MPLv2)
  31090. * @description Implements support for XEP-0280 Message Carbons
  31091. */
  31092. const {
  31093. u: carbons_u
  31094. } = core_converse.env;
  31095. /**
  31096. * Ask the XMPP server to enable Message Carbons
  31097. * See [XEP-0280](https://xmpp.org/extensions/xep-0280.html#enabling)
  31098. */
  31099. async function enableCarbons(reconnecting) {
  31100. var _converse$session;
  31101. if (reconnecting && shared_converse.session.get('carbons_enabled')) {
  31102. if (shared_converse.session.get('smacks_enabled')) {
  31103. // No need to re-enable carbons when resuming a XEP-0198 stream
  31104. return;
  31105. }
  31106. shared_converse.session.set({
  31107. 'carbons_enabled': false
  31108. });
  31109. }
  31110. if (!core_api.settings.get("message_carbons") || (_converse$session = shared_converse.session) !== null && _converse$session !== void 0 && _converse$session.get('carbons_enabled')) {
  31111. return;
  31112. }
  31113. const iq = new Strophe.Builder('iq', {
  31114. 'from': shared_converse.connection.jid,
  31115. 'type': 'set'
  31116. }).c('enable', {
  31117. xmlns: Strophe.NS.CARBONS
  31118. });
  31119. const result = await core_api.sendIQ(iq, null, false);
  31120. if (result === null) {
  31121. headless_log.warn(`A timeout occurred while trying to enable carbons`);
  31122. } else if (carbons_u.isErrorStanza(result)) {
  31123. headless_log.warn('An error occurred while trying to enable message carbons.');
  31124. headless_log.error(result);
  31125. } else {
  31126. shared_converse.session.set({
  31127. 'carbons_enabled': true
  31128. });
  31129. headless_log.debug('Message carbons have been enabled.');
  31130. }
  31131. shared_converse.session.save(); // Gather multiple sets into one save
  31132. }
  31133. core_converse.plugins.add('converse-carbons', {
  31134. initialize() {
  31135. core_api.settings.extend({
  31136. message_carbons: true
  31137. });
  31138. core_api.listen.on('connected', () => enableCarbons());
  31139. core_api.listen.on('reconnected', () => enableCarbons(true));
  31140. }
  31141. });
  31142. ;// CONCATENATED MODULE: ./src/headless/plugins/chatboxes/chatboxes.js
  31143. const ChatBoxes = Collection.extend({
  31144. comparator: 'time_opened',
  31145. model(attrs, options) {
  31146. return new shared_converse.ChatBox(attrs, options);
  31147. },
  31148. onChatBoxesFetched(collection) {
  31149. collection.filter(c => !c.isValid()).forEach(c => c.destroy());
  31150. /**
  31151. * Triggered once all chat boxes have been recreated from the browser cache
  31152. * @event _converse#chatBoxesFetched
  31153. * @type { object }
  31154. * @property { _converse.ChatBox | _converse.ChatRoom } chatbox
  31155. * @property { XMLElement } stanza
  31156. * @example _converse.api.listen.on('chatBoxesFetched', obj => { ... });
  31157. * @example _converse.api.waitUntil('chatBoxesFetched').then(() => { ... });
  31158. */
  31159. core_api.trigger('chatBoxesFetched');
  31160. },
  31161. onConnected(reconnecting) {
  31162. if (reconnecting) {
  31163. return;
  31164. }
  31165. initStorage(this, `converse.chatboxes-${shared_converse.bare_jid}`);
  31166. this.fetch({
  31167. 'add': true,
  31168. 'success': c => this.onChatBoxesFetched(c)
  31169. });
  31170. }
  31171. });
  31172. /* harmony default export */ const chatboxes = (ChatBoxes);
  31173. ;// CONCATENATED MODULE: ./src/headless/plugins/chatboxes/utils.js
  31174. const {
  31175. Strophe: chatboxes_utils_Strophe
  31176. } = core_converse.env;
  31177. async function createChatBox(jid, attrs, Model) {
  31178. jid = chatboxes_utils_Strophe.getBareJidFromJid(jid.toLowerCase());
  31179. Object.assign(attrs, {
  31180. 'jid': jid,
  31181. 'id': jid
  31182. });
  31183. let chatbox;
  31184. try {
  31185. chatbox = new Model(attrs, {
  31186. 'collection': shared_converse.chatboxes
  31187. });
  31188. } catch (e) {
  31189. headless_log.error(e);
  31190. return null;
  31191. }
  31192. await chatbox.initialized;
  31193. if (!chatbox.isValid()) {
  31194. chatbox.destroy();
  31195. return null;
  31196. }
  31197. shared_converse.chatboxes.add(chatbox);
  31198. return chatbox;
  31199. }
  31200. ;// CONCATENATED MODULE: ./src/headless/plugins/chatboxes/api.js
  31201. /**
  31202. * The "chatboxes" namespace.
  31203. *
  31204. * @namespace api.chatboxes
  31205. * @memberOf api
  31206. */
  31207. /* harmony default export */ const chatboxes_api = ({
  31208. /**
  31209. * @method api.chats.create
  31210. * @param { String|String[] } jids - A JID or array of JIDs
  31211. * @param { Object } [attrs] An object containing configuration attributes
  31212. * @param { Model } model - The type of chatbox that should be created
  31213. */
  31214. async create() {
  31215. let jids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  31216. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  31217. let model = arguments.length > 2 ? arguments[2] : undefined;
  31218. await core_api.waitUntil('chatBoxesFetched');
  31219. if (typeof jids === 'string') {
  31220. return createChatBox(jids, attrs, model);
  31221. } else {
  31222. return Promise.all(jids.map(jid => createChatBox(jid, attrs, model)));
  31223. }
  31224. },
  31225. /**
  31226. * @method api.chats.get
  31227. * @param { String|String[] } jids - A JID or array of JIDs
  31228. */
  31229. async get(jids) {
  31230. await core_api.waitUntil('chatBoxesFetched');
  31231. if (jids === undefined) {
  31232. return shared_converse.chatboxes.models;
  31233. } else if (typeof jids === 'string') {
  31234. return shared_converse.chatboxes.get(jids.toLowerCase());
  31235. } else {
  31236. jids = jids.map(j => j.toLowerCase());
  31237. return shared_converse.chatboxes.models.filter(m => jids.includes(m.get('jid')));
  31238. }
  31239. }
  31240. });
  31241. ;// CONCATENATED MODULE: ./src/headless/plugins/chatboxes/index.js
  31242. /**
  31243. * @copyright 2022, the Converse.js contributors
  31244. * @license Mozilla Public License (MPLv2)
  31245. */
  31246. const {
  31247. Strophe: chatboxes_Strophe
  31248. } = core_converse.env;
  31249. core_converse.plugins.add('converse-chatboxes', {
  31250. dependencies: ["converse-emoji", "converse-roster", "converse-vcard"],
  31251. initialize() {
  31252. core_api.promises.add(['chatBoxesFetched', 'chatBoxesInitialized', 'privateChatsAutoJoined']);
  31253. Object.assign(core_api, {
  31254. 'chatboxes': chatboxes_api
  31255. });
  31256. shared_converse.ChatBoxes = chatboxes;
  31257. core_api.listen.on('addClientFeatures', () => {
  31258. core_api.disco.own.features.add(chatboxes_Strophe.NS.MESSAGE_CORRECT);
  31259. core_api.disco.own.features.add(chatboxes_Strophe.NS.HTTPUPLOAD);
  31260. core_api.disco.own.features.add(chatboxes_Strophe.NS.OUTOFBAND);
  31261. });
  31262. core_api.listen.on('pluginsInitialized', () => {
  31263. shared_converse.chatboxes = new shared_converse.ChatBoxes();
  31264. /**
  31265. * Triggered once the _converse.ChatBoxes collection has been initialized.
  31266. * @event _converse#chatBoxesInitialized
  31267. * @example _converse.api.listen.on('chatBoxesInitialized', () => { ... });
  31268. * @example _converse.api.waitUntil('chatBoxesInitialized').then(() => { ... });
  31269. */
  31270. core_api.trigger('chatBoxesInitialized');
  31271. });
  31272. core_api.listen.on('presencesInitialized', reconnecting => shared_converse.chatboxes.onConnected(reconnecting));
  31273. core_api.listen.on('reconnected', () => shared_converse.chatboxes.forEach(m => m.onReconnection()));
  31274. }
  31275. });
  31276. ;// CONCATENATED MODULE: ./src/headless/plugins/headlines.js
  31277. /**
  31278. * @module converse-headlines
  31279. * @copyright 2022, the Converse.js contributors
  31280. * @description XEP-0045 Multi-User Chat Views
  31281. */
  31282. core_converse.plugins.add('converse-headlines', {
  31283. /* Plugin dependencies are other plugins which might be
  31284. * overridden or relied upon, and therefore need to be loaded before
  31285. * this plugin.
  31286. *
  31287. * If the setting "strict_plugin_dependencies" is set to true,
  31288. * an error will be raised if the plugin is not found. By default it's
  31289. * false, which means these plugins are only loaded opportunistically.
  31290. *
  31291. * NB: These plugins need to have already been loaded via require.js.
  31292. */
  31293. dependencies: ["converse-chat"],
  31294. overrides: {
  31295. // Overrides mentioned here will be picked up by converse.js's
  31296. // plugin architecture they will replace existing methods on the
  31297. // relevant objects or classes.
  31298. //
  31299. // New functions which don't exist yet can also be added.
  31300. ChatBoxes: {
  31301. model(attrs, options) {
  31302. const {
  31303. _converse
  31304. } = this.__super__;
  31305. if (attrs.type == _converse.HEADLINES_TYPE) {
  31306. return new _converse.HeadlinesBox(attrs, options);
  31307. } else {
  31308. return this.__super__.model.apply(this, arguments);
  31309. }
  31310. }
  31311. }
  31312. },
  31313. initialize() {
  31314. /* The initialize function gets called as soon as the plugin is
  31315. * loaded by converse.js's plugin machinery.
  31316. */
  31317. /**
  31318. * Shows headline messages
  31319. * @class
  31320. * @namespace _converse.HeadlinesBox
  31321. * @memberOf _converse
  31322. */
  31323. shared_converse.HeadlinesBox = shared_converse.ChatBox.extend({
  31324. defaults() {
  31325. return {
  31326. 'bookmarked': false,
  31327. 'hidden': ['mobile', 'fullscreen'].includes(core_api.settings.get("view_mode")),
  31328. 'message_type': 'headline',
  31329. 'num_unread': 0,
  31330. 'time_opened': this.get('time_opened') || new Date().getTime(),
  31331. 'type': shared_converse.HEADLINES_TYPE
  31332. };
  31333. },
  31334. async initialize() {
  31335. this.set({
  31336. 'box_id': `box-${this.get('jid')}`
  31337. });
  31338. this.initUI();
  31339. this.initMessages();
  31340. await this.fetchMessages();
  31341. /**
  31342. * Triggered once a {@link _converse.HeadlinesBox} has been created and initialized.
  31343. * @event _converse#headlinesBoxInitialized
  31344. * @type { _converse.HeadlinesBox }
  31345. * @example _converse.api.listen.on('headlinesBoxInitialized', model => { ... });
  31346. */
  31347. core_api.trigger('headlinesBoxInitialized', this);
  31348. }
  31349. });
  31350. async function onHeadlineMessage(stanza) {
  31351. // Handler method for all incoming messages of type "headline".
  31352. if (isHeadline(stanza) || isServerMessage(stanza)) {
  31353. const from_jid = stanza.getAttribute('from');
  31354. await core_api.waitUntil('rosterInitialized');
  31355. if (from_jid.includes('@') && !shared_converse.roster.get(from_jid) && !core_api.settings.get("allow_non_roster_messaging")) {
  31356. return;
  31357. }
  31358. if (stanza.querySelector('body') === null) {
  31359. // Avoid creating a chat box if we have nothing to show inside it.
  31360. return;
  31361. }
  31362. const chatbox = shared_converse.chatboxes.create({
  31363. 'id': from_jid,
  31364. 'jid': from_jid,
  31365. 'type': shared_converse.HEADLINES_TYPE,
  31366. 'from': from_jid
  31367. });
  31368. const attrs = await parseMessage(stanza, shared_converse);
  31369. await chatbox.createMessage(attrs);
  31370. core_api.trigger('message', {
  31371. chatbox,
  31372. stanza,
  31373. attrs
  31374. });
  31375. }
  31376. }
  31377. /************************ BEGIN Event Handlers ************************/
  31378. function registerHeadlineHandler() {
  31379. shared_converse.connection.addHandler(message => onHeadlineMessage(message) || true, null, 'message');
  31380. }
  31381. core_api.listen.on('connected', registerHeadlineHandler);
  31382. core_api.listen.on('reconnected', registerHeadlineHandler);
  31383. /************************ END Event Handlers ************************/
  31384. /************************ BEGIN API ************************/
  31385. Object.assign(core_api, {
  31386. /**
  31387. * The "headlines" namespace, which is used for headline-channels
  31388. * which are read-only channels containing messages of type
  31389. * "headline".
  31390. *
  31391. * @namespace api.headlines
  31392. * @memberOf api
  31393. */
  31394. headlines: {
  31395. /**
  31396. * Retrieves a headline-channel or all headline-channels.
  31397. *
  31398. * @method api.headlines.get
  31399. * @param {String|String[]} jids - e.g. 'buddy@example.com' or ['buddy1@example.com', 'buddy2@example.com']
  31400. * @param {Object} [attrs] - Attributes to be set on the _converse.ChatBox model.
  31401. * @param {Boolean} [create=false] - Whether the chat should be created if it's not found.
  31402. * @returns { Promise<_converse.HeadlinesBox> }
  31403. */
  31404. async get(jids) {
  31405. let attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  31406. let create = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  31407. async function _get(jid) {
  31408. let model = await core_api.chatboxes.get(jid);
  31409. if (!model && create) {
  31410. model = await core_api.chatboxes.create(jid, attrs, shared_converse.HeadlinesBox);
  31411. } else {
  31412. model = model && model.get('type') === shared_converse.HEADLINES_TYPE ? model : null;
  31413. if (model && Object.keys(attrs).length) {
  31414. model.save(attrs);
  31415. }
  31416. }
  31417. return model;
  31418. }
  31419. if (jids === undefined) {
  31420. const chats = await core_api.chatboxes.get();
  31421. return chats.filter(c => c.get('type') === shared_converse.HEADLINES_TYPE);
  31422. } else if (typeof jids === 'string') {
  31423. return _get(jids);
  31424. }
  31425. return Promise.all(jids.map(jid => _get(jid)));
  31426. }
  31427. }
  31428. });
  31429. /************************ END API ************************/
  31430. }
  31431. });
  31432. ;// CONCATENATED MODULE: ./src/headless/plugins/mam/placeholder.js
  31433. const placeholder_u = core_converse.env.utils;
  31434. class MAMPlaceholderMessage extends Model {
  31435. defaults() {
  31436. // eslint-disable-line class-methods-use-this
  31437. return {
  31438. 'msgid': placeholder_u.getUniqueId(),
  31439. 'is_ephemeral': false
  31440. };
  31441. }
  31442. }
  31443. ;// CONCATENATED MODULE: ./src/headless/shared/rsm.js
  31444. /**
  31445. * @module converse-rsm
  31446. * @copyright The Converse.js contributors
  31447. * @license Mozilla Public License (MPLv2)
  31448. * @description XEP-0059 Result Set Management
  31449. * Some code taken from the Strophe RSM plugin, licensed under the MIT License
  31450. * Copyright 2006-2017 Strophe (https://github.com/strophe/strophejs)
  31451. */
  31452. const {
  31453. Strophe: rsm_Strophe,
  31454. $build: rsm_$build
  31455. } = core_converse.env;
  31456. rsm_Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
  31457. /**
  31458. * @typedef { Object } RSMQueryParameters
  31459. * [XEP-0059 RSM](https://xmpp.org/extensions/xep-0059.html) Attributes that can be used to filter query results
  31460. * @property { String } [after] - The XEP-0359 stanza ID of a message after which messages should be returned. Implies forward paging.
  31461. * @property { String } [before] - The XEP-0359 stanza ID of a message before which messages should be returned. Implies backward paging.
  31462. * @property { Integer } [index=0] - The index of the results page to return.
  31463. * @property { Integer } [max] - The maximum number of items to return.
  31464. */
  31465. const RSM_QUERY_PARAMETERS = ['after', 'before', 'index', 'max'];
  31466. const rsm_toNumber = v => Number(v);
  31467. const rsm_toString = v => v.toString();
  31468. const RSM_TYPES = {
  31469. 'after': rsm_toString,
  31470. 'before': rsm_toString,
  31471. 'count': rsm_toNumber,
  31472. 'first': rsm_toString,
  31473. 'index': rsm_toNumber,
  31474. 'last': rsm_toString,
  31475. 'max': rsm_toNumber
  31476. };
  31477. const isUndefined = x => typeof x === 'undefined'; // This array contains both query attributes and response attributes
  31478. const RSM_ATTRIBUTES = Object.keys(RSM_TYPES);
  31479. /**
  31480. * Instances of this class are used to page through query results according to XEP-0059 Result Set Management
  31481. * @class RSM
  31482. */
  31483. class RSM {
  31484. static getQueryParameters() {
  31485. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  31486. return lodash_es_pick(options, RSM_QUERY_PARAMETERS);
  31487. }
  31488. static parseXMLResult(set) {
  31489. const result = {};
  31490. for (var i = 0; i < RSM_ATTRIBUTES.length; i++) {
  31491. const attr = RSM_ATTRIBUTES[i];
  31492. const elem = set.getElementsByTagName(attr)[0];
  31493. if (!isUndefined(elem) && elem !== null) {
  31494. result[attr] = RSM_TYPES[attr](rsm_Strophe.getText(elem));
  31495. if (attr == 'first') {
  31496. result.index = RSM_TYPES['index'](elem.getAttribute('index'));
  31497. }
  31498. }
  31499. }
  31500. return result;
  31501. }
  31502. /**
  31503. * Create a new RSM instance
  31504. * @param { Object } options - Configuration options
  31505. * @constructor
  31506. */
  31507. constructor() {
  31508. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  31509. this.query = RSM.getQueryParameters(options);
  31510. this.result = options.xml ? RSM.parseXMLResult(options.xml) : {};
  31511. }
  31512. /**
  31513. * Returns a `<set>` XML element that confirms to XEP-0059 Result Set Management.
  31514. * The element is constructed based on the {@link module:converse-rsm~RSMQueryParameters}
  31515. * that are set on this RSM instance.
  31516. * @returns { XMLElement }
  31517. */
  31518. toXML() {
  31519. const xml = rsm_$build('set', {
  31520. xmlns: rsm_Strophe.NS.RSM
  31521. });
  31522. const reducer = (xml, a) => !isUndefined(this.query[a]) ? xml.c(a).t((this.query[a] || '').toString()).up() : xml;
  31523. return RSM_QUERY_PARAMETERS.reduce(reducer, xml).tree();
  31524. }
  31525. next(max, before) {
  31526. const options = Object.assign({}, this.query, {
  31527. after: this.result.last,
  31528. before,
  31529. max
  31530. });
  31531. return new RSM(options);
  31532. }
  31533. previous(max, after) {
  31534. const options = Object.assign({}, this.query, {
  31535. after,
  31536. before: this.result.first,
  31537. max
  31538. });
  31539. return new RSM(options);
  31540. }
  31541. }
  31542. shared_converse.RSM_ATTRIBUTES = RSM_ATTRIBUTES;
  31543. shared_converse.RSM = RSM;
  31544. ;// CONCATENATED MODULE: ./src/headless/plugins/mam/api.js
  31545. const {
  31546. Strophe: mam_api_Strophe,
  31547. $iq: mam_api_$iq,
  31548. dayjs
  31549. } = core_converse.env;
  31550. const {
  31551. NS: api_NS
  31552. } = mam_api_Strophe;
  31553. const api_u = core_converse.env.utils;
  31554. /* harmony default export */ const mam_api = ({
  31555. /**
  31556. * The [XEP-0313](https://xmpp.org/extensions/xep-0313.html) Message Archive Management API
  31557. *
  31558. * Enables you to query an XMPP server for archived messages.
  31559. *
  31560. * See also the [message-archiving](/docs/html/configuration.html#message-archiving)
  31561. * option in the configuration settings section, which you'll
  31562. * usually want to use in conjunction with this API.
  31563. *
  31564. * @namespace _converse.api.archive
  31565. * @memberOf _converse.api
  31566. */
  31567. archive: {
  31568. /**
  31569. * @typedef { module:converse-rsm~RSMQueryParameters } MAMFilterParameters
  31570. * Filter parameters which can be used to filter a MAM XEP-0313 archive
  31571. * @property { String } [end] - A date string in ISO-8601 format, before which messages should be returned. Implies backward paging.
  31572. * @property { String } [start] - A date string in ISO-8601 format, after which messages should be returned. Implies forward paging.
  31573. * @property { String } [with] - A JID against which to match messages, according to either their `to` or `from` attributes.
  31574. * An item in a MUC archive matches if the publisher of the item matches the JID.
  31575. * If `with` is omitted, all messages that match the rest of the query will be returned, regardless of to/from
  31576. * addresses of each message.
  31577. */
  31578. /**
  31579. * The options that can be passed in to the {@link _converse.api.archive.query } method
  31580. * @typedef { module:converse-mam~MAMFilterParameters } ArchiveQueryOptions
  31581. * @property { Boolean } [groupchat=false] - Whether the MAM archive is for a groupchat.
  31582. */
  31583. /**
  31584. * Query for archived messages.
  31585. *
  31586. * The options parameter can also be an instance of
  31587. * RSM to enable easy querying between results pages.
  31588. *
  31589. * @method _converse.api.archive.query
  31590. * @param { module:converse-mam~ArchiveQueryOptions } options - An object containing query parameters
  31591. * @throws {Error} An error is thrown if the XMPP server responds with an error.
  31592. * @returns { Promise<module:converse-mam~MAMQueryResult> } A promise which resolves
  31593. * to a {@link module:converse-mam~MAMQueryResult } object.
  31594. *
  31595. * @example
  31596. * // Requesting all archived messages
  31597. * // ================================
  31598. * //
  31599. * // The simplest query that can be made is to simply not pass in any parameters.
  31600. * // Such a query will return all archived messages for the current user.
  31601. *
  31602. * let result;
  31603. * try {
  31604. * result = await api.archive.query();
  31605. * } catch (e) {
  31606. * // The query was not successful, perhaps inform the user?
  31607. * // The IQ stanza returned by the XMPP server is passed in, so that you
  31608. * // may inspect it and determine what the problem was.
  31609. * }
  31610. * // Do something with the messages, like showing them in your webpage.
  31611. * result.messages.forEach(m => this.showMessage(m));
  31612. *
  31613. * @example
  31614. * // Requesting all archived messages for a particular contact or room
  31615. * // =================================================================
  31616. * //
  31617. * // To query for messages sent between the current user and another user or room,
  31618. * // the query options need to contain the the JID (Jabber ID) of the user or
  31619. * // room under the `with` key.
  31620. *
  31621. * // For a particular user
  31622. * let result;
  31623. * try {
  31624. * result = await api.archive.query({'with': 'john@doe.net'});
  31625. * } catch (e) {
  31626. * // The query was not successful
  31627. * }
  31628. *
  31629. * // For a particular room
  31630. * let result;
  31631. * try {
  31632. * result = await api.archive.query({'with': 'discuss@conference.doglovers.net', 'groupchat': true});
  31633. * } catch (e) {
  31634. * // The query was not successful
  31635. * }
  31636. *
  31637. * @example
  31638. * // Requesting all archived messages before or after a certain date
  31639. * // ===============================================================
  31640. * //
  31641. * // The `start` and `end` parameters are used to query for messages
  31642. * // within a certain timeframe. The passed in date values may either be ISO8601
  31643. * // formatted date strings, or JavaScript Date objects.
  31644. *
  31645. * const options = {
  31646. * 'with': 'john@doe.net',
  31647. * 'start': '2010-06-07T00:00:00Z',
  31648. * 'end': '2010-07-07T13:23:54Z'
  31649. * };
  31650. * let result;
  31651. * try {
  31652. * result = await api.archive.query(options);
  31653. * } catch (e) {
  31654. * // The query was not successful
  31655. * }
  31656. *
  31657. * @example
  31658. * // Limiting the amount of messages returned
  31659. * // ========================================
  31660. * //
  31661. * // The amount of returned messages may be limited with the `max` parameter.
  31662. * // By default, the messages are returned from oldest to newest.
  31663. *
  31664. * // Return maximum 10 archived messages
  31665. * let result;
  31666. * try {
  31667. * result = await api.archive.query({'with': 'john@doe.net', 'max':10});
  31668. * } catch (e) {
  31669. * // The query was not successful
  31670. * }
  31671. *
  31672. * @example
  31673. * // Paging forwards through a set of archived messages
  31674. * // ==================================================
  31675. * //
  31676. * // When limiting the amount of messages returned per query, you might want to
  31677. * // repeatedly make a further query to fetch the next batch of messages.
  31678. * //
  31679. * // To simplify this usecase for you, the callback method receives not only an array
  31680. * // with the returned archived messages, but also a special RSM (*Result Set Management*)
  31681. * // object which contains the query parameters you passed in, as well
  31682. * // as two utility methods `next`, and `previous`.
  31683. * //
  31684. * // When you call one of these utility methods on the returned RSM object, and then
  31685. * // pass the result into a new query, you'll receive the next or previous batch of
  31686. * // archived messages. Please note, when calling these methods, pass in an integer
  31687. * // to limit your results.
  31688. *
  31689. * const options = {'with': 'john@doe.net', 'max':10};
  31690. * let result;
  31691. * try {
  31692. * result = await api.archive.query(options);
  31693. * } catch (e) {
  31694. * // The query was not successful
  31695. * }
  31696. * // Do something with the messages, like showing them in your webpage.
  31697. * result.messages.forEach(m => this.showMessage(m));
  31698. *
  31699. * while (!result.complete) {
  31700. * try {
  31701. * result = await api.archive.query(Object.assign(options, rsm.next(10).query));
  31702. * } catch (e) {
  31703. * // The query was not successful
  31704. * }
  31705. * // Do something with the messages, like showing them in your webpage.
  31706. * result.messages.forEach(m => this.showMessage(m));
  31707. * }
  31708. *
  31709. * @example
  31710. * // Paging backwards through a set of archived messages
  31711. * // ===================================================
  31712. * //
  31713. * // To page backwards through the archive, you need to know the UID of the message
  31714. * // which you'd like to page backwards from and then pass that as value for the
  31715. * // `before` parameter. If you simply want to page backwards from the most recent
  31716. * // message, pass in the `before` parameter with an empty string value `''`.
  31717. *
  31718. * let result;
  31719. * const options = {'before': '', 'max':5};
  31720. * try {
  31721. * result = await api.archive.query(options);
  31722. * } catch (e) {
  31723. * // The query was not successful
  31724. * }
  31725. * // Do something with the messages, like showing them in your webpage.
  31726. * result.messages.forEach(m => this.showMessage(m));
  31727. *
  31728. * // Now we query again, to get the previous batch.
  31729. * try {
  31730. * result = await api.archive.query(Object.assign(options, rsm.previous(5).query));
  31731. * } catch (e) {
  31732. * // The query was not successful
  31733. * }
  31734. * // Do something with the messages, like showing them in your webpage.
  31735. * result.messages.forEach(m => this.showMessage(m));
  31736. *
  31737. */
  31738. async query(options) {
  31739. if (!core_api.connection.connected()) {
  31740. throw new Error('Can\'t call `api.archive.query` before having established an XMPP session');
  31741. }
  31742. const attrs = {
  31743. 'type': 'set'
  31744. };
  31745. if (options && options.groupchat) {
  31746. if (!options['with']) {
  31747. throw new Error('You need to specify a "with" value containing ' + 'the chat room JID, when querying groupchat messages.');
  31748. }
  31749. attrs.to = options['with'];
  31750. }
  31751. const jid = attrs.to || shared_converse.bare_jid;
  31752. const supported = await core_api.disco.supports(api_NS.MAM, jid);
  31753. if (!supported) {
  31754. headless_log.warn(`Did not fetch MAM archive for ${jid} because it doesn't support ${api_NS.MAM}`);
  31755. return {
  31756. 'messages': []
  31757. };
  31758. }
  31759. const queryid = api_u.getUniqueId();
  31760. const stanza = mam_api_$iq(attrs).c('query', {
  31761. 'xmlns': api_NS.MAM,
  31762. 'queryid': queryid
  31763. });
  31764. if (options) {
  31765. stanza.c('x', {
  31766. 'xmlns': api_NS.XFORM,
  31767. 'type': 'submit'
  31768. }).c('field', {
  31769. 'var': 'FORM_TYPE',
  31770. 'type': 'hidden'
  31771. }).c('value').t(api_NS.MAM).up().up();
  31772. if (options['with'] && !options.groupchat) {
  31773. stanza.c('field', {
  31774. 'var': 'with'
  31775. }).c('value').t(options['with']).up().up();
  31776. }
  31777. ['start', 'end'].forEach(t => {
  31778. if (options[t]) {
  31779. const date = dayjs(options[t]);
  31780. if (date.isValid()) {
  31781. stanza.c('field', {
  31782. 'var': t
  31783. }).c('value').t(date.toISOString()).up().up();
  31784. } else {
  31785. throw new TypeError(`archive.query: invalid date provided for: ${t}`);
  31786. }
  31787. }
  31788. });
  31789. stanza.up();
  31790. const rsm = new RSM(options);
  31791. if (Object.keys(rsm.query).length) {
  31792. stanza.cnode(rsm.toXML());
  31793. }
  31794. }
  31795. const messages = [];
  31796. const message_handler = shared_converse.connection.addHandler(stanza => {
  31797. const result = sizzle_default()(`message > result[xmlns="${api_NS.MAM}"]`, stanza).pop();
  31798. if (result === undefined || result.getAttribute('queryid') !== queryid) {
  31799. return true;
  31800. }
  31801. const from = stanza.getAttribute('from') || shared_converse.bare_jid;
  31802. if (options.groupchat) {
  31803. if (from !== options['with']) {
  31804. headless_log.warn(`Ignoring alleged groupchat MAM message from ${stanza.getAttribute('from')}`);
  31805. return true;
  31806. }
  31807. } else if (from !== shared_converse.bare_jid) {
  31808. headless_log.warn(`Ignoring alleged MAM message from ${stanza.getAttribute('from')}`);
  31809. return true;
  31810. }
  31811. messages.push(stanza);
  31812. return true;
  31813. }, api_NS.MAM);
  31814. let error;
  31815. const timeout = core_api.settings.get('message_archiving_timeout');
  31816. const iq_result = await core_api.sendIQ(stanza, timeout, false);
  31817. if (iq_result === null) {
  31818. const {
  31819. __
  31820. } = shared_converse;
  31821. const err_msg = __("Timeout while trying to fetch archived messages.");
  31822. headless_log.error(err_msg);
  31823. error = new shared_converse.TimeoutError(err_msg);
  31824. return {
  31825. messages,
  31826. error
  31827. };
  31828. } else if (api_u.isErrorStanza(iq_result)) {
  31829. const {
  31830. __
  31831. } = shared_converse;
  31832. const err_msg = __('An error occurred while querying for archived messages.');
  31833. headless_log.error(err_msg);
  31834. headless_log.error(iq_result);
  31835. error = new Error(err_msg);
  31836. return {
  31837. messages,
  31838. error
  31839. };
  31840. }
  31841. shared_converse.connection.deleteHandler(message_handler);
  31842. let rsm;
  31843. const fin = iq_result && sizzle_default()(`fin[xmlns="${api_NS.MAM}"]`, iq_result).pop();
  31844. const complete = (fin === null || fin === void 0 ? void 0 : fin.getAttribute('complete')) === 'true';
  31845. const set = sizzle_default()(`set[xmlns="${api_NS.RSM}"]`, fin).pop();
  31846. if (set) {
  31847. rsm = new RSM({ ...options,
  31848. 'xml': set
  31849. });
  31850. }
  31851. /**
  31852. * @typedef { Object } MAMQueryResult
  31853. * @property { Array } messages
  31854. * @property { RSM } [rsm] - An instance of {@link RSM}.
  31855. * You can call `next()` or `previous()` on this instance,
  31856. * to get the RSM query parameters for the next or previous
  31857. * page in the result set.
  31858. * @property { Boolean } complete
  31859. * @property { Error } [error]
  31860. */
  31861. return {
  31862. messages,
  31863. rsm,
  31864. complete
  31865. };
  31866. }
  31867. }
  31868. });
  31869. ;// CONCATENATED MODULE: ./src/headless/plugins/mam/utils.js
  31870. const {
  31871. Strophe: mam_utils_Strophe,
  31872. $iq: mam_utils_$iq
  31873. } = core_converse.env;
  31874. const {
  31875. NS: utils_NS
  31876. } = mam_utils_Strophe;
  31877. const mam_utils_u = core_converse.env.utils;
  31878. function onMAMError(iq) {
  31879. if (iq !== null && iq !== void 0 && iq.querySelectorAll('feature-not-implemented').length) {
  31880. headless_log.warn(`Message Archive Management (XEP-0313) not supported by ${iq.getAttribute('from')}`);
  31881. } else {
  31882. headless_log.error(`Error while trying to set archiving preferences for ${iq.getAttribute('from')}.`);
  31883. headless_log.error(iq);
  31884. }
  31885. }
  31886. /**
  31887. * Handle returned IQ stanza containing Message Archive
  31888. * Management (XEP-0313) preferences.
  31889. *
  31890. * XXX: For now we only handle the global default preference.
  31891. * The XEP also provides for per-JID preferences, which is
  31892. * currently not supported in converse.js.
  31893. *
  31894. * Per JID preferences will be set in chat boxes, so it'll
  31895. * probbaly be handled elsewhere in any case.
  31896. */
  31897. function onMAMPreferences(iq, feature) {
  31898. const preference = sizzle_default()(`prefs[xmlns="${utils_NS.MAM}"]`, iq).pop();
  31899. const default_pref = preference.getAttribute('default');
  31900. if (default_pref !== core_api.settings.get('message_archiving')) {
  31901. const stanza = mam_utils_$iq({
  31902. 'type': 'set'
  31903. }).c('prefs', {
  31904. 'xmlns': utils_NS.MAM,
  31905. 'default': core_api.settings.get('message_archiving')
  31906. });
  31907. Array.from(preference.children).forEach(child => stanza.cnode(child).up()); // XXX: Strictly speaking, the server should respond with the updated prefs
  31908. // (see example 18: https://xmpp.org/extensions/xep-0313.html#config)
  31909. // but Prosody doesn't do this, so we don't rely on it.
  31910. core_api.sendIQ(stanza).then(() => feature.save({
  31911. 'preferences': {
  31912. 'default': core_api.settings.get('message_archiving')
  31913. }
  31914. })).catch(shared_converse.onMAMError);
  31915. } else {
  31916. feature.save({
  31917. 'preferences': {
  31918. 'default': core_api.settings.get('message_archiving')
  31919. }
  31920. });
  31921. }
  31922. }
  31923. function getMAMPrefsFromFeature(feature) {
  31924. const prefs = feature.get('preferences') || {};
  31925. if (feature.get('var') !== utils_NS.MAM || core_api.settings.get('message_archiving') === undefined) {
  31926. return;
  31927. }
  31928. if (prefs['default'] !== core_api.settings.get('message_archiving')) {
  31929. core_api.sendIQ(mam_utils_$iq({
  31930. 'type': 'get'
  31931. }).c('prefs', {
  31932. 'xmlns': utils_NS.MAM
  31933. })).then(iq => shared_converse.onMAMPreferences(iq, feature)).catch(shared_converse.onMAMError);
  31934. }
  31935. }
  31936. function preMUCJoinMAMFetch(muc) {
  31937. if (!core_api.settings.get('muc_show_logs_before_join') || !muc.features.get('mam_enabled') || muc.get('prejoin_mam_fetched')) {
  31938. return;
  31939. }
  31940. fetchNewestMessages(muc);
  31941. muc.save({
  31942. 'prejoin_mam_fetched': true
  31943. });
  31944. }
  31945. async function handleMAMResult(model, result, query, options, should_page) {
  31946. await core_api.emojis.initialize();
  31947. const is_muc = model.get('type') === shared_converse.CHATROOMS_TYPE;
  31948. const doParseMessage = s => is_muc ? parseMUCMessage(s, model) : parseMessage(s);
  31949. const messages = await Promise.all(result.messages.map(doParseMessage));
  31950. result.messages = messages;
  31951. /**
  31952. * Synchronous event which allows listeners to first do some
  31953. * work based on the MAM result before calling the handlers here.
  31954. * @event _converse#MAMResult
  31955. */
  31956. const data = {
  31957. query,
  31958. 'chatbox': model,
  31959. messages
  31960. };
  31961. await core_api.trigger('MAMResult', data, {
  31962. 'synchronous': true
  31963. });
  31964. messages.forEach(m => model.queueMessage(m));
  31965. if (result.error) {
  31966. const event_id = result.error.retry_event_id = mam_utils_u.getUniqueId();
  31967. core_api.listen.once(event_id, () => fetchArchivedMessages(model, options, should_page));
  31968. model.createMessageFromError(result.error);
  31969. }
  31970. }
  31971. /**
  31972. * @typedef { Object } MAMOptions
  31973. * A map of MAM related options that may be passed to fetchArchivedMessages
  31974. * @param { integer } [options.max] - The maximum number of items to return.
  31975. * Defaults to "archived_messages_page_size"
  31976. * @param { string } [options.after] - The XEP-0359 stanza ID of a message
  31977. * after which messages should be returned. Implies forward paging.
  31978. * @param { string } [options.before] - The XEP-0359 stanza ID of a message
  31979. * before which messages should be returned. Implies backward paging.
  31980. * @param { string } [options.end] - A date string in ISO-8601 format,
  31981. * before which messages should be returned. Implies backward paging.
  31982. * @param { string } [options.start] - A date string in ISO-8601 format,
  31983. * after which messages should be returned. Implies forward paging.
  31984. * @param { string } [options.with] - The JID of the entity with
  31985. * which messages were exchanged.
  31986. * @param { boolean } [options.groupchat] - True if archive in groupchat.
  31987. */
  31988. /**
  31989. * Fetch XEP-0313 archived messages based on the passed in criteria.
  31990. * @param { _converse.ChatBox | _converse.ChatRoom } model
  31991. * @param { MAMOptions } [options]
  31992. * @param { ('forwards'|'backwards'|null)} [should_page=null] - Determines whether
  31993. * this function should recursively page through the entire result set if a limited
  31994. * number of results were returned.
  31995. */
  31996. async function fetchArchivedMessages(model) {
  31997. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  31998. let should_page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  31999. if (model.disable_mam) {
  32000. return;
  32001. }
  32002. const is_muc = model.get('type') === shared_converse.CHATROOMS_TYPE;
  32003. const mam_jid = is_muc ? model.get('jid') : shared_converse.bare_jid;
  32004. if (!(await core_api.disco.supports(utils_NS.MAM, mam_jid))) {
  32005. return;
  32006. }
  32007. const max = core_api.settings.get('archived_messages_page_size');
  32008. const query = Object.assign({
  32009. 'groupchat': is_muc,
  32010. 'max': max,
  32011. 'with': model.get('jid')
  32012. }, options);
  32013. const result = await core_api.archive.query(query);
  32014. await handleMAMResult(model, result, query, options, should_page);
  32015. if (result.rsm && !result.complete) {
  32016. if (should_page) {
  32017. if (should_page === 'forwards') {
  32018. options = result.rsm.next(max, options.before).query;
  32019. } else if (should_page === 'backwards') {
  32020. options = result.rsm.previous(max, options.after).query;
  32021. }
  32022. return fetchArchivedMessages(model, options, should_page);
  32023. } else {
  32024. createPlaceholder(model, options, result);
  32025. }
  32026. }
  32027. }
  32028. /**
  32029. * Create a placeholder message which is used to indicate gaps in the history.
  32030. * @param { _converse.ChatBox | _converse.ChatRoom } model
  32031. * @param { MAMOptions } options
  32032. * @param { object } result - The RSM result object
  32033. */
  32034. async function createPlaceholder(model, options, result) {
  32035. if (options.before == '' && (model.messages.length === 0 || !options.start)) {
  32036. // Fetching the latest MAM messages with an empty local cache
  32037. return;
  32038. }
  32039. if (options.before && !options.start) {
  32040. // Infinite scrolling upward
  32041. return;
  32042. }
  32043. if (options.before == null) {
  32044. // eslint-disable-line no-eq-null
  32045. // Adding placeholders when paging forwards is not supported yet,
  32046. // since currently with standard Converse, we only page forwards
  32047. // when fetching the entire history (i.e. no gaps should arise).
  32048. return;
  32049. }
  32050. const msgs = await Promise.all(result.messages);
  32051. const {
  32052. rsm
  32053. } = result;
  32054. const key = `stanza_id ${model.get('jid')}`;
  32055. const adjacent_message = msgs.find(m => m[key] === rsm.result.first);
  32056. const msg_data = {
  32057. 'template_hook': 'getMessageTemplate',
  32058. 'time': new Date(new Date(adjacent_message['time']) - 1).toISOString(),
  32059. 'before': rsm.result.first,
  32060. 'start': options.start
  32061. };
  32062. model.messages.add(new MAMPlaceholderMessage(msg_data));
  32063. }
  32064. /**
  32065. * Fetches messages that might have been archived *after*
  32066. * the last archived message in our local cache.
  32067. * @param { _converse.ChatBox | _converse.ChatRoom }
  32068. */
  32069. function fetchNewestMessages(model) {
  32070. if (model.disable_mam) {
  32071. return;
  32072. }
  32073. const most_recent_msg = model.getMostRecentMessage(); // if clear_messages_on_reconnection is true, than any recent messages
  32074. // must have been received *after* connection and we instead must query
  32075. // for earlier messages
  32076. if (most_recent_msg && !core_api.settings.get('clear_messages_on_reconnection')) {
  32077. const should_page = core_api.settings.get('mam_request_all_pages');
  32078. if (should_page) {
  32079. const stanza_id = most_recent_msg.get(`stanza_id ${model.get('jid')}`);
  32080. if (stanza_id) {
  32081. fetchArchivedMessages(model, {
  32082. 'after': stanza_id
  32083. }, 'forwards');
  32084. } else {
  32085. fetchArchivedMessages(model, {
  32086. 'start': most_recent_msg.get('time')
  32087. }, 'forwards');
  32088. }
  32089. } else {
  32090. fetchArchivedMessages(model, {
  32091. 'before': '',
  32092. 'start': most_recent_msg.get('time')
  32093. });
  32094. }
  32095. } else {
  32096. fetchArchivedMessages(model, {
  32097. 'before': ''
  32098. });
  32099. }
  32100. }
  32101. ;// CONCATENATED MODULE: ./src/headless/plugins/mam/index.js
  32102. /**
  32103. * @description XEP-0313 Message Archive Management
  32104. * @copyright 2022, the Converse.js contributors
  32105. * @license Mozilla Public License (MPLv2)
  32106. */
  32107. const {
  32108. Strophe: mam_Strophe
  32109. } = core_converse.env;
  32110. const {
  32111. NS: mam_NS
  32112. } = mam_Strophe;
  32113. core_converse.plugins.add('converse-mam', {
  32114. dependencies: ['converse-disco', 'converse-muc'],
  32115. initialize() {
  32116. core_api.settings.extend({
  32117. archived_messages_page_size: '50',
  32118. mam_request_all_pages: true,
  32119. message_archiving: undefined,
  32120. // Supported values are 'always', 'never', 'roster' (https://xmpp.org/extensions/xep-0313.html#prefs)
  32121. message_archiving_timeout: 20000 // Time (in milliseconds) to wait before aborting MAM request
  32122. });
  32123. Object.assign(core_api, mam_api); // This is mainly done to aid with tests
  32124. Object.assign(shared_converse, {
  32125. onMAMError: onMAMError,
  32126. onMAMPreferences: onMAMPreferences,
  32127. handleMAMResult: handleMAMResult,
  32128. MAMPlaceholderMessage: MAMPlaceholderMessage
  32129. });
  32130. /************************ Event Handlers ************************/
  32131. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(mam_NS.MAM));
  32132. core_api.listen.on('serviceDiscovered', getMAMPrefsFromFeature);
  32133. core_api.listen.on('chatRoomViewInitialized', view => {
  32134. if (core_api.settings.get('muc_show_logs_before_join')) {
  32135. preMUCJoinMAMFetch(view.model); // If we want to show MAM logs before entering the MUC, we need
  32136. // to be informed once it's clear that this MUC supports MAM.
  32137. view.model.features.on('change:mam_enabled', () => preMUCJoinMAMFetch(view.model));
  32138. }
  32139. });
  32140. core_api.listen.on('enteredNewRoom', muc => muc.features.get('mam_enabled') && fetchNewestMessages(muc));
  32141. core_api.listen.on('chatReconnected', chat => {
  32142. // XXX: For MUCs, we listen to enteredNewRoom instead
  32143. if (chat.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  32144. fetchNewestMessages(chat);
  32145. }
  32146. });
  32147. core_api.listen.on('afterMessagesFetched', chat => {
  32148. // XXX: We don't want to query MAM every time this is triggered
  32149. // since it's not necessary when the chat is restored from cache.
  32150. // (given that BOSH or SMACKS will ensure that you get messages
  32151. // sent during the reload).
  32152. // With MUCs we can listen for `enteredNewRoom`.
  32153. if (chat.get('type') === shared_converse.PRIVATE_CHAT_TYPE && !shared_converse.connection.restored) {
  32154. fetchNewestMessages(chat);
  32155. }
  32156. });
  32157. }
  32158. });
  32159. ;// CONCATENATED MODULE: ./src/headless/plugins/ping/utils.js
  32160. const {
  32161. Strophe: ping_utils_Strophe,
  32162. $iq: ping_utils_$iq
  32163. } = core_converse.env;
  32164. let lastStanzaDate;
  32165. function utils_onWindowStateChanged(data) {
  32166. if (data.state === 'visible' && core_api.connection.connected()) {
  32167. core_api.ping(null, 5000);
  32168. }
  32169. }
  32170. function setLastStanzaDate(date) {
  32171. lastStanzaDate = date;
  32172. }
  32173. function pong(ping) {
  32174. lastStanzaDate = new Date();
  32175. const from = ping.getAttribute('from');
  32176. const id = ping.getAttribute('id');
  32177. const iq = ping_utils_$iq({
  32178. type: 'result',
  32179. to: from,
  32180. id: id
  32181. });
  32182. shared_converse.connection.sendIQ(iq);
  32183. return true;
  32184. }
  32185. function registerPongHandler() {
  32186. const {
  32187. connection
  32188. } = shared_converse;
  32189. if (connection.disco) {
  32190. core_api.disco.own.features.add(ping_utils_Strophe.NS.PING);
  32191. }
  32192. return connection.addHandler(pong, ping_utils_Strophe.NS.PING, "iq", "get");
  32193. }
  32194. function registerPingHandler() {
  32195. shared_converse.connection.addHandler(() => {
  32196. if (core_api.settings.get('ping_interval') > 0) {
  32197. // Handler on each stanza, saves the received date
  32198. // in order to ping only when needed.
  32199. lastStanzaDate = new Date();
  32200. return true;
  32201. }
  32202. });
  32203. }
  32204. function onConnected() {
  32205. // Wrapper so that we can spy on registerPingHandler in tests
  32206. registerPongHandler();
  32207. registerPingHandler();
  32208. }
  32209. function onEverySecond() {
  32210. if (shared_converse.isTestEnv() || !core_api.connection.connected()) {
  32211. return;
  32212. }
  32213. const ping_interval = core_api.settings.get('ping_interval');
  32214. if (ping_interval > 0) {
  32215. const now = new Date();
  32216. if (!lastStanzaDate) {
  32217. lastStanzaDate = now;
  32218. }
  32219. if ((now - lastStanzaDate) / 1000 > ping_interval) {
  32220. core_api.ping();
  32221. }
  32222. }
  32223. }
  32224. ;// CONCATENATED MODULE: ./src/headless/plugins/ping/api.js
  32225. const {
  32226. Strophe: ping_api_Strophe,
  32227. $iq: ping_api_$iq,
  32228. u: ping_api_u
  32229. } = core_converse.env;
  32230. /* harmony default export */ const ping_api = ({
  32231. /**
  32232. * Pings the service represented by the passed in JID by sending an IQ stanza.
  32233. * @private
  32234. * @method api.ping
  32235. * @param { String } [jid] - The JID of the service to ping
  32236. * @param { Integer } [timeout] - The amount of time in
  32237. * milliseconds to wait for a response. The default is 10000;
  32238. */
  32239. async ping(jid, timeout) {
  32240. // XXX: We could first check here if the server advertised that it supports PING.
  32241. // However, some servers don't advertise while still responding to pings
  32242. //
  32243. // const feature = _converse.disco_entities[_converse.domain].features.findWhere({'var': Strophe.NS.PING});
  32244. setLastStanzaDate(new Date());
  32245. jid = jid || ping_api_Strophe.getDomainFromJid(shared_converse.bare_jid);
  32246. if (shared_converse.connection) {
  32247. const iq = ping_api_$iq({
  32248. 'type': 'get',
  32249. 'to': jid,
  32250. 'id': ping_api_u.getUniqueId('ping')
  32251. }).c('ping', {
  32252. 'xmlns': ping_api_Strophe.NS.PING
  32253. });
  32254. const result = await core_api.sendIQ(iq, timeout || 10000, false);
  32255. if (result === null) {
  32256. headless_log.warn(`Timeout while pinging ${jid}`);
  32257. if (jid === ping_api_Strophe.getDomainFromJid(shared_converse.bare_jid)) {
  32258. core_api.connection.reconnect();
  32259. }
  32260. } else if (ping_api_u.isErrorStanza(result)) {
  32261. headless_log.error(`Error while pinging ${jid}`);
  32262. headless_log.error(result);
  32263. }
  32264. return true;
  32265. }
  32266. return false;
  32267. }
  32268. });
  32269. ;// CONCATENATED MODULE: ./src/headless/plugins/ping/index.js
  32270. /**
  32271. * @description
  32272. * Converse.js plugin which add support for application-level pings
  32273. * as specified in XEP-0199 XMPP Ping.
  32274. * @copyright 2022, the Converse.js contributors
  32275. * @license Mozilla Public License (MPLv2)
  32276. */
  32277. const {
  32278. Strophe: ping_Strophe
  32279. } = core_converse.env;
  32280. ping_Strophe.addNamespace('PING', "urn:xmpp:ping");
  32281. core_converse.plugins.add('converse-ping', {
  32282. initialize() {
  32283. core_api.settings.extend({
  32284. ping_interval: 60 //in seconds
  32285. });
  32286. Object.assign(core_api, ping_api);
  32287. setInterval(onEverySecond, 1000);
  32288. core_api.listen.on('connected', onConnected);
  32289. core_api.listen.on('reconnected', onConnected);
  32290. core_api.listen.on('windowStateChanged', utils_onWindowStateChanged);
  32291. }
  32292. });
  32293. ;// CONCATENATED MODULE: ./src/headless/plugins/pubsub.js
  32294. /**
  32295. * @module converse-pubsub
  32296. * @copyright The Converse.js contributors
  32297. * @license Mozilla Public License (MPLv2)
  32298. */
  32299. const {
  32300. Strophe: pubsub_Strophe,
  32301. $iq: pubsub_$iq
  32302. } = core_converse.env;
  32303. pubsub_Strophe.addNamespace('PUBSUB_ERROR', pubsub_Strophe.NS.PUBSUB + "#errors");
  32304. core_converse.plugins.add('converse-pubsub', {
  32305. dependencies: ["converse-disco"],
  32306. initialize() {
  32307. /************************ BEGIN API ************************/
  32308. // We extend the default converse.js API to add methods specific to MUC groupchats.
  32309. Object.assign(shared_converse.api, {
  32310. /**
  32311. * The "pubsub" namespace groups methods relevant to PubSub
  32312. *
  32313. * @namespace _converse.api.pubsub
  32314. * @memberOf _converse.api
  32315. */
  32316. 'pubsub': {
  32317. /**
  32318. * Publshes an item to a PubSub node
  32319. *
  32320. * @method _converse.api.pubsub.publish
  32321. * @param {string} jid The JID of the pubsub service where the node resides.
  32322. * @param {string} node The node being published to
  32323. * @param {Strophe.Builder} item The Strophe.Builder representation of the XML element being published
  32324. * @param {object} options An object representing the publisher options
  32325. * (see https://xmpp.org/extensions/xep-0060.html#publisher-publish-options)
  32326. * @param {boolean} strict_options Indicates whether the publisher
  32327. * options are a strict requirement or not. If they're NOT
  32328. * strict, then Converse will publish to the node even if
  32329. * the publish options precondication cannot be met.
  32330. */
  32331. async 'publish'(jid, node, item, options) {
  32332. let strict_options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  32333. const stanza = pubsub_$iq({
  32334. 'from': shared_converse.bare_jid,
  32335. 'type': 'set',
  32336. 'to': jid
  32337. }).c('pubsub', {
  32338. 'xmlns': pubsub_Strophe.NS.PUBSUB
  32339. }).c('publish', {
  32340. 'node': node
  32341. }).cnode(item.tree()).up().up();
  32342. if (options) {
  32343. jid = jid || shared_converse.bare_jid;
  32344. if (await core_api.disco.supports(pubsub_Strophe.NS.PUBSUB + '#publish-options', jid)) {
  32345. stanza.c('publish-options').c('x', {
  32346. 'xmlns': pubsub_Strophe.NS.XFORM,
  32347. 'type': 'submit'
  32348. }).c('field', {
  32349. 'var': 'FORM_TYPE',
  32350. 'type': 'hidden'
  32351. }).c('value').t(`${pubsub_Strophe.NS.PUBSUB}#publish-options`).up().up();
  32352. Object.keys(options).forEach(k => stanza.c('field', {
  32353. 'var': k
  32354. }).c('value').t(options[k]).up().up());
  32355. } else {
  32356. headless_log.warn(`_converse.api.publish: ${jid} does not support #publish-options, ` + `so we didn't set them even though they were provided.`);
  32357. }
  32358. }
  32359. try {
  32360. await core_api.sendIQ(stanza);
  32361. } catch (iq) {
  32362. if (iq instanceof Element && strict_options && iq.querySelector(`precondition-not-met[xmlns="${pubsub_Strophe.NS.PUBSUB_ERROR}"]`)) {
  32363. // The publish-options precondition couldn't be
  32364. // met. We re-publish but without publish-options.
  32365. const el = stanza.nodeTree;
  32366. el.querySelector('publish-options').outerHTML = '';
  32367. headless_log.warn(`PubSub: Republishing without publish options. ${el.outerHTML}`);
  32368. await core_api.sendIQ(el);
  32369. } else {
  32370. throw iq;
  32371. }
  32372. }
  32373. }
  32374. }
  32375. });
  32376. /************************ END API ************************/
  32377. }
  32378. });
  32379. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isNumber.js
  32380. /** `Object#toString` result references. */
  32381. var isNumber_numberTag = '[object Number]';
  32382. /**
  32383. * Checks if `value` is classified as a `Number` primitive or object.
  32384. *
  32385. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  32386. * classified as numbers, use the `_.isFinite` method.
  32387. *
  32388. * @static
  32389. * @memberOf _
  32390. * @since 0.1.0
  32391. * @category Lang
  32392. * @param {*} value The value to check.
  32393. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  32394. * @example
  32395. *
  32396. * _.isNumber(3);
  32397. * // => true
  32398. *
  32399. * _.isNumber(Number.MIN_VALUE);
  32400. * // => true
  32401. *
  32402. * _.isNumber(Infinity);
  32403. * // => true
  32404. *
  32405. * _.isNumber('3');
  32406. * // => false
  32407. */
  32408. function isNumber(value) {
  32409. return typeof value == 'number' ||
  32410. (lodash_es_isObjectLike(value) && _baseGetTag(value) == isNumber_numberTag);
  32411. }
  32412. /* harmony default export */ const lodash_es_isNumber = (isNumber);
  32413. ;// CONCATENATED MODULE: ./node_modules/lodash-es/isNaN.js
  32414. /**
  32415. * Checks if `value` is `NaN`.
  32416. *
  32417. * **Note:** This method is based on
  32418. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  32419. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  32420. * `undefined` and other non-number values.
  32421. *
  32422. * @static
  32423. * @memberOf _
  32424. * @since 0.1.0
  32425. * @category Lang
  32426. * @param {*} value The value to check.
  32427. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  32428. * @example
  32429. *
  32430. * _.isNaN(NaN);
  32431. * // => true
  32432. *
  32433. * _.isNaN(new Number(NaN));
  32434. * // => true
  32435. *
  32436. * isNaN(undefined);
  32437. * // => true
  32438. *
  32439. * _.isNaN(undefined);
  32440. * // => false
  32441. */
  32442. function isNaN_isNaN(value) {
  32443. // An `NaN` primitive is the only value that is not equal to itself.
  32444. // Perform the `toStringTag` check first to avoid errors with some
  32445. // ActiveX objects in IE.
  32446. return lodash_es_isNumber(value) && value != +value;
  32447. }
  32448. /* harmony default export */ const lodash_es_isNaN = (isNaN_isNaN);
  32449. ;// CONCATENATED MODULE: ./src/headless/plugins/status/status.js
  32450. const {
  32451. Strophe: status_Strophe,
  32452. $pres: status_$pres
  32453. } = core_converse.env;
  32454. const XMPPStatus = Model.extend({
  32455. defaults() {
  32456. return {
  32457. "status": core_api.settings.get("default_state")
  32458. };
  32459. },
  32460. initialize() {
  32461. this.on('change', item => {
  32462. if (!lodash_es_isObject(item.changed)) {
  32463. return;
  32464. }
  32465. if ('status' in item.changed || 'status_message' in item.changed) {
  32466. core_api.user.presence.send(this.get('status'), null, this.get('status_message'));
  32467. }
  32468. });
  32469. },
  32470. getNickname() {
  32471. return core_api.settings.get('nickname');
  32472. },
  32473. getFullname() {
  32474. // Gets overridden in converse-vcard
  32475. return '';
  32476. },
  32477. async constructPresence(type) {
  32478. let to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  32479. let status_message = arguments.length > 2 ? arguments[2] : undefined;
  32480. type = typeof type === 'string' ? type : this.get('status') || core_api.settings.get("default_state");
  32481. status_message = typeof status_message === 'string' ? status_message : this.get('status_message');
  32482. let presence;
  32483. const attrs = {
  32484. to
  32485. };
  32486. if (type === 'unavailable' || type === 'probe' || type === 'error' || type === 'unsubscribe' || type === 'unsubscribed' || type === 'subscribe' || type === 'subscribed') {
  32487. attrs['type'] = type;
  32488. presence = status_$pres(attrs);
  32489. } else if (type === 'offline') {
  32490. attrs['type'] = 'unavailable';
  32491. presence = status_$pres(attrs);
  32492. } else if (type === 'online') {
  32493. presence = status_$pres(attrs);
  32494. } else {
  32495. presence = status_$pres(attrs).c('show').t(type).up();
  32496. }
  32497. if (status_message) {
  32498. presence.c('status').t(status_message).up();
  32499. }
  32500. const priority = core_api.settings.get("priority");
  32501. presence.c('priority').t(lodash_es_isNaN(Number(priority)) ? 0 : priority).up();
  32502. if (shared_converse.idle) {
  32503. const idle_since = new Date();
  32504. idle_since.setSeconds(idle_since.getSeconds() - shared_converse.idle_seconds);
  32505. presence.c('idle', {
  32506. xmlns: status_Strophe.NS.IDLE,
  32507. since: idle_since.toISOString()
  32508. });
  32509. }
  32510. presence = await core_api.hook('constructedPresence', null, presence);
  32511. return presence;
  32512. }
  32513. });
  32514. /* harmony default export */ const status_status = (XMPPStatus);
  32515. ;// CONCATENATED MODULE: ./src/headless/plugins/status/api.js
  32516. /* harmony default export */ const status_api = ({
  32517. /**
  32518. * @namespace _converse.api.user.presence
  32519. * @memberOf _converse.api.user
  32520. */
  32521. presence: {
  32522. /**
  32523. * Send out a presence stanza
  32524. * @method _converse.api.user.presence.send
  32525. * @param { String } type
  32526. * @param { String } to
  32527. * @param { String } [status] - An optional status message
  32528. * @param { Element[]|Strophe.Builder[]|Element|Strophe.Builder } [child_nodes]
  32529. * Nodes(s) to be added as child nodes of the `presence` XML element.
  32530. */
  32531. async send(type, to, status, child_nodes) {
  32532. var _child_nodes;
  32533. await core_api.waitUntil('statusInitialized');
  32534. if (child_nodes && !Array.isArray(child_nodes)) {
  32535. child_nodes = [child_nodes];
  32536. }
  32537. const model = shared_converse.xmppstatus;
  32538. const presence = await model.constructPresence(type, to, status);
  32539. (_child_nodes = child_nodes) === null || _child_nodes === void 0 ? void 0 : _child_nodes.map(c => (c === null || c === void 0 ? void 0 : c.tree()) ?? c).forEach(c => presence.cnode(c).up());
  32540. core_api.send(presence);
  32541. if (['away', 'chat', 'dnd', 'online', 'xa', undefined].includes(type)) {
  32542. const mucs = await core_api.rooms.get();
  32543. mucs.forEach(muc => muc.sendStatusPresence(type, status, child_nodes));
  32544. }
  32545. }
  32546. },
  32547. /**
  32548. * Set and get the user's chat status, also called their *availability*.
  32549. * @namespace _converse.api.user.status
  32550. * @memberOf _converse.api.user
  32551. */
  32552. status: {
  32553. /**
  32554. * Return the current user's availability status.
  32555. * @async
  32556. * @method _converse.api.user.status.get
  32557. * @example _converse.api.user.status.get();
  32558. */
  32559. async get() {
  32560. await core_api.waitUntil('statusInitialized');
  32561. return shared_converse.xmppstatus.get('status');
  32562. },
  32563. /**
  32564. * The user's status can be set to one of the following values:
  32565. *
  32566. * @async
  32567. * @method _converse.api.user.status.set
  32568. * @param {string} value The user's chat status (e.g. 'away', 'dnd', 'offline', 'online', 'unavailable' or 'xa')
  32569. * @param {string} [message] A custom status message
  32570. *
  32571. * @example _converse.api.user.status.set('dnd');
  32572. * @example _converse.api.user.status.set('dnd', 'In a meeting');
  32573. */
  32574. async set(value, message) {
  32575. const data = {
  32576. 'status': value
  32577. };
  32578. if (!Object.keys(shared_converse.STATUS_WEIGHTS).includes(value)) {
  32579. throw new Error('Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1');
  32580. }
  32581. if (typeof message === 'string') {
  32582. data.status_message = message;
  32583. }
  32584. await core_api.waitUntil('statusInitialized');
  32585. shared_converse.xmppstatus.save(data);
  32586. },
  32587. /**
  32588. * Set and retrieve the user's custom status message.
  32589. *
  32590. * @namespace _converse.api.user.status.message
  32591. * @memberOf _converse.api.user.status
  32592. */
  32593. message: {
  32594. /**
  32595. * @async
  32596. * @method _converse.api.user.status.message.get
  32597. * @returns {string} The status message
  32598. * @example const message = _converse.api.user.status.message.get()
  32599. */
  32600. async get() {
  32601. await core_api.waitUntil('statusInitialized');
  32602. return shared_converse.xmppstatus.get('status_message');
  32603. },
  32604. /**
  32605. * @async
  32606. * @method _converse.api.user.status.message.set
  32607. * @param {string} status The status message
  32608. * @example _converse.api.user.status.message.set('In a meeting');
  32609. */
  32610. async set(status) {
  32611. await core_api.waitUntil('statusInitialized');
  32612. shared_converse.xmppstatus.save({
  32613. status_message: status
  32614. });
  32615. }
  32616. }
  32617. }
  32618. });
  32619. ;// CONCATENATED MODULE: ./src/headless/plugins/status/utils.js
  32620. const {
  32621. Strophe: status_utils_Strophe,
  32622. $build: status_utils_$build
  32623. } = core_converse.env;
  32624. function utils_onStatusInitialized(reconnecting) {
  32625. /**
  32626. * Triggered when the user's own chat status has been initialized.
  32627. * @event _converse#statusInitialized
  32628. * @example _converse.api.listen.on('statusInitialized', status => { ... });
  32629. * @example _converse.api.waitUntil('statusInitialized').then(() => { ... });
  32630. */
  32631. core_api.trigger('statusInitialized', reconnecting);
  32632. }
  32633. function initStatus(reconnecting) {
  32634. // If there's no xmppstatus obj, then we were never connected to
  32635. // begin with, so we set reconnecting to false.
  32636. reconnecting = shared_converse.xmppstatus === undefined ? false : reconnecting;
  32637. if (reconnecting) {
  32638. utils_onStatusInitialized(reconnecting);
  32639. } else {
  32640. const id = `converse.xmppstatus-${shared_converse.bare_jid}`;
  32641. shared_converse.xmppstatus = new shared_converse.XMPPStatus({
  32642. id
  32643. });
  32644. initStorage(shared_converse.xmppstatus, id, 'session');
  32645. shared_converse.xmppstatus.fetch({
  32646. 'success': () => utils_onStatusInitialized(reconnecting),
  32647. 'error': () => utils_onStatusInitialized(reconnecting),
  32648. 'silent': true
  32649. });
  32650. }
  32651. }
  32652. function onUserActivity() {
  32653. var _converse$connection;
  32654. /* Resets counters and flags relating to CSI and auto_away/auto_xa */
  32655. if (shared_converse.idle_seconds > 0) {
  32656. shared_converse.idle_seconds = 0;
  32657. }
  32658. if (!((_converse$connection = shared_converse.connection) !== null && _converse$connection !== void 0 && _converse$connection.authenticated)) {
  32659. // We can't send out any stanzas when there's no authenticated connection.
  32660. // This can happen when the connection reconnects.
  32661. return;
  32662. }
  32663. if (shared_converse.inactive) {
  32664. shared_converse.sendCSI(shared_converse.ACTIVE);
  32665. }
  32666. if (shared_converse.idle) {
  32667. shared_converse.idle = false;
  32668. core_api.user.presence.send();
  32669. }
  32670. if (shared_converse.auto_changed_status === true) {
  32671. shared_converse.auto_changed_status = false; // XXX: we should really remember the original state here, and
  32672. // then set it back to that...
  32673. shared_converse.xmppstatus.set('status', core_api.settings.get("default_state"));
  32674. }
  32675. }
  32676. function utils_onEverySecond() {
  32677. var _converse$connection2;
  32678. /* An interval handler running every second.
  32679. * Used for CSI and the auto_away and auto_xa features.
  32680. */
  32681. if (!((_converse$connection2 = shared_converse.connection) !== null && _converse$connection2 !== void 0 && _converse$connection2.authenticated)) {
  32682. // We can't send out any stanzas when there's no authenticated connection.
  32683. // This can happen when the connection reconnects.
  32684. return;
  32685. }
  32686. const stat = shared_converse.xmppstatus.get('status');
  32687. shared_converse.idle_seconds++;
  32688. if (core_api.settings.get("csi_waiting_time") > 0 && shared_converse.idle_seconds > core_api.settings.get("csi_waiting_time") && !shared_converse.inactive) {
  32689. shared_converse.sendCSI(shared_converse.INACTIVE);
  32690. }
  32691. if (core_api.settings.get("idle_presence_timeout") > 0 && shared_converse.idle_seconds > core_api.settings.get("idle_presence_timeout") && !shared_converse.idle) {
  32692. shared_converse.idle = true;
  32693. core_api.user.presence.send();
  32694. }
  32695. if (core_api.settings.get("auto_away") > 0 && shared_converse.idle_seconds > core_api.settings.get("auto_away") && stat !== 'away' && stat !== 'xa' && stat !== 'dnd') {
  32696. shared_converse.auto_changed_status = true;
  32697. shared_converse.xmppstatus.set('status', 'away');
  32698. } else if (core_api.settings.get("auto_xa") > 0 && shared_converse.idle_seconds > core_api.settings.get("auto_xa") && stat !== 'xa' && stat !== 'dnd') {
  32699. shared_converse.auto_changed_status = true;
  32700. shared_converse.xmppstatus.set('status', 'xa');
  32701. }
  32702. }
  32703. /**
  32704. * Send out a Client State Indication (XEP-0352)
  32705. * @function sendCSI
  32706. * @param { String } stat - The user's chat status
  32707. */
  32708. function sendCSI(stat) {
  32709. core_api.send(status_utils_$build(stat, {
  32710. xmlns: status_utils_Strophe.NS.CSI
  32711. }));
  32712. shared_converse.inactive = stat === shared_converse.INACTIVE ? true : false;
  32713. }
  32714. function registerIntervalHandler() {
  32715. /* Set an interval of one second and register a handler for it.
  32716. * Required for the auto_away, auto_xa and csi_waiting_time features.
  32717. */
  32718. if (core_api.settings.get("auto_away") < 1 && core_api.settings.get("auto_xa") < 1 && core_api.settings.get("csi_waiting_time") < 1 && core_api.settings.get("idle_presence_timeout") < 1) {
  32719. // Waiting time of less then one second means features aren't used.
  32720. return;
  32721. }
  32722. shared_converse.idle_seconds = 0;
  32723. shared_converse.auto_changed_status = false; // Was the user's status changed by Converse?
  32724. const {
  32725. unloadevent
  32726. } = shared_converse;
  32727. window.addEventListener('click', shared_converse.onUserActivity);
  32728. window.addEventListener('focus', shared_converse.onUserActivity);
  32729. window.addEventListener('keypress', shared_converse.onUserActivity);
  32730. window.addEventListener('mousemove', shared_converse.onUserActivity);
  32731. window.addEventListener(unloadevent, shared_converse.onUserActivity, {
  32732. 'once': true,
  32733. 'passive': true
  32734. });
  32735. window.addEventListener(unloadevent, () => {
  32736. var _converse$session;
  32737. return (_converse$session = shared_converse.session) === null || _converse$session === void 0 ? void 0 : _converse$session.save('active', false);
  32738. });
  32739. shared_converse.everySecondTrigger = window.setInterval(shared_converse.onEverySecond, 1000);
  32740. }
  32741. function addStatusToMUCJoinPresence(_, stanza) {
  32742. const {
  32743. xmppstatus
  32744. } = shared_converse;
  32745. const status = xmppstatus.get('status');
  32746. if (['away', 'chat', 'dnd', 'xa'].includes(status)) {
  32747. stanza.c('show').t(status).up();
  32748. }
  32749. const status_message = xmppstatus.get('status_message');
  32750. if (status_message) {
  32751. stanza.c('status').t(status_message).up();
  32752. }
  32753. return stanza;
  32754. }
  32755. ;// CONCATENATED MODULE: ./src/headless/plugins/status/index.js
  32756. /**
  32757. * @copyright The Converse.js contributors
  32758. * @license Mozilla Public License (MPLv2)
  32759. */
  32760. const {
  32761. Strophe: plugins_status_Strophe
  32762. } = core_converse.env;
  32763. plugins_status_Strophe.addNamespace('IDLE', 'urn:xmpp:idle:1');
  32764. core_converse.plugins.add('converse-status', {
  32765. initialize() {
  32766. core_api.settings.extend({
  32767. auto_away: 0,
  32768. // Seconds after which user status is set to 'away'
  32769. auto_xa: 0,
  32770. // Seconds after which user status is set to 'xa'
  32771. csi_waiting_time: 0,
  32772. // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
  32773. default_state: 'online',
  32774. idle_presence_timeout: 300,
  32775. // Seconds after which an idle presence is sent
  32776. priority: 0
  32777. });
  32778. core_api.promises.add(['statusInitialized']);
  32779. shared_converse.XMPPStatus = status_status;
  32780. shared_converse.onUserActivity = onUserActivity;
  32781. shared_converse.onEverySecond = utils_onEverySecond;
  32782. shared_converse.sendCSI = sendCSI;
  32783. shared_converse.registerIntervalHandler = registerIntervalHandler;
  32784. Object.assign(shared_converse.api.user, status_api);
  32785. if (core_api.settings.get("idle_presence_timeout") > 0) {
  32786. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(plugins_status_Strophe.NS.IDLE));
  32787. }
  32788. core_api.listen.on('presencesInitialized', reconnecting => {
  32789. if (!reconnecting) {
  32790. shared_converse.registerIntervalHandler();
  32791. }
  32792. });
  32793. core_api.listen.on('clearSession', () => {
  32794. if (shared_converse.shouldClearCache() && shared_converse.xmppstatus) {
  32795. shared_converse.xmppstatus.destroy();
  32796. delete shared_converse.xmppstatus;
  32797. core_api.promises.add(['statusInitialized']);
  32798. }
  32799. });
  32800. core_api.listen.on('connected', () => initStatus(false));
  32801. core_api.listen.on('reconnected', () => initStatus(true));
  32802. core_api.listen.on('constructedMUCPresence', addStatusToMUCJoinPresence);
  32803. }
  32804. });
  32805. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/filter.js
  32806. const RosterFilter = Model.extend({
  32807. initialize() {
  32808. this.set({
  32809. 'filter_text': '',
  32810. 'filter_type': 'contacts',
  32811. 'chat_state': 'online'
  32812. });
  32813. }
  32814. });
  32815. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/utils.js
  32816. const {
  32817. $pres: utils_$pres
  32818. } = core_converse.env;
  32819. function initRoster() {
  32820. // Initialize the collections that represent the roster contacts and groups
  32821. const roster = shared_converse.roster = new shared_converse.RosterContacts();
  32822. let id = `converse.contacts-${shared_converse.bare_jid}`;
  32823. initStorage(roster, id);
  32824. const filter = shared_converse.roster_filter = new RosterFilter();
  32825. filter.id = `_converse.rosterfilter-${shared_converse.bare_jid}`;
  32826. initStorage(filter, filter.id);
  32827. filter.fetch();
  32828. id = `converse-roster-model-${shared_converse.bare_jid}`;
  32829. roster.data = new Model();
  32830. roster.data.id = id;
  32831. initStorage(roster.data, id);
  32832. roster.data.fetch();
  32833. /**
  32834. * Triggered once the `_converse.RosterContacts`
  32835. * been created, but not yet populated with data.
  32836. * This event is useful when you want to create views for these collections.
  32837. * @event _converse#chatBoxMaximized
  32838. * @example _converse.api.listen.on('rosterInitialized', () => { ... });
  32839. * @example _converse.api.waitUntil('rosterInitialized').then(() => { ... });
  32840. */
  32841. core_api.trigger('rosterInitialized');
  32842. }
  32843. /**
  32844. * Fetch all the roster groups, and then the roster contacts.
  32845. * Emit an event after fetching is done in each case.
  32846. * @private
  32847. * @param { Bool } ignore_cache - If set to to true, the local cache
  32848. * will be ignored it's guaranteed that the XMPP server
  32849. * will be queried for the roster.
  32850. */
  32851. async function populateRoster() {
  32852. let ignore_cache = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  32853. if (ignore_cache) {
  32854. shared_converse.send_initial_presence = true;
  32855. }
  32856. try {
  32857. await shared_converse.roster.fetchRosterContacts();
  32858. core_api.trigger('rosterContactsFetched');
  32859. } catch (reason) {
  32860. headless_log.error(reason);
  32861. } finally {
  32862. shared_converse.send_initial_presence && core_api.user.presence.send();
  32863. }
  32864. }
  32865. function updateUnreadCounter(chatbox) {
  32866. var _converse$roster;
  32867. const contact = (_converse$roster = shared_converse.roster) === null || _converse$roster === void 0 ? void 0 : _converse$roster.get(chatbox.get('jid'));
  32868. contact === null || contact === void 0 ? void 0 : contact.save({
  32869. 'num_unread': chatbox.get('num_unread')
  32870. });
  32871. }
  32872. function registerPresenceHandler() {
  32873. unregisterPresenceHandler();
  32874. shared_converse.presence_ref = shared_converse.connection.addHandler(presence => {
  32875. shared_converse.roster.presenceHandler(presence);
  32876. return true;
  32877. }, null, 'presence', null);
  32878. }
  32879. function unregisterPresenceHandler() {
  32880. if (shared_converse.presence_ref !== undefined) {
  32881. shared_converse.connection.deleteHandler(shared_converse.presence_ref);
  32882. delete shared_converse.presence_ref;
  32883. }
  32884. }
  32885. async function clearPresences() {
  32886. var _converse$presences;
  32887. await ((_converse$presences = shared_converse.presences) === null || _converse$presences === void 0 ? void 0 : _converse$presences.clearStore());
  32888. }
  32889. /**
  32890. * Roster specific event handler for the clearSession event
  32891. */
  32892. async function utils_onClearSession() {
  32893. await clearPresences();
  32894. if (shared_converse.shouldClearCache()) {
  32895. if (shared_converse.rostergroups) {
  32896. await shared_converse.rostergroups.clearStore();
  32897. delete shared_converse.rostergroups;
  32898. }
  32899. if (shared_converse.roster) {
  32900. var _converse$roster$data;
  32901. (_converse$roster$data = shared_converse.roster.data) === null || _converse$roster$data === void 0 ? void 0 : _converse$roster$data.destroy();
  32902. await shared_converse.roster.clearStore();
  32903. delete shared_converse.roster;
  32904. }
  32905. }
  32906. }
  32907. /**
  32908. * Roster specific event handler for the presencesInitialized event
  32909. * @param { Boolean } reconnecting
  32910. */
  32911. function onPresencesInitialized(reconnecting) {
  32912. if (reconnecting) {
  32913. /**
  32914. * Similar to `rosterInitialized`, but instead pertaining to reconnection.
  32915. * This event indicates that the roster and its groups are now again
  32916. * available after Converse.js has reconnected.
  32917. * @event _converse#rosterReadyAfterReconnection
  32918. * @example _converse.api.listen.on('rosterReadyAfterReconnection', () => { ... });
  32919. */
  32920. core_api.trigger('rosterReadyAfterReconnection');
  32921. } else {
  32922. initRoster();
  32923. }
  32924. shared_converse.roster.onConnected();
  32925. registerPresenceHandler();
  32926. populateRoster(!shared_converse.connection.restored);
  32927. }
  32928. /**
  32929. * Roster specific event handler for the statusInitialized event
  32930. * @param { Boolean } reconnecting
  32931. */
  32932. async function roster_utils_onStatusInitialized(reconnecting) {
  32933. if (reconnecting) {
  32934. // When reconnecting and not resuming a previous session,
  32935. // we clear all cached presence data, since it might be stale
  32936. // and we'll receive new presence updates
  32937. !shared_converse.connection.hasResumed() && (await clearPresences());
  32938. } else {
  32939. shared_converse.presences = new shared_converse.Presences();
  32940. const id = `converse.presences-${shared_converse.bare_jid}`;
  32941. initStorage(shared_converse.presences, id, 'session'); // We might be continuing an existing session, so we fetch
  32942. // cached presence data.
  32943. shared_converse.presences.fetch();
  32944. }
  32945. /**
  32946. * Triggered once the _converse.Presences collection has been
  32947. * initialized and its cached data fetched.
  32948. * Returns a boolean indicating whether this event has fired due to
  32949. * Converse having reconnected.
  32950. * @event _converse#presencesInitialized
  32951. * @type { bool }
  32952. * @example _converse.api.listen.on('presencesInitialized', reconnecting => { ... });
  32953. */
  32954. core_api.trigger('presencesInitialized', reconnecting);
  32955. }
  32956. /**
  32957. * Roster specific event handler for the chatBoxesInitialized event
  32958. */
  32959. function onChatBoxesInitialized() {
  32960. shared_converse.chatboxes.on('change:num_unread', updateUnreadCounter);
  32961. shared_converse.chatboxes.on('add', chatbox => {
  32962. if (chatbox.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  32963. chatbox.setRosterContact(chatbox.get('jid'));
  32964. }
  32965. });
  32966. }
  32967. /**
  32968. * Roster specific handler for the rosterContactsFetched promise
  32969. */
  32970. function onRosterContactsFetched() {
  32971. shared_converse.roster.on('add', contact => {
  32972. // When a new contact is added, check if we already have a
  32973. // chatbox open for it, and if so attach it to the chatbox.
  32974. const chatbox = shared_converse.chatboxes.findWhere({
  32975. 'jid': contact.get('jid')
  32976. });
  32977. chatbox === null || chatbox === void 0 ? void 0 : chatbox.setRosterContact(contact.get('jid'));
  32978. });
  32979. }
  32980. /**
  32981. * Reject or cancel another user's subscription to our presence updates.
  32982. * @function rejectPresenceSubscription
  32983. * @param { String } jid - The Jabber ID of the user whose subscription is being canceled
  32984. * @param { String } message - An optional message to the user
  32985. */
  32986. function rejectPresenceSubscription(jid, message) {
  32987. const pres = utils_$pres({
  32988. to: jid,
  32989. type: "unsubscribed"
  32990. });
  32991. if (message && message !== "") {
  32992. pres.c("status").t(message);
  32993. }
  32994. core_api.send(pres);
  32995. }
  32996. function contactsComparator(contact1, contact2) {
  32997. const status1 = contact1.presence.get('show') || 'offline';
  32998. const status2 = contact2.presence.get('show') || 'offline';
  32999. if (shared_converse.STATUS_WEIGHTS[status1] === shared_converse.STATUS_WEIGHTS[status2]) {
  33000. const name1 = contact1.getDisplayName().toLowerCase();
  33001. const name2 = contact2.getDisplayName().toLowerCase();
  33002. return name1 < name2 ? -1 : name1 > name2 ? 1 : 0;
  33003. } else {
  33004. return shared_converse.STATUS_WEIGHTS[status1] < shared_converse.STATUS_WEIGHTS[status2] ? -1 : 1;
  33005. }
  33006. }
  33007. function groupsComparator(a, b) {
  33008. const HEADER_WEIGHTS = {};
  33009. HEADER_WEIGHTS[shared_converse.HEADER_UNREAD] = 0;
  33010. HEADER_WEIGHTS[shared_converse.HEADER_REQUESTING_CONTACTS] = 1;
  33011. HEADER_WEIGHTS[shared_converse.HEADER_CURRENT_CONTACTS] = 2;
  33012. HEADER_WEIGHTS[shared_converse.HEADER_UNGROUPED] = 3;
  33013. HEADER_WEIGHTS[shared_converse.HEADER_PENDING_CONTACTS] = 4;
  33014. const WEIGHTS = HEADER_WEIGHTS;
  33015. const special_groups = Object.keys(HEADER_WEIGHTS);
  33016. const a_is_special = special_groups.includes(a);
  33017. const b_is_special = special_groups.includes(b);
  33018. if (!a_is_special && !b_is_special) {
  33019. return a.toLowerCase() < b.toLowerCase() ? -1 : a.toLowerCase() > b.toLowerCase() ? 1 : 0;
  33020. } else if (a_is_special && b_is_special) {
  33021. return WEIGHTS[a] < WEIGHTS[b] ? -1 : WEIGHTS[a] > WEIGHTS[b] ? 1 : 0;
  33022. } else if (!a_is_special && b_is_special) {
  33023. const a_header = shared_converse.HEADER_CURRENT_CONTACTS;
  33024. return WEIGHTS[a_header] < WEIGHTS[b] ? -1 : WEIGHTS[a_header] > WEIGHTS[b] ? 1 : 0;
  33025. } else if (a_is_special && !b_is_special) {
  33026. const b_header = shared_converse.HEADER_CURRENT_CONTACTS;
  33027. return WEIGHTS[a] < WEIGHTS[b_header] ? -1 : WEIGHTS[a] > WEIGHTS[b_header] ? 1 : 0;
  33028. }
  33029. }
  33030. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/contact.js
  33031. const {
  33032. Strophe: contact_Strophe,
  33033. $iq: contact_$iq,
  33034. $pres: contact_$pres
  33035. } = core_converse.env;
  33036. /**
  33037. * @class
  33038. * @namespace RosterContact
  33039. */
  33040. const RosterContact = Model.extend({
  33041. idAttribute: 'jid',
  33042. defaults: {
  33043. 'chat_state': undefined,
  33044. 'groups': [],
  33045. 'image': shared_converse.DEFAULT_IMAGE,
  33046. 'image_type': shared_converse.DEFAULT_IMAGE_TYPE,
  33047. 'num_unread': 0,
  33048. 'status': undefined
  33049. },
  33050. async initialize(attributes) {
  33051. this.initialized = getOpenPromise();
  33052. this.setPresence();
  33053. const {
  33054. jid
  33055. } = attributes;
  33056. this.set({ ...attributes,
  33057. ...{
  33058. 'jid': contact_Strophe.getBareJidFromJid(jid).toLowerCase(),
  33059. 'user_id': contact_Strophe.getNodeFromJid(jid)
  33060. }
  33061. });
  33062. /**
  33063. * When a contact's presence status has changed.
  33064. * The presence status is either `online`, `offline`, `dnd`, `away` or `xa`.
  33065. * @event _converse#contactPresenceChanged
  33066. * @type { _converse.RosterContact }
  33067. * @example _converse.api.listen.on('contactPresenceChanged', contact => { ... });
  33068. */
  33069. this.listenTo(this.presence, 'change:show', () => core_api.trigger('contactPresenceChanged', this));
  33070. this.listenTo(this.presence, 'change:show', () => this.trigger('presenceChanged'));
  33071. /**
  33072. * Synchronous event which provides a hook for further initializing a RosterContact
  33073. * @event _converse#rosterContactInitialized
  33074. * @param { _converse.RosterContact } contact
  33075. */
  33076. await core_api.trigger('rosterContactInitialized', this, {
  33077. 'Synchronous': true
  33078. });
  33079. this.initialized.resolve();
  33080. },
  33081. setPresence() {
  33082. const jid = this.get('jid');
  33083. this.presence = shared_converse.presences.findWhere(jid) || shared_converse.presences.create({
  33084. jid
  33085. });
  33086. },
  33087. openChat() {
  33088. const attrs = this.attributes;
  33089. core_api.chats.open(attrs.jid, attrs, true);
  33090. },
  33091. /**
  33092. * Return a string of tab-separated values that are to be used when
  33093. * matching against filter text.
  33094. *
  33095. * The goal is to be able to filter against the VCard fullname,
  33096. * roster nickname and JID.
  33097. * @returns { String } Lower-cased, tab-separated values
  33098. */
  33099. getFilterCriteria() {
  33100. const nick = this.get('nickname');
  33101. const jid = this.get('jid');
  33102. let criteria = this.getDisplayName();
  33103. criteria = !criteria.includes(jid) ? criteria.concat(` ${jid}`) : criteria;
  33104. criteria = !criteria.includes(nick) ? criteria.concat(` ${nick}`) : criteria;
  33105. return criteria.toLowerCase();
  33106. },
  33107. getDisplayName() {
  33108. // Gets overridden in converse-vcard where the fullname is may be returned
  33109. if (this.get('nickname')) {
  33110. return this.get('nickname');
  33111. } else {
  33112. return this.get('jid');
  33113. }
  33114. },
  33115. getFullname() {
  33116. // Gets overridden in converse-vcard where the fullname may be returned
  33117. return this.get('jid');
  33118. },
  33119. /**
  33120. * Send a presence subscription request to this roster contact
  33121. * @private
  33122. * @method _converse.RosterContacts#subscribe
  33123. * @param { String } message - An optional message to explain the
  33124. * reason for the subscription request.
  33125. */
  33126. subscribe(message) {
  33127. const pres = contact_$pres({
  33128. to: this.get('jid'),
  33129. type: "subscribe"
  33130. });
  33131. if (message && message !== "") {
  33132. pres.c("status").t(message).up();
  33133. }
  33134. const nick = shared_converse.xmppstatus.getNickname() || shared_converse.xmppstatus.getFullname();
  33135. if (nick) {
  33136. pres.c('nick', {
  33137. 'xmlns': contact_Strophe.NS.NICK
  33138. }).t(nick).up();
  33139. }
  33140. core_api.send(pres);
  33141. this.save('ask', "subscribe"); // ask === 'subscribe' Means we have asked to subscribe to them.
  33142. return this;
  33143. },
  33144. /**
  33145. * Upon receiving the presence stanza of type "subscribed",
  33146. * the user SHOULD acknowledge receipt of that subscription
  33147. * state notification by sending a presence stanza of type
  33148. * "subscribe" to the contact
  33149. * @private
  33150. * @method _converse.RosterContacts#ackSubscribe
  33151. */
  33152. ackSubscribe() {
  33153. core_api.send(contact_$pres({
  33154. 'type': 'subscribe',
  33155. 'to': this.get('jid')
  33156. }));
  33157. },
  33158. /**
  33159. * Upon receiving the presence stanza of type "unsubscribed",
  33160. * the user SHOULD acknowledge receipt of that subscription state
  33161. * notification by sending a presence stanza of type "unsubscribe"
  33162. * this step lets the user's server know that it MUST no longer
  33163. * send notification of the subscription state change to the user.
  33164. * @private
  33165. * @method _converse.RosterContacts#ackUnsubscribe
  33166. * @param { String } jid - The Jabber ID of the user who is unsubscribing
  33167. */
  33168. ackUnsubscribe() {
  33169. core_api.send(contact_$pres({
  33170. 'type': 'unsubscribe',
  33171. 'to': this.get('jid')
  33172. }));
  33173. this.removeFromRoster();
  33174. this.destroy();
  33175. },
  33176. /**
  33177. * Unauthorize this contact's presence subscription
  33178. * @private
  33179. * @method _converse.RosterContacts#unauthorize
  33180. * @param { String } message - Optional message to send to the person being unauthorized
  33181. */
  33182. unauthorize(message) {
  33183. rejectPresenceSubscription(this.get('jid'), message);
  33184. return this;
  33185. },
  33186. /**
  33187. * Authorize presence subscription
  33188. * @private
  33189. * @method _converse.RosterContacts#authorize
  33190. * @param { String } message - Optional message to send to the person being authorized
  33191. */
  33192. authorize(message) {
  33193. const pres = contact_$pres({
  33194. 'to': this.get('jid'),
  33195. 'type': "subscribed"
  33196. });
  33197. if (message && message !== "") {
  33198. pres.c("status").t(message);
  33199. }
  33200. core_api.send(pres);
  33201. return this;
  33202. },
  33203. /**
  33204. * Instruct the XMPP server to remove this contact from our roster
  33205. * @private
  33206. * @method _converse.RosterContacts#
  33207. * @returns { Promise }
  33208. */
  33209. removeFromRoster() {
  33210. const iq = contact_$iq({
  33211. type: 'set'
  33212. }).c('query', {
  33213. xmlns: contact_Strophe.NS.ROSTER
  33214. }).c('item', {
  33215. jid: this.get('jid'),
  33216. subscription: "remove"
  33217. });
  33218. return core_api.sendIQ(iq);
  33219. }
  33220. });
  33221. /* harmony default export */ const contact = (RosterContact);
  33222. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseSum.js
  33223. /**
  33224. * The base implementation of `_.sum` and `_.sumBy` without support for
  33225. * iteratee shorthands.
  33226. *
  33227. * @private
  33228. * @param {Array} array The array to iterate over.
  33229. * @param {Function} iteratee The function invoked per iteration.
  33230. * @returns {number} Returns the sum.
  33231. */
  33232. function baseSum(array, iteratee) {
  33233. var result,
  33234. index = -1,
  33235. length = array.length;
  33236. while (++index < length) {
  33237. var current = iteratee(array[index]);
  33238. if (current !== undefined) {
  33239. result = result === undefined ? current : (result + current);
  33240. }
  33241. }
  33242. return result;
  33243. }
  33244. /* harmony default export */ const _baseSum = (baseSum);
  33245. ;// CONCATENATED MODULE: ./node_modules/lodash-es/sum.js
  33246. /**
  33247. * Computes the sum of the values in `array`.
  33248. *
  33249. * @static
  33250. * @memberOf _
  33251. * @since 3.4.0
  33252. * @category Math
  33253. * @param {Array} array The array to iterate over.
  33254. * @returns {number} Returns the sum.
  33255. * @example
  33256. *
  33257. * _.sum([4, 2, 8, 6]);
  33258. * // => 20
  33259. */
  33260. function sum(array) {
  33261. return (array && array.length)
  33262. ? _baseSum(array, lodash_es_identity)
  33263. : 0;
  33264. }
  33265. /* harmony default export */ const lodash_es_sum = (sum);
  33266. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/contacts.js
  33267. const {
  33268. Strophe: contacts_Strophe,
  33269. $iq: contacts_$iq,
  33270. sizzle: contacts_sizzle,
  33271. u: contacts_u
  33272. } = core_converse.env;
  33273. const RosterContacts = Collection.extend({
  33274. model: contact,
  33275. initialize() {
  33276. const id = `roster.state-${shared_converse.bare_jid}-${this.get('jid')}`;
  33277. this.state = new Model({
  33278. id,
  33279. 'collapsed_groups': []
  33280. });
  33281. initStorage(this.state, id);
  33282. this.state.fetch();
  33283. },
  33284. onConnected() {
  33285. // Called as soon as the connection has been established
  33286. // (either after initial login, or after reconnection).
  33287. // Use the opportunity to register stanza handlers.
  33288. this.registerRosterHandler();
  33289. this.registerRosterXHandler();
  33290. },
  33291. registerRosterHandler() {
  33292. // Register a handler for roster IQ "set" stanzas, which update
  33293. // roster contacts.
  33294. shared_converse.connection.addHandler(iq => {
  33295. shared_converse.roster.onRosterPush(iq);
  33296. return true;
  33297. }, contacts_Strophe.NS.ROSTER, 'iq', "set");
  33298. },
  33299. registerRosterXHandler() {
  33300. // Register a handler for RosterX message stanzas, which are
  33301. // used to suggest roster contacts to a user.
  33302. let t = 0;
  33303. shared_converse.connection.addHandler(function (msg) {
  33304. window.setTimeout(function () {
  33305. shared_converse.connection.flush();
  33306. shared_converse.roster.subscribeToSuggestedItems.bind(shared_converse.roster)(msg);
  33307. }, t);
  33308. t += msg.querySelectorAll('item').length * 250;
  33309. return true;
  33310. }, contacts_Strophe.NS.ROSTERX, 'message', null);
  33311. },
  33312. /**
  33313. * Fetches the roster contacts, first by trying the browser cache,
  33314. * and if that's empty, then by querying the XMPP server.
  33315. * @private
  33316. * @returns {promise} Promise which resolves once the contacts have been fetched.
  33317. */
  33318. async fetchRosterContacts() {
  33319. const result = await new Promise((resolve, reject) => {
  33320. this.fetch({
  33321. 'add': true,
  33322. 'silent': true,
  33323. 'success': resolve,
  33324. 'error': (_, e) => reject(e)
  33325. });
  33326. });
  33327. if (contacts_u.isErrorObject(result)) {
  33328. headless_log.error(result); // Force a full roster refresh
  33329. shared_converse.session.save('roster_cached', false);
  33330. this.data.save('version', undefined);
  33331. }
  33332. if (shared_converse.session.get('roster_cached')) {
  33333. /**
  33334. * The contacts roster has been retrieved from the local cache (`sessionStorage`).
  33335. * @event _converse#cachedRoster
  33336. * @type { _converse.RosterContacts }
  33337. * @example _converse.api.listen.on('cachedRoster', (items) => { ... });
  33338. * @example _converse.api.waitUntil('cachedRoster').then(items => { ... });
  33339. */
  33340. core_api.trigger('cachedRoster', result);
  33341. } else {
  33342. shared_converse.send_initial_presence = true;
  33343. return shared_converse.roster.fetchFromServer();
  33344. }
  33345. },
  33346. subscribeToSuggestedItems(msg) {
  33347. Array.from(msg.querySelectorAll('item')).forEach(item => {
  33348. if (item.getAttribute('action') === 'add') {
  33349. shared_converse.roster.addAndSubscribe(item.getAttribute('jid'), shared_converse.xmppstatus.getNickname() || shared_converse.xmppstatus.getFullname());
  33350. }
  33351. });
  33352. return true;
  33353. },
  33354. isSelf(jid) {
  33355. return contacts_u.isSameBareJID(jid, shared_converse.connection.jid);
  33356. },
  33357. /**
  33358. * Add a roster contact and then once we have confirmation from
  33359. * the XMPP server we subscribe to that contact's presence updates.
  33360. * @private
  33361. * @method _converse.RosterContacts#addAndSubscribe
  33362. * @param { String } jid - The Jabber ID of the user being added and subscribed to.
  33363. * @param { String } name - The name of that user
  33364. * @param { Array.String } groups - Any roster groups the user might belong to
  33365. * @param { String } message - An optional message to explain the reason for the subscription request.
  33366. * @param { Object } attributes - Any additional attributes to be stored on the user's model.
  33367. */
  33368. async addAndSubscribe(jid, name, groups, message, attributes) {
  33369. const contact = await this.addContactToRoster(jid, name, groups, attributes);
  33370. if (contact instanceof shared_converse.RosterContact) {
  33371. contact.subscribe(message);
  33372. }
  33373. },
  33374. /**
  33375. * Send an IQ stanza to the XMPP server to add a new roster contact.
  33376. * @private
  33377. * @method _converse.RosterContacts#sendContactAddIQ
  33378. * @param { String } jid - The Jabber ID of the user being added
  33379. * @param { String } name - The name of that user
  33380. * @param { Array.String } groups - Any roster groups the user might belong to
  33381. * @param { Function } callback - A function to call once the IQ is returned
  33382. * @param { Function } errback - A function to call if an error occurred
  33383. */
  33384. sendContactAddIQ(jid, name, groups) {
  33385. name = name ? name : null;
  33386. const iq = contacts_$iq({
  33387. 'type': 'set'
  33388. }).c('query', {
  33389. 'xmlns': contacts_Strophe.NS.ROSTER
  33390. }).c('item', {
  33391. jid,
  33392. name
  33393. });
  33394. groups.forEach(g => iq.c('group').t(g).up());
  33395. return core_api.sendIQ(iq);
  33396. },
  33397. /**
  33398. * Adds a RosterContact instance to _converse.roster and
  33399. * registers the contact on the XMPP server.
  33400. * Returns a promise which is resolved once the XMPP server has responded.
  33401. * @private
  33402. * @method _converse.RosterContacts#addContactToRoster
  33403. * @param { String } jid - The Jabber ID of the user being added and subscribed to.
  33404. * @param { String } name - The name of that user
  33405. * @param { Array.String } groups - Any roster groups the user might belong to
  33406. * @param { Object } attributes - Any additional attributes to be stored on the user's model.
  33407. */
  33408. async addContactToRoster(jid, name, groups, attributes) {
  33409. await core_api.waitUntil('rosterContactsFetched');
  33410. groups = groups || [];
  33411. try {
  33412. await this.sendContactAddIQ(jid, name, groups);
  33413. } catch (e) {
  33414. const {
  33415. __
  33416. } = shared_converse;
  33417. headless_log.error(e);
  33418. alert(__('Sorry, there was an error while trying to add %1$s as a contact.', name || jid));
  33419. return e;
  33420. }
  33421. return this.create(Object.assign({
  33422. 'ask': undefined,
  33423. 'nickname': name,
  33424. groups,
  33425. jid,
  33426. 'requesting': false,
  33427. 'subscription': 'none'
  33428. }, attributes), {
  33429. 'sort': false
  33430. });
  33431. },
  33432. async subscribeBack(bare_jid, presence) {
  33433. const contact = this.get(bare_jid);
  33434. if (contact instanceof shared_converse.RosterContact) {
  33435. contact.authorize().subscribe();
  33436. } else {
  33437. var _sizzle$pop;
  33438. // Can happen when a subscription is retried or roster was deleted
  33439. const nickname = ((_sizzle$pop = contacts_sizzle(`nick[xmlns="${contacts_Strophe.NS.NICK}"]`, presence).pop()) === null || _sizzle$pop === void 0 ? void 0 : _sizzle$pop.textContent) || null;
  33440. const contact = await this.addContactToRoster(bare_jid, nickname, [], {
  33441. 'subscription': 'from'
  33442. });
  33443. if (contact instanceof shared_converse.RosterContact) {
  33444. contact.authorize().subscribe();
  33445. }
  33446. }
  33447. },
  33448. getNumOnlineContacts() {
  33449. const ignored = ['offline', 'unavailable'];
  33450. return lodash_es_sum(this.models.filter(m => !ignored.includes(m.presence.get('show'))));
  33451. },
  33452. /**
  33453. * Handle roster updates from the XMPP server.
  33454. * See: https://xmpp.org/rfcs/rfc6121.html#roster-syntax-actions-push
  33455. * @private
  33456. * @method _converse.RosterContacts#onRosterPush
  33457. * @param { XMLElement } IQ - The IQ stanza received from the XMPP server.
  33458. */
  33459. onRosterPush(iq) {
  33460. const id = iq.getAttribute('id');
  33461. const from = iq.getAttribute('from');
  33462. if (from && from !== shared_converse.bare_jid) {
  33463. // https://tools.ietf.org/html/rfc6121#page-15
  33464. //
  33465. // A receiving client MUST ignore the stanza unless it has no 'from'
  33466. // attribute (i.e., implicitly from the bare JID of the user's
  33467. // account) or it has a 'from' attribute whose value matches the
  33468. // user's bare JID <user@domainpart>.
  33469. headless_log.warn(`Ignoring roster illegitimate roster push message from ${iq.getAttribute('from')}`);
  33470. return;
  33471. }
  33472. core_api.send(contacts_$iq({
  33473. type: 'result',
  33474. id,
  33475. from: shared_converse.connection.jid
  33476. }));
  33477. const query = contacts_sizzle(`query[xmlns="${contacts_Strophe.NS.ROSTER}"]`, iq).pop();
  33478. this.data.save('version', query.getAttribute('ver'));
  33479. const items = contacts_sizzle(`item`, query);
  33480. if (items.length > 1) {
  33481. headless_log.error(iq);
  33482. throw new Error('Roster push query may not contain more than one "item" element.');
  33483. }
  33484. if (items.length === 0) {
  33485. headless_log.warn(iq);
  33486. headless_log.warn('Received a roster push stanza without an "item" element.');
  33487. return;
  33488. }
  33489. this.updateContact(items.pop());
  33490. /**
  33491. * When the roster receives a push event from server (i.e. new entry in your contacts roster).
  33492. * @event _converse#rosterPush
  33493. * @type { XMLElement }
  33494. * @example _converse.api.listen.on('rosterPush', iq => { ... });
  33495. */
  33496. core_api.trigger('rosterPush', iq);
  33497. return;
  33498. },
  33499. rosterVersioningSupported() {
  33500. return core_api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version');
  33501. },
  33502. /**
  33503. * Fetch the roster from the XMPP server
  33504. * @private
  33505. * @emits _converse#roster
  33506. * @returns {promise}
  33507. */
  33508. async fetchFromServer() {
  33509. const stanza = contacts_$iq({
  33510. 'type': 'get',
  33511. 'id': contacts_u.getUniqueId('roster')
  33512. }).c('query', {
  33513. xmlns: contacts_Strophe.NS.ROSTER
  33514. });
  33515. if (this.rosterVersioningSupported()) {
  33516. stanza.attrs({
  33517. 'ver': this.data.get('version')
  33518. });
  33519. }
  33520. const iq = await core_api.sendIQ(stanza, null, false);
  33521. if (iq.getAttribute('type') === 'result') {
  33522. const query = contacts_sizzle(`query[xmlns="${contacts_Strophe.NS.ROSTER}"]`, iq).pop();
  33523. if (query) {
  33524. const items = contacts_sizzle(`item`, query);
  33525. if (!this.data.get('version')) {
  33526. // We're getting the full roster, so remove all cached
  33527. // contacts that aren't included in it.
  33528. const jids = items.map(item => item.getAttribute('jid'));
  33529. this.models.forEach(m => !m.get('requesting') && !jids.includes(m.get('jid')) && m.destroy());
  33530. }
  33531. items.forEach(item => this.updateContact(item));
  33532. this.data.save('version', query.getAttribute('ver'));
  33533. }
  33534. } else if (!contacts_u.isServiceUnavailableError(iq)) {
  33535. // Some unknown error happened, so we will try to fetch again if the page reloads.
  33536. headless_log.error(iq);
  33537. headless_log.error("Error while trying to fetch roster from the server");
  33538. return;
  33539. }
  33540. shared_converse.session.save('roster_cached', true);
  33541. /**
  33542. * When the roster has been received from the XMPP server.
  33543. * See also the `cachedRoster` event further up, which gets called instead of
  33544. * `roster` if its already in `sessionStorage`.
  33545. * @event _converse#roster
  33546. * @type { XMLElement }
  33547. * @example _converse.api.listen.on('roster', iq => { ... });
  33548. * @example _converse.api.waitUntil('roster').then(iq => { ... });
  33549. */
  33550. core_api.trigger('roster', iq);
  33551. },
  33552. /* Update or create RosterContact models based on the given `item` XML
  33553. * node received in the resulting IQ stanza from the server.
  33554. * @private
  33555. * @param { XMLElement } item
  33556. */
  33557. updateContact(item) {
  33558. const jid = item.getAttribute('jid');
  33559. const contact = this.get(jid);
  33560. const subscription = item.getAttribute("subscription");
  33561. const ask = item.getAttribute("ask");
  33562. const groups = [...new Set(contacts_sizzle('group', item).map(e => e.textContent))];
  33563. if (!contact) {
  33564. if (subscription === "none" && ask === null || subscription === "remove") {
  33565. return; // We're lazy when adding contacts.
  33566. }
  33567. this.create({
  33568. 'ask': ask,
  33569. 'nickname': item.getAttribute("name"),
  33570. 'groups': groups,
  33571. 'jid': jid,
  33572. 'subscription': subscription
  33573. }, {
  33574. sort: false
  33575. });
  33576. } else {
  33577. if (subscription === "remove") {
  33578. return contact.destroy();
  33579. } // We only find out about requesting contacts via the
  33580. // presence handler, so if we receive a contact
  33581. // here, we know they aren't requesting anymore.
  33582. // see docs/DEVELOPER.rst
  33583. contact.save({
  33584. 'subscription': subscription,
  33585. 'ask': ask,
  33586. 'nickname': item.getAttribute("name"),
  33587. 'requesting': null,
  33588. 'groups': groups
  33589. });
  33590. }
  33591. },
  33592. createRequestingContact(presence) {
  33593. var _sizzle$pop2;
  33594. const bare_jid = contacts_Strophe.getBareJidFromJid(presence.getAttribute('from'));
  33595. const nickname = ((_sizzle$pop2 = contacts_sizzle(`nick[xmlns="${contacts_Strophe.NS.NICK}"]`, presence).pop()) === null || _sizzle$pop2 === void 0 ? void 0 : _sizzle$pop2.textContent) || null;
  33596. const user_data = {
  33597. 'jid': bare_jid,
  33598. 'subscription': 'none',
  33599. 'ask': null,
  33600. 'requesting': true,
  33601. 'nickname': nickname
  33602. };
  33603. /**
  33604. * Triggered when someone has requested to subscribe to your presence (i.e. to be your contact).
  33605. * @event _converse#contactRequest
  33606. * @type { _converse.RosterContact }
  33607. * @example _converse.api.listen.on('contactRequest', contact => { ... });
  33608. */
  33609. core_api.trigger('contactRequest', this.create(user_data));
  33610. },
  33611. handleIncomingSubscription(presence) {
  33612. const jid = presence.getAttribute('from'),
  33613. bare_jid = contacts_Strophe.getBareJidFromJid(jid),
  33614. contact = this.get(bare_jid);
  33615. if (!core_api.settings.get('allow_contact_requests')) {
  33616. const {
  33617. __
  33618. } = shared_converse;
  33619. rejectPresenceSubscription(jid, __("This client does not allow presence subscriptions"));
  33620. }
  33621. if (core_api.settings.get('auto_subscribe')) {
  33622. if (!contact || contact.get('subscription') !== 'to') {
  33623. this.subscribeBack(bare_jid, presence);
  33624. } else {
  33625. contact.authorize();
  33626. }
  33627. } else {
  33628. if (contact) {
  33629. if (contact.get('subscription') !== 'none') {
  33630. contact.authorize();
  33631. } else if (contact.get('ask') === "subscribe") {
  33632. contact.authorize();
  33633. }
  33634. } else {
  33635. this.createRequestingContact(presence);
  33636. }
  33637. }
  33638. },
  33639. handleOwnPresence(presence) {
  33640. const jid = presence.getAttribute('from'),
  33641. resource = contacts_Strophe.getResourceFromJid(jid),
  33642. presence_type = presence.getAttribute('type');
  33643. if (shared_converse.connection.jid !== jid && presence_type !== 'unavailable' && (core_api.settings.get('synchronize_availability') === true || core_api.settings.get('synchronize_availability') === resource)) {
  33644. var _presence$querySelect, _presence$querySelect2;
  33645. // Another resource has changed its status and
  33646. // synchronize_availability option set to update,
  33647. // we'll update ours as well.
  33648. const show = ((_presence$querySelect = presence.querySelector('show')) === null || _presence$querySelect === void 0 ? void 0 : _presence$querySelect.textContent) || 'online';
  33649. shared_converse.xmppstatus.save({
  33650. 'status': show
  33651. }, {
  33652. 'silent': true
  33653. });
  33654. const status_message = (_presence$querySelect2 = presence.querySelector('status')) === null || _presence$querySelect2 === void 0 ? void 0 : _presence$querySelect2.textContent;
  33655. if (status_message) {
  33656. shared_converse.xmppstatus.save({
  33657. 'status_message': status_message
  33658. });
  33659. }
  33660. }
  33661. if (shared_converse.jid === jid && presence_type === 'unavailable') {
  33662. // XXX: We've received an "unavailable" presence from our
  33663. // own resource. Apparently this happens due to a
  33664. // Prosody bug, whereby we send an IQ stanza to remove
  33665. // a roster contact, and Prosody then sends
  33666. // "unavailable" globally, instead of directed to the
  33667. // particular user that's removed.
  33668. //
  33669. // Here is the bug report: https://prosody.im/issues/1121
  33670. //
  33671. // I'm not sure whether this might legitimately happen
  33672. // in other cases.
  33673. //
  33674. // As a workaround for now we simply send our presence again,
  33675. // otherwise we're treated as offline.
  33676. core_api.user.presence.send();
  33677. }
  33678. },
  33679. presenceHandler(presence) {
  33680. var _presence$querySelect3;
  33681. const presence_type = presence.getAttribute('type');
  33682. if (presence_type === 'error') {
  33683. return true;
  33684. }
  33685. const jid = presence.getAttribute('from'),
  33686. bare_jid = contacts_Strophe.getBareJidFromJid(jid);
  33687. if (this.isSelf(bare_jid)) {
  33688. return this.handleOwnPresence(presence);
  33689. } else if (contacts_sizzle(`query[xmlns="${contacts_Strophe.NS.MUC}"]`, presence).length) {
  33690. return; // Ignore MUC
  33691. }
  33692. const status_message = (_presence$querySelect3 = presence.querySelector('status')) === null || _presence$querySelect3 === void 0 ? void 0 : _presence$querySelect3.textContent;
  33693. const contact = this.get(bare_jid);
  33694. if (contact && status_message !== contact.get('status')) {
  33695. contact.save({
  33696. 'status': status_message
  33697. });
  33698. }
  33699. if (presence_type === 'subscribed' && contact) {
  33700. contact.ackSubscribe();
  33701. } else if (presence_type === 'unsubscribed' && contact) {
  33702. contact.ackUnsubscribe();
  33703. } else if (presence_type === 'unsubscribe') {
  33704. return;
  33705. } else if (presence_type === 'subscribe') {
  33706. this.handleIncomingSubscription(presence);
  33707. } else if (presence_type === 'unavailable' && contact) {
  33708. const resource = contacts_Strophe.getResourceFromJid(jid);
  33709. contact.presence.removeResource(resource);
  33710. } else if (contact) {
  33711. // presence_type is undefined
  33712. contact.presence.addResource(presence);
  33713. }
  33714. }
  33715. });
  33716. /* harmony default export */ const contacts = (RosterContacts);
  33717. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/api.js
  33718. const {
  33719. Strophe: roster_api_Strophe
  33720. } = core_converse.env;
  33721. /* harmony default export */ const roster_api = ({
  33722. /**
  33723. * @namespace _converse.api.contacts
  33724. * @memberOf _converse.api
  33725. */
  33726. contacts: {
  33727. /**
  33728. * This method is used to retrieve roster contacts.
  33729. *
  33730. * @method _converse.api.contacts.get
  33731. * @params {(string[]|string)} jid|jids The JID or JIDs of
  33732. * the contacts to be returned.
  33733. * @returns {promise} Promise which resolves with the
  33734. * _converse.RosterContact (or an array of them) representing the contact.
  33735. *
  33736. * @example
  33737. * // Fetch a single contact
  33738. * _converse.api.listen.on('rosterContactsFetched', function () {
  33739. * const contact = await _converse.api.contacts.get('buddy@example.com')
  33740. * // ...
  33741. * });
  33742. *
  33743. * @example
  33744. * // To get multiple contacts, pass in an array of JIDs:
  33745. * _converse.api.listen.on('rosterContactsFetched', function () {
  33746. * const contacts = await _converse.api.contacts.get(
  33747. * ['buddy1@example.com', 'buddy2@example.com']
  33748. * )
  33749. * // ...
  33750. * });
  33751. *
  33752. * @example
  33753. * // To return all contacts, simply call ``get`` without any parameters:
  33754. * _converse.api.listen.on('rosterContactsFetched', function () {
  33755. * const contacts = await _converse.api.contacts.get();
  33756. * // ...
  33757. * });
  33758. */
  33759. async get(jids) {
  33760. await core_api.waitUntil('rosterContactsFetched');
  33761. const _getter = jid => shared_converse.roster.get(roster_api_Strophe.getBareJidFromJid(jid));
  33762. if (jids === undefined) {
  33763. jids = shared_converse.roster.pluck('jid');
  33764. } else if (typeof jids === 'string') {
  33765. return _getter(jids);
  33766. }
  33767. return jids.map(_getter);
  33768. },
  33769. /**
  33770. * Add a contact.
  33771. *
  33772. * @method _converse.api.contacts.add
  33773. * @param {string} jid The JID of the contact to be added
  33774. * @param {string} [name] A custom name to show the user by in the roster
  33775. * @example
  33776. * _converse.api.contacts.add('buddy@example.com')
  33777. * @example
  33778. * _converse.api.contacts.add('buddy@example.com', 'Buddy')
  33779. */
  33780. async add(jid, name) {
  33781. await core_api.waitUntil('rosterContactsFetched');
  33782. if (typeof jid !== 'string' || !jid.includes('@')) {
  33783. throw new TypeError('contacts.add: invalid jid');
  33784. }
  33785. return shared_converse.roster.addAndSubscribe(jid, name);
  33786. }
  33787. }
  33788. });
  33789. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/presence.js
  33790. const {
  33791. Strophe: presence_Strophe,
  33792. dayjs: presence_dayjs,
  33793. sizzle: presence_sizzle
  33794. } = core_converse.env;
  33795. const Resource = Model.extend({
  33796. 'idAttribute': 'name'
  33797. });
  33798. const Resources = Collection.extend({
  33799. 'model': Resource
  33800. });
  33801. const Presence = Model.extend({
  33802. idAttribute: 'jid',
  33803. defaults: {
  33804. 'show': 'offline'
  33805. },
  33806. initialize() {
  33807. this.resources = new Resources();
  33808. const id = `converse.identities-${this.get('jid')}`;
  33809. initStorage(this.resources, id, 'session');
  33810. this.listenTo(this.resources, 'update', this.onResourcesChanged);
  33811. this.listenTo(this.resources, 'change', this.onResourcesChanged);
  33812. },
  33813. onResourcesChanged() {
  33814. var _hpr$attributes;
  33815. const hpr = this.getHighestPriorityResource();
  33816. const show = (hpr === null || hpr === void 0 ? void 0 : (_hpr$attributes = hpr.attributes) === null || _hpr$attributes === void 0 ? void 0 : _hpr$attributes.show) || 'offline';
  33817. if (this.get('show') !== show) {
  33818. this.save({
  33819. 'show': show
  33820. });
  33821. }
  33822. },
  33823. /**
  33824. * Return the resource with the highest priority.
  33825. * If multiple resources have the same priority, take the latest one.
  33826. * @private
  33827. */
  33828. getHighestPriorityResource() {
  33829. return this.resources.sortBy(r => `${r.get('priority')}-${r.get('timestamp')}`).reverse()[0];
  33830. },
  33831. /**
  33832. * Adds a new resource and it's associated attributes as taken
  33833. * from the passed in presence stanza.
  33834. * Also updates the presence if the resource has higher priority (and is newer).
  33835. * @private
  33836. * @param { XMLElement } presence: The presence stanza
  33837. */
  33838. addResource(presence) {
  33839. var _presence$querySelect, _presence$querySelect2;
  33840. const jid = presence.getAttribute('from'),
  33841. name = presence_Strophe.getResourceFromJid(jid),
  33842. delay = presence_sizzle(`delay[xmlns="${presence_Strophe.NS.DELAY}"]`, presence).pop(),
  33843. priority = ((_presence$querySelect = presence.querySelector('priority')) === null || _presence$querySelect === void 0 ? void 0 : _presence$querySelect.textContent) ?? 0,
  33844. resource = this.resources.get(name),
  33845. settings = {
  33846. 'name': name,
  33847. 'priority': lodash_es_isNaN(parseInt(priority, 10)) ? 0 : parseInt(priority, 10),
  33848. 'show': ((_presence$querySelect2 = presence.querySelector('show')) === null || _presence$querySelect2 === void 0 ? void 0 : _presence$querySelect2.textContent) ?? 'online',
  33849. 'timestamp': delay ? presence_dayjs(delay.getAttribute('stamp')).toISOString() : new Date().toISOString()
  33850. };
  33851. if (resource) {
  33852. resource.save(settings);
  33853. } else {
  33854. this.resources.create(settings);
  33855. }
  33856. },
  33857. /**
  33858. * Remove the passed in resource from the resources map.
  33859. * Also redetermines the presence given that there's one less
  33860. * resource.
  33861. * @private
  33862. * @param { string } name: The resource name
  33863. */
  33864. removeResource(name) {
  33865. const resource = this.resources.get(name);
  33866. if (resource) {
  33867. resource.destroy();
  33868. }
  33869. }
  33870. });
  33871. const Presences = Collection.extend({
  33872. 'model': Presence
  33873. });
  33874. ;// CONCATENATED MODULE: ./src/headless/plugins/roster/index.js
  33875. /**
  33876. * @copyright The Converse.js contributors
  33877. * @license Mozilla Public License (MPLv2)
  33878. */
  33879. core_converse.plugins.add('converse-roster', {
  33880. dependencies: ['converse-status'],
  33881. initialize() {
  33882. core_api.settings.extend({
  33883. 'allow_contact_requests': true,
  33884. 'auto_subscribe': false,
  33885. 'synchronize_availability': true
  33886. });
  33887. core_api.promises.add(['cachedRoster', 'roster', 'rosterContactsFetched', 'rosterInitialized']); // API methods only available to plugins
  33888. Object.assign(shared_converse.api, roster_api);
  33889. const {
  33890. __
  33891. } = shared_converse;
  33892. shared_converse.HEADER_CURRENT_CONTACTS = __('My contacts');
  33893. shared_converse.HEADER_PENDING_CONTACTS = __('Pending contacts');
  33894. shared_converse.HEADER_REQUESTING_CONTACTS = __('Contact requests');
  33895. shared_converse.HEADER_UNGROUPED = __('Ungrouped');
  33896. shared_converse.HEADER_UNREAD = __('New messages');
  33897. shared_converse.Presence = Presence;
  33898. shared_converse.Presences = Presences;
  33899. shared_converse.RosterContact = contact;
  33900. shared_converse.RosterContacts = contacts;
  33901. core_api.listen.on('beforeTearDown', () => unregisterPresenceHandler());
  33902. core_api.listen.on('chatBoxesInitialized', onChatBoxesInitialized);
  33903. core_api.listen.on('clearSession', utils_onClearSession);
  33904. core_api.listen.on('presencesInitialized', onPresencesInitialized);
  33905. core_api.listen.on('statusInitialized', roster_utils_onStatusInitialized);
  33906. core_api.listen.on('streamResumptionFailed', () => shared_converse.session.set('roster_cached', false));
  33907. core_api.waitUntil('rosterContactsFetched').then(onRosterContactsFetched);
  33908. }
  33909. });
  33910. ;// CONCATENATED MODULE: ./src/headless/plugins/smacks/utils.js
  33911. const {
  33912. Strophe: smacks_utils_Strophe
  33913. } = core_converse.env;
  33914. const smacks_utils_u = core_converse.env.utils;
  33915. function isStreamManagementSupported() {
  33916. if (core_api.connection.isType('bosh') && !shared_converse.isTestEnv()) {
  33917. return false;
  33918. }
  33919. return core_api.disco.stream.getFeature('sm', smacks_utils_Strophe.NS.SM);
  33920. }
  33921. function handleAck(el) {
  33922. if (!shared_converse.session.get('smacks_enabled')) {
  33923. return true;
  33924. }
  33925. const handled = parseInt(el.getAttribute('h'), 10);
  33926. const last_known_handled = shared_converse.session.get('num_stanzas_handled_by_server');
  33927. const delta = handled - last_known_handled;
  33928. if (delta < 0) {
  33929. const err_msg = `New reported stanza count lower than previous. ` + `New: ${handled} - Previous: ${last_known_handled}`;
  33930. headless_log.error(err_msg);
  33931. }
  33932. const unacked_stanzas = shared_converse.session.get('unacked_stanzas');
  33933. if (delta > unacked_stanzas.length) {
  33934. const err_msg = `Higher reported acknowledge count than unacknowledged stanzas. ` + `Reported Acknowledged Count: ${delta} -` + `Unacknowledged Stanza Count: ${unacked_stanzas.length} -` + `New: ${handled} - Previous: ${last_known_handled}`;
  33935. headless_log.error(err_msg);
  33936. }
  33937. shared_converse.session.save({
  33938. 'num_stanzas_handled_by_server': handled,
  33939. 'num_stanzas_since_last_ack': 0,
  33940. 'unacked_stanzas': unacked_stanzas.slice(delta)
  33941. });
  33942. return true;
  33943. }
  33944. function sendAck() {
  33945. if (shared_converse.session.get('smacks_enabled')) {
  33946. const h = shared_converse.session.get('num_stanzas_handled');
  33947. const stanza = smacks_utils_u.toStanza(`<a xmlns="${smacks_utils_Strophe.NS.SM}" h="${h}"/>`);
  33948. core_api.send(stanza);
  33949. }
  33950. return true;
  33951. }
  33952. function stanzaHandler(el) {
  33953. if (shared_converse.session.get('smacks_enabled')) {
  33954. if (smacks_utils_u.isTagEqual(el, 'iq') || smacks_utils_u.isTagEqual(el, 'presence') || smacks_utils_u.isTagEqual(el, 'message')) {
  33955. const h = shared_converse.session.get('num_stanzas_handled');
  33956. shared_converse.session.save('num_stanzas_handled', h + 1);
  33957. }
  33958. }
  33959. return true;
  33960. }
  33961. function initSessionData() {
  33962. shared_converse.session.save({
  33963. 'smacks_enabled': shared_converse.session.get('smacks_enabled') || false,
  33964. 'num_stanzas_handled': shared_converse.session.get('num_stanzas_handled') || 0,
  33965. 'num_stanzas_handled_by_server': shared_converse.session.get('num_stanzas_handled_by_server') || 0,
  33966. 'num_stanzas_since_last_ack': shared_converse.session.get('num_stanzas_since_last_ack') || 0,
  33967. 'unacked_stanzas': shared_converse.session.get('unacked_stanzas') || []
  33968. });
  33969. }
  33970. function resetSessionData() {
  33971. var _converse$session;
  33972. (_converse$session = shared_converse.session) === null || _converse$session === void 0 ? void 0 : _converse$session.save({
  33973. 'smacks_enabled': false,
  33974. 'num_stanzas_handled': 0,
  33975. 'num_stanzas_handled_by_server': 0,
  33976. 'num_stanzas_since_last_ack': 0,
  33977. 'unacked_stanzas': []
  33978. });
  33979. }
  33980. function saveSessionData(el) {
  33981. const data = {
  33982. 'smacks_enabled': true
  33983. };
  33984. if (['1', 'true'].includes(el.getAttribute('resume'))) {
  33985. data['smacks_stream_id'] = el.getAttribute('id');
  33986. }
  33987. shared_converse.session.save(data);
  33988. return true;
  33989. }
  33990. function onFailedStanza(el) {
  33991. if (el.querySelector('item-not-found')) {
  33992. // Stream resumption must happen before resource binding but
  33993. // enabling a new stream must happen after resource binding.
  33994. // Since resumption failed, we simply continue.
  33995. //
  33996. // After resource binding, sendEnableStanza will be called
  33997. // based on the afterResourceBinding event.
  33998. headless_log.warn('Could not resume previous SMACKS session, session id not found. ' + 'A new session will be established.');
  33999. } else {
  34000. headless_log.error('Failed to enable stream management');
  34001. headless_log.error(el.outerHTML);
  34002. }
  34003. resetSessionData();
  34004. /**
  34005. * Triggered when the XEP-0198 stream could not be resumed.
  34006. * @event _converse#streamResumptionFailed
  34007. */
  34008. core_api.trigger('streamResumptionFailed');
  34009. return true;
  34010. }
  34011. function resendUnackedStanzas() {
  34012. const stanzas = shared_converse.session.get('unacked_stanzas'); // We clear the unacked_stanzas array because it'll get populated
  34013. // again in `onStanzaSent`
  34014. shared_converse.session.save('unacked_stanzas', []); // XXX: Currently we're resending *all* unacked stanzas, including
  34015. // IQ[type="get"] stanzas that longer have handlers (because the
  34016. // page reloaded or we reconnected, causing removal of handlers).
  34017. //
  34018. // *Side-note:* Is it necessary to clear handlers upon reconnection?
  34019. //
  34020. // I've considered not resending those stanzas, but then keeping
  34021. // track of what's been sent and ack'd and their order gets
  34022. // prohibitively complex.
  34023. //
  34024. // It's unclear how much of a problem this poses.
  34025. //
  34026. // Two possible solutions are running @converse/headless as a
  34027. // service worker or handling IQ[type="result"] stanzas
  34028. // differently, more like push stanzas, so that they don't need
  34029. // explicit handlers.
  34030. stanzas.forEach(s => core_api.send(s));
  34031. }
  34032. function onResumedStanza(el) {
  34033. saveSessionData(el);
  34034. handleAck(el);
  34035. resendUnackedStanzas();
  34036. shared_converse.connection.do_bind = false; // No need to bind our resource anymore
  34037. shared_converse.connection.authenticated = true;
  34038. shared_converse.connection.restored = true;
  34039. shared_converse.connection._changeConnectStatus(smacks_utils_Strophe.Status.CONNECTED, null);
  34040. }
  34041. async function sendResumeStanza() {
  34042. const promise = getOpenPromise();
  34043. shared_converse.connection._addSysHandler(el => promise.resolve(onResumedStanza(el)), smacks_utils_Strophe.NS.SM, 'resumed');
  34044. shared_converse.connection._addSysHandler(el => promise.resolve(onFailedStanza(el)), smacks_utils_Strophe.NS.SM, 'failed');
  34045. const previous_id = shared_converse.session.get('smacks_stream_id');
  34046. const h = shared_converse.session.get('num_stanzas_handled');
  34047. const stanza = smacks_utils_u.toStanza(`<resume xmlns="${smacks_utils_Strophe.NS.SM}" h="${h}" previd="${previous_id}"/>`);
  34048. core_api.send(stanza);
  34049. shared_converse.connection.flush();
  34050. await promise;
  34051. }
  34052. async function sendEnableStanza() {
  34053. if (!core_api.settings.get('enable_smacks') || shared_converse.session.get('smacks_enabled')) {
  34054. return;
  34055. }
  34056. if (await isStreamManagementSupported()) {
  34057. const promise = getOpenPromise();
  34058. shared_converse.connection._addSysHandler(el => promise.resolve(saveSessionData(el)), smacks_utils_Strophe.NS.SM, 'enabled');
  34059. shared_converse.connection._addSysHandler(el => promise.resolve(onFailedStanza(el)), smacks_utils_Strophe.NS.SM, 'failed');
  34060. const resume = core_api.connection.isType('websocket') || shared_converse.isTestEnv();
  34061. const stanza = smacks_utils_u.toStanza(`<enable xmlns="${smacks_utils_Strophe.NS.SM}" resume="${resume}"/>`);
  34062. core_api.send(stanza);
  34063. shared_converse.connection.flush();
  34064. await promise;
  34065. }
  34066. }
  34067. const smacks_handlers = [];
  34068. async function enableStreamManagement() {
  34069. var _converse$session2;
  34070. if (!core_api.settings.get('enable_smacks')) {
  34071. return;
  34072. }
  34073. if (!(await isStreamManagementSupported())) {
  34074. return;
  34075. }
  34076. const conn = shared_converse.connection;
  34077. while (smacks_handlers.length) {
  34078. conn.deleteHandler(smacks_handlers.pop());
  34079. }
  34080. smacks_handlers.push(conn.addHandler(stanzaHandler));
  34081. smacks_handlers.push(conn.addHandler(sendAck, smacks_utils_Strophe.NS.SM, 'r'));
  34082. smacks_handlers.push(conn.addHandler(handleAck, smacks_utils_Strophe.NS.SM, 'a'));
  34083. if ((_converse$session2 = shared_converse.session) !== null && _converse$session2 !== void 0 && _converse$session2.get('smacks_stream_id')) {
  34084. await sendResumeStanza();
  34085. } else {
  34086. resetSessionData();
  34087. }
  34088. }
  34089. function onStanzaSent(stanza) {
  34090. if (!shared_converse.session) {
  34091. headless_log.warn('No _converse.session!');
  34092. return;
  34093. }
  34094. if (!shared_converse.session.get('smacks_enabled')) {
  34095. return;
  34096. }
  34097. if (smacks_utils_u.isTagEqual(stanza, 'iq') || smacks_utils_u.isTagEqual(stanza, 'presence') || smacks_utils_u.isTagEqual(stanza, 'message')) {
  34098. const stanza_string = smacks_utils_Strophe.serialize(stanza);
  34099. shared_converse.session.save('unacked_stanzas', (shared_converse.session.get('unacked_stanzas') || []).concat([stanza_string]));
  34100. const max_unacked = core_api.settings.get('smacks_max_unacked_stanzas');
  34101. if (max_unacked > 0) {
  34102. const num = shared_converse.session.get('num_stanzas_since_last_ack') + 1;
  34103. if (num % max_unacked === 0) {
  34104. // Request confirmation of sent stanzas
  34105. core_api.send(smacks_utils_u.toStanza(`<r xmlns="${smacks_utils_Strophe.NS.SM}"/>`));
  34106. }
  34107. shared_converse.session.save({
  34108. 'num_stanzas_since_last_ack': num
  34109. });
  34110. }
  34111. }
  34112. }
  34113. ;// CONCATENATED MODULE: ./src/headless/plugins/smacks/index.js
  34114. /**
  34115. * @copyright The Converse.js contributors
  34116. * @license Mozilla Public License (MPLv2)
  34117. * @description Converse.js plugin which adds support for XEP-0198: Stream Management
  34118. */
  34119. const {
  34120. Strophe: smacks_Strophe
  34121. } = core_converse.env;
  34122. smacks_Strophe.addNamespace('SM', 'urn:xmpp:sm:3');
  34123. core_converse.plugins.add('converse-smacks', {
  34124. initialize() {
  34125. // Configuration values for this plugin
  34126. // ====================================
  34127. // Refer to docs/source/configuration.rst for explanations of these
  34128. // configuration settings.
  34129. core_api.settings.extend({
  34130. 'enable_smacks': true,
  34131. 'smacks_max_unacked_stanzas': 5
  34132. });
  34133. core_api.listen.on('afterResourceBinding', sendEnableStanza);
  34134. core_api.listen.on('beforeResourceBinding', enableStreamManagement);
  34135. core_api.listen.on('send', onStanzaSent);
  34136. core_api.listen.on('userSessionInitialized', initSessionData);
  34137. }
  34138. });
  34139. ;// CONCATENATED MODULE: ./src/headless/plugins/vcard/vcard.js
  34140. /**
  34141. * Represents a VCard
  34142. * @class
  34143. * @namespace _converse.VCard
  34144. * @memberOf _converse
  34145. */
  34146. const VCard = Model.extend({
  34147. idAttribute: 'jid',
  34148. defaults: {
  34149. 'image': shared_converse.DEFAULT_IMAGE,
  34150. 'image_type': shared_converse.DEFAULT_IMAGE_TYPE
  34151. },
  34152. set(key, val, options) {
  34153. // Override Model.prototype.set to make sure that the
  34154. // default `image` and `image_type` values are maintained.
  34155. let attrs;
  34156. if (typeof key === 'object') {
  34157. attrs = key;
  34158. options = val;
  34159. } else {
  34160. (attrs = {})[key] = val;
  34161. }
  34162. if ('image' in attrs && !attrs['image']) {
  34163. attrs['image'] = shared_converse.DEFAULT_IMAGE;
  34164. attrs['image_type'] = shared_converse.DEFAULT_IMAGE_TYPE;
  34165. return Model.prototype.set.call(this, attrs, options);
  34166. } else {
  34167. return Model.prototype.set.apply(this, arguments);
  34168. }
  34169. },
  34170. getDisplayName() {
  34171. return this.get('nickname') || this.get('fullname') || this.get('jid');
  34172. }
  34173. });
  34174. /* harmony default export */ const vcard = (VCard);
  34175. ;// CONCATENATED MODULE: ./src/headless/plugins/vcard/utils.js
  34176. const {
  34177. Strophe: vcard_utils_Strophe,
  34178. $iq: vcard_utils_$iq,
  34179. u: vcard_utils_u
  34180. } = core_converse.env;
  34181. async function onVCardData(jid, iq) {
  34182. const vcard = iq.querySelector('vCard');
  34183. let result = {};
  34184. if (vcard !== null) {
  34185. var _vcard$querySelector, _vcard$querySelector2, _vcard$querySelector3, _vcard$querySelector4, _vcard$querySelector5, _vcard$querySelector6, _vcard$querySelector7;
  34186. result = {
  34187. 'stanza': iq,
  34188. 'fullname': (_vcard$querySelector = vcard.querySelector('FN')) === null || _vcard$querySelector === void 0 ? void 0 : _vcard$querySelector.textContent,
  34189. 'nickname': (_vcard$querySelector2 = vcard.querySelector('NICKNAME')) === null || _vcard$querySelector2 === void 0 ? void 0 : _vcard$querySelector2.textContent,
  34190. 'image': (_vcard$querySelector3 = vcard.querySelector('PHOTO BINVAL')) === null || _vcard$querySelector3 === void 0 ? void 0 : _vcard$querySelector3.textContent,
  34191. 'image_type': (_vcard$querySelector4 = vcard.querySelector('PHOTO TYPE')) === null || _vcard$querySelector4 === void 0 ? void 0 : _vcard$querySelector4.textContent,
  34192. 'url': (_vcard$querySelector5 = vcard.querySelector('URL')) === null || _vcard$querySelector5 === void 0 ? void 0 : _vcard$querySelector5.textContent,
  34193. 'role': (_vcard$querySelector6 = vcard.querySelector('ROLE')) === null || _vcard$querySelector6 === void 0 ? void 0 : _vcard$querySelector6.textContent,
  34194. 'email': (_vcard$querySelector7 = vcard.querySelector('EMAIL USERID')) === null || _vcard$querySelector7 === void 0 ? void 0 : _vcard$querySelector7.textContent,
  34195. 'vcard_updated': new Date().toISOString(),
  34196. 'vcard_error': undefined
  34197. };
  34198. }
  34199. if (result.image) {
  34200. const buffer = vcard_utils_u.base64ToArrayBuffer(result['image']);
  34201. const ab = await crypto.subtle.digest('SHA-1', buffer);
  34202. result['image_hash'] = vcard_utils_u.arrayBufferToHex(ab);
  34203. }
  34204. return result;
  34205. }
  34206. function createStanza(type, jid, vcard_el) {
  34207. const iq = vcard_utils_$iq(jid ? {
  34208. 'type': type,
  34209. 'to': jid
  34210. } : {
  34211. 'type': type
  34212. });
  34213. if (!vcard_el) {
  34214. iq.c("vCard", {
  34215. 'xmlns': vcard_utils_Strophe.NS.VCARD
  34216. });
  34217. } else {
  34218. iq.cnode(vcard_el);
  34219. }
  34220. return iq;
  34221. }
  34222. function onOccupantAvatarChanged(occupant) {
  34223. const hash = occupant.get('image_hash');
  34224. const vcards = [];
  34225. if (occupant.get('jid')) {
  34226. vcards.push(shared_converse.vcards.get(occupant.get('jid')));
  34227. }
  34228. vcards.push(shared_converse.vcards.get(occupant.get('from')));
  34229. vcards.forEach(v => hash && (v === null || v === void 0 ? void 0 : v.get('image_hash')) !== hash && core_api.vcard.update(v, true));
  34230. }
  34231. async function setVCardOnModel(model) {
  34232. let jid;
  34233. if (model instanceof shared_converse.Message) {
  34234. if (['error', 'info'].includes(model.get('type'))) {
  34235. return;
  34236. }
  34237. jid = model.get('from');
  34238. } else {
  34239. jid = model.get('jid');
  34240. }
  34241. if (!jid) {
  34242. headless_log.warn(`Could not set VCard on model because no JID found!`);
  34243. return;
  34244. }
  34245. await core_api.waitUntil('VCardsInitialized');
  34246. model.vcard = shared_converse.vcards.get(jid) || shared_converse.vcards.create({
  34247. jid
  34248. });
  34249. model.vcard.on('change', () => model.trigger('vcard:change'));
  34250. model.trigger('vcard:add');
  34251. }
  34252. function getVCardForOccupant(occupant) {
  34253. var _occupant$collection;
  34254. const muc = occupant === null || occupant === void 0 ? void 0 : (_occupant$collection = occupant.collection) === null || _occupant$collection === void 0 ? void 0 : _occupant$collection.chatroom;
  34255. const nick = occupant.get('nick');
  34256. if (nick && (muc === null || muc === void 0 ? void 0 : muc.get('nick')) === nick) {
  34257. return shared_converse.xmppstatus.vcard;
  34258. } else {
  34259. const jid = occupant.get('jid') || occupant.get('from');
  34260. if (jid) {
  34261. return shared_converse.vcards.get(jid) || shared_converse.vcards.create({
  34262. jid
  34263. });
  34264. } else {
  34265. headless_log.warn(`Could not get VCard for occupant because no JID found!`);
  34266. return;
  34267. }
  34268. }
  34269. }
  34270. async function setVCardOnOccupant(occupant) {
  34271. await core_api.waitUntil('VCardsInitialized');
  34272. occupant.vcard = getVCardForOccupant(occupant);
  34273. if (occupant.vcard) {
  34274. occupant.vcard.on('change', () => occupant.trigger('vcard:change'));
  34275. occupant.trigger('vcard:add');
  34276. }
  34277. }
  34278. function getVCardForMUCMessage(message) {
  34279. var _message$collection;
  34280. const muc = message === null || message === void 0 ? void 0 : (_message$collection = message.collection) === null || _message$collection === void 0 ? void 0 : _message$collection.chatbox;
  34281. const nick = vcard_utils_Strophe.getResourceFromJid(message.get('from'));
  34282. if (nick && (muc === null || muc === void 0 ? void 0 : muc.get('nick')) === nick) {
  34283. return shared_converse.xmppstatus.vcard;
  34284. } else {
  34285. var _message$occupant;
  34286. const jid = ((_message$occupant = message.occupant) === null || _message$occupant === void 0 ? void 0 : _message$occupant.get('jid')) || message.get('from');
  34287. if (jid) {
  34288. return shared_converse.vcards.get(jid) || shared_converse.vcards.create({
  34289. jid
  34290. });
  34291. } else {
  34292. headless_log.warn(`Could not get VCard for message because no JID found! msgid: ${message.get('msgid')}`);
  34293. return;
  34294. }
  34295. }
  34296. }
  34297. async function setVCardOnMUCMessage(message) {
  34298. if (['error', 'info'].includes(message.get('type'))) {
  34299. return;
  34300. } else {
  34301. await core_api.waitUntil('VCardsInitialized');
  34302. message.vcard = getVCardForMUCMessage(message);
  34303. if (message.vcard) {
  34304. message.vcard.on('change', () => message.trigger('vcard:change'));
  34305. message.trigger('vcard:add');
  34306. }
  34307. }
  34308. }
  34309. async function initVCardCollection() {
  34310. shared_converse.vcards = new shared_converse.VCards();
  34311. const id = `${shared_converse.bare_jid}-converse.vcards`;
  34312. initStorage(shared_converse.vcards, id);
  34313. await new Promise(resolve => {
  34314. shared_converse.vcards.fetch({
  34315. 'success': resolve,
  34316. 'error': resolve
  34317. }, {
  34318. 'silent': true
  34319. });
  34320. });
  34321. const vcards = shared_converse.vcards;
  34322. if (shared_converse.session) {
  34323. const jid = shared_converse.session.get('bare_jid');
  34324. const status = shared_converse.xmppstatus;
  34325. status.vcard = vcards.get(jid) || vcards.create({
  34326. 'jid': jid
  34327. });
  34328. if (status.vcard) {
  34329. status.vcard.on('change', () => status.trigger('vcard:change'));
  34330. status.trigger('vcard:add');
  34331. }
  34332. }
  34333. /**
  34334. * Triggered as soon as the `_converse.vcards` collection has been initialized and populated from cache.
  34335. * @event _converse#VCardsInitialized
  34336. */
  34337. core_api.trigger('VCardsInitialized');
  34338. }
  34339. function clearVCardsSession() {
  34340. if (shared_converse.shouldClearCache()) {
  34341. core_api.promises.add('VCardsInitialized');
  34342. if (shared_converse.vcards) {
  34343. shared_converse.vcards.clearStore();
  34344. delete shared_converse.vcards;
  34345. }
  34346. }
  34347. }
  34348. async function getVCard(jid) {
  34349. const to = vcard_utils_Strophe.getBareJidFromJid(jid) === shared_converse.bare_jid ? null : jid;
  34350. let iq;
  34351. try {
  34352. iq = await core_api.sendIQ(createStanza("get", to));
  34353. } catch (iq) {
  34354. return {
  34355. jid,
  34356. 'stanza': iq,
  34357. 'vcard_error': new Date().toISOString()
  34358. };
  34359. }
  34360. return onVCardData(jid, iq);
  34361. }
  34362. ;// CONCATENATED MODULE: ./src/headless/plugins/vcard/api.js
  34363. const {
  34364. dayjs: api_dayjs,
  34365. u: vcard_api_u
  34366. } = core_converse.env;
  34367. /* harmony default export */ const vcard_api = ({
  34368. /**
  34369. * The XEP-0054 VCard API
  34370. *
  34371. * This API lets you access and update user VCards
  34372. *
  34373. * @namespace _converse.api.vcard
  34374. * @memberOf _converse.api
  34375. */
  34376. vcard: {
  34377. /**
  34378. * Enables setting new values for a VCard.
  34379. *
  34380. * Sends out an IQ stanza to set the user's VCard and if
  34381. * successful, it updates the {@link _converse.VCard}
  34382. * for the passed in JID.
  34383. *
  34384. * @method _converse.api.vcard.set
  34385. * @param {string} jid The JID for which the VCard should be set
  34386. * @param {object} data A map of VCard keys and values
  34387. * @example
  34388. * let jid = _converse.bare_jid;
  34389. * _converse.api.vcard.set( jid, {
  34390. * 'fn': 'John Doe',
  34391. * 'nickname': 'jdoe'
  34392. * }).then(() => {
  34393. * // Succes
  34394. * }).catch((e) => {
  34395. * // Failure, e is your error object
  34396. * }).
  34397. */
  34398. async set(jid, data) {
  34399. if (!jid) {
  34400. throw Error("No jid provided for the VCard data");
  34401. }
  34402. const div = document.createElement('div');
  34403. const vcard_el = vcard_api_u.toStanza(`
  34404. <vCard xmlns="vcard-temp">
  34405. <FN>${data.fn}</FN>
  34406. <NICKNAME>${data.nickname}</NICKNAME>
  34407. <URL>${data.url}</URL>
  34408. <ROLE>${data.role}</ROLE>
  34409. <EMAIL><INTERNET/><PREF/><USERID>${data.email}</USERID></EMAIL>
  34410. <PHOTO>
  34411. <TYPE>${data.image_type}</TYPE>
  34412. <BINVAL>${data.image}</BINVAL>
  34413. </PHOTO>
  34414. </vCard>`, div);
  34415. let result;
  34416. try {
  34417. result = await core_api.sendIQ(createStanza("set", jid, vcard_el));
  34418. } catch (e) {
  34419. throw e;
  34420. }
  34421. await core_api.vcard.update(jid, true);
  34422. return result;
  34423. },
  34424. /**
  34425. * @method _converse.api.vcard.get
  34426. * @param {Model|string} model Either a `Model` instance, or a string JID.
  34427. * If a `Model` instance is passed in, then it must have either a `jid`
  34428. * attribute or a `muc_jid` attribute.
  34429. * @param {boolean} [force] A boolean indicating whether the vcard should be
  34430. * fetched from the server even if it's been fetched before.
  34431. * @returns {promise} A Promise which resolves with the VCard data for a particular JID or for
  34432. * a `Model` instance which represents an entity with a JID (such as a roster contact,
  34433. * chat or chatroom occupant).
  34434. *
  34435. * @example
  34436. * const { api } = _converse;
  34437. * api.waitUntil('rosterContactsFetched').then(() => {
  34438. * api.vcard.get('someone@example.org').then(
  34439. * (vcard) => {
  34440. * // Do something with the vcard...
  34441. * }
  34442. * );
  34443. * });
  34444. */
  34445. get(model, force) {
  34446. if (typeof model === 'string') {
  34447. return getVCard(model);
  34448. }
  34449. const error_date = model.get('vcard_error');
  34450. const already_tried_today = error_date && api_dayjs(error_date).isSame(new Date(), "day");
  34451. if (force || !model.get('vcard_updated') && !already_tried_today) {
  34452. const jid = model.get('jid');
  34453. if (!jid) {
  34454. headless_log.error("No JID to get vcard for");
  34455. }
  34456. return getVCard(jid);
  34457. } else {
  34458. return Promise.resolve({});
  34459. }
  34460. },
  34461. /**
  34462. * Fetches the VCard associated with a particular `Model` instance
  34463. * (by using its `jid` or `muc_jid` attribute) and then updates the model with the
  34464. * returned VCard data.
  34465. *
  34466. * @method _converse.api.vcard.update
  34467. * @param {Model} model A `Model` instance
  34468. * @param {boolean} [force] A boolean indicating whether the vcard should be
  34469. * fetched again even if it's been fetched before.
  34470. * @returns {promise} A promise which resolves once the update has completed.
  34471. * @example
  34472. * const { api } = _converse;
  34473. * api.waitUntil('rosterContactsFetched').then(async () => {
  34474. * const chatbox = await api.chats.get('someone@example.org');
  34475. * api.vcard.update(chatbox);
  34476. * });
  34477. */
  34478. async update(model, force) {
  34479. const data = await this.get(model, force);
  34480. model = typeof model === 'string' ? shared_converse.vcards.get(model) : model;
  34481. if (!model) {
  34482. headless_log.error(`Could not find a VCard model for ${model}`);
  34483. return;
  34484. }
  34485. if (Object.keys(data).length) {
  34486. delete data['stanza'];
  34487. model.save(data);
  34488. }
  34489. }
  34490. }
  34491. });
  34492. ;// CONCATENATED MODULE: ./src/headless/plugins/vcard/index.js
  34493. /**
  34494. * @copyright The Converse.js contributors
  34495. * @license Mozilla Public License (MPLv2)
  34496. */
  34497. const {
  34498. Strophe: vcard_Strophe
  34499. } = core_converse.env;
  34500. core_converse.plugins.add('converse-vcard', {
  34501. dependencies: ["converse-status", "converse-roster"],
  34502. overrides: {
  34503. XMPPStatus: {
  34504. getNickname() {
  34505. const {
  34506. _converse
  34507. } = this.__super__;
  34508. const nick = this.__super__.getNickname.apply(this);
  34509. if (!nick && _converse.xmppstatus.vcard) {
  34510. return _converse.xmppstatus.vcard.get('nickname');
  34511. } else {
  34512. return nick;
  34513. }
  34514. },
  34515. getFullname() {
  34516. const {
  34517. _converse
  34518. } = this.__super__;
  34519. const fullname = this.__super__.getFullname.apply(this);
  34520. if (!fullname && _converse.xmppstatus.vcard) {
  34521. return _converse.xmppstatus.vcard.get('fullname');
  34522. } else {
  34523. return fullname;
  34524. }
  34525. }
  34526. },
  34527. RosterContact: {
  34528. getDisplayName() {
  34529. if (!this.get('nickname') && this.vcard) {
  34530. return this.vcard.getDisplayName();
  34531. } else {
  34532. return this.__super__.getDisplayName.apply(this);
  34533. }
  34534. },
  34535. getFullname() {
  34536. if (this.vcard) {
  34537. return this.vcard.get('fullname');
  34538. } else {
  34539. return this.__super__.getFullname.apply(this);
  34540. }
  34541. }
  34542. }
  34543. },
  34544. initialize() {
  34545. core_api.promises.add('VCardsInitialized');
  34546. shared_converse.VCard = vcard;
  34547. shared_converse.VCards = Collection.extend({
  34548. model: shared_converse.VCard,
  34549. initialize() {
  34550. this.on('add', v => v.get('jid') && core_api.vcard.update(v));
  34551. }
  34552. });
  34553. core_api.listen.on('chatRoomInitialized', m => {
  34554. setVCardOnModel(m);
  34555. m.occupants.forEach(setVCardOnOccupant);
  34556. m.listenTo(m.occupants, 'add', setVCardOnOccupant);
  34557. m.listenTo(m.occupants, 'change:image_hash', o => onOccupantAvatarChanged(o));
  34558. });
  34559. core_api.listen.on('chatBoxInitialized', m => setVCardOnModel(m));
  34560. core_api.listen.on('chatRoomMessageInitialized', m => setVCardOnMUCMessage(m));
  34561. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(vcard_Strophe.NS.VCARD));
  34562. core_api.listen.on('clearSession', () => clearVCardsSession());
  34563. core_api.listen.on('messageInitialized', m => setVCardOnModel(m));
  34564. core_api.listen.on('rosterContactInitialized', m => setVCardOnModel(m));
  34565. core_api.listen.on('statusInitialized', initVCardCollection);
  34566. Object.assign(shared_converse.api, vcard_api);
  34567. }
  34568. });
  34569. ;// CONCATENATED MODULE: ./src/headless/headless.js
  34570. /* START: Removable components
  34571. * --------------------
  34572. * Any of the following components may be removed if they're not needed.
  34573. */
  34574. // XEP-0050 Ad Hoc Commands
  34575. // XEP-0199 XMPP Ping
  34576. // XEP-0206 BOSH
  34577. // XEP-0115 Entity Capabilities
  34578. // XEP-0280 Message Carbons
  34579. // RFC-6121 Instant messaging
  34580. // XEP-0030 Service discovery
  34581. // Support for headline messages
  34582. // XEP-0313 Message Archive Management
  34583. // XEP-0045 Multi-user chat
  34584. // XEP-0199 XMPP Ping
  34585. // XEP-0060 Pubsub
  34586. // RFC-6121 Contacts Roster
  34587. // XEP-0198 Stream Management
  34588. // XEP-0054 VCard-temp
  34589. /* END: Removable components */
  34590. /* harmony default export */ const headless = ((/* unused pure expression or super */ null && (converse)));
  34591. // EXTERNAL MODULE: ./node_modules/jed/jed.js
  34592. var jed = __webpack_require__(2353);
  34593. var jed_default = /*#__PURE__*/__webpack_require__.n(jed);
  34594. ;// CONCATENATED MODULE: ./src/i18n/index.js
  34595. /**
  34596. * @module i18n
  34597. * @copyright 2022, the Converse.js contributors
  34598. * @license Mozilla Public License (MPLv2)
  34599. * @description This is the internationalization module
  34600. */
  34601. const {
  34602. dayjs: i18n_dayjs
  34603. } = core_converse.env;
  34604. function detectLocale(library_check) {
  34605. /* Determine which locale is supported by the user's system as well
  34606. * as by the relevant library (e.g. converse.js or dayjs).
  34607. * @param { Function } library_check - Returns a boolean indicating whether
  34608. * the locale is supported.
  34609. */
  34610. let locale;
  34611. if (window.navigator.userLanguage) {
  34612. locale = isLocaleAvailable(window.navigator.userLanguage, library_check);
  34613. }
  34614. if (window.navigator.languages && !locale) {
  34615. for (let i = 0; i < window.navigator.languages.length && !locale; i++) {
  34616. locale = isLocaleAvailable(window.navigator.languages[i], library_check);
  34617. }
  34618. }
  34619. if (window.navigator.browserLanguage && !locale) {
  34620. locale = isLocaleAvailable(window.navigator.browserLanguage, library_check);
  34621. }
  34622. if (window.navigator.language && !locale) {
  34623. locale = isLocaleAvailable(window.navigator.language, library_check);
  34624. }
  34625. if (window.navigator.systemLanguage && !locale) {
  34626. locale = isLocaleAvailable(window.navigator.systemLanguage, library_check);
  34627. }
  34628. return locale || 'en';
  34629. }
  34630. function isConverseLocale(locale, supported_locales) {
  34631. return typeof locale === 'string' && supported_locales.includes(locale);
  34632. }
  34633. function getLocale(preferred_locale, isSupportedByLibrary) {
  34634. if (typeof preferred_locale === 'string') {
  34635. if (preferred_locale === 'en' || isSupportedByLibrary(preferred_locale)) {
  34636. return preferred_locale;
  34637. }
  34638. }
  34639. return detectLocale(isSupportedByLibrary) || 'en';
  34640. }
  34641. /* Check whether the locale or sub locale (e.g. en-US, en) is supported.
  34642. * @param { String } locale - The locale to check for
  34643. * @param { Function } available - Returns a boolean indicating whether the locale is supported
  34644. */
  34645. function isLocaleAvailable(locale, available) {
  34646. if (available(locale)) {
  34647. return locale;
  34648. } else {
  34649. var sublocale = locale.split("-")[0];
  34650. if (sublocale !== locale && available(sublocale)) {
  34651. return sublocale;
  34652. }
  34653. }
  34654. }
  34655. /* Fetch the translations for the given local at the given URL.
  34656. * @private
  34657. * @method i18n#fetchTranslations
  34658. * @param { _converse }
  34659. */
  34660. async function fetchTranslations(_converse) {
  34661. const {
  34662. api,
  34663. locale
  34664. } = _converse;
  34665. const dayjs_locale = locale.toLowerCase().replace('_', '-');
  34666. if (!isConverseLocale(locale, api.settings.get("locales")) || locale === 'en') {
  34667. return;
  34668. }
  34669. const {
  34670. default: data
  34671. } = await __webpack_require__(7521)(`./${locale}/LC_MESSAGES/converse.po`);
  34672. await __webpack_require__(9434)(`./${dayjs_locale}.js`);
  34673. i18n_dayjs.locale(getLocale(dayjs_locale, l => i18n_dayjs.locale(l)));
  34674. jed_instance = new (jed_default())(data);
  34675. }
  34676. let jed_instance;
  34677. /**
  34678. * @namespace i18n
  34679. */
  34680. Object.assign(i18n, {
  34681. getLocale(preferred_locale, available_locales) {
  34682. return getLocale(preferred_locale, preferred => isConverseLocale(preferred, available_locales));
  34683. },
  34684. translate(str) {
  34685. if (!jed_instance) {
  34686. return jed_default().sprintf.apply((jed_default()), arguments);
  34687. }
  34688. const t = jed_instance.translate(str);
  34689. if (arguments.length > 1) {
  34690. return t.fetch.apply(t, [].slice.call(arguments, 1));
  34691. } else {
  34692. return t.fetch();
  34693. }
  34694. },
  34695. async initialize() {
  34696. if (shared_converse.isTestEnv()) {
  34697. shared_converse.locale = 'en';
  34698. } else {
  34699. try {
  34700. const preferred_locale = core_api.settings.get('i18n');
  34701. shared_converse.locale = i18n.getLocale(preferred_locale, core_api.settings.get("locales"));
  34702. await fetchTranslations(shared_converse);
  34703. } catch (e) {
  34704. headless_log.fatal(e.message);
  34705. shared_converse.locale = 'en';
  34706. }
  34707. }
  34708. },
  34709. __() {
  34710. return i18n.translate(...arguments);
  34711. }
  34712. });
  34713. const __ = i18n.__;
  34714. ;// CONCATENATED MODULE: ./src/shared/registry.js
  34715. const registry = {};
  34716. function registry_define(name, constructor) {
  34717. this.registry[name] = constructor;
  34718. }
  34719. function register() {
  34720. Object.keys(registry).forEach(name => {
  34721. if (!customElements.get(name)) {
  34722. customElements.define(name, registry[name]);
  34723. }
  34724. });
  34725. }
  34726. core_api.elements = {
  34727. registry,
  34728. define: registry_define,
  34729. register
  34730. };
  34731. ;// CONCATENATED MODULE: ./src/shared/components/element.js
  34732. class CustomElement extends lit_element_s {
  34733. createRenderRoot() {
  34734. // Render without the shadow DOM
  34735. return this;
  34736. }
  34737. connectedCallback() {
  34738. var _this$initialize;
  34739. super.connectedCallback();
  34740. (_this$initialize = this.initialize) === null || _this$initialize === void 0 ? void 0 : _this$initialize.call(this);
  34741. }
  34742. disconnectedCallback() {
  34743. super.disconnectedCallback();
  34744. this.stopListening();
  34745. }
  34746. }
  34747. Object.assign(CustomElement.prototype, Events);
  34748. ;// CONCATENATED MODULE: ./src/shared/constants.js
  34749. // These are all the view-layer plugins.
  34750. //
  34751. // For the full Converse build, this list serves
  34752. // as a whitelist (see src/converse.js) in addition to the
  34753. // CORE_PLUGINS list in src/headless/consts.js.
  34754. const VIEW_PLUGINS = ['converse-bookmark-views', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', 'converse-dragresize', 'converse-fullscreen', 'converse-headlines-view', 'converse-mam-views', 'converse-minimize', 'converse-modal', 'converse-muc-views', 'converse-notification', 'converse-omemo', 'converse-profile', 'converse-push', 'converse-register', 'converse-roomslist', 'converse-rootview', 'converse-rosterview', 'converse-singleton'];
  34755. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js
  34756. var injectStylesIntoStyleTag = __webpack_require__(3379);
  34757. var injectStylesIntoStyleTag_default = /*#__PURE__*/__webpack_require__.n(injectStylesIntoStyleTag);
  34758. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleDomAPI.js
  34759. var styleDomAPI = __webpack_require__(7795);
  34760. var styleDomAPI_default = /*#__PURE__*/__webpack_require__.n(styleDomAPI);
  34761. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertBySelector.js
  34762. var insertBySelector = __webpack_require__(569);
  34763. var insertBySelector_default = /*#__PURE__*/__webpack_require__.n(insertBySelector);
  34764. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js
  34765. var setAttributesWithoutAttributes = __webpack_require__(3565);
  34766. var setAttributesWithoutAttributes_default = /*#__PURE__*/__webpack_require__.n(setAttributesWithoutAttributes);
  34767. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/insertStyleElement.js
  34768. var insertStyleElement = __webpack_require__(9216);
  34769. var insertStyleElement_default = /*#__PURE__*/__webpack_require__.n(insertStyleElement);
  34770. // EXTERNAL MODULE: ./node_modules/style-loader/dist/runtime/styleTagTransform.js
  34771. var styleTagTransform = __webpack_require__(4589);
  34772. var styleTagTransform_default = /*#__PURE__*/__webpack_require__.n(styleTagTransform);
  34773. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/styles/index.scss
  34774. var styles = __webpack_require__(9537);
  34775. ;// CONCATENATED MODULE: ./src/shared/styles/index.scss
  34776. var options = {};
  34777. options.styleTagTransform = (styleTagTransform_default());
  34778. options.setAttributes = (setAttributesWithoutAttributes_default());
  34779. options.insert = insertBySelector_default().bind(null, "head");
  34780. options.domAPI = (styleDomAPI_default());
  34781. options.insertStyleElement = (insertStyleElement_default());
  34782. var update = injectStylesIntoStyleTag_default()(styles/* default */.Z, options);
  34783. /* harmony default export */ const shared_styles = (styles/* default */.Z && styles/* default.locals */.Z.locals ? styles/* default.locals */.Z.locals : undefined);
  34784. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/templates/form.js
  34785. /* harmony default export */ const templates_form = (o => {
  34786. var _o$bookmark, _o$bookmark2;
  34787. const name = ((_o$bookmark = o.bookmark) === null || _o$bookmark === void 0 ? void 0 : _o$bookmark.get('name')) ?? o.name;
  34788. const nick = ((_o$bookmark2 = o.bookmark) === null || _o$bookmark2 === void 0 ? void 0 : _o$bookmark2.get('nick')) ?? o.nick;
  34789. const i18n_heading = __('Bookmark for "%1$s"', name);
  34790. const i18n_autojoin = __('Would you like this groupchat to be automatically joined upon startup?');
  34791. const i18n_remove = __('Remove');
  34792. const i18n_name = __('The name for this bookmark:');
  34793. const i18n_nick = __('What should your nickname for this groupchat be?');
  34794. const i18n_submit = o.bookmark ? __('Update') : __('Save');
  34795. return $`
  34796. <form class="converse-form chatroom-form" @submit=${o.onSubmit}>
  34797. <legend>${i18n_heading}</legend>
  34798. <fieldset class="form-group">
  34799. <label for="converse_muc_bookmark_name">${i18n_name}</label>
  34800. <input class="form-control" type="text" value="${name}" name="name" required="required" id="converse_muc_bookmark_name"/>
  34801. </fieldset>
  34802. <fieldset class="form-group">
  34803. <label for="converse_muc_bookmark_nick">${i18n_nick}</label>
  34804. <input class="form-control" type="text" name="nick" value="${nick || ''}" id="converse_muc_bookmark_nick"/>
  34805. </fieldset>
  34806. <fieldset class="form-group form-check">
  34807. <input class="form-check-input" id="converse_muc_bookmark_autojoin" type="checkbox" name="autojoin"/>
  34808. <label class="form-check-label" for="converse_muc_bookmark_autojoin">${i18n_autojoin}</label>
  34809. </fieldset>
  34810. <fieldset class="form-group">
  34811. <input class="btn btn-primary" type="submit" value="${i18n_submit}">
  34812. ${o.bookmark ? $`<input class="btn btn-secondary button-remove" type="button" value="${i18n_remove}" @click=${o.onCancel}>` : ''}
  34813. </fieldset>
  34814. </form>
  34815. `;
  34816. });
  34817. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/form.js
  34818. class MUCBookmarkForm extends CustomElement {
  34819. static get properties() {
  34820. return {
  34821. 'jid': {
  34822. type: String
  34823. }
  34824. };
  34825. }
  34826. connectedCallback() {
  34827. super.connectedCallback();
  34828. this.model = shared_converse.chatboxes.get(this.jid);
  34829. this.bookmark = shared_converse.bookmarks.get(this.model.get('jid'));
  34830. }
  34831. render() {
  34832. return templates_form(Object.assign(this.model.toJSON(), {
  34833. 'bookmark': this.bookmark,
  34834. 'onCancel': ev => this.removeBookmark(ev),
  34835. 'onSubmit': ev => this.onBookmarkFormSubmitted(ev)
  34836. }));
  34837. }
  34838. onBookmarkFormSubmitted(ev) {
  34839. var _ev$target$querySelec, _ev$target$querySelec2, _ev$target$querySelec3;
  34840. ev.preventDefault();
  34841. shared_converse.bookmarks.createBookmark({
  34842. 'jid': this.model.get('jid'),
  34843. 'autojoin': ((_ev$target$querySelec = ev.target.querySelector('input[name="autojoin"]')) === null || _ev$target$querySelec === void 0 ? void 0 : _ev$target$querySelec.checked) || false,
  34844. 'name': (_ev$target$querySelec2 = ev.target.querySelector('input[name=name]')) === null || _ev$target$querySelec2 === void 0 ? void 0 : _ev$target$querySelec2.value,
  34845. 'nick': (_ev$target$querySelec3 = ev.target.querySelector('input[name=nick]')) === null || _ev$target$querySelec3 === void 0 ? void 0 : _ev$target$querySelec3.value
  34846. });
  34847. this.closeBookmarkForm(ev);
  34848. }
  34849. removeBookmark(ev) {
  34850. var _this$bookmark;
  34851. (_this$bookmark = this.bookmark) === null || _this$bookmark === void 0 ? void 0 : _this$bookmark.destroy();
  34852. this.closeBookmarkForm(ev);
  34853. }
  34854. closeBookmarkForm(ev) {
  34855. ev.preventDefault();
  34856. const evt = document.createEvent('Event');
  34857. evt.initEvent('hide.bs.modal', true, true);
  34858. this.dispatchEvent(evt);
  34859. }
  34860. }
  34861. core_api.elements.define('converse-muc-bookmark-form', MUCBookmarkForm);
  34862. /* harmony default export */ const bookmark_views_form = (MUCBookmarkForm);
  34863. // EXTERNAL MODULE: ./node_modules/bootstrap.native/dist/bootstrap-native.js
  34864. var bootstrap_native = __webpack_require__(6151);
  34865. var bootstrap_native_default = /*#__PURE__*/__webpack_require__.n(bootstrap_native);
  34866. ;// CONCATENATED MODULE: ./src/templates/alert.js
  34867. /* harmony default export */ const templates_alert = (o => $`<div class="alert ${o.type}" role="alert"><p>${o.message}</p></div>`);
  34868. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/view.js
  34869. // Backbone.js 1.4.0
  34870. // (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
  34871. // Backbone may be freely distributed under the MIT license.
  34872. // View
  34873. // ----
  34874. // Views are almost more convention than they are actual code. A View
  34875. // is simply a JavaScript object that represents a logical chunk of UI in the
  34876. // DOM. This might be a single item, an entire list, a sidebar or panel, or
  34877. // even the surrounding frame which wraps your whole app. Defining a chunk of
  34878. // UI as a **View** allows you to define your DOM events declaratively, without
  34879. // having to worry about render order ... and makes it easy for the view to
  34880. // react to specific changes in the state of your models.
  34881. const paddedLt = /^\s*</; // Caches a local reference to `Element.prototype` for faster access.
  34882. const ElementProto = typeof Element !== 'undefined' && Element.prototype || {};
  34883. const view_indexOf = function (array, item) {
  34884. for (let i = 0, len = array.length; i < len; i++) if (array[i] === item) return i;
  34885. return -1;
  34886. }; // Creating a View creates its initial element outside of the DOM,
  34887. // if an existing element is not provided...
  34888. const View = function (options) {
  34889. this.cid = lodash_es_uniqueId('view');
  34890. this._domEvents = [];
  34891. this.preinitialize.apply(this, arguments);
  34892. lodash_es_assignIn(this, lodash_es_pick(options, viewOptions));
  34893. this._ensureElement();
  34894. this.initialize.apply(this, arguments);
  34895. };
  34896. View.extend = inherits; // Cached regex to split keys for `delegate`.
  34897. const delegateEventSplitter = /^(\S+)\s*(.*)$/; // List of view options to be set as properties.
  34898. const viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; // Set up all inheritable **View** properties and methods.
  34899. Object.assign(View.prototype, Events, {
  34900. // The default `tagName` of a View's element is `"div"`.
  34901. tagName: 'div',
  34902. $: function (selector) {
  34903. return this.el.querySelectorAll(selector);
  34904. },
  34905. // preinitialize is an empty function by default. You can override it with a function
  34906. // or object. preinitialize will run before any instantiation logic is run in the View
  34907. preinitialize: function () {},
  34908. // Initialize is an empty function by default. Override it with your own
  34909. // initialization logic.
  34910. initialize: function () {},
  34911. // **render** is the core function that your view should override, in order
  34912. // to populate its element (`this.el`), with the appropriate HTML. The
  34913. // convention is for **render** to always return `this`.
  34914. render: function () {
  34915. lodash_es_isFunction(this.beforeRender) && this.beforeRender();
  34916. lodash_es_isFunction(this.toHTML) && x(this.toHTML(), this.el);
  34917. lodash_es_isFunction(this.afterRender) && this.afterRender();
  34918. return this;
  34919. },
  34920. // Remove this view by taking the element out of the DOM, and removing any
  34921. // applicable Backbone.Events listeners.
  34922. remove: function () {
  34923. this._removeElement();
  34924. this.stopListening();
  34925. return this;
  34926. },
  34927. // Remove this view's element from the document and all event listeners
  34928. // attached to it. Exposed for subclasses using an alternative DOM
  34929. // manipulation API.
  34930. _removeElement: function () {
  34931. this.undelegateEvents();
  34932. if (this.el.parentNode) this.el.parentNode.removeChild(this.el);
  34933. },
  34934. // Change the view's element (`this.el` property) and re-delegate the
  34935. // view's events on the new element.
  34936. setElement: function (element) {
  34937. this.undelegateEvents();
  34938. this._setElement(element);
  34939. this.delegateEvents();
  34940. return this;
  34941. },
  34942. // Apply the `element` to the view. `element` can be a CSS selector,
  34943. // a string of HTML, or an Element node. If passed a NodeList or CSS
  34944. // selector, uses just the first match.
  34945. _setElement: function (element) {
  34946. if (typeof element == 'string') {
  34947. if (paddedLt.test(element)) {
  34948. const el = document.createElement('div');
  34949. el.innerHTML = element;
  34950. this.el = el.firstChild;
  34951. } else {
  34952. this.el = document.querySelector(element);
  34953. }
  34954. } else if (element && !lodash_es_isElement(element) && element.length) {
  34955. this.el = element[0];
  34956. } else {
  34957. this.el = element;
  34958. }
  34959. },
  34960. // Set callbacks, where `this.events` is a hash of
  34961. //
  34962. // *{"event selector": "callback"}*
  34963. //
  34964. // {
  34965. // 'mousedown .title': 'edit',
  34966. // 'click .button': 'save',
  34967. // 'click .open': function(e) { ... }
  34968. // }
  34969. //
  34970. // pairs. Callbacks will be bound to the view, with `this` set properly.
  34971. // Uses event delegation for efficiency.
  34972. // Omitting the selector binds the event to `this.el`.
  34973. delegateEvents: function (events) {
  34974. events || (events = lodash_es_result(this, 'events'));
  34975. if (!events) return this;
  34976. this.undelegateEvents();
  34977. for (const key in events) {
  34978. let method = events[key];
  34979. if (!lodash_es_isFunction(method)) method = this[method];
  34980. if (!method) continue;
  34981. const match = key.match(delegateEventSplitter);
  34982. this.delegate(match[1], match[2], method.bind(this));
  34983. }
  34984. return this;
  34985. },
  34986. // Make a event delegation handler for the given `eventName` and `selector`
  34987. // and attach it to `this.el`.
  34988. // If selector is empty, the listener will be bound to `this.el`. If not, a
  34989. // new handler that will recursively traverse up the event target's DOM
  34990. // hierarchy looking for a node that matches the selector. If one is found,
  34991. // the event's `delegateTarget` property is set to it and the return the
  34992. // result of calling bound `listener` with the parameters given to the
  34993. // handler.
  34994. delegate: function (eventName, selector, listener) {
  34995. const root = this.el;
  34996. if (!root) {
  34997. return this;
  34998. }
  34999. if (typeof selector === 'function') {
  35000. listener = selector;
  35001. selector = null;
  35002. } // Given that `focus` and `blur` events do not bubble, do not delegate these events
  35003. if (['focus', 'blur'].indexOf(eventName) !== -1) {
  35004. const els = this.el.querySelectorAll(selector);
  35005. for (let i = 0, len = els.length; i < len; i++) {
  35006. const item = els[i];
  35007. item.addEventListener(eventName, listener, false);
  35008. this._domEvents.push({
  35009. el: item,
  35010. eventName: eventName,
  35011. handler: listener
  35012. });
  35013. }
  35014. return listener;
  35015. }
  35016. const handler = selector ? function (e) {
  35017. let node = e.target || e.srcElement;
  35018. for (; node && node != root; node = node.parentNode) {
  35019. if (node.matches(selector)) {
  35020. e.delegateTarget = node;
  35021. listener(e);
  35022. }
  35023. }
  35024. } : listener;
  35025. this.el.addEventListener(eventName, handler, false);
  35026. this._domEvents.push({
  35027. el: this.el,
  35028. eventName: eventName,
  35029. handler: handler,
  35030. listener: listener,
  35031. selector: selector
  35032. });
  35033. return this;
  35034. },
  35035. // Clears all callbacks previously bound to the view by `delegateEvents`.
  35036. // You usually don't need to use this, but may wish to if you have multiple
  35037. // Backbone views attached to the same DOM element.
  35038. undelegateEvents: function () {
  35039. if (this.el) {
  35040. for (let i = 0, len = this._domEvents.length; i < len; i++) {
  35041. const item = this._domEvents[i];
  35042. item.el.removeEventListener(item.eventName, item.handler, false);
  35043. }
  35044. this._domEvents.length = 0;
  35045. }
  35046. return this;
  35047. },
  35048. // A finer-grained `undelegateEvents` for removing a single delegated event.
  35049. // `selector` and `listener` are both optional.
  35050. undelegate: function (eventName, selector, listener) {
  35051. if (typeof selector === 'function') {
  35052. listener = selector;
  35053. selector = null;
  35054. }
  35055. if (this.el) {
  35056. const handlers = this._domEvents.slice();
  35057. let i = handlers.length;
  35058. while (i--) {
  35059. const item = handlers[i];
  35060. const match = item.eventName === eventName && (listener ? item.listener === listener : true) && (selector ? item.selector === selector : true);
  35061. if (!match) {
  35062. continue;
  35063. }
  35064. item.el.removeEventListener(item.eventName, item.handler, false);
  35065. this._domEvents.splice(i, 1);
  35066. }
  35067. }
  35068. return this;
  35069. },
  35070. // Produces a DOM element to be assigned to your view. Exposed for
  35071. // subclasses using an alternative DOM manipulation API.
  35072. _createElement: function (tagName) {
  35073. return document.createElement(tagName);
  35074. },
  35075. // Ensure that the View has a DOM element to render into.
  35076. // If `this.el` is a string, pass it through `$()`, take the first
  35077. // matching element, and re-assign it to `el`. Otherwise, create
  35078. // an element from the `id`, `className` and `tagName` properties.
  35079. _ensureElement: function () {
  35080. if (!this.el) {
  35081. const attrs = lodash_es_assignIn({}, lodash_es_result(this, 'attributes'));
  35082. if (this.id) attrs.id = lodash_es_result(this, 'id');
  35083. if (this.className) attrs['class'] = lodash_es_result(this, 'className');
  35084. this.setElement(this._createElement(lodash_es_result(this, 'tagName')));
  35085. this._setAttributes(attrs);
  35086. } else {
  35087. this.setElement(lodash_es_result(this, 'el'));
  35088. }
  35089. },
  35090. // Set attributes from a hash on this view's element. Exposed for
  35091. // subclasses using an alternative DOM manipulation API.
  35092. _setAttributes: function (attrs) {
  35093. for (const attr in attrs) {
  35094. attr in this.el ? this.el[attr] = attrs[attr] : this.el.setAttribute(attr, attrs[attr]);
  35095. }
  35096. }
  35097. });
  35098. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/modal/styles/_modal.scss
  35099. var _modal = __webpack_require__(1638);
  35100. ;// CONCATENATED MODULE: ./src/plugins/modal/styles/_modal.scss
  35101. var _modal_options = {};
  35102. _modal_options.styleTagTransform = (styleTagTransform_default());
  35103. _modal_options.setAttributes = (setAttributesWithoutAttributes_default());
  35104. _modal_options.insert = insertBySelector_default().bind(null, "head");
  35105. _modal_options.domAPI = (styleDomAPI_default());
  35106. _modal_options.insertStyleElement = (insertStyleElement_default());
  35107. var _modal_update = injectStylesIntoStyleTag_default()(_modal/* default */.Z, _modal_options);
  35108. /* harmony default export */ const styles_modal = (_modal/* default */.Z && _modal/* default.locals */.Z.locals ? _modal/* default.locals */.Z.locals : undefined);
  35109. ;// CONCATENATED MODULE: ./src/plugins/modal/base.js
  35110. const {
  35111. sizzle: base_sizzle
  35112. } = core_converse.env;
  35113. const base_u = core_converse.env.utils;
  35114. const BaseModal = View.extend({
  35115. className: "modal",
  35116. persistent: false,
  35117. // Whether this modal should persist in the DOM once it's been closed
  35118. events: {
  35119. 'click .nav-item .nav-link': 'switchTab'
  35120. },
  35121. initialize(options) {
  35122. if (!this.id) {
  35123. throw new Error("Each modal class must have a unique id attribute");
  35124. } // Allow properties to be set via passed in options
  35125. Object.assign(this, options);
  35126. this.render();
  35127. this.el.setAttribute('tabindex', '-1');
  35128. this.el.setAttribute('role', 'dialog');
  35129. this.el.setAttribute('aria-hidden', 'true');
  35130. const label_id = this.el.querySelector('.modal-title').getAttribute('id');
  35131. label_id && this.el.setAttribute('aria-labelledby', label_id);
  35132. this.insertIntoDOM();
  35133. const Modal = (bootstrap_native_default()).Modal;
  35134. this.modal = new Modal(this.el, {
  35135. backdrop: true,
  35136. keyboard: true
  35137. });
  35138. this.el.addEventListener('hide.bs.modal', () => this.onHide(), false);
  35139. },
  35140. onHide() {
  35141. base_u.removeClass('selected', this.trigger_el);
  35142. !this.persistent && core_api.modal.remove(this);
  35143. },
  35144. insertIntoDOM() {
  35145. const container_el = document.querySelector("#converse-modals");
  35146. container_el.insertAdjacentElement('beforeEnd', this.el);
  35147. },
  35148. switchTab(ev) {
  35149. ev.stopPropagation();
  35150. ev.preventDefault();
  35151. base_sizzle('.nav-link.active', this.el).forEach(el => {
  35152. base_u.removeClass('active', this.el.querySelector(el.getAttribute('href')));
  35153. base_u.removeClass('active', el);
  35154. });
  35155. base_u.addClass('active', ev.target);
  35156. base_u.addClass('active', this.el.querySelector(ev.target.getAttribute('href')));
  35157. },
  35158. alert(message) {
  35159. let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'primary';
  35160. const body = this.el.querySelector('.modal-alert');
  35161. if (body === null) {
  35162. headless_log.error("Could not find a .modal-alert element in the modal to show an alert message in!");
  35163. return;
  35164. } // FIXME: Instead of adding the alert imperatively, we should
  35165. // find a way to let the modal rerender with an alert message
  35166. x(templates_alert({
  35167. 'type': `alert-${type}`,
  35168. 'message': message
  35169. }), body);
  35170. const el = body.firstElementChild;
  35171. setTimeout(() => {
  35172. base_u.addClass('fade-out', el);
  35173. setTimeout(() => base_u.removeElement(el), 600);
  35174. }, 5000);
  35175. },
  35176. show(ev) {
  35177. if (ev) {
  35178. ev.preventDefault();
  35179. this.trigger_el = ev.target;
  35180. !base_u.hasClass('chat-image', this.trigger_el) && base_u.addClass('selected', this.trigger_el);
  35181. }
  35182. this.modal.show();
  35183. }
  35184. });
  35185. /* harmony default export */ const base = (BaseModal);
  35186. ;// CONCATENATED MODULE: ./src/plugins/modal/templates/buttons.js
  35187. const modal_close_button = $`<button type="button" class="btn btn-secondary" data-dismiss="modal">${__('Close')}</button>`;
  35188. const modal_header_close_button = $`<button type="button" class="close" data-dismiss="modal" aria-label="${__('Close')}"><span aria-hidden="true">×</span></button>`;
  35189. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/templates/modal.js
  35190. /* harmony default export */ const modal = (o => {
  35191. const i18n_moderator_tools = __('Bookmark');
  35192. return $`
  35193. <div class="modal-dialog" role="document">
  35194. <div class="modal-content">
  35195. <div class="modal-header">
  35196. <h5 class="modal-title" id="converse-modtools-modal-label">${i18n_moderator_tools}</h5>
  35197. ${modal_header_close_button}
  35198. </div>
  35199. <div class="modal-body d-flex flex-column">
  35200. <converse-muc-bookmark-form class="muc-form-container" jid="${o.jid}"></converse-muc-bookmark-form>
  35201. </div>
  35202. </div>
  35203. </div>`;
  35204. });
  35205. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/modal.js
  35206. const MUCBookmarkFormModal = base.extend({
  35207. id: "converse-bookmark-modal",
  35208. initialize(attrs) {
  35209. this.jid = attrs.jid;
  35210. this.affiliation = attrs.affiliation;
  35211. base.prototype.initialize.apply(this, arguments);
  35212. },
  35213. toHTML() {
  35214. return modal(this);
  35215. }
  35216. });
  35217. /* harmony default export */ const bookmark_views_modal = (MUCBookmarkFormModal);
  35218. ;// CONCATENATED MODULE: ./node_modules/lodash-es/invokeMap.js
  35219. /**
  35220. * Invokes the method at `path` of each element in `collection`, returning
  35221. * an array of the results of each invoked method. Any additional arguments
  35222. * are provided to each invoked method. If `path` is a function, it's invoked
  35223. * for, and `this` bound to, each element in `collection`.
  35224. *
  35225. * @static
  35226. * @memberOf _
  35227. * @since 4.0.0
  35228. * @category Collection
  35229. * @param {Array|Object} collection The collection to iterate over.
  35230. * @param {Array|Function|string} path The path of the method to invoke or
  35231. * the function invoked per iteration.
  35232. * @param {...*} [args] The arguments to invoke each method with.
  35233. * @returns {Array} Returns the array of results.
  35234. * @example
  35235. *
  35236. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  35237. * // => [[1, 5, 7], [1, 2, 3]]
  35238. *
  35239. * _.invokeMap([123, 456], String.prototype.split, '');
  35240. * // => [['1', '2', '3'], ['4', '5', '6']]
  35241. */
  35242. var invokeMap = _baseRest(function(collection, path, args) {
  35243. var index = -1,
  35244. isFunc = typeof path == 'function',
  35245. result = lodash_es_isArrayLike(collection) ? Array(collection.length) : [];
  35246. _baseEach(collection, function(value) {
  35247. result[++index] = isFunc ? _apply(path, value, args) : _baseInvoke(value, path, args);
  35248. });
  35249. return result;
  35250. });
  35251. /* harmony default export */ const lodash_es_invokeMap = (invokeMap);
  35252. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/utils.js
  35253. function getHeadingButtons(view, buttons) {
  35254. if (core_api.settings.get('allow_bookmarks') && view.model.get('type') === shared_converse.CHATROOMS_TYPE) {
  35255. const bookmarked = view.model.get('bookmarked');
  35256. const data = {
  35257. 'i18n_title': bookmarked ? __('Unbookmark this groupchat') : __('Bookmark this groupchat'),
  35258. 'i18n_text': bookmarked ? __('Unbookmark') : __('Bookmark'),
  35259. 'handler': ev => view.showBookmarkModal(ev),
  35260. 'a_class': 'toggle-bookmark',
  35261. 'icon_class': 'fa-bookmark',
  35262. 'name': 'bookmark'
  35263. };
  35264. const names = buttons.map(t => t.name);
  35265. const idx = names.indexOf('details');
  35266. const data_promise = checkBookmarksSupport().then(s => s ? data : null);
  35267. return idx > -1 ? [...buttons.slice(0, idx), data_promise, ...buttons.slice(idx)] : [data_promise, ...buttons];
  35268. }
  35269. return buttons;
  35270. }
  35271. function removeBookmarkViaEvent(ev) {
  35272. ev.preventDefault();
  35273. const name = ev.target.getAttribute('data-bookmark-name');
  35274. const jid = ev.target.getAttribute('data-room-jid');
  35275. if (confirm(__('Are you sure you want to remove the bookmark "%1$s"?', name))) {
  35276. lodash_es_invokeMap(shared_converse.bookmarks.where({
  35277. jid
  35278. }), Model.prototype.destroy);
  35279. }
  35280. }
  35281. function addBookmarkViaEvent(ev) {
  35282. ev.preventDefault();
  35283. const jid = ev.target.getAttribute('data-room-jid');
  35284. core_api.modal.show(bookmark_views_modal, {
  35285. jid
  35286. }, ev);
  35287. }
  35288. function openRoomViaEvent(ev) {
  35289. ev.preventDefault();
  35290. const {
  35291. Strophe
  35292. } = core_converse.env;
  35293. const name = ev.target.textContent;
  35294. const jid = ev.target.getAttribute('data-room-jid');
  35295. const data = {
  35296. 'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)) || jid
  35297. };
  35298. core_api.rooms.open(jid, data, true);
  35299. }
  35300. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/templates/item.js
  35301. /* harmony default export */ const item = (bm => {
  35302. const jid = bm.get('jid');
  35303. const is_hidden = !!(core_api.settings.get('hide_open_bookmarks') && shared_converse.chatboxes.get(jid));
  35304. const info_remove_bookmark = __('Unbookmark this groupchat');
  35305. const open_title = __('Click to open this groupchat');
  35306. return $`
  35307. <div class="list-item controlbox-padded room-item available-chatroom d-flex flex-row ${is_hidden ? 'hidden' : ''}" data-room-jid="${jid}">
  35308. <a class="list-item-link open-room w-100" data-room-jid="${jid}"
  35309. title="${open_title}"
  35310. @click=${openRoomViaEvent}>${bm.getDisplayName()}</a>
  35311. <a class="list-item-action remove-bookmark fa fa-bookmark align-self-center ${bm.get('bookmarked') ? 'button-on' : ''}"
  35312. data-room-jid="${jid}"
  35313. data-bookmark-name="${bm.getDisplayName()}"
  35314. title="${info_remove_bookmark}"
  35315. @click=${removeBookmarkViaEvent}></a>
  35316. </div>
  35317. `;
  35318. });
  35319. ;// CONCATENATED MODULE: ./node_modules/lit-html/directive.js
  35320. /**
  35321. * @license
  35322. * Copyright 2017 Google LLC
  35323. * SPDX-License-Identifier: BSD-3-Clause
  35324. */
  35325. const directive_t = {
  35326. ATTRIBUTE: 1,
  35327. CHILD: 2,
  35328. PROPERTY: 3,
  35329. BOOLEAN_ATTRIBUTE: 4,
  35330. EVENT: 5,
  35331. ELEMENT: 6
  35332. },
  35333. directive_e = t => function () {
  35334. for (var _len = arguments.length, e = new Array(_len), _key = 0; _key < _len; _key++) {
  35335. e[_key] = arguments[_key];
  35336. }
  35337. return {
  35338. _$litDirective$: t,
  35339. values: e
  35340. };
  35341. };
  35342. class directive_i {
  35343. constructor(t) {}
  35344. get _$AU() {
  35345. return this._$AM._$AU;
  35346. }
  35347. _$AT(t, e, i) {
  35348. this._$Ct = t, this._$AM = e, this._$Ci = i;
  35349. }
  35350. _$AS(t, e) {
  35351. return this.update(t, e);
  35352. }
  35353. update(t, e) {
  35354. return this.render(...e);
  35355. }
  35356. }
  35357. ;// CONCATENATED MODULE: ./node_modules/lit-html/directive-helpers.js
  35358. /**
  35359. * @license
  35360. * Copyright 2020 Google LLC
  35361. * SPDX-License-Identifier: BSD-3-Clause
  35362. */
  35363. const {
  35364. H: directive_helpers_i
  35365. } = R,
  35366. directive_helpers_t = o => null === o || "object" != typeof o && "function" != typeof o,
  35367. directive_helpers_n = {
  35368. HTML: 1,
  35369. SVG: 2
  35370. },
  35371. directive_helpers_v = (o, i) => {
  35372. var t, n;
  35373. return void 0 === i ? void 0 !== (null === (t = o) || void 0 === t ? void 0 : t._$litType$) : (null === (n = o) || void 0 === n ? void 0 : n._$litType$) === i;
  35374. },
  35375. directive_helpers_l = o => {
  35376. var i;
  35377. return void 0 !== (null === (i = o) || void 0 === i ? void 0 : i._$litDirective$);
  35378. },
  35379. directive_helpers_d = o => {
  35380. var i;
  35381. return null === (i = o) || void 0 === i ? void 0 : i._$litDirective$;
  35382. },
  35383. directive_helpers_r = o => void 0 === o.strings,
  35384. directive_helpers_e = () => document.createComment(""),
  35385. directive_helpers_u = (o, t, n) => {
  35386. var v;
  35387. const l = o._$AA.parentNode,
  35388. d = void 0 === t ? o._$AB : t._$AA;
  35389. if (void 0 === n) {
  35390. const t = l.insertBefore(directive_helpers_e(), d),
  35391. v = l.insertBefore(directive_helpers_e(), d);
  35392. n = new directive_helpers_i(t, v, o, o.options);
  35393. } else {
  35394. const i = n._$AB.nextSibling,
  35395. t = n._$AM,
  35396. r = t !== o;
  35397. if (r) {
  35398. let i;
  35399. null === (v = n._$AQ) || void 0 === v || v.call(n, o), n._$AM = o, void 0 !== n._$AP && (i = o._$AU) !== t._$AU && n._$AP(i);
  35400. }
  35401. if (i !== d || r) {
  35402. let o = n._$AA;
  35403. for (; o !== i;) {
  35404. const i = o.nextSibling;
  35405. l.insertBefore(o, d), o = i;
  35406. }
  35407. }
  35408. }
  35409. return n;
  35410. },
  35411. directive_helpers_c = function (o, i) {
  35412. let t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : o;
  35413. return o._$AI(i, t), o;
  35414. },
  35415. directive_helpers_f = {},
  35416. directive_helpers_s = function (o) {
  35417. let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : directive_helpers_f;
  35418. return o._$AH = i;
  35419. },
  35420. directive_helpers_a = o => o._$AH,
  35421. directive_helpers_m = o => {
  35422. var i;
  35423. null === (i = o._$AP) || void 0 === i || i.call(o, !1, !0);
  35424. let t = o._$AA;
  35425. const n = o._$AB.nextSibling;
  35426. for (; t !== n;) {
  35427. const o = t.nextSibling;
  35428. t.remove(), t = o;
  35429. }
  35430. },
  35431. directive_helpers_p = o => {
  35432. o._$AR();
  35433. };
  35434. ;// CONCATENATED MODULE: ./node_modules/lit-html/async-directive.js
  35435. /**
  35436. * @license
  35437. * Copyright 2017 Google LLC
  35438. * SPDX-License-Identifier: BSD-3-Clause
  35439. */
  35440. const async_directive_e = (i, t) => {
  35441. var s, o;
  35442. const n = i._$AN;
  35443. if (void 0 === n) return !1;
  35444. for (const i of n) null === (o = (s = i)._$AO) || void 0 === o || o.call(s, t, !1), async_directive_e(i, t);
  35445. return !0;
  35446. },
  35447. async_directive_o = i => {
  35448. let t, s;
  35449. do {
  35450. if (void 0 === (t = i._$AM)) break;
  35451. s = t._$AN, s.delete(i), i = t;
  35452. } while (0 === (null == s ? void 0 : s.size));
  35453. },
  35454. async_directive_n = i => {
  35455. for (let t; t = i._$AM; i = t) {
  35456. let s = t._$AN;
  35457. if (void 0 === s) t._$AN = s = new Set();else if (s.has(i)) break;
  35458. s.add(i), async_directive_l(t);
  35459. }
  35460. };
  35461. function async_directive_r(i) {
  35462. void 0 !== this._$AN ? (async_directive_o(this), this._$AM = i, async_directive_n(this)) : this._$AM = i;
  35463. }
  35464. function async_directive_h(i) {
  35465. let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  35466. let s = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  35467. const n = this._$AH,
  35468. r = this._$AN;
  35469. if (void 0 !== r && 0 !== r.size) if (t) {
  35470. if (Array.isArray(n)) for (let i = s; i < n.length; i++) async_directive_e(n[i], !1), async_directive_o(n[i]);else null != n && (async_directive_e(n, !1), async_directive_o(n));
  35471. } else async_directive_e(this, i);
  35472. }
  35473. const async_directive_l = i => {
  35474. var t, e, o, n;
  35475. i.type == directive_t.CHILD && (null !== (t = (o = i)._$AP) && void 0 !== t || (o._$AP = async_directive_h), null !== (e = (n = i)._$AQ) && void 0 !== e || (n._$AQ = async_directive_r));
  35476. };
  35477. class async_directive_d extends directive_i {
  35478. constructor() {
  35479. super(...arguments), this._$AN = void 0;
  35480. }
  35481. _$AT(i, t, s) {
  35482. super._$AT(i, t, s), async_directive_n(this), this.isConnected = i._$AU;
  35483. }
  35484. _$AO(i) {
  35485. let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
  35486. var s, n;
  35487. i !== this.isConnected && (this.isConnected = i, i ? null === (s = this.reconnected) || void 0 === s || s.call(this) : null === (n = this.disconnected) || void 0 === n || n.call(this)), t && (async_directive_e(this, i), async_directive_o(this));
  35488. }
  35489. setValue(t) {
  35490. if (directive_helpers_r(this._$Ct)) this._$Ct._$AI(t, this);else {
  35491. const i = [...this._$Ct._$AH];
  35492. i[this._$Ci] = t, this._$Ct._$AI(i, this, 0);
  35493. }
  35494. }
  35495. disconnected() {}
  35496. reconnected() {}
  35497. }
  35498. ;// CONCATENATED MODULE: ./node_modules/lit-html/directives/private-async-helpers.js
  35499. /**
  35500. * @license
  35501. * Copyright 2021 Google LLC
  35502. * SPDX-License-Identifier: BSD-3-Clause
  35503. */
  35504. const private_async_helpers_t = async (t, s) => {
  35505. for await (const i of t) if (!1 === (await s(i))) return;
  35506. };
  35507. class private_async_helpers_s {
  35508. constructor(t) {
  35509. this.U = t;
  35510. }
  35511. disconnect() {
  35512. this.U = void 0;
  35513. }
  35514. reconnect(t) {
  35515. this.U = t;
  35516. }
  35517. deref() {
  35518. return this.U;
  35519. }
  35520. }
  35521. class private_async_helpers_i {
  35522. constructor() {
  35523. this.Y = void 0, this.q = void 0;
  35524. }
  35525. get() {
  35526. return this.Y;
  35527. }
  35528. pause() {
  35529. var t;
  35530. null !== (t = this.Y) && void 0 !== t || (this.Y = new Promise(t => this.q = t));
  35531. }
  35532. resume() {
  35533. var t;
  35534. null === (t = this.q) || void 0 === t || t.call(this), this.Y = this.q = void 0;
  35535. }
  35536. }
  35537. ;// CONCATENATED MODULE: ./node_modules/lit-html/directives/until.js
  35538. /**
  35539. * @license
  35540. * Copyright 2017 Google LLC
  35541. * SPDX-License-Identifier: BSD-3-Clause
  35542. */
  35543. const until_n = t => !directive_helpers_t(t) && "function" == typeof t.then;
  35544. class until_h extends async_directive_d {
  35545. constructor() {
  35546. super(...arguments), this._$Cwt = 1073741823, this._$Cyt = [], this._$CG = new private_async_helpers_s(this), this._$CK = new private_async_helpers_i();
  35547. }
  35548. render() {
  35549. var i;
  35550. for (var _len = arguments.length, s = new Array(_len), _key = 0; _key < _len; _key++) {
  35551. s[_key] = arguments[_key];
  35552. }
  35553. return null !== (i = s.find(t => !until_n(t))) && void 0 !== i ? i : b;
  35554. }
  35555. update(s, i) {
  35556. const r = this._$Cyt;
  35557. let e = r.length;
  35558. this._$Cyt = i;
  35559. const o = this._$CG,
  35560. h = this._$CK;
  35561. this.isConnected || this.disconnected();
  35562. for (let t = 0; t < i.length && !(t > this._$Cwt); t++) {
  35563. const s = i[t];
  35564. if (!until_n(s)) return this._$Cwt = t, s;
  35565. t < e && s === r[t] || (this._$Cwt = 1073741823, e = 0, Promise.resolve(s).then(async t => {
  35566. for (; h.get();) await h.get();
  35567. const i = o.deref();
  35568. if (void 0 !== i) {
  35569. const r = i._$Cyt.indexOf(s);
  35570. r > -1 && r < i._$Cwt && (i._$Cwt = r, i.setValue(t));
  35571. }
  35572. }));
  35573. }
  35574. return b;
  35575. }
  35576. disconnected() {
  35577. this._$CG.disconnect(), this._$CK.pause();
  35578. }
  35579. reconnected() {
  35580. this._$CG.reconnect(this), this._$CK.resume();
  35581. }
  35582. }
  35583. const until_c = directive_e(until_h);
  35584. ;// CONCATENATED MODULE: ./node_modules/lit/directives/until.js
  35585. //# sourceMappingURL=until.js.map
  35586. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/templates/list.js
  35587. const list = (el, bookmarks) => {
  35588. const desc_bookmarks = __('Click to toggle the bookmarks list');
  35589. const label_bookmarks = __('Bookmarks');
  35590. const toggle_state = el.model.get('toggle-state');
  35591. return $`
  35592. <div class="list-container list-container--bookmarks ${bookmarks.length ? 'fade-in' : 'hidden'}">
  35593. <a class="list-toggle bookmarks-toggle controlbox-padded"
  35594. title="${desc_bookmarks}"
  35595. @click=${() => el.toggleBookmarksList()}>
  35596. <span class="fa ${toggle_state === shared_converse.OPENED ? 'fa-caret-down' : 'fa-caret-right'}">
  35597. </span> ${label_bookmarks}</a>
  35598. <div class="items-list bookmarks rooms-list ${toggle_state === shared_converse.OPENED ? 'fade-in' : 'hidden fade-out'}">
  35599. ${shared_converse.bookmarks.map(bm => item(bm))}
  35600. </div>
  35601. </div>
  35602. `;
  35603. };
  35604. /* harmony default export */ const templates_list = (el => {
  35605. const bookmarks = shared_converse.bookmarks.getUnopenedBookmarks();
  35606. return until_c(bookmarks.then(bookmarks => list(el, bookmarks)), '');
  35607. });
  35608. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/bookmarks-list.js
  35609. class BookmarksView extends CustomElement {
  35610. async initialize() {
  35611. await core_api.waitUntil('bookmarksInitialized');
  35612. const {
  35613. bookmarks,
  35614. chatboxes
  35615. } = shared_converse;
  35616. this.listenTo(bookmarks, 'add', () => this.requestUpdate());
  35617. this.listenTo(bookmarks, 'remove', () => this.requestUpdate());
  35618. this.listenTo(chatboxes, 'add', () => this.requestUpdate());
  35619. this.listenTo(chatboxes, 'remove', () => this.requestUpdate());
  35620. const id = `converse.bookmarks-list-model-${shared_converse.bare_jid}`;
  35621. this.model = new shared_converse.BookmarksList({
  35622. id
  35623. });
  35624. initStorage(this.model, id);
  35625. this.listenTo(this.model, 'change', () => this.requestUpdate());
  35626. this.model.fetch({
  35627. 'success': () => this.requestUpdate(),
  35628. 'error': () => this.requestUpdate()
  35629. });
  35630. }
  35631. render() {
  35632. return shared_converse.bookmarks && this.model ? templates_list(this) : '';
  35633. }
  35634. toggleBookmarksList(ev) {
  35635. var _ev$preventDefault;
  35636. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  35637. const {
  35638. CLOSED,
  35639. OPENED
  35640. } = shared_converse;
  35641. this.model.save({
  35642. 'toggle-state': this.model.get('toggle-state') === CLOSED ? OPENED : CLOSED
  35643. });
  35644. }
  35645. }
  35646. core_api.elements.define('converse-bookmarks', BookmarksView);
  35647. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/mixins.js
  35648. const {
  35649. u: mixins_u
  35650. } = core_converse.env;
  35651. const bookmarkableChatRoomView = {
  35652. /**
  35653. * Set whether the groupchat is bookmarked or not.
  35654. * @private
  35655. */
  35656. setBookmarkState() {
  35657. if (shared_converse.bookmarks !== undefined) {
  35658. const models = shared_converse.bookmarks.where({
  35659. 'jid': this.model.get('jid')
  35660. });
  35661. if (!models.length) {
  35662. this.model.save('bookmarked', false);
  35663. } else {
  35664. this.model.save('bookmarked', true);
  35665. }
  35666. }
  35667. },
  35668. renderBookmarkForm() {
  35669. if (!this.bookmark_form) {
  35670. this.bookmark_form = new shared_converse.MUCBookmarkForm({
  35671. 'model': this.model,
  35672. 'chatroomview': this
  35673. });
  35674. const container_el = this.querySelector('.chatroom-body');
  35675. container_el.insertAdjacentElement('beforeend', this.bookmark_form.el);
  35676. }
  35677. mixins_u.showElement(this.bookmark_form.el);
  35678. },
  35679. showBookmarkModal(ev) {
  35680. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  35681. const jid = this.model.get('jid');
  35682. core_api.modal.show(bookmark_views_modal, {
  35683. jid
  35684. }, ev);
  35685. }
  35686. };
  35687. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/bookmark-views/styles/bookmarks.scss
  35688. var bookmarks = __webpack_require__(5251);
  35689. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/styles/bookmarks.scss
  35690. var bookmarks_options = {};
  35691. bookmarks_options.styleTagTransform = (styleTagTransform_default());
  35692. bookmarks_options.setAttributes = (setAttributesWithoutAttributes_default());
  35693. bookmarks_options.insert = insertBySelector_default().bind(null, "head");
  35694. bookmarks_options.domAPI = (styleDomAPI_default());
  35695. bookmarks_options.insertStyleElement = (insertStyleElement_default());
  35696. var bookmarks_update = injectStylesIntoStyleTag_default()(bookmarks/* default */.Z, bookmarks_options);
  35697. /* harmony default export */ const styles_bookmarks = (bookmarks/* default */.Z && bookmarks/* default.locals */.Z.locals ? bookmarks/* default.locals */.Z.locals : undefined);
  35698. ;// CONCATENATED MODULE: ./src/plugins/bookmark-views/index.js
  35699. /**
  35700. * @description Converse.js plugin which adds views for XEP-0048 bookmarks
  35701. * @copyright 2022, the Converse.js contributors
  35702. * @license Mozilla Public License (MPLv2)
  35703. */
  35704. core_converse.plugins.add('converse-bookmark-views', {
  35705. /* Plugin dependencies are other plugins which might be
  35706. * overridden or relied upon, and therefore need to be loaded before
  35707. * this plugin.
  35708. *
  35709. * If the setting "strict_plugin_dependencies" is set to true,
  35710. * an error will be raised if the plugin is not found. By default it's
  35711. * false, which means these plugins are only loaded opportunistically.
  35712. */
  35713. dependencies: ['converse-chatboxes', 'converse-muc', 'converse-muc-views'],
  35714. initialize() {
  35715. // Configuration values for this plugin
  35716. // ====================================
  35717. // Refer to docs/source/configuration.rst for explanations of these
  35718. // configuration settings.
  35719. core_api.settings.extend({
  35720. hide_open_bookmarks: true
  35721. });
  35722. shared_converse.removeBookmarkViaEvent = removeBookmarkViaEvent;
  35723. shared_converse.addBookmarkViaEvent = addBookmarkViaEvent;
  35724. Object.assign(shared_converse.ChatRoomView.prototype, bookmarkableChatRoomView);
  35725. shared_converse.MUCBookmarkForm = bookmark_views_form;
  35726. shared_converse.BookmarksView = BookmarksView;
  35727. core_api.listen.on('getHeadingButtons', getHeadingButtons);
  35728. core_api.listen.on('chatRoomViewInitialized', view => view.setBookmarkState());
  35729. }
  35730. });
  35731. ;// CONCATENATED MODULE: ./src/templates/background_logo.js
  35732. /* harmony default export */ const background_logo = (() => $`
  35733. <div class="inner-content converse-brand row">
  35734. <div class="converse-brand__padding"></div>
  35735. <div class="converse-brand__heading">
  35736. <svg height="200px"
  35737. xmlns="http://www.w3.org/2000/svg"
  35738. xmlns:xlink="http://www.w3.org/1999/xlink"
  35739. viewBox="0 0 364 364"
  35740. version="1.1">
  35741. <title>Logo Converse</title>
  35742. <defs>
  35743. <linearGradient id="gradient" x1="92.14" y1="27.64" x2="267.65" y2="331.62" gradientUnits="userSpaceOnUse">
  35744. <stop offset="0" stop-color="#fff1d1"/>
  35745. <stop offset="0.05" stop-color="#fae8c1"/>
  35746. <stop offset="0.15" stop-color="#f0d5a1"/>
  35747. <stop offset="0.27" stop-color="#e7c687"/>
  35748. <stop offset="0.4" stop-color="#e1bb72"/>
  35749. <stop offset="0.54" stop-color="#dcb264"/>
  35750. <stop offset="0.71" stop-color="#daad5c"/>
  35751. <stop offset="1" stop-color="#d9ac59"/>
  35752. </linearGradient>
  35753. <filter id="shadow">
  35754. <feGaussianBlur in="SourceAlpha" stdDeviation="2.3" result="blur1"/>
  35755. <feOffset in="blur1" dx="3" dy="3" result="blur2"/>
  35756. <feColorMatrix in="blur2" type="matrix" result="blur3"
  35757. values="1 0 0 0 0.1
  35758. 0 1 0 0 0.1
  35759. 0 0 1 0 0.1
  35760. 0 0 0 1 0"/>
  35761. <feMerge>
  35762. <feMergeNode in="blur3"/>
  35763. <feMergeNode in="SourceGraphic"/>
  35764. </feMerge>
  35765. </filter>
  35766. </defs>
  35767. <g filter="url(#shadow)">
  35768. <path d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" fill="#d9ac59"/>
  35769. <path d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" fill="url(#gradient)"/>
  35770. </g>
  35771. </svg>
  35772. <span class="converse-brand__text">
  35773. <span>converse<span class="subdued">.js</span></span>
  35774. <p class="byline">messaging freedom</p>
  35775. </span>
  35776. </div>
  35777. ${core_api.settings.get('view_mode') === 'overlayed' ? $`<div class="converse-brand__padding"></div>` : ''}
  35778. </div>`);
  35779. ;// CONCATENATED MODULE: ./node_modules/lit-html/directives/repeat.js
  35780. /**
  35781. * @license
  35782. * Copyright 2017 Google LLC
  35783. * SPDX-License-Identifier: BSD-3-Clause
  35784. */
  35785. const repeat_u = (e, s, t) => {
  35786. const r = new Map();
  35787. for (let l = s; l <= t; l++) r.set(e[l], l);
  35788. return r;
  35789. },
  35790. repeat_c = directive_e(class extends directive_i {
  35791. constructor(e) {
  35792. if (super(e), e.type !== directive_t.CHILD) throw Error("repeat() can only be used in text expressions");
  35793. }
  35794. dt(e, s, t) {
  35795. let r;
  35796. void 0 === t ? t = s : void 0 !== s && (r = s);
  35797. const l = [],
  35798. o = [];
  35799. let i = 0;
  35800. for (const s of e) l[i] = r ? r(s, i) : i, o[i] = t(s, i), i++;
  35801. return {
  35802. values: o,
  35803. keys: l
  35804. };
  35805. }
  35806. render(e, s, t) {
  35807. return this.dt(e, s, t).values;
  35808. }
  35809. update(s, _ref) {
  35810. let [t, r, c] = _ref;
  35811. var d;
  35812. const a = directive_helpers_a(s),
  35813. {
  35814. values: p,
  35815. keys: v
  35816. } = this.dt(t, r, c);
  35817. if (!Array.isArray(a)) return this.ut = v, p;
  35818. const h = null !== (d = this.ut) && void 0 !== d ? d : this.ut = [],
  35819. m = [];
  35820. let y,
  35821. x,
  35822. j = 0,
  35823. k = a.length - 1,
  35824. w = 0,
  35825. A = p.length - 1;
  35826. for (; j <= k && w <= A;) if (null === a[j]) j++;else if (null === a[k]) k--;else if (h[j] === v[w]) m[w] = directive_helpers_c(a[j], p[w]), j++, w++;else if (h[k] === v[A]) m[A] = directive_helpers_c(a[k], p[A]), k--, A--;else if (h[j] === v[A]) m[A] = directive_helpers_c(a[j], p[A]), directive_helpers_u(s, m[A + 1], a[j]), j++, A--;else if (h[k] === v[w]) m[w] = directive_helpers_c(a[k], p[w]), directive_helpers_u(s, a[j], a[k]), k--, w++;else if (void 0 === y && (y = repeat_u(v, w, A), x = repeat_u(h, j, k)), y.has(h[j])) {
  35827. if (y.has(h[k])) {
  35828. const e = x.get(v[w]),
  35829. t = void 0 !== e ? a[e] : null;
  35830. if (null === t) {
  35831. const e = directive_helpers_u(s, a[j]);
  35832. directive_helpers_c(e, p[w]), m[w] = e;
  35833. } else m[w] = directive_helpers_c(t, p[w]), directive_helpers_u(s, a[j], t), a[e] = null;
  35834. w++;
  35835. } else directive_helpers_m(a[k]), k--;
  35836. } else directive_helpers_m(a[j]), j++;
  35837. for (; w <= A;) {
  35838. const e = directive_helpers_u(s, m[A + 1]);
  35839. directive_helpers_c(e, p[w]), m[w++] = e;
  35840. }
  35841. for (; j <= k;) {
  35842. const e = a[j++];
  35843. null !== e && directive_helpers_m(e);
  35844. }
  35845. return this.ut = v, directive_helpers_s(s, m), b;
  35846. }
  35847. });
  35848. ;// CONCATENATED MODULE: ./node_modules/lit/directives/repeat.js
  35849. //# sourceMappingURL=repeat.js.map
  35850. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/templates/chats.js
  35851. function shouldShowChat(c) {
  35852. const {
  35853. CONTROLBOX_TYPE
  35854. } = shared_converse;
  35855. const is_minimized = core_api.settings.get('view_mode') === 'overlayed' && c.get('minimized');
  35856. return c.get('type') === CONTROLBOX_TYPE || !(c.get('hidden') || is_minimized);
  35857. }
  35858. /* harmony default export */ const chats = (() => {
  35859. const {
  35860. chatboxes,
  35861. CONTROLBOX_TYPE,
  35862. CHATROOMS_TYPE,
  35863. HEADLINES_TYPE
  35864. } = shared_converse;
  35865. const view_mode = core_api.settings.get('view_mode');
  35866. const connection = shared_converse === null || shared_converse === void 0 ? void 0 : shared_converse.connection;
  35867. const logged_out = !(connection !== null && connection !== void 0 && connection.connected) || !(connection !== null && connection !== void 0 && connection.authenticated) || (connection === null || connection === void 0 ? void 0 : connection.disconnecting);
  35868. return $`
  35869. ${!logged_out && view_mode === 'overlayed' ? $`<converse-minimized-chats></converse-minimized-chats>` : ''}
  35870. ${repeat_c(chatboxes.filter(shouldShowChat), m => m.get('jid'), m => {
  35871. if (m.get('type') === CONTROLBOX_TYPE) {
  35872. return $`
  35873. ${view_mode === 'overlayed' ? $`<converse-controlbox-toggle class="${!m.get('closed') ? 'hidden' : ''}"></converse-controlbox-toggle>` : ''}
  35874. <converse-controlbox
  35875. id="controlbox"
  35876. class="chatbox ${view_mode === 'overlayed' && m.get('closed') ? 'hidden' : ''} ${logged_out ? 'logged-out' : ''}"
  35877. style="${m.get('width') ? `width: ${m.get('width')}` : ''}"></converse-controlbox>
  35878. `;
  35879. } else if (m.get('type') === CHATROOMS_TYPE) {
  35880. return $`
  35881. <converse-muc jid="${m.get('jid')}" class="chatbox chatroom"></converse-muc>
  35882. `;
  35883. } else if (m.get('type') === HEADLINES_TYPE) {
  35884. return $`
  35885. <converse-headlines jid="${m.get('jid')}" class="chatbox headlines"></converse-headlines>
  35886. `;
  35887. } else {
  35888. return $`
  35889. <converse-chat jid="${m.get('jid')}" class="chatbox"></converse-chat>
  35890. `;
  35891. }
  35892. })}
  35893. `;
  35894. });
  35895. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/view.js
  35896. class ConverseChats extends CustomElement {
  35897. initialize() {
  35898. this.model = shared_converse.chatboxes;
  35899. this.listenTo(this.model, 'add', () => this.requestUpdate());
  35900. this.listenTo(this.model, 'change:closed', () => this.requestUpdate());
  35901. this.listenTo(this.model, 'change:hidden', () => this.requestUpdate());
  35902. this.listenTo(this.model, 'change:jid', () => this.requestUpdate());
  35903. this.listenTo(this.model, 'change:minimized', () => this.requestUpdate());
  35904. this.listenTo(this.model, 'destroy', () => this.requestUpdate()); // Use listenTo instead of api.listen.to so that event handlers
  35905. // automatically get deregistered when the component is dismounted
  35906. this.listenTo(shared_converse, 'connected', () => this.requestUpdate());
  35907. this.listenTo(shared_converse, 'reconnected', () => this.requestUpdate());
  35908. this.listenTo(shared_converse, 'disconnected', () => this.requestUpdate());
  35909. const settings = getAppSettings();
  35910. this.listenTo(settings, 'change:view_mode', () => this.requestUpdate());
  35911. this.listenTo(settings, 'change:singleton', () => this.requestUpdate());
  35912. const bg = document.getElementById('conversejs-bg');
  35913. if (bg && !bg.innerHTML.trim()) {
  35914. x(background_logo(), bg);
  35915. }
  35916. const body = document.querySelector('body');
  35917. body.classList.add(`converse-${core_api.settings.get('view_mode')}`);
  35918. /**
  35919. * Triggered once the _converse.ChatBoxViews view-colleciton has been initialized
  35920. * @event _converse#chatBoxViewsInitialized
  35921. * @example _converse.api.listen.on('chatBoxViewsInitialized', () => { ... });
  35922. */
  35923. core_api.trigger('chatBoxViewsInitialized');
  35924. }
  35925. render() {
  35926. // eslint-disable-line class-methods-use-this
  35927. return chats();
  35928. }
  35929. }
  35930. core_api.elements.define('converse-chats', ConverseChats);
  35931. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/container.js
  35932. class ChatBoxViews {
  35933. constructor() {
  35934. this.views = {};
  35935. }
  35936. add(key, val) {
  35937. this.views[key] = val;
  35938. }
  35939. get(key) {
  35940. return this.views[key];
  35941. }
  35942. xget(id) {
  35943. return this.keys().filter(k => k !== id).reduce((acc, k) => {
  35944. acc[k] = this.views[k];
  35945. return acc;
  35946. }, {});
  35947. }
  35948. getAll() {
  35949. return Object.values(this.views);
  35950. }
  35951. keys() {
  35952. return Object.keys(this.views);
  35953. }
  35954. remove(key) {
  35955. delete this.views[key];
  35956. }
  35957. map(f) {
  35958. return Object.values(this.views).map(f);
  35959. }
  35960. forEach(f) {
  35961. return Object.values(this.views).forEach(f);
  35962. }
  35963. filter(f) {
  35964. return Object.values(this.views).filter(f);
  35965. }
  35966. closeAllChatBoxes() {
  35967. return Promise.all(Object.values(this.views).map(v => v.close({
  35968. 'name': 'closeAllChatBoxes'
  35969. })));
  35970. }
  35971. }
  35972. /* harmony default export */ const container = (ChatBoxViews);
  35973. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/utils.js
  35974. function calculateViewportHeightUnit() {
  35975. const vh = window.innerHeight * 0.01;
  35976. document.documentElement.style.setProperty('--vh', `${vh}px`);
  35977. }
  35978. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/chatboxviews/styles/chats.scss
  35979. var styles_chats = __webpack_require__(6931);
  35980. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/styles/chats.scss
  35981. var chats_options = {};
  35982. chats_options.styleTagTransform = (styleTagTransform_default());
  35983. chats_options.setAttributes = (setAttributesWithoutAttributes_default());
  35984. chats_options.insert = insertBySelector_default().bind(null, "head");
  35985. chats_options.domAPI = (styleDomAPI_default());
  35986. chats_options.insertStyleElement = (insertStyleElement_default());
  35987. var chats_update = injectStylesIntoStyleTag_default()(styles_chats/* default */.Z, chats_options);
  35988. /* harmony default export */ const chatboxviews_styles_chats = (styles_chats/* default */.Z && styles_chats/* default.locals */.Z.locals ? styles_chats/* default.locals */.Z.locals : undefined);
  35989. ;// CONCATENATED MODULE: ./src/plugins/chatboxviews/index.js
  35990. /**
  35991. * @module converse-chatboxviews
  35992. * @copyright 2022, the Converse.js contributors
  35993. * @license Mozilla Public License (MPLv2)
  35994. */
  35995. core_converse.plugins.add('converse-chatboxviews', {
  35996. dependencies: ['converse-chatboxes', 'converse-vcard'],
  35997. initialize() {
  35998. core_api.promises.add(['chatBoxViewsInitialized']); // Configuration values for this plugin
  35999. // ====================================
  36000. // Refer to docs/source/configuration.rst for explanations of these
  36001. // configuration settings.
  36002. core_api.settings.extend({
  36003. 'animate': true
  36004. });
  36005. shared_converse.chatboxviews = new container();
  36006. /************************ BEGIN Event Handlers ************************/
  36007. core_api.listen.on('chatBoxesInitialized', () => {
  36008. shared_converse.chatboxes.on('destroy', m => shared_converse.chatboxviews.remove(m.get('jid')));
  36009. });
  36010. core_api.listen.on('cleanup', () => delete shared_converse.chatboxviews);
  36011. core_api.listen.on('clearSession', () => shared_converse.chatboxviews.closeAllChatBoxes());
  36012. core_api.listen.on('chatBoxViewsInitialized', calculateViewportHeightUnit);
  36013. window.addEventListener('resize', calculateViewportHeightUnit);
  36014. /************************ END Event Handlers ************************/
  36015. Object.assign(core_converse, {
  36016. /**
  36017. * Public API method which will ensure that the #conversejs element
  36018. * is inserted into a container element.
  36019. *
  36020. * This method is useful when the #conversejs element has been
  36021. * detached from the DOM somehow.
  36022. * @async
  36023. * @memberOf converse
  36024. * @method insertInto
  36025. * @example
  36026. * converse.insertInto(document.querySelector('#converse-container'));
  36027. */
  36028. insertInto(container) {
  36029. var _converse$chatboxview;
  36030. const el = (_converse$chatboxview = shared_converse.chatboxviews) === null || _converse$chatboxview === void 0 ? void 0 : _converse$chatboxview.el;
  36031. if (el && !container.contains(el)) {
  36032. container.insertAdjacentElement('afterBegin', el);
  36033. } else if (!el) {
  36034. throw new Error('Cannot insert non-existing #conversejs element into the DOM');
  36035. }
  36036. }
  36037. });
  36038. }
  36039. });
  36040. ;// CONCATENATED MODULE: ./src/plugins/modal/templates/alert.js
  36041. /* harmony default export */ const modal_templates_alert = (o => $`
  36042. <div class="modal-dialog" role="document">
  36043. <div class="modal-content">
  36044. <div class="modal-header ${o.level}">
  36045. <h5 class="modal-title">${o.title}</h5>
  36046. ${modal_header_close_button}
  36047. </div>
  36048. <div class="modal-body">
  36049. <span class="modal-alert"></span>
  36050. ${o.messages.map(message => $`<p>${message}</p>`)}
  36051. </div>
  36052. </div>
  36053. </div>`);
  36054. ;// CONCATENATED MODULE: ./src/plugins/modal/alert.js
  36055. const Alert = base.extend({
  36056. id: 'alert-modal',
  36057. initialize() {
  36058. base.prototype.initialize.apply(this, arguments);
  36059. this.listenTo(this.model, 'change', this.render);
  36060. },
  36061. toHTML() {
  36062. return modal_templates_alert(Object.assign({
  36063. __: __
  36064. }, this.model.toJSON()));
  36065. }
  36066. });
  36067. /* harmony default export */ const modal_alert = (Alert);
  36068. ;// CONCATENATED MODULE: ./src/plugins/modal/templates/prompt.js
  36069. const tpl_field = f => $`
  36070. <div class="form-group">
  36071. <label>
  36072. ${f.label || ''}
  36073. <input type="text"
  36074. name="${f.name}"
  36075. class="${f.challenge_failed ? 'error' : ''} form-control form-control--labeled"
  36076. ?required="${f.required}"
  36077. placeholder="${f.placeholder}" />
  36078. </label>
  36079. </div>
  36080. `;
  36081. /* harmony default export */ const templates_prompt = (o => $`
  36082. <div class="modal-dialog" role="document">
  36083. <div class="modal-content">
  36084. <div class="modal-header ${o.level || ''}">
  36085. <h5 class="modal-title">${o.title}</h5>
  36086. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  36087. <span aria-hidden="true">×</span>
  36088. </button>
  36089. </div>
  36090. <div class="modal-body">
  36091. <span class="modal-alert"></span>
  36092. <form class="converse-form converse-form--modal confirm" action="#">
  36093. <div class="form-group">
  36094. ${o.messages.map(message => $`<p>${message}</p>`)}
  36095. </div>
  36096. ${o.fields.map(f => tpl_field(f))}
  36097. <div class="form-group">
  36098. <button type="submit" class="btn btn-primary">${__('OK')}</button>
  36099. <input type="button" class="btn btn-secondary" data-dismiss="modal" value="${__('Cancel')}"/>
  36100. </div>
  36101. </form>
  36102. </div>
  36103. </div>
  36104. </div>
  36105. `);
  36106. ;// CONCATENATED MODULE: ./src/plugins/modal/confirm.js
  36107. const Confirm = base.extend({
  36108. id: 'confirm-modal',
  36109. events: {
  36110. 'submit .confirm': 'onConfimation'
  36111. },
  36112. initialize() {
  36113. this.confirmation = getOpenPromise();
  36114. base.prototype.initialize.apply(this, arguments);
  36115. this.listenTo(this.model, 'change', this.render);
  36116. this.el.addEventListener('closed.bs.modal', () => this.confirmation.reject(), false);
  36117. },
  36118. toHTML() {
  36119. return templates_prompt(this.model.toJSON());
  36120. },
  36121. afterRender() {
  36122. if (!this.close_handler_registered) {
  36123. this.el.addEventListener('closed.bs.modal', () => {
  36124. if (!this.confirmation.isResolved) {
  36125. this.confirmation.reject();
  36126. }
  36127. }, false);
  36128. this.close_handler_registered = true;
  36129. }
  36130. },
  36131. onConfimation(ev) {
  36132. ev.preventDefault();
  36133. const form_data = new FormData(ev.target);
  36134. const fields = (this.model.get('fields') || []).map(field => {
  36135. const value = form_data.get(field.name).trim();
  36136. field.value = value;
  36137. if (field.challenge) {
  36138. field.challenge_failed = value !== field.challenge;
  36139. }
  36140. return field;
  36141. });
  36142. if (fields.filter(c => c.challenge_failed).length) {
  36143. this.model.set('fields', fields); // Setting an array doesn't trigger a change event
  36144. this.model.trigger('change');
  36145. return;
  36146. }
  36147. this.confirmation.resolve(fields);
  36148. this.modal.hide();
  36149. }
  36150. });
  36151. /* harmony default export */ const modal_confirm = (Confirm);
  36152. ;// CONCATENATED MODULE: ./src/plugins/modal/api.js
  36153. let modals = [];
  36154. const modal_api = {
  36155. /**
  36156. * API namespace for methods relating to modals
  36157. * @namespace _converse.api.modal
  36158. * @memberOf _converse.api
  36159. */
  36160. modal: {
  36161. /**
  36162. * Shows a modal of type `ModalClass` to the user.
  36163. * Will create a new instance of that class if an existing one isn't
  36164. * found.
  36165. * @param { Class } ModalClass
  36166. * @param { Object } [properties] - Optional properties that will be
  36167. * set on a newly created modal instance (if no pre-existing modal was
  36168. * found).
  36169. * @param { Event } [event] - The DOM event that causes the modal to be shown.
  36170. */
  36171. show(ModalClass, properties, ev) {
  36172. const modal = this.get(ModalClass.id) || this.create(ModalClass, properties);
  36173. modal.show(ev);
  36174. return modal;
  36175. },
  36176. /**
  36177. * Return a modal with the passed-in identifier, if it exists.
  36178. * @param { String } id
  36179. */
  36180. get(id) {
  36181. return modals.filter(m => m.id == id).pop();
  36182. },
  36183. /**
  36184. * Create a modal of the passed-in type.
  36185. * @param { Class } ModalClass
  36186. * @param { Object } [properties] - Optional properties that will be
  36187. * set on the modal instance.
  36188. */
  36189. create(ModalClass, properties) {
  36190. const modal = new ModalClass(properties);
  36191. modals.push(modal);
  36192. return modal;
  36193. },
  36194. /**
  36195. * Remove a particular modal
  36196. * @param { View } modal
  36197. */
  36198. remove(modal) {
  36199. modals = modals.filter(m => m !== modal);
  36200. modal.remove();
  36201. },
  36202. /**
  36203. * Remove all modals
  36204. */
  36205. removeAll() {
  36206. modals.forEach(m => m.remove());
  36207. modals = [];
  36208. }
  36209. },
  36210. /**
  36211. * Show a confirm modal to the user.
  36212. * @method _converse.api.confirm
  36213. * @param { String } title - The header text for the confirmation dialog
  36214. * @param { (Array<String>|String) } messages - The text to show to the user
  36215. * @param { Array<Field> } fields - An object representing a fields presented to the user.
  36216. * @property { String } Field.label - The form label for the input field.
  36217. * @property { String } Field.name - The name for the input field.
  36218. * @property { String } [Field.challenge] - A challenge value that must be provided by the user.
  36219. * @property { String } [Field.placeholder] - The placeholder for the input field.
  36220. * @property { Boolean} [Field.required] - Whether the field is required or not
  36221. * @returns { Promise<Array|false> } A promise which resolves with an array of
  36222. * filled in fields or `false` if the confirm dialog was closed or canceled.
  36223. */
  36224. async confirm(title) {
  36225. let messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  36226. let fields = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  36227. if (typeof messages === 'string') {
  36228. messages = [messages];
  36229. }
  36230. const model = new Model({
  36231. title,
  36232. messages,
  36233. fields,
  36234. 'type': 'confirm'
  36235. });
  36236. const confirm = new modal_confirm({
  36237. model
  36238. });
  36239. confirm.show();
  36240. let result;
  36241. try {
  36242. result = await confirm.confirmation;
  36243. } catch (e) {
  36244. result = false;
  36245. }
  36246. confirm.remove();
  36247. return result;
  36248. },
  36249. /**
  36250. * Show a prompt modal to the user.
  36251. * @method _converse.api.prompt
  36252. * @param { String } title - The header text for the prompt
  36253. * @param { (Array<String>|String) } messages - The prompt text to show to the user
  36254. * @param { String } placeholder - The placeholder text for the prompt input
  36255. * @returns { Promise<String|false> } A promise which resolves with the text provided by the
  36256. * user or `false` if the user canceled the prompt.
  36257. */
  36258. async prompt(title) {
  36259. let messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  36260. let placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  36261. if (typeof messages === 'string') {
  36262. messages = [messages];
  36263. }
  36264. const model = new Model({
  36265. title,
  36266. messages,
  36267. 'fields': [{
  36268. 'name': 'reason',
  36269. 'placeholder': placeholder
  36270. }],
  36271. 'type': 'prompt'
  36272. });
  36273. const prompt = new modal_confirm({
  36274. model
  36275. });
  36276. prompt.show();
  36277. let result;
  36278. try {
  36279. var _await$prompt$confirm;
  36280. result = (_await$prompt$confirm = (await prompt.confirmation).pop()) === null || _await$prompt$confirm === void 0 ? void 0 : _await$prompt$confirm.value;
  36281. } catch (e) {
  36282. result = false;
  36283. }
  36284. prompt.remove();
  36285. return result;
  36286. },
  36287. /**
  36288. * Show an alert modal to the user.
  36289. * @method _converse.api.alert
  36290. * @param { ('info'|'warn'|'error') } type - The type of alert.
  36291. * @param { String } title - The header text for the alert.
  36292. * @param { (Array<String>|String) } messages - The alert text to show to the user.
  36293. */
  36294. alert(type, title, messages) {
  36295. if (typeof messages === 'string') {
  36296. messages = [messages];
  36297. }
  36298. let level;
  36299. if (type === 'error') {
  36300. level = 'alert-danger';
  36301. } else if (type === 'info') {
  36302. level = 'alert-info';
  36303. } else if (type === 'warn') {
  36304. level = 'alert-warning';
  36305. }
  36306. const model = new Model({
  36307. 'title': title,
  36308. 'messages': messages,
  36309. 'level': level,
  36310. 'type': 'alert'
  36311. });
  36312. modal_api.modal.show(modal_alert, {
  36313. model
  36314. });
  36315. }
  36316. };
  36317. /* harmony default export */ const plugins_modal_api = (modal_api);
  36318. ;// CONCATENATED MODULE: ./src/plugins/modal/index.js
  36319. /**
  36320. * @copyright The Converse.js contributors
  36321. * @license Mozilla Public License (MPLv2)
  36322. */
  36323. core_converse.env.BootstrapModal = base; // expose to plugins
  36324. core_converse.plugins.add('converse-modal', {
  36325. initialize() {
  36326. core_api.listen.on('disconnect', () => {
  36327. const container = document.querySelector("#converse-modals");
  36328. if (container) {
  36329. container.innerHTML = '';
  36330. }
  36331. });
  36332. core_api.listen.on('clearSession', () => core_api.modal.removeAll());
  36333. Object.assign(shared_converse.api, plugins_modal_api);
  36334. }
  36335. });
  36336. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/message-actions.scss
  36337. var message_actions = __webpack_require__(4166);
  36338. ;// CONCATENATED MODULE: ./src/shared/chat/styles/message-actions.scss
  36339. var message_actions_options = {};
  36340. message_actions_options.styleTagTransform = (styleTagTransform_default());
  36341. message_actions_options.setAttributes = (setAttributesWithoutAttributes_default());
  36342. message_actions_options.insert = insertBySelector_default().bind(null, "head");
  36343. message_actions_options.domAPI = (styleDomAPI_default());
  36344. message_actions_options.insertStyleElement = (insertStyleElement_default());
  36345. var message_actions_update = injectStylesIntoStyleTag_default()(message_actions/* default */.Z, message_actions_options);
  36346. /* harmony default export */ const styles_message_actions = (message_actions/* default */.Z && message_actions/* default.locals */.Z.locals ? message_actions/* default.locals */.Z.locals : undefined);
  36347. ;// CONCATENATED MODULE: ./src/shared/chat/message-actions.js
  36348. const {
  36349. Strophe: message_actions_Strophe,
  36350. u: message_actions_u
  36351. } = core_converse.env;
  36352. class MessageActions extends CustomElement {
  36353. static get properties() {
  36354. return {
  36355. is_retracted: {
  36356. type: Boolean
  36357. },
  36358. model: {
  36359. type: Object
  36360. }
  36361. };
  36362. }
  36363. initialize() {
  36364. const settings = getAppSettings();
  36365. this.listenTo(settings, 'change:allowed_audio_domains', () => this.requestUpdate());
  36366. this.listenTo(settings, 'change:allowed_image_domains', () => this.requestUpdate());
  36367. this.listenTo(settings, 'change:allowed_video_domains', () => this.requestUpdate());
  36368. this.listenTo(settings, 'change:render_media', () => this.requestUpdate());
  36369. this.listenTo(this.model, 'change', () => this.requestUpdate());
  36370. }
  36371. render() {
  36372. return $`${until_c(this.renderActions(), '')}`;
  36373. }
  36374. async renderActions() {
  36375. // We want to let the message actions menu drop upwards if we're at the
  36376. // bottom of the message history, and down otherwise. This is to avoid
  36377. // the menu disappearing behind the bottom panel (toolbar, textarea etc).
  36378. // That's difficult to know from state, so we're making an approximation here.
  36379. const should_drop_up = this.model.collection.length > 2 && this.model === this.model.collection.last();
  36380. const buttons = await this.getActionButtons();
  36381. const items = buttons.map(b => MessageActions.getActionsDropdownItem(b));
  36382. if (items.length) {
  36383. return $`<converse-dropdown
  36384. class="chat-msg__actions ${should_drop_up ? 'dropup dropup--left' : 'dropleft'}"
  36385. .items=${items}
  36386. ></converse-dropdown>`;
  36387. } else {
  36388. return '';
  36389. }
  36390. }
  36391. static getActionsDropdownItem(o) {
  36392. return $`
  36393. <button class="chat-msg__action ${o.button_class}" @click=${o.handler}>
  36394. <converse-icon
  36395. class="${o.icon_class}"
  36396. color="var(--text-color-lighten-15-percent)"
  36397. size="1em"
  36398. ></converse-icon>
  36399. ${o.i18n_text}
  36400. </button>
  36401. `;
  36402. }
  36403. onMessageEditButtonClicked(ev) {
  36404. var _u$ancestor, _u$ancestor$querySele;
  36405. ev.preventDefault();
  36406. const currently_correcting = this.model.collection.findWhere('correcting'); // TODO: Use state intead of DOM querying
  36407. // Then this code can also be put on the model
  36408. const unsent_text = (_u$ancestor = message_actions_u.ancestor(this, '.chatbox')) === null || _u$ancestor === void 0 ? void 0 : (_u$ancestor$querySele = _u$ancestor.querySelector('.chat-textarea')) === null || _u$ancestor$querySele === void 0 ? void 0 : _u$ancestor$querySele.value;
  36409. if (unsent_text && (!currently_correcting || currently_correcting.getMessageText() !== unsent_text)) {
  36410. if (!confirm(__('You have an unsent message which will be lost if you continue. Are you sure?'))) {
  36411. return;
  36412. }
  36413. }
  36414. if (currently_correcting !== this.model) {
  36415. currently_correcting === null || currently_correcting === void 0 ? void 0 : currently_correcting.save('correcting', false);
  36416. this.model.save('correcting', true);
  36417. } else {
  36418. this.model.save('correcting', false);
  36419. }
  36420. }
  36421. async onDirectMessageRetractButtonClicked() {
  36422. if (this.model.get('sender') !== 'me') {
  36423. return headless_log.error("onMessageRetractButtonClicked called for someone else's message!");
  36424. }
  36425. const retraction_warning = __('Be aware that other XMPP/Jabber clients (and servers) may ' + 'not yet support retractions and that this message may not ' + 'be removed everywhere.');
  36426. const messages = [__('Are you sure you want to retract this message?')];
  36427. if (core_api.settings.get('show_retraction_warning')) {
  36428. messages[1] = retraction_warning;
  36429. }
  36430. const result = await core_api.confirm(__('Confirm'), messages);
  36431. if (result) {
  36432. const chatbox = this.model.collection.chatbox;
  36433. chatbox.retractOwnMessage(this.model);
  36434. }
  36435. }
  36436. /**
  36437. * Retract someone else's message in this groupchat.
  36438. * @private
  36439. * @param { _converse.Message } message - The message which we're retracting.
  36440. * @param { string } [reason] - The reason for retracting the message.
  36441. */
  36442. async retractOtherMessage(reason) {
  36443. const chatbox = this.model.collection.chatbox;
  36444. const result = await chatbox.retractOtherMessage(this.model, reason);
  36445. if (result === null) {
  36446. const err_msg = __(`A timeout occurred while trying to retract the message`);
  36447. core_api.alert('error', __('Error'), err_msg);
  36448. headless_log(err_msg, message_actions_Strophe.LogLevel.WARN);
  36449. } else if (message_actions_u.isErrorStanza(result)) {
  36450. const err_msg = __(`Sorry, you're not allowed to retract this message.`);
  36451. core_api.alert('error', __('Error'), err_msg);
  36452. headless_log(err_msg, message_actions_Strophe.LogLevel.WARN);
  36453. headless_log(result, message_actions_Strophe.LogLevel.WARN);
  36454. }
  36455. }
  36456. async onMUCMessageRetractButtonClicked() {
  36457. const retraction_warning = __('Be aware that other XMPP/Jabber clients (and servers) may ' + 'not yet support retractions and that this message may not ' + 'be removed everywhere.');
  36458. if (this.model.mayBeRetracted()) {
  36459. const messages = [__('Are you sure you want to retract this message?')];
  36460. if (core_api.settings.get('show_retraction_warning')) {
  36461. messages[1] = retraction_warning;
  36462. }
  36463. if (await core_api.confirm(__('Confirm'), messages)) {
  36464. const chatbox = this.model.collection.chatbox;
  36465. chatbox.retractOwnMessage(this.model);
  36466. }
  36467. } else if (await this.model.mayBeModerated()) {
  36468. if (this.model.get('sender') === 'me') {
  36469. let messages = [__('Are you sure you want to retract this message?')];
  36470. if (core_api.settings.get('show_retraction_warning')) {
  36471. messages = [messages[0], retraction_warning, messages[1]];
  36472. }
  36473. !!(await core_api.confirm(__('Confirm'), messages)) && this.retractOtherMessage();
  36474. } else {
  36475. let messages = [__('You are about to retract this message.'), __('You may optionally include a message, explaining the reason for the retraction.')];
  36476. if (core_api.settings.get('show_retraction_warning')) {
  36477. messages = [messages[0], retraction_warning, messages[1]];
  36478. }
  36479. const reason = await core_api.prompt(__('Message Retraction'), messages, __('Optional reason'));
  36480. reason !== false && this.retractOtherMessage(reason);
  36481. }
  36482. } else {
  36483. const err_msg = __(`Sorry, you're not allowed to retract this message`);
  36484. core_api.alert('error', __('Error'), err_msg);
  36485. }
  36486. }
  36487. onMessageRetractButtonClicked(ev) {
  36488. var _ev$preventDefault;
  36489. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  36490. const chatbox = this.model.collection.chatbox;
  36491. if (chatbox.get('type') === shared_converse.CHATROOMS_TYPE) {
  36492. this.onMUCMessageRetractButtonClicked();
  36493. } else {
  36494. this.onDirectMessageRetractButtonClicked();
  36495. }
  36496. }
  36497. onMediaToggleClicked(ev) {
  36498. var _ev$preventDefault2;
  36499. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  36500. if (this.hasHiddenMedia(this.getMediaURLs())) {
  36501. this.model.save({
  36502. 'hide_url_previews': false,
  36503. 'url_preview_transition': 'fade-in'
  36504. });
  36505. } else {
  36506. const ogp_metadata = this.model.get('ogp_metadata') || [];
  36507. if (ogp_metadata.length) {
  36508. this.model.set('url_preview_transition', 'fade-out');
  36509. } else {
  36510. this.model.save({
  36511. 'hide_url_previews': true,
  36512. 'url_preview_transition': 'fade-in'
  36513. });
  36514. }
  36515. }
  36516. }
  36517. /**
  36518. * Check whether media is hidden or shown, which is used to determine the toggle text.
  36519. *
  36520. * If `render_media` is an array, check if there are media URLs outside
  36521. * of that array, in which case we consider message media on the whole to be hidden (since
  36522. * those excluded by the whitelist will be, even if the render_media whitelisted URLs are shown).
  36523. * @param { Array<String> } media_urls
  36524. * @returns { Boolean }
  36525. */
  36526. hasHiddenMedia(media_urls) {
  36527. if (typeof this.model.get('hide_url_previews') === 'boolean') {
  36528. return this.model.get('hide_url_previews');
  36529. }
  36530. const render_media = core_api.settings.get('render_media');
  36531. if (Array.isArray(render_media)) {
  36532. return media_urls.reduce((acc, url) => acc || !isDomainWhitelisted(render_media, url), false);
  36533. } else {
  36534. return !render_media;
  36535. }
  36536. }
  36537. getMediaURLs() {
  36538. const unfurls_to_show = (this.model.get('ogp_metadata') || []).map(o => ({
  36539. 'url': o['og:image'],
  36540. 'is_image': true
  36541. })).filter(o => isMediaURLDomainAllowed(o));
  36542. const media_urls = getMediaURLs(this.model.get('media_urls') || [], this.model.get('body')).filter(o => isMediaURLDomainAllowed(o));
  36543. return [...new Set([...media_urls.map(o => o.url), ...unfurls_to_show.map(o => o.url)])];
  36544. }
  36545. /**
  36546. * Adds a media rendering toggle to this message's action buttons if necessary.
  36547. *
  36548. * The toggle is only added if the message contains media URLs and if the
  36549. * user is allowed to show or hide media for those URLs.
  36550. *
  36551. * Whether a user is allowed to show or hide domains depends on the config settings:
  36552. * * allowed_audio_domains
  36553. * * allowed_video_domains
  36554. * * allowed_image_domains
  36555. *
  36556. * Whether media is currently shown or hidden is determined by the { @link hasHiddenMedia } method.
  36557. *
  36558. * @param { Array<MessageActionAttributes> } buttons - An array of objects representing action buttons
  36559. */
  36560. addMediaRenderingToggle(buttons) {
  36561. const urls = this.getMediaURLs();
  36562. if (urls.length) {
  36563. const hidden = this.hasHiddenMedia(urls);
  36564. buttons.push({
  36565. 'i18n_text': hidden ? __('Show media') : __('Hide media'),
  36566. 'handler': ev => this.onMediaToggleClicked(ev),
  36567. 'button_class': 'chat-msg__action-hide-previews',
  36568. 'icon_class': hidden ? 'fas fa-eye' : 'fas fa-eye-slash',
  36569. 'name': 'hide'
  36570. });
  36571. }
  36572. }
  36573. async getActionButtons() {
  36574. const buttons = [];
  36575. if (this.model.get('editable')) {
  36576. /**
  36577. * @typedef { Object } MessageActionAttributes
  36578. * An object which represents a message action (as shown in the message dropdown);
  36579. * @property { String } i18n_text
  36580. * @property { Function } handler
  36581. * @property { String } button_class
  36582. * @property { String } icon_class
  36583. * @property { String } name
  36584. */
  36585. buttons.push({
  36586. 'i18n_text': this.model.get('correcting') ? __('Cancel Editing') : __('Edit'),
  36587. 'handler': ev => this.onMessageEditButtonClicked(ev),
  36588. 'button_class': 'chat-msg__action-edit',
  36589. 'icon_class': 'fa fa-pencil-alt',
  36590. 'name': 'edit'
  36591. });
  36592. }
  36593. const may_be_moderated = ['groupchat', 'mep'].includes(this.model.get('type')) && (await this.model.mayBeModerated());
  36594. const retractable = !this.is_retracted && (this.model.mayBeRetracted() || may_be_moderated);
  36595. if (retractable) {
  36596. buttons.push({
  36597. 'i18n_text': __('Retract'),
  36598. 'handler': ev => this.onMessageRetractButtonClicked(ev),
  36599. 'button_class': 'chat-msg__action-retract',
  36600. 'icon_class': 'fas fa-trash-alt',
  36601. 'name': 'retract'
  36602. });
  36603. }
  36604. if (!this.model.collection) {
  36605. // While we were awaiting, this model got removed from the
  36606. // collection (happens during tests)
  36607. return [];
  36608. }
  36609. this.addMediaRenderingToggle(buttons);
  36610. /**
  36611. * *Hook* which allows plugins to add more message action buttons
  36612. * @event _converse#getMessageActionButtons
  36613. * @example
  36614. * api.listen.on('getMessageActionButtons', (el, buttons) => {
  36615. * buttons.push({
  36616. * 'i18n_text': 'Foo',
  36617. * 'handler': ev => alert('Foo!'),
  36618. * 'button_class': 'chat-msg__action-foo',
  36619. * 'icon_class': 'fa fa-check',
  36620. * 'name': 'foo'
  36621. * });
  36622. * return buttons;
  36623. * });
  36624. */
  36625. return core_api.hook('getMessageActionButtons', this, buttons);
  36626. }
  36627. }
  36628. core_api.elements.define('converse-message-actions', MessageActions);
  36629. ;// CONCATENATED MODULE: ./src/modals/templates/image.js
  36630. /* harmony default export */ const templates_image = (o => {
  36631. return $`
  36632. <div class="modal-dialog fit-content" role="document">
  36633. <div class="modal-content fit-content">
  36634. <div class="modal-header">
  36635. <h4 class="modal-title" id="message-versions-modal-label">${__('Image: ')}<a target="_blank" rel="noopener" href="${o.src}">${o.src}</a></h4>
  36636. ${modal_header_close_button}
  36637. </div>
  36638. <div class="modal-body modal-body--image fit-content">
  36639. <img class="chat-image" src="${o.src}" @load=${o.onload}>
  36640. </div>
  36641. <div class="modal-footer">${modal_close_button}</div>
  36642. </div>
  36643. </div>`;
  36644. });
  36645. ;// CONCATENATED MODULE: ./src/modals/image.js
  36646. /* harmony default export */ const modals_image = (base.extend({
  36647. id: 'image-modal',
  36648. toHTML() {
  36649. return templates_image({
  36650. 'src': this.src,
  36651. 'onload': ev => ev.target.parentElement.style.height = `${ev.target.height}px`
  36652. });
  36653. }
  36654. }));
  36655. ;// CONCATENATED MODULE: ./node_modules/lit/directive.js
  36656. //# sourceMappingURL=directive.js.map
  36657. ;// CONCATENATED MODULE: ./src/templates/audio.js
  36658. /* harmony default export */ const audio = ((url, hide_url) => $`<audio controls src="${url}"></audio>${hide_url ? '' : $`<a target="_blank" rel="noopener" href="${url}">${url}</a>`}`);
  36659. ;// CONCATENATED MODULE: ./src/shared/gif/stream.js
  36660. class Stream {
  36661. constructor(data) {
  36662. if (data.toString().indexOf('ArrayBuffer') > 0) {
  36663. data = new Uint8Array(data);
  36664. }
  36665. this.data = data;
  36666. this.len = this.data.length;
  36667. this.pos = 0;
  36668. }
  36669. readByte() {
  36670. if (this.pos >= this.data.length) {
  36671. throw new Error('Attempted to read past end of stream.');
  36672. }
  36673. if (this.data instanceof Uint8Array) return this.data[this.pos++];else return this.data.charCodeAt(this.pos++) & 0xFF;
  36674. }
  36675. readBytes(n) {
  36676. const bytes = [];
  36677. for (let i = 0; i < n; i++) {
  36678. bytes.push(this.readByte());
  36679. }
  36680. return bytes;
  36681. }
  36682. read(n) {
  36683. let s = '';
  36684. for (let i = 0; i < n; i++) {
  36685. s += String.fromCharCode(this.readByte());
  36686. }
  36687. return s;
  36688. }
  36689. readUnsigned() {
  36690. // Little-endian.
  36691. const a = this.readBytes(2);
  36692. return (a[1] << 8) + a[0];
  36693. }
  36694. }
  36695. ;// CONCATENATED MODULE: ./src/shared/gif/utils.js
  36696. /**
  36697. * @copyright Shachaf Ben-Kiki and the Converse.js contributors
  36698. * @description
  36699. * Started as a fork of Shachaf Ben-Kiki's jsgif library
  36700. * https://github.com/shachaf/jsgif
  36701. * @license MIT License
  36702. */
  36703. function bitsToNum(ba) {
  36704. return ba.reduce(function (s, n) {
  36705. return s * 2 + n;
  36706. }, 0);
  36707. }
  36708. function byteToBitArr(bite) {
  36709. const a = [];
  36710. for (let i = 7; i >= 0; i--) {
  36711. a.push(!!(bite & 1 << i));
  36712. }
  36713. return a;
  36714. }
  36715. function lzwDecode(minCodeSize, data) {
  36716. // TODO: Now that the GIF parser is a bit different, maybe this should get an array of bytes instead of a String?
  36717. let pos = 0; // Maybe this streaming thing should be merged with the Stream?
  36718. function readCode(size) {
  36719. let code = 0;
  36720. for (let i = 0; i < size; i++) {
  36721. if (data.charCodeAt(pos >> 3) & 1 << (pos & 7)) {
  36722. code |= 1 << i;
  36723. }
  36724. pos++;
  36725. }
  36726. return code;
  36727. }
  36728. const output = [];
  36729. const clearCode = 1 << minCodeSize;
  36730. const eoiCode = clearCode + 1;
  36731. let codeSize = minCodeSize + 1;
  36732. let dict = [];
  36733. const clear = function () {
  36734. dict = [];
  36735. codeSize = minCodeSize + 1;
  36736. for (let i = 0; i < clearCode; i++) {
  36737. dict[i] = [i];
  36738. }
  36739. dict[clearCode] = [];
  36740. dict[eoiCode] = null;
  36741. };
  36742. let code;
  36743. let last;
  36744. while (true) {
  36745. // eslint-disable-line no-constant-condition
  36746. last = code;
  36747. code = readCode(codeSize);
  36748. if (code === clearCode) {
  36749. clear();
  36750. continue;
  36751. }
  36752. if (code === eoiCode) break;
  36753. if (code < dict.length) {
  36754. if (last !== clearCode) {
  36755. dict.push(dict[last].concat(dict[code][0]));
  36756. }
  36757. } else {
  36758. if (code !== dict.length) throw new Error('Invalid LZW code.');
  36759. dict.push(dict[last].concat(dict[last][0]));
  36760. }
  36761. output.push.apply(output, dict[code]);
  36762. if (dict.length === 1 << codeSize && codeSize < 12) {
  36763. // If we're at the last code and codeSize is 12, the next code will be a clearCode, and it'll be 12 bits long.
  36764. codeSize++;
  36765. }
  36766. } // I don't know if this is technically an error, but some GIFs do it.
  36767. //if (Math.ceil(pos / 8) !== data.length) throw new Error('Extraneous LZW bytes.');
  36768. return output;
  36769. }
  36770. function readSubBlocks(st) {
  36771. let size, data;
  36772. data = '';
  36773. do {
  36774. size = st.readByte();
  36775. data += st.read(size);
  36776. } while (size !== 0);
  36777. return data;
  36778. }
  36779. /**
  36780. * Parses GIF image color table information
  36781. * @param { Stream } st
  36782. * @param { Number } entries
  36783. */
  36784. function parseCT(st, entries) {
  36785. // Each entry is 3 bytes, for RGB.
  36786. const ct = [];
  36787. for (let i = 0; i < entries; i++) {
  36788. ct.push(st.readBytes(3));
  36789. }
  36790. return ct;
  36791. }
  36792. /**
  36793. * Parses GIF image information
  36794. * @param { Stream } st
  36795. * @param { ByteStream } img
  36796. * @param { Function } [callback]
  36797. */
  36798. function parseImg(st, img, callback) {
  36799. function deinterlace(pixels, width) {
  36800. // Of course this defeats the purpose of interlacing. And it's *probably*
  36801. // the least efficient way it's ever been implemented. But nevertheless...
  36802. const newPixels = new Array(pixels.length);
  36803. const rows = pixels.length / width;
  36804. function cpRow(toRow, fromRow) {
  36805. const fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
  36806. newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
  36807. } // See appendix E.
  36808. const offsets = [0, 4, 2, 1];
  36809. const steps = [8, 8, 4, 2];
  36810. let fromRow = 0;
  36811. for (let pass = 0; pass < 4; pass++) {
  36812. for (let toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
  36813. cpRow(toRow, fromRow);
  36814. fromRow++;
  36815. }
  36816. }
  36817. return newPixels;
  36818. }
  36819. img.leftPos = st.readUnsigned();
  36820. img.topPos = st.readUnsigned();
  36821. img.width = st.readUnsigned();
  36822. img.height = st.readUnsigned();
  36823. const bits = byteToBitArr(st.readByte());
  36824. img.lctFlag = bits.shift();
  36825. img.interlaced = bits.shift();
  36826. img.sorted = bits.shift();
  36827. img.reserved = bits.splice(0, 2);
  36828. img.lctSize = bitsToNum(bits.splice(0, 3));
  36829. if (img.lctFlag) {
  36830. img.lct = parseCT(st, 1 << img.lctSize + 1);
  36831. }
  36832. img.lzwMinCodeSize = st.readByte();
  36833. const lzwData = readSubBlocks(st);
  36834. img.pixels = lzwDecode(img.lzwMinCodeSize, lzwData);
  36835. if (img.interlaced) {
  36836. // Move
  36837. img.pixels = deinterlace(img.pixels, img.width);
  36838. }
  36839. callback === null || callback === void 0 ? void 0 : callback(img);
  36840. }
  36841. /**
  36842. * Parses GIF header information
  36843. * @param { Stream } st
  36844. * @param { Function } [callback]
  36845. */
  36846. function parseHeader(st, callback) {
  36847. const hdr = {};
  36848. hdr.sig = st.read(3);
  36849. hdr.ver = st.read(3);
  36850. if (hdr.sig !== 'GIF') {
  36851. throw new Error('Not a GIF file.');
  36852. }
  36853. hdr.width = st.readUnsigned();
  36854. hdr.height = st.readUnsigned();
  36855. const bits = byteToBitArr(st.readByte());
  36856. hdr.gctFlag = bits.shift();
  36857. hdr.colorRes = bitsToNum(bits.splice(0, 3));
  36858. hdr.sorted = bits.shift();
  36859. hdr.gctSize = bitsToNum(bits.splice(0, 3));
  36860. hdr.bgColor = st.readByte();
  36861. hdr.pixelAspectRatio = st.readByte(); // if not 0, aspectRatio = (pixelAspectRatio + 15) / 64
  36862. if (hdr.gctFlag) {
  36863. hdr.gct = parseCT(st, 1 << hdr.gctSize + 1);
  36864. }
  36865. callback === null || callback === void 0 ? void 0 : callback(hdr);
  36866. }
  36867. function parseExt(st, block, handler) {
  36868. function parseGCExt(block) {
  36869. st.readByte(); // blocksize, always 4
  36870. const bits = byteToBitArr(st.readByte());
  36871. block.reserved = bits.splice(0, 3); // Reserved; should be 000.
  36872. block.disposalMethod = bitsToNum(bits.splice(0, 3));
  36873. block.userInput = bits.shift();
  36874. block.transparencyGiven = bits.shift();
  36875. block.delayTime = st.readUnsigned();
  36876. block.transparencyIndex = st.readByte();
  36877. block.terminator = st.readByte();
  36878. handler === null || handler === void 0 ? void 0 : handler.gce(block);
  36879. }
  36880. function parseComExt(block) {
  36881. block.comment = readSubBlocks(st);
  36882. handler.com && handler.com(block);
  36883. }
  36884. function parsePTExt(block) {
  36885. // No one *ever* uses this. If you use it, deal with parsing it yourself.
  36886. st.readByte(); // blocksize, always 12
  36887. block.ptHeader = st.readBytes(12);
  36888. block.ptData = readSubBlocks(st);
  36889. handler.pte && handler.pte(block);
  36890. }
  36891. function parseAppExt(block) {
  36892. function parseNetscapeExt(block) {
  36893. st.readByte(); // blocksize, always 3
  36894. block.unknown = st.readByte(); // ??? Always 1? What is this?
  36895. block.iterations = st.readUnsigned();
  36896. block.terminator = st.readByte();
  36897. handler.app && handler.app.NETSCAPE && handler.app.NETSCAPE(block);
  36898. }
  36899. function parseUnknownAppExt(block) {
  36900. block.appData = readSubBlocks(st); // FIXME: This won't work if a handler wants to match on any identifier.
  36901. handler.app && handler.app[block.identifier] && handler.app[block.identifier](block);
  36902. }
  36903. st.readByte(); // blocksize, always 11
  36904. block.identifier = st.read(8);
  36905. block.authCode = st.read(3);
  36906. switch (block.identifier) {
  36907. case 'NETSCAPE':
  36908. parseNetscapeExt(block);
  36909. break;
  36910. default:
  36911. parseUnknownAppExt(block);
  36912. break;
  36913. }
  36914. }
  36915. function parseUnknownExt(block) {
  36916. block.data = readSubBlocks(st);
  36917. handler.unknown && handler.unknown(block);
  36918. }
  36919. block.label = st.readByte();
  36920. switch (block.label) {
  36921. case 0xF9:
  36922. block.extType = 'gce';
  36923. parseGCExt(block);
  36924. break;
  36925. case 0xFE:
  36926. block.extType = 'com';
  36927. parseComExt(block);
  36928. break;
  36929. case 0x01:
  36930. block.extType = 'pte';
  36931. parsePTExt(block);
  36932. break;
  36933. case 0xFF:
  36934. block.extType = 'app';
  36935. parseAppExt(block);
  36936. break;
  36937. default:
  36938. block.extType = 'unknown';
  36939. parseUnknownExt(block);
  36940. break;
  36941. }
  36942. }
  36943. /**
  36944. * @param { Stream } st
  36945. * @param { GIFParserHandlers } handler
  36946. */
  36947. function parseBlock(st, handler) {
  36948. const block = {};
  36949. block.sentinel = st.readByte();
  36950. switch (String.fromCharCode(block.sentinel)) {
  36951. // For ease of matching
  36952. case '!':
  36953. block.type = 'ext';
  36954. parseExt(st, block, handler);
  36955. break;
  36956. case ',':
  36957. block.type = 'img';
  36958. parseImg(st, block, handler === null || handler === void 0 ? void 0 : handler.img);
  36959. break;
  36960. case ';':
  36961. block.type = 'eof';
  36962. handler === null || handler === void 0 ? void 0 : handler.eof(block);
  36963. break;
  36964. default:
  36965. throw new Error('Unknown block: 0x' + block.sentinel.toString(16));
  36966. // TODO: Pad this with a 0.
  36967. }
  36968. if (block.type !== 'eof') setTimeout(() => parseBlock(st, handler), 0);
  36969. }
  36970. /**
  36971. * Takes a Stream and parses it for GIF data, calling the relevant handler
  36972. * methods on the passed in `handler` object.
  36973. * @param { Stream } st
  36974. * @param { GIFParserHandlers } handler
  36975. */
  36976. function parseGIF(st) {
  36977. let handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  36978. parseHeader(st, handler === null || handler === void 0 ? void 0 : handler.hdr);
  36979. setTimeout(() => parseBlock(st, handler), 0);
  36980. }
  36981. ;// CONCATENATED MODULE: ./src/shared/gif/index.js
  36982. /**
  36983. * @copyright Shachaf Ben-Kiki, JC Brand
  36984. * @description
  36985. * Started as a fork of Shachaf Ben-Kiki's jsgif library
  36986. * https://github.com/shachaf/jsgif
  36987. * @license MIT License
  36988. */
  36989. const DELAY_FACTOR = 10;
  36990. class ConverseGif {
  36991. /**
  36992. * Creates a new ConverseGif instance
  36993. * @param { HTMLElement } el
  36994. * @param { Object } [options]
  36995. * @param { Number } [options.width] - The width, in pixels, of the canvas
  36996. * @param { Number } [options.height] - The height, in pixels, of the canvas
  36997. * @param { Boolean } [options.loop=true] - Setting this to `true` will enable looping of the gif
  36998. * @param { Boolean } [options.autoplay=true] - Same as the rel:autoplay attribute above, this arg overrides the img tag info.
  36999. * @param { Number } [options.max_width] - Scale images over max_width down to max_width. Helpful with mobile.
  37000. * @param { Function } [options.onIterationEnd] - Add a callback for when the gif reaches the end of a single loop (one iteration). The first argument passed will be the gif HTMLElement.
  37001. * @param { Boolean } [options.show_progress_bar=true]
  37002. * @param { String } [options.progress_bg_color='rgba(0,0,0,0.4)']
  37003. * @param { String } [options.progress_color='rgba(255,0,22,.8)']
  37004. * @param { Number } [options.progress_bar_height=5]
  37005. */
  37006. constructor(el, opts) {
  37007. this.options = Object.assign({
  37008. width: null,
  37009. height: null,
  37010. autoplay: true,
  37011. loop: true,
  37012. show_progress_bar: true,
  37013. progress_bg_color: 'rgba(0,0,0,0.4)',
  37014. progress_color: 'rgba(255,0,22,.8)',
  37015. progress_bar_height: 5
  37016. }, opts);
  37017. this.el = el;
  37018. this.gif_el = el.querySelector('img');
  37019. this.canvas = el.querySelector('canvas');
  37020. this.ctx = this.canvas.getContext('2d'); // It's good practice to pre-render to an offscreen canvas
  37021. this.offscreenCanvas = document.createElement('canvas');
  37022. this.ctx_scaled = false;
  37023. this.disposal_method = null;
  37024. this.disposal_restore_from_idx = null;
  37025. this.frame = null;
  37026. this.frame_offsets = []; // elements have .x and .y properties
  37027. this.frames = [];
  37028. this.last_disposal_method = null;
  37029. this.last_img = null;
  37030. this.load_error = null;
  37031. this.playing = this.options.autoplay;
  37032. this.transparency = null;
  37033. this.frame_idx = 0;
  37034. this.iteration_count = 0;
  37035. this.start = null;
  37036. this.initialize();
  37037. }
  37038. async initialize() {
  37039. if (this.options.width && this.options.height) {
  37040. this.setSizes(this.options.width, this.options.height);
  37041. }
  37042. const data = await this.fetchGIF(this.gif_el.src);
  37043. requestAnimationFrame(() => this.startParsing(data));
  37044. }
  37045. initPlayer() {
  37046. if (this.load_error) return;
  37047. if (!(this.options.width && this.options.height)) {
  37048. this.ctx.scale(this.getCanvasScale(), this.getCanvasScale());
  37049. } // Show the first frame
  37050. this.frame_idx = 0;
  37051. this.putFrame(this.frame_idx);
  37052. if (this.options.autoplay) {
  37053. var _this$frames$this$fra;
  37054. const delay = (((_this$frames$this$fra = this.frames[this.frame_idx]) === null || _this$frames$this$fra === void 0 ? void 0 : _this$frames$this$fra.delay) ?? 0) * DELAY_FACTOR;
  37055. setTimeout(() => this.play(), delay);
  37056. }
  37057. }
  37058. /**
  37059. * Gets the index of the frame "up next"
  37060. * @returns {number}
  37061. */
  37062. getNextFrameNo() {
  37063. return (this.frame_idx + 1 + this.frames.length) % this.frames.length;
  37064. }
  37065. /**
  37066. * Called once we've looped through all frames in the GIF
  37067. * @returns { Boolean } - Returns `true` if the GIF is now paused (i.e. further iterations are not desired)
  37068. */
  37069. onIterationEnd() {
  37070. var _this$options$onItera, _this$options;
  37071. this.iteration_count++;
  37072. (_this$options$onItera = (_this$options = this.options).onIterationEnd) === null || _this$options$onItera === void 0 ? void 0 : _this$options$onItera.call(_this$options, this);
  37073. if (!this.options.loop) {
  37074. this.pause();
  37075. return true;
  37076. }
  37077. return false;
  37078. }
  37079. /**
  37080. * Inner callback for the `requestAnimationFrame` function.
  37081. *
  37082. * This method gets wrapped by an arrow function so that the `previous_timestamp` and
  37083. * `frame_delay` parameters can also be passed in. The `timestamp`
  37084. * parameter comes from `requestAnimationFrame`.
  37085. *
  37086. * The purpose of this method is to call `putFrame` with the right delay
  37087. * in order to render the GIF animation.
  37088. *
  37089. * Note, this method will cause the *next* upcoming frame to be rendered,
  37090. * not the current one.
  37091. *
  37092. * This means `this.frame_idx` will be incremented before calling `this.putFrame`, so
  37093. * `putFrame(0)` needs to be called *before* this method, otherwise the
  37094. * animation will incorrectly start from frame #1 (this is done in `initPlayer`).
  37095. *
  37096. * @param { DOMHighRestTimestamp } timestamp - The timestamp as returned by `requestAnimationFrame`
  37097. * @param { DOMHighRestTimestamp } previous_timestamp - The timestamp from the previous iteration of this method.
  37098. * We need this in order to calculate whether we have waited long enough to
  37099. * show the next frame.
  37100. * @param { Number } frame_delay - The delay (in 1/100th of a second)
  37101. * before the currently being shown frame should be replaced by a new one.
  37102. */
  37103. onAnimationFrame(timestamp, previous_timestamp, frame_delay) {
  37104. var _this$frames$this$fra2;
  37105. if (!this.playing) {
  37106. return;
  37107. }
  37108. if (timestamp - previous_timestamp < frame_delay) {
  37109. this.hovering ? this.drawPauseIcon() : this.putFrame(this.frame_idx); // We need to wait longer
  37110. requestAnimationFrame(ts => this.onAnimationFrame(ts, previous_timestamp, frame_delay));
  37111. return;
  37112. }
  37113. const next_frame = this.getNextFrameNo();
  37114. if (next_frame === 0 && this.onIterationEnd()) {
  37115. return;
  37116. }
  37117. this.frame_idx = next_frame;
  37118. this.putFrame(this.frame_idx);
  37119. const delay = (((_this$frames$this$fra2 = this.frames[this.frame_idx]) === null || _this$frames$this$fra2 === void 0 ? void 0 : _this$frames$this$fra2.delay) || 8) * DELAY_FACTOR;
  37120. requestAnimationFrame(ts => this.onAnimationFrame(ts, timestamp, delay));
  37121. }
  37122. setSizes(w, h) {
  37123. this.canvas.width = w * this.getCanvasScale();
  37124. this.canvas.height = h * this.getCanvasScale();
  37125. this.offscreenCanvas.width = w;
  37126. this.offscreenCanvas.height = h;
  37127. this.offscreenCanvas.style.width = w + 'px';
  37128. this.offscreenCanvas.style.height = h + 'px';
  37129. this.offscreenCanvas.getContext('2d').setTransform(1, 0, 0, 1, 0, 0);
  37130. }
  37131. setFrameOffset(frame, offset) {
  37132. if (!this.frame_offsets[frame]) {
  37133. this.frame_offsets[frame] = offset;
  37134. return;
  37135. }
  37136. if (typeof offset.x !== 'undefined') {
  37137. this.frame_offsets[frame].x = offset.x;
  37138. }
  37139. if (typeof offset.y !== 'undefined') {
  37140. this.frame_offsets[frame].y = offset.y;
  37141. }
  37142. }
  37143. doShowProgress(pos, length, draw) {
  37144. if (draw && this.options.show_progress_bar) {
  37145. let height = this.options.progress_bar_height;
  37146. const top = (this.canvas.height - height) / (this.ctx_scaled ? this.getCanvasScale() : 1);
  37147. const mid = pos / length * this.canvas.width / (this.ctx_scaled ? this.getCanvasScale() : 1);
  37148. const width = this.canvas.width / (this.ctx_scaled ? this.getCanvasScale() : 1);
  37149. height /= this.ctx_scaled ? this.getCanvasScale() : 1;
  37150. this.ctx.fillStyle = this.options.progress_bg_color;
  37151. this.ctx.fillRect(mid, top, width - mid, height);
  37152. this.ctx.fillStyle = this.options.progress_color;
  37153. this.ctx.fillRect(0, top, mid, height);
  37154. }
  37155. }
  37156. /**
  37157. * Starts parsing the GIF stream data by calling `parseGIF` and passing in
  37158. * a map of handler functions.
  37159. * @param { String } data - The GIF file data, as returned by the server
  37160. */
  37161. startParsing(data) {
  37162. const stream = new Stream(data);
  37163. /**
  37164. * @typedef { Object } GIFParserHandlers
  37165. * A map of callback functions passed `parseGIF`. These functions are
  37166. * called as various parts of the GIF file format are parsed.
  37167. * @property { Function } hdr - Callback to handle the GIF header data
  37168. * @property { Function } gce - Callback to handle the GIF Graphic Control Extension data
  37169. * @property { Function } com - Callback to handle the comment extension block
  37170. * @property { Function } img - Callback to handle image data
  37171. * @property { Function } eof - Callback once the end of file has been reached
  37172. */
  37173. const handler = {
  37174. 'hdr': this.withProgress(stream, header => this.handleHeader(header)),
  37175. 'gce': this.withProgress(stream, gce => this.handleGCE(gce)),
  37176. 'com': this.withProgress(stream),
  37177. 'img': this.withProgress(stream, img => this.doImg(img), true),
  37178. 'eof': () => this.handleEOF(stream)
  37179. };
  37180. try {
  37181. parseGIF(stream, handler);
  37182. } catch (err) {
  37183. this.showError('parse');
  37184. }
  37185. }
  37186. drawError() {
  37187. this.ctx.fillStyle = 'black';
  37188. this.ctx.fillRect(0, 0, this.options.width ? this.options.width : this.hdr.width, this.options.height ? this.options.height : this.hdr.height);
  37189. this.ctx.strokeStyle = 'red';
  37190. this.ctx.lineWidth = 3;
  37191. this.ctx.moveTo(0, 0);
  37192. this.ctx.lineTo(this.options.width ? this.options.width : this.hdr.width, this.options.height ? this.options.height : this.hdr.height);
  37193. this.ctx.moveTo(0, this.options.height ? this.options.height : this.hdr.height);
  37194. this.ctx.lineTo(this.options.width ? this.options.width : this.hdr.width, 0);
  37195. this.ctx.stroke();
  37196. }
  37197. showError(errtype) {
  37198. this.load_error = errtype;
  37199. this.hdr = {
  37200. width: this.gif_el.width,
  37201. height: this.gif_el.height
  37202. }; // Fake header.
  37203. this.frames = [];
  37204. this.drawError();
  37205. this.el.requestUpdate();
  37206. }
  37207. handleHeader(header) {
  37208. this.hdr = header;
  37209. this.setSizes(this.options.width ?? this.hdr.width, this.options.height ?? this.hdr.height);
  37210. }
  37211. /**
  37212. * Handler for GIF Graphic Control Extension (GCE) data
  37213. */
  37214. handleGCE(gce) {
  37215. this.pushFrame(gce.delayTime);
  37216. this.clear();
  37217. this.transparency = gce.transparencyGiven ? gce.transparencyIndex : null;
  37218. this.disposal_method = gce.disposalMethod;
  37219. }
  37220. /**
  37221. * Handler for when the end of the GIF's file has been reached
  37222. */
  37223. handleEOF(stream) {
  37224. this.doDecodeProgress(stream, false);
  37225. if (!(this.options.width && this.options.height)) {
  37226. this.canvas.width = this.hdr.width * this.getCanvasScale();
  37227. this.canvas.height = this.hdr.height * this.getCanvasScale();
  37228. }
  37229. this.initPlayer();
  37230. !this.options.autoplay && this.drawPlayIcon();
  37231. }
  37232. pushFrame(delay) {
  37233. if (!this.frame) return;
  37234. this.frames.push({
  37235. data: this.frame.getImageData(0, 0, this.hdr.width, this.hdr.height),
  37236. delay
  37237. });
  37238. this.frame_offsets.push({
  37239. x: 0,
  37240. y: 0
  37241. });
  37242. }
  37243. doImg(img) {
  37244. this.frame = this.frame || this.offscreenCanvas.getContext('2d');
  37245. const currIdx = this.frames.length; //ct = color table, gct = global color table
  37246. const ct = img.lctFlag ? img.lct : this.hdr.gct; // TODO: What if neither exists?
  37247. /*
  37248. * Disposal method indicates the way in which the graphic is to
  37249. * be treated after being displayed.
  37250. *
  37251. * Values : 0 - No disposal specified. The decoder is
  37252. * not required to take any action.
  37253. * 1 - Do not dispose. The graphic is to be left
  37254. * in place.
  37255. * 2 - Restore to background color. The area used by the
  37256. * graphic must be restored to the background color.
  37257. * 3 - Restore to previous. The decoder is required to
  37258. * restore the area overwritten by the graphic with
  37259. * what was there prior to rendering the graphic.
  37260. *
  37261. * Importantly, "previous" means the frame state
  37262. * after the last disposal of method 0, 1, or 2.
  37263. */
  37264. if (currIdx > 0) {
  37265. if (this.last_disposal_method === 3) {
  37266. // Restore to previous
  37267. // If we disposed every frame including first frame up to this point, then we have
  37268. // no composited frame to restore to. In this case, restore to background instead.
  37269. if (this.disposal_restore_from_idx !== null) {
  37270. this.frame.putImageData(this.frames[this.disposal_restore_from_idx].data, 0, 0);
  37271. } else {
  37272. this.frame.clearRect(this.last_img.leftPos, this.last_img.topPos, this.last_img.width, this.last_img.height);
  37273. }
  37274. } else {
  37275. this.disposal_restore_from_idx = currIdx - 1;
  37276. }
  37277. if (this.last_disposal_method === 2) {
  37278. // Restore to background color
  37279. // Browser implementations historically restore to transparent; we do the same.
  37280. // http://www.wizards-toolkit.org/discourse-server/viewtopic.php?f=1&t=21172#p86079
  37281. this.frame.clearRect(this.last_img.leftPos, this.last_img.topPos, this.last_img.width, this.last_img.height);
  37282. }
  37283. } // else, Undefined/Do not dispose.
  37284. // frame contains final pixel data from the last frame; do nothing
  37285. //Get existing pixels for img region after applying disposal method
  37286. const imgData = this.frame.getImageData(img.leftPos, img.topPos, img.width, img.height); //apply color table colors
  37287. img.pixels.forEach((pixel, i) => {
  37288. // imgData.data === [R,G,B,A,R,G,B,A,...]
  37289. if (pixel !== this.transparency) {
  37290. imgData.data[i * 4 + 0] = ct[pixel][0];
  37291. imgData.data[i * 4 + 1] = ct[pixel][1];
  37292. imgData.data[i * 4 + 2] = ct[pixel][2];
  37293. imgData.data[i * 4 + 3] = 255; // Opaque.
  37294. }
  37295. });
  37296. this.frame.putImageData(imgData, img.leftPos, img.topPos);
  37297. if (!this.ctx_scaled) {
  37298. this.ctx.scale(this.getCanvasScale(), this.getCanvasScale());
  37299. this.ctx_scaled = true;
  37300. }
  37301. if (!this.last_img) {
  37302. // This is the first receivd image, so we draw it
  37303. this.ctx.drawImage(this.offscreenCanvas, 0, 0);
  37304. }
  37305. this.last_img = img;
  37306. }
  37307. /**
  37308. * Draws a gif frame at a specific index inside the canvas.
  37309. * @param { Number } i - The frame index
  37310. */
  37311. putFrame(i) {
  37312. let show_pause_on_hover = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  37313. i = parseInt(i, 10);
  37314. if (i > this.frames.length - 1) {
  37315. i = 0;
  37316. }
  37317. if (i < 0) {
  37318. i = 0;
  37319. }
  37320. const offset = this.frame_offsets[i];
  37321. this.offscreenCanvas.getContext('2d').putImageData(this.frames[i].data, offset.x, offset.y);
  37322. this.ctx.globalCompositeOperation = 'copy';
  37323. this.ctx.drawImage(this.offscreenCanvas, 0, 0);
  37324. if (show_pause_on_hover && this.hovering) {
  37325. this.drawPauseIcon();
  37326. }
  37327. }
  37328. clear() {
  37329. this.transparency = null;
  37330. this.last_disposal_method = this.disposal_method;
  37331. this.disposal_method = null;
  37332. this.frame = null;
  37333. }
  37334. /**
  37335. * Start playing the gif
  37336. */
  37337. play() {
  37338. this.playing = true;
  37339. requestAnimationFrame(ts => this.onAnimationFrame(ts, 0, 0));
  37340. }
  37341. /**
  37342. * Pause the gif
  37343. */
  37344. pause() {
  37345. this.playing = false;
  37346. requestAnimationFrame(() => this.drawPlayIcon());
  37347. }
  37348. drawPauseIcon() {
  37349. if (!this.playing) {
  37350. return;
  37351. } // Clear the potential play button by re-rendering the current frame
  37352. this.putFrame(this.frame_idx, false);
  37353. this.ctx.globalCompositeOperation = 'source-over'; // Draw dark overlay
  37354. this.ctx.fillStyle = 'rgb(0, 0, 0, 0.25)';
  37355. this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
  37356. const icon_size = this.canvas.height * 0.1; // Draw bars
  37357. this.ctx.lineWidth = this.canvas.height * 0.04;
  37358. this.ctx.beginPath();
  37359. this.ctx.moveTo(this.canvas.width / 2 - icon_size / 2, this.canvas.height / 2 - icon_size);
  37360. this.ctx.lineTo(this.canvas.width / 2 - icon_size / 2, this.canvas.height / 2 + icon_size);
  37361. this.ctx.fillStyle = 'rgb(200, 200, 200, 0.75)';
  37362. this.ctx.stroke();
  37363. this.ctx.beginPath();
  37364. this.ctx.moveTo(this.canvas.width / 2 + icon_size / 2, this.canvas.height / 2 - icon_size);
  37365. this.ctx.lineTo(this.canvas.width / 2 + icon_size / 2, this.canvas.height / 2 + icon_size);
  37366. this.ctx.fillStyle = 'rgb(200, 200, 200, 0.75)';
  37367. this.ctx.stroke(); // Draw circle
  37368. this.ctx.lineWidth = this.canvas.height * 0.02;
  37369. this.ctx.strokeStyle = 'rgb(200, 200, 200, 0.75)';
  37370. this.ctx.beginPath();
  37371. this.ctx.arc(this.canvas.width / 2, this.canvas.height / 2, icon_size * 1.5, 0, 2 * Math.PI);
  37372. this.ctx.stroke();
  37373. }
  37374. drawPlayIcon() {
  37375. if (this.playing) {
  37376. return;
  37377. } // Clear the potential pause button by re-rendering the current frame
  37378. this.putFrame(this.frame_idx, false);
  37379. this.ctx.globalCompositeOperation = 'source-over'; // Draw dark overlay
  37380. this.ctx.fillStyle = 'rgb(0, 0, 0, 0.25)';
  37381. this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); // Draw triangle
  37382. const triangle_size = this.canvas.height * 0.1;
  37383. const region = new Path2D();
  37384. region.moveTo(this.canvas.width / 2 + triangle_size, this.canvas.height / 2); // start at the pointy end
  37385. region.lineTo(this.canvas.width / 2 - triangle_size / 2, this.canvas.height / 2 + triangle_size);
  37386. region.lineTo(this.canvas.width / 2 - triangle_size / 2, this.canvas.height / 2 - triangle_size);
  37387. region.closePath();
  37388. this.ctx.fillStyle = 'rgb(200, 200, 200, 0.75)';
  37389. this.ctx.fill(region); // Draw circle
  37390. const circle_size = triangle_size * 1.5;
  37391. this.ctx.lineWidth = this.canvas.height * 0.02;
  37392. this.ctx.strokeStyle = 'rgb(200, 200, 200, 0.75)';
  37393. this.ctx.beginPath();
  37394. this.ctx.arc(this.canvas.width / 2, this.canvas.height / 2, circle_size, 0, 2 * Math.PI);
  37395. this.ctx.stroke();
  37396. }
  37397. doDecodeProgress(stream, draw) {
  37398. this.doShowProgress(stream.pos, stream.data.length, draw);
  37399. }
  37400. /**
  37401. * @param{boolean=} draw Whether to draw progress bar or not;
  37402. * this is not idempotent because of translucency.
  37403. * Note that this means that the text will be unsynchronized
  37404. * with the progress bar on non-frames;
  37405. * but those are typically so small (GCE etc.) that it doesn't really matter
  37406. */
  37407. withProgress(stream, fn, draw) {
  37408. return block => {
  37409. fn === null || fn === void 0 ? void 0 : fn(block);
  37410. this.doDecodeProgress(stream, draw);
  37411. };
  37412. }
  37413. getCanvasScale() {
  37414. let scale;
  37415. if (this.options.max_width && this.hdr && this.hdr.width > this.options.max_width) {
  37416. scale = this.options.max_width / this.hdr.width;
  37417. } else {
  37418. scale = 1;
  37419. }
  37420. return scale;
  37421. }
  37422. /**
  37423. * Makes an HTTP request to fetch a GIF
  37424. * @param { String } url
  37425. * @returns { Promise<String> } Returns a promise which resolves with the response data.
  37426. */
  37427. fetchGIF(url) {
  37428. const promise = getOpenPromise();
  37429. const h = new XMLHttpRequest();
  37430. h.open('GET', url, true);
  37431. h === null || h === void 0 ? void 0 : h.overrideMimeType('text/plain; charset=x-user-defined');
  37432. h.onload = () => {
  37433. if (h.status != 200) {
  37434. this.showError('xhr - response');
  37435. return promise.reject();
  37436. }
  37437. promise.resolve(h.response);
  37438. };
  37439. h.onprogress = e => e.lengthComputable && this.doShowProgress(e.loaded, e.total, true);
  37440. h.onerror = () => this.showError('xhr');
  37441. h.send();
  37442. return promise;
  37443. }
  37444. }
  37445. ;// CONCATENATED MODULE: ./src/templates/file.js
  37446. /* harmony default export */ const file = ((url, name) => {
  37447. const i18n_download = __('Download file "%1$s"', name);
  37448. return $`<a target="_blank" rel="noopener" href="${url}">${i18n_download}</a>`;
  37449. });
  37450. ;// CONCATENATED MODULE: ./src/templates/form_captcha.js
  37451. /* harmony default export */ const form_captcha = (o => $`
  37452. <fieldset class="form-group">
  37453. ${o.label ? $`<label>${o.label}</label>` : ''}
  37454. <img src="data:${o.type};base64,${o.data}">
  37455. <input name="${o.name}" type="text" ?required="${o.required}" />
  37456. </fieldset>
  37457. `);
  37458. ;// CONCATENATED MODULE: ./src/templates/form_checkbox.js
  37459. /* harmony default export */ const form_checkbox = (o => $`
  37460. <fieldset class="form-group">
  37461. <input id="${o.id}" name="${o.name}" type="checkbox" ?checked=${o.checked} ?required=${o.required} />
  37462. <label class="form-check-label" for="${o.id}">${o.label}</label>
  37463. </fieldset>`);
  37464. ;// CONCATENATED MODULE: ./src/templates/form_help.js
  37465. /* harmony default export */ const form_help = (o => $`<p class="form-help">${o.text}</p>`);
  37466. ;// CONCATENATED MODULE: ./src/templates/form_input.js
  37467. /* harmony default export */ const form_input = (o => $`
  37468. <div class="form-group">
  37469. ${o.type !== 'hidden' ? $`<label for="${o.id}">${o.label}</label>` : ''}
  37470. <!-- This is a hack to prevent Chrome from auto-filling the username in
  37471. any of the other input fields in the MUC configuration form. -->
  37472. ${o.type === 'password' && o.fixed_username ? $`
  37473. <input class="hidden-username" type="text" autocomplete="username" value="${o.fixed_username}"></input>
  37474. ` : ''}
  37475. <input
  37476. autocomplete="${o.autocomplete || ''}"
  37477. class="form-control"
  37478. id="${o.id}"
  37479. name="${o.name}"
  37480. placeholder="${o.placeholder || ''}"
  37481. type="${o.type}"
  37482. value="${o.value || ''}"
  37483. ?required=${o.required} />
  37484. </div>`);
  37485. ;// CONCATENATED MODULE: ./src/templates/form_select.js
  37486. const tpl_option = o => $`<option value="${o.value}" ?selected="${o.selected}">${o.label}</option>`;
  37487. /* harmony default export */ const form_select = (o => {
  37488. var _o$options;
  37489. return $`
  37490. <div class="form-group">
  37491. <label for="${o.id}">${o.label}</label>
  37492. <select class="form-control" id="${o.id}" name="${o.name}" ?multiple="${o.multiple}">
  37493. ${(_o$options = o.options) === null || _o$options === void 0 ? void 0 : _o$options.map(o => tpl_option(o))}
  37494. </select>
  37495. </div>`;
  37496. });
  37497. ;// CONCATENATED MODULE: ./src/templates/form_textarea.js
  37498. /* harmony default export */ const form_textarea = (o => $`
  37499. <label class="label-ta">${o.label}</label>
  37500. <textarea name="${o.name}">${o.value}</textarea>
  37501. `);
  37502. ;// CONCATENATED MODULE: ./src/templates/form_url.js
  37503. /* harmony default export */ const form_url = (o => $`
  37504. <label>${o.label}
  37505. <a class="form-url" target="_blank" rel="noopener" href="${o.value}">${o.value}</a>
  37506. </label>`);
  37507. ;// CONCATENATED MODULE: ./src/templates/form_username.js
  37508. /* harmony default export */ const form_username = (o => $`
  37509. <div class="form-group">
  37510. ${o.label ? $`<label>${o.label}</label>` : ''}
  37511. <div class="input-group">
  37512. <div class="input-group-prepend">
  37513. <input name="${o.name}"
  37514. type="${o.type}"
  37515. value="${o.value || ''}"
  37516. ?required="${o.required}" />
  37517. <div class="input-group-text col" title="${o.domain}">${o.domain}</div>
  37518. </div>
  37519. </div>
  37520. </div>`);
  37521. ;// CONCATENATED MODULE: ./src/templates/hyperlink.js
  37522. function onClickXMPPURI(ev) {
  37523. ev.preventDefault();
  37524. core_api.rooms.open(ev.target.href);
  37525. }
  37526. /* harmony default export */ const hyperlink = ((uri, url_text) => {
  37527. let href_text = uri.normalizePath().toString();
  37528. if (!uri._parts.protocol && !url_text.startsWith('http://') && !url_text.startsWith('https://')) {
  37529. href_text = 'http://' + href_text;
  37530. }
  37531. if (uri._parts.protocol === 'xmpp' && uri._parts.query === 'join') {
  37532. return $`
  37533. <a target="_blank"
  37534. rel="noopener"
  37535. @click=${onClickXMPPURI}
  37536. href="${href_text}">${url_text}</a>`;
  37537. }
  37538. return $`<a target="_blank" rel="noopener" href="${href_text}">${url_text}</a>`;
  37539. });
  37540. ;// CONCATENATED MODULE: ./src/templates/video.js
  37541. /* harmony default export */ const video = ((url, hide_url) => $`<video controls preload="metadata" src="${url}"></video>${hide_url ? '' : $`<a target="_blank" rel="noopener" href="${url}">${url}</a>`}`);
  37542. ;// CONCATENATED MODULE: ./src/utils/html.js
  37543. /**
  37544. * @copyright 2022, the Converse.js contributors
  37545. * @license Mozilla Public License (MPLv2)
  37546. * @description This is the DOM/HTML utilities module.
  37547. */
  37548. const {
  37549. sizzle: html_sizzle
  37550. } = core_converse.env;
  37551. const APPROVED_URL_PROTOCOLS = ['http', 'https', 'xmpp', 'mailto'];
  37552. function getAutoCompleteProperty(name, options) {
  37553. return {
  37554. 'muc#roomconfig_lang': 'language',
  37555. 'muc#roomconfig_roomsecret': options !== null && options !== void 0 && options.new_password ? 'new-password' : 'current-password'
  37556. }[name];
  37557. }
  37558. const XFORM_TYPE_MAP = {
  37559. 'text-private': 'password',
  37560. 'text-single': 'text',
  37561. 'fixed': 'label',
  37562. 'boolean': 'checkbox',
  37563. 'hidden': 'hidden',
  37564. 'jid-multi': 'textarea',
  37565. 'list-single': 'dropdown',
  37566. 'list-multi': 'dropdown'
  37567. };
  37568. const XFORM_VALIDATE_TYPE_MAP = {
  37569. 'xs:anyURI': 'url',
  37570. 'xs:byte': 'number',
  37571. 'xs:date': 'date',
  37572. 'xs:dateTime': 'datetime',
  37573. 'xs:int': 'number',
  37574. 'xs:integer': 'number',
  37575. 'xs:time': 'time'
  37576. };
  37577. function getInputType(field) {
  37578. const type = XFORM_TYPE_MAP[field.getAttribute('type')];
  37579. if (type == 'text') {
  37580. const datatypes = field.getElementsByTagNameNS("http://jabber.org/protocol/xdata-validate", "validate");
  37581. if (datatypes.length === 1) {
  37582. const datatype = datatypes[0].getAttribute("datatype");
  37583. return XFORM_VALIDATE_TYPE_MAP[datatype] || type;
  37584. }
  37585. }
  37586. return type;
  37587. }
  37588. function slideOutWrapup(el) {
  37589. /* Wrapup function for slideOut. */
  37590. el.removeAttribute('data-slider-marker');
  37591. el.classList.remove('collapsed');
  37592. el.style.overflow = '';
  37593. el.style.height = '';
  37594. }
  37595. function getFileName(uri) {
  37596. try {
  37597. return decodeURI(uri.filename());
  37598. } catch (error) {
  37599. headless_log.debug(error);
  37600. return uri.filename();
  37601. }
  37602. }
  37603. /**
  37604. * Returns the markup for a URL that points to a downloadable asset
  37605. * (such as a video, image or audio file).
  37606. * @method u#getOOBURLMarkup
  37607. * @param { String } url
  37608. * @returns { String }
  37609. */
  37610. function getOOBURLMarkup(url) {
  37611. const uri = getURI(url);
  37612. if (uri === null) {
  37613. return url;
  37614. }
  37615. if (isVideoURL(uri)) {
  37616. return video(url);
  37617. } else if (isAudioURL(uri)) {
  37618. return audio(url);
  37619. } else if (isImageURL(uri)) {
  37620. return file(uri.toString(), getFileName(uri));
  37621. } else {
  37622. return file(uri.toString(), getFileName(uri));
  37623. }
  37624. }
  37625. /**
  37626. * Return the height of the passed in DOM element,
  37627. * based on the heights of its children.
  37628. * @method u#calculateElementHeight
  37629. * @param {HTMLElement} el
  37630. * @returns {integer}
  37631. */
  37632. utils_core.calculateElementHeight = function (el) {
  37633. return Array.from(el.children).reduce((result, child) => result + child.offsetHeight, 0);
  37634. };
  37635. utils_core.getNextElement = function (el) {
  37636. let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '*';
  37637. let next_el = el.nextElementSibling;
  37638. while (next_el !== null && !html_sizzle.matchesSelector(next_el, selector)) {
  37639. next_el = next_el.nextElementSibling;
  37640. }
  37641. return next_el;
  37642. };
  37643. utils_core.getPreviousElement = function (el) {
  37644. let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '*';
  37645. let prev_el = el.previousElementSibling;
  37646. while (prev_el !== null && !html_sizzle.matchesSelector(prev_el, selector)) {
  37647. prev_el = prev_el.previousElementSibling;
  37648. }
  37649. return prev_el;
  37650. };
  37651. utils_core.getFirstChildElement = function (el) {
  37652. let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '*';
  37653. let first_el = el.firstElementChild;
  37654. while (first_el !== null && !html_sizzle.matchesSelector(first_el, selector)) {
  37655. first_el = first_el.nextElementSibling;
  37656. }
  37657. return first_el;
  37658. };
  37659. utils_core.getLastChildElement = function (el) {
  37660. let selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '*';
  37661. let last_el = el.lastElementChild;
  37662. while (last_el !== null && !html_sizzle.matchesSelector(last_el, selector)) {
  37663. last_el = last_el.previousElementSibling;
  37664. }
  37665. return last_el;
  37666. };
  37667. utils_core.hasClass = function (className, el) {
  37668. return el instanceof Element && el.classList.contains(className);
  37669. };
  37670. utils_core.toggleClass = function (className, el) {
  37671. utils_core.hasClass(className, el) ? utils_core.removeClass(className, el) : utils_core.addClass(className, el);
  37672. };
  37673. /**
  37674. * Add a class to an element.
  37675. * @method u#addClass
  37676. * @param {string} className
  37677. * @param {Element} el
  37678. */
  37679. utils_core.addClass = function (className, el) {
  37680. el instanceof Element && el.classList.add(className);
  37681. return el;
  37682. };
  37683. /**
  37684. * Remove a class from an element.
  37685. * @method u#removeClass
  37686. * @param {string} className
  37687. * @param {Element} el
  37688. */
  37689. utils_core.removeClass = function (className, el) {
  37690. el instanceof Element && el.classList.remove(className);
  37691. return el;
  37692. };
  37693. utils_core.removeElement = function (el) {
  37694. el instanceof Element && el.parentNode && el.parentNode.removeChild(el);
  37695. return el;
  37696. };
  37697. utils_core.getElementFromTemplateResult = function (tr) {
  37698. const div = document.createElement('div');
  37699. x(tr, div);
  37700. return div.firstElementChild;
  37701. };
  37702. utils_core.showElement = el => {
  37703. utils_core.removeClass('collapsed', el);
  37704. utils_core.removeClass('hidden', el);
  37705. };
  37706. utils_core.hideElement = function (el) {
  37707. el instanceof Element && el.classList.add('hidden');
  37708. return el;
  37709. };
  37710. function ancestor(el, selector) {
  37711. let parent = el;
  37712. while (parent !== null && !html_sizzle.matchesSelector(parent, selector)) {
  37713. parent = parent.parentElement;
  37714. }
  37715. return parent;
  37716. }
  37717. /**
  37718. * Return the element's siblings until one matches the selector.
  37719. * @private
  37720. * @method u#nextUntil
  37721. * @param { HTMLElement } el
  37722. * @param { String } selector
  37723. */
  37724. utils_core.nextUntil = function (el, selector) {
  37725. const matches = [];
  37726. let sibling_el = el.nextElementSibling;
  37727. while (sibling_el !== null && !sibling_el.matches(selector)) {
  37728. matches.push(sibling_el);
  37729. sibling_el = sibling_el.nextElementSibling;
  37730. }
  37731. return matches;
  37732. };
  37733. /**
  37734. * Helper method that replace HTML-escaped symbols with equivalent characters
  37735. * (e.g. transform occurrences of '&amp;' to '&')
  37736. * @private
  37737. * @method u#unescapeHTML
  37738. * @param { String } string - a String containing the HTML-escaped symbols.
  37739. */
  37740. utils_core.unescapeHTML = function (string) {
  37741. var div = document.createElement('div');
  37742. div.innerHTML = string;
  37743. return div.innerText;
  37744. };
  37745. utils_core.escapeHTML = function (string) {
  37746. return string.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  37747. };
  37748. function isProtocolApproved(protocol) {
  37749. let safeProtocolsList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : APPROVED_URL_PROTOCOLS;
  37750. return !!safeProtocolsList.includes(protocol);
  37751. } // Will return false if URL is malformed or contains disallowed characters
  37752. function isUrlValid(urlString) {
  37753. try {
  37754. const url = new URL(urlString);
  37755. return !!url;
  37756. } catch (error) {
  37757. return false;
  37758. }
  37759. }
  37760. function getHyperlinkTemplate(url) {
  37761. const http_url = RegExp('^w{3}.', 'ig').test(url) ? `http://${url}` : url;
  37762. const uri = getURI(url);
  37763. if (uri !== null && isUrlValid(http_url) && (isProtocolApproved(uri._parts.protocol) || !uri._parts.protocol)) {
  37764. return hyperlink(uri, url);
  37765. }
  37766. return url;
  37767. }
  37768. utils_core.slideInAllElements = function (elements) {
  37769. let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
  37770. return Promise.all(Array.from(elements).map(e => utils_core.slideIn(e, duration)));
  37771. };
  37772. utils_core.slideToggleElement = function (el, duration) {
  37773. if (utils_core.hasClass('collapsed', el) || utils_core.hasClass('hidden', el)) {
  37774. return utils_core.slideOut(el, duration);
  37775. } else {
  37776. return utils_core.slideIn(el, duration);
  37777. }
  37778. };
  37779. /**
  37780. * Shows/expands an element by sliding it out of itself
  37781. * @private
  37782. * @method u#slideOut
  37783. * @param { HTMLElement } el - The HTML string
  37784. * @param { Number } duration - The duration amount in milliseconds
  37785. */
  37786. utils_core.slideOut = function (el) {
  37787. let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  37788. return new Promise((resolve, reject) => {
  37789. if (!el) {
  37790. const err = 'An element needs to be passed in to slideOut';
  37791. headless_log.warn(err);
  37792. reject(new Error(err));
  37793. return;
  37794. }
  37795. const marker = el.getAttribute('data-slider-marker');
  37796. if (marker) {
  37797. el.removeAttribute('data-slider-marker');
  37798. window.cancelAnimationFrame(marker);
  37799. }
  37800. const end_height = utils_core.calculateElementHeight(el);
  37801. if (window.converse_disable_effects) {
  37802. // Effects are disabled (for tests)
  37803. el.style.height = end_height + 'px';
  37804. slideOutWrapup(el);
  37805. resolve();
  37806. return;
  37807. }
  37808. if (!utils_core.hasClass('collapsed', el) && !utils_core.hasClass('hidden', el)) {
  37809. resolve();
  37810. return;
  37811. }
  37812. const steps = duration / 17; // We assume 17ms per animation which is ~60FPS
  37813. let height = 0;
  37814. function draw() {
  37815. height += end_height / steps;
  37816. if (height < end_height) {
  37817. el.style.height = height + 'px';
  37818. el.setAttribute('data-slider-marker', window.requestAnimationFrame(draw));
  37819. } else {
  37820. // We recalculate the height to work around an apparent
  37821. // browser bug where browsers don't know the correct
  37822. // offsetHeight beforehand.
  37823. el.removeAttribute('data-slider-marker');
  37824. el.style.height = utils_core.calculateElementHeight(el) + 'px';
  37825. el.style.overflow = '';
  37826. el.style.height = '';
  37827. resolve();
  37828. }
  37829. }
  37830. el.style.height = '0';
  37831. el.style.overflow = 'hidden';
  37832. el.classList.remove('hidden');
  37833. el.classList.remove('collapsed');
  37834. el.setAttribute('data-slider-marker', window.requestAnimationFrame(draw));
  37835. });
  37836. };
  37837. utils_core.slideIn = function (el) {
  37838. let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  37839. /* Hides/collapses an element by sliding it into itself. */
  37840. return new Promise((resolve, reject) => {
  37841. if (!el) {
  37842. const err = 'An element needs to be passed in to slideIn';
  37843. headless_log.warn(err);
  37844. return reject(new Error(err));
  37845. } else if (utils_core.hasClass('collapsed', el)) {
  37846. return resolve(el);
  37847. } else if (window.converse_disable_effects) {
  37848. // Effects are disabled (for tests)
  37849. el.classList.add('collapsed');
  37850. el.style.height = '';
  37851. return resolve(el);
  37852. }
  37853. const marker = el.getAttribute('data-slider-marker');
  37854. if (marker) {
  37855. el.removeAttribute('data-slider-marker');
  37856. window.cancelAnimationFrame(marker);
  37857. }
  37858. const original_height = el.offsetHeight,
  37859. steps = duration / 17; // We assume 17ms per animation which is ~60FPS
  37860. let height = original_height;
  37861. el.style.overflow = 'hidden';
  37862. function draw() {
  37863. height -= original_height / steps;
  37864. if (height > 0) {
  37865. el.style.height = height + 'px';
  37866. el.setAttribute('data-slider-marker', window.requestAnimationFrame(draw));
  37867. } else {
  37868. el.removeAttribute('data-slider-marker');
  37869. el.classList.add('collapsed');
  37870. el.style.height = '';
  37871. resolve(el);
  37872. }
  37873. }
  37874. el.setAttribute('data-slider-marker', window.requestAnimationFrame(draw));
  37875. });
  37876. };
  37877. function afterAnimationEnds(el, callback) {
  37878. el.classList.remove('visible');
  37879. if (lodash_es_isFunction(callback)) {
  37880. callback();
  37881. }
  37882. }
  37883. utils_core.isInDOM = function (el) {
  37884. return document.querySelector('body').contains(el);
  37885. };
  37886. utils_core.isVisible = function (el) {
  37887. if (el === null) {
  37888. return false;
  37889. }
  37890. if (utils_core.hasClass('hidden', el)) {
  37891. return false;
  37892. } // XXX: Taken from jQuery's "visible" implementation
  37893. return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
  37894. };
  37895. utils_core.fadeIn = function (el, callback) {
  37896. if (!el) {
  37897. headless_log.warn('An element needs to be passed in to fadeIn');
  37898. }
  37899. if (window.converse_disable_effects) {
  37900. el.classList.remove('hidden');
  37901. return afterAnimationEnds(el, callback);
  37902. }
  37903. if (utils_core.hasClass('hidden', el)) {
  37904. el.classList.add('visible');
  37905. el.classList.remove('hidden');
  37906. el.addEventListener('webkitAnimationEnd', () => afterAnimationEnds(el, callback));
  37907. el.addEventListener('animationend', () => afterAnimationEnds(el, callback));
  37908. el.addEventListener('oanimationend', () => afterAnimationEnds(el, callback));
  37909. } else {
  37910. afterAnimationEnds(el, callback);
  37911. }
  37912. };
  37913. /**
  37914. * Takes an XML field in XMPP XForm (XEP-004: Data Forms) format returns a
  37915. * [TemplateResult](https://lit.polymer-project.org/api/classes/_lit_html_.templateresult.html).
  37916. * @method u#xForm2TemplateResult
  37917. * @param { XMLElement } field - the field to convert
  37918. * @param { XMLElement } stanza - the containing stanza
  37919. * @param { Object } options
  37920. * @returns { TemplateResult }
  37921. */
  37922. utils_core.xForm2TemplateResult = function (field, stanza, options) {
  37923. if (field.getAttribute('type') === 'list-single' || field.getAttribute('type') === 'list-multi') {
  37924. const values = utils_core.queryChildren(field, 'value').map(el => el === null || el === void 0 ? void 0 : el.textContent);
  37925. const options = utils_core.queryChildren(field, 'option').map(option => {
  37926. var _option$querySelector;
  37927. const value = (_option$querySelector = option.querySelector('value')) === null || _option$querySelector === void 0 ? void 0 : _option$querySelector.textContent;
  37928. return {
  37929. 'value': value,
  37930. 'label': option.getAttribute('label'),
  37931. 'selected': values.includes(value),
  37932. 'required': !!field.querySelector('required')
  37933. };
  37934. });
  37935. return form_select({
  37936. options,
  37937. 'id': utils_core.getUniqueId(),
  37938. 'label': field.getAttribute('label'),
  37939. 'multiple': field.getAttribute('type') === 'list-multi',
  37940. 'name': field.getAttribute('var'),
  37941. 'required': !!field.querySelector('required')
  37942. });
  37943. } else if (field.getAttribute('type') === 'fixed') {
  37944. var _field$querySelector;
  37945. const text = (_field$querySelector = field.querySelector('value')) === null || _field$querySelector === void 0 ? void 0 : _field$querySelector.textContent;
  37946. return form_help({
  37947. text
  37948. });
  37949. } else if (field.getAttribute('type') === 'jid-multi') {
  37950. var _field$querySelector2;
  37951. return form_textarea({
  37952. 'name': field.getAttribute('var'),
  37953. 'label': field.getAttribute('label') || '',
  37954. 'value': (_field$querySelector2 = field.querySelector('value')) === null || _field$querySelector2 === void 0 ? void 0 : _field$querySelector2.textContent,
  37955. 'required': !!field.querySelector('required')
  37956. });
  37957. } else if (field.getAttribute('type') === 'boolean') {
  37958. var _field$querySelector3;
  37959. const value = (_field$querySelector3 = field.querySelector('value')) === null || _field$querySelector3 === void 0 ? void 0 : _field$querySelector3.textContent;
  37960. return form_checkbox({
  37961. 'id': utils_core.getUniqueId(),
  37962. 'name': field.getAttribute('var'),
  37963. 'label': field.getAttribute('label') || '',
  37964. 'checked': (value === '1' || value === 'true') && 'checked="1"' || '',
  37965. 'required': !!field.querySelector('required')
  37966. });
  37967. } else if (field.getAttribute('var') === 'url') {
  37968. var _field$querySelector4;
  37969. return form_url({
  37970. 'label': field.getAttribute('label') || '',
  37971. 'value': (_field$querySelector4 = field.querySelector('value')) === null || _field$querySelector4 === void 0 ? void 0 : _field$querySelector4.textContent
  37972. });
  37973. } else if (field.getAttribute('var') === 'username') {
  37974. var _field$querySelector5;
  37975. return form_username({
  37976. 'domain': ' @' + options.domain,
  37977. 'name': field.getAttribute('var'),
  37978. 'type': getInputType(field),
  37979. 'label': field.getAttribute('label') || '',
  37980. 'value': (_field$querySelector5 = field.querySelector('value')) === null || _field$querySelector5 === void 0 ? void 0 : _field$querySelector5.textContent,
  37981. 'required': !!field.querySelector('required')
  37982. });
  37983. } else if (field.getAttribute('var') === 'ocr') {
  37984. // Captcha
  37985. const uri = field.querySelector('uri');
  37986. const el = html_sizzle('data[cid="' + uri.textContent.replace(/^cid:/, '') + '"]', stanza)[0];
  37987. return form_captcha({
  37988. 'label': field.getAttribute('label'),
  37989. 'name': field.getAttribute('var'),
  37990. 'data': el === null || el === void 0 ? void 0 : el.textContent,
  37991. 'type': uri.getAttribute('type'),
  37992. 'required': !!field.querySelector('required')
  37993. });
  37994. } else {
  37995. var _field$querySelector6;
  37996. const name = field.getAttribute('var');
  37997. return form_input({
  37998. 'id': utils_core.getUniqueId(),
  37999. 'label': field.getAttribute('label') || '',
  38000. 'name': name,
  38001. 'fixed_username': options === null || options === void 0 ? void 0 : options.fixed_username,
  38002. 'autocomplete': getAutoCompleteProperty(name, options),
  38003. 'placeholder': null,
  38004. 'required': !!field.querySelector('required'),
  38005. 'type': getInputType(field),
  38006. 'value': (_field$querySelector6 = field.querySelector('value')) === null || _field$querySelector6 === void 0 ? void 0 : _field$querySelector6.textContent
  38007. });
  38008. }
  38009. };
  38010. Object.assign(utils_core, {
  38011. getOOBURLMarkup,
  38012. ancestor
  38013. });
  38014. /* harmony default export */ const html = (utils_core);
  38015. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/components/styles/gif.scss
  38016. var gif = __webpack_require__(4903);
  38017. ;// CONCATENATED MODULE: ./src/shared/components/styles/gif.scss
  38018. var gif_options = {};
  38019. gif_options.styleTagTransform = (styleTagTransform_default());
  38020. gif_options.setAttributes = (setAttributesWithoutAttributes_default());
  38021. gif_options.insert = insertBySelector_default().bind(null, "head");
  38022. gif_options.domAPI = (styleDomAPI_default());
  38023. gif_options.insertStyleElement = (insertStyleElement_default());
  38024. var gif_update = injectStylesIntoStyleTag_default()(gif/* default */.Z, gif_options);
  38025. /* harmony default export */ const styles_gif = (gif/* default */.Z && gif/* default.locals */.Z.locals ? gif/* default.locals */.Z.locals : undefined);
  38026. ;// CONCATENATED MODULE: ./src/shared/components/gif.js
  38027. class ConverseGIFElement extends CustomElement {
  38028. static get properties() {
  38029. /**
  38030. * @typedef { Object } ConverseGIFComponentProperties
  38031. * @property { Boolean } autoplay
  38032. * @property { Boolean } noloop
  38033. * @property { String } progress_color
  38034. * @property { String } nick
  38035. * @property { ('url'|'empty'|'error') } fallback
  38036. * @property { String } src
  38037. */
  38038. return {
  38039. 'autoplay': {
  38040. type: Boolean
  38041. },
  38042. 'noloop': {
  38043. type: Boolean
  38044. },
  38045. 'progress_color': {
  38046. type: String
  38047. },
  38048. 'fallback': {
  38049. type: String
  38050. },
  38051. 'src': {
  38052. type: String
  38053. }
  38054. };
  38055. }
  38056. constructor() {
  38057. super();
  38058. this.autoplay = false;
  38059. this.noloop = false;
  38060. this.fallback = 'url';
  38061. }
  38062. initGIF() {
  38063. const options = {
  38064. 'autoplay': this.autoplay,
  38065. 'loop': !this.noloop
  38066. };
  38067. if (this.progress_color) {
  38068. options['progress_color'] = this.progress_color;
  38069. }
  38070. this.supergif = new ConverseGif(this, options);
  38071. }
  38072. updated(changed) {
  38073. if (!this.supergif || changed.has('src')) {
  38074. this.initGIF();
  38075. return;
  38076. }
  38077. if (changed.has('autoplay')) {
  38078. this.supergif.options.autoplay = this.autoplay;
  38079. }
  38080. if (changed.has('noloop')) {
  38081. this.supergif.options.loop = !this.noloop;
  38082. }
  38083. if (changed.has('progress_color')) {
  38084. this.supergif.options.progress_color = this.progress_color;
  38085. }
  38086. }
  38087. render() {
  38088. var _this$supergif;
  38089. return (_this$supergif = this.supergif) !== null && _this$supergif !== void 0 && _this$supergif.load_error && ['url', 'empty'].includes(this.fallback) ? this.renderErrorFallback() : $`<canvas class="gif-canvas"
  38090. @mouseover=${() => this.setHover()}
  38091. @mouseleave=${() => this.unsetHover()}
  38092. @click=${ev => this.onControlsClicked(ev)}><img class="gif" src="${this.src}"></a></canvas>`;
  38093. }
  38094. renderErrorFallback() {
  38095. if (this.fallback === 'url') {
  38096. return getHyperlinkTemplate(this.src);
  38097. } else if (this.fallback === 'empty') {
  38098. return '';
  38099. }
  38100. }
  38101. setHover() {
  38102. if (this.supergif) {
  38103. this.supergif.hovering = true;
  38104. this.hover_timeout && clearTimeout(this.hover_timeout);
  38105. this.hover_timeout = setTimeout(() => this.unsetHover(), 2000);
  38106. }
  38107. }
  38108. unsetHover() {
  38109. if (this.supergif) this.supergif.hovering = false;
  38110. }
  38111. onControlsClicked(ev) {
  38112. ev.preventDefault();
  38113. if (this.supergif.playing) {
  38114. this.supergif.pause();
  38115. } else {
  38116. // When the user manually clicks play, we turn on looping
  38117. this.supergif.options.loop = true;
  38118. this.supergif.play();
  38119. }
  38120. }
  38121. }
  38122. core_api.elements.define('converse-gif', ConverseGIFElement);
  38123. ;// CONCATENATED MODULE: ./src/templates/gif.js
  38124. /* harmony default export */ const templates_gif = ((url, hide_url) => $`<converse-gif autoplay noloop fallback='empty' src=${url}></converse-gif>${hide_url ? '' : $`<a target="_blank" rel="noopener" href="${url}">${url}</a>`}`);
  38125. ;// CONCATENATED MODULE: ./node_modules/lit/async-directive.js
  38126. //# sourceMappingURL=async-directive.js.map
  38127. ;// CONCATENATED MODULE: ./src/shared/directives/image.js
  38128. const {
  38129. URI: image_URI
  38130. } = core_converse.env;
  38131. class ImageDirective extends async_directive_d {
  38132. render(src, href, onLoad, onClick) {
  38133. return href ? $`<a href="${href}" class="chat-image__link" target="_blank" rel="noopener">${this.renderImage(src, href, onLoad, onClick)}</a>` : this.renderImage(src, href, onLoad, onClick);
  38134. }
  38135. renderImage(src, href, onLoad, onClick) {
  38136. return $`<img class="chat-image img-thumbnail"
  38137. loading="lazy"
  38138. src="${src}"
  38139. @click=${onClick}
  38140. @error=${() => this.onError(src, href, onLoad, onClick)}
  38141. @load=${onLoad}/></a>`;
  38142. }
  38143. onError(src, href, onLoad, onClick) {
  38144. if (isURLWithImageExtension(src)) {
  38145. href && this.setValue(getHyperlinkTemplate(href));
  38146. } else {
  38147. // Before giving up and falling back to just rendering a hyperlink,
  38148. // we attach `.png` and try one more time.
  38149. // This works with some Imgur URLs
  38150. const uri = new image_URI(src);
  38151. const filename = uri.filename();
  38152. uri.filename(`${filename}.png`);
  38153. this.setValue(renderImage(uri.toString(), href, onLoad, onClick));
  38154. }
  38155. }
  38156. }
  38157. /**
  38158. * lit directive which attempts to render an <img> element from a URL.
  38159. * It will fall back to rendering an <a> element if it can't.
  38160. *
  38161. * @param { String } src - The value that will be assigned to the `src` attribute of the `<img>` element.
  38162. * @param { String } href - The value that will be assigned to the `href` attribute of the `<img>` element.
  38163. * @param { Function } onLoad - A callback function to be called once the image has loaded.
  38164. * @param { Function } onClick - A callback function to be called once the image has been clicked.
  38165. */
  38166. const renderImage = directive_e(ImageDirective);
  38167. ;// CONCATENATED MODULE: ./src/templates/image.js
  38168. /* harmony default export */ const src_templates_image = (o => $`${renderImage(o.src || o.url, o.href, o.onLoad, o.onClick)}`);
  38169. ;// CONCATENATED MODULE: ./src/shared/directives/styling.js
  38170. async function transform(t) {
  38171. try {
  38172. await t.addTemplates();
  38173. } catch (e) {
  38174. headless_log.error(e);
  38175. }
  38176. return t.payload;
  38177. }
  38178. class StylingDirective extends directive_i {
  38179. render(txt, offset, options) {
  38180. // eslint-disable-line class-methods-use-this
  38181. const t = new RichText(txt, offset, Object.assign(options, {
  38182. 'show_images': false,
  38183. 'embed_videos': false,
  38184. 'embed_audio': false
  38185. }));
  38186. return $`${until_c(transform(t), $`${t}`)}`;
  38187. }
  38188. }
  38189. const renderStylingDirectiveBody = directive_e(StylingDirective);
  38190. ;// CONCATENATED MODULE: ./src/shared/styling.js
  38191. /**
  38192. * @copyright 2022, the Converse.js contributors
  38193. * @license Mozilla Public License (MPLv2)
  38194. * @description Utility functions to help with parsing XEP-393 message styling hints
  38195. * @todo Other parsing helpers can be made more abstract and placed here.
  38196. */
  38197. const bracketing_directives = ['*', '_', '~', '`'];
  38198. const styling_directives = [...bracketing_directives, '```', '>'];
  38199. const styling_map = {
  38200. '*': {
  38201. 'name': 'strong',
  38202. 'type': 'span'
  38203. },
  38204. '_': {
  38205. 'name': 'emphasis',
  38206. 'type': 'span'
  38207. },
  38208. '~': {
  38209. 'name': 'strike',
  38210. 'type': 'span'
  38211. },
  38212. '`': {
  38213. 'name': 'preformatted',
  38214. 'type': 'span'
  38215. },
  38216. '```': {
  38217. 'name': 'preformatted_block',
  38218. 'type': 'block'
  38219. },
  38220. '>': {
  38221. 'name': 'quote',
  38222. 'type': 'block'
  38223. }
  38224. };
  38225. const dont_escape = ['_', '>', '`', '~'];
  38226. const styling_templates = {
  38227. // m is the chatbox model
  38228. // i is the offset of this directive relative to the start of the original message
  38229. 'emphasis': (txt, i, options) => $`<span class="styling-directive">_</span><i>${renderStylingDirectiveBody(txt, i, options)}</i><span class="styling-directive">_</span>`,
  38230. 'preformatted': txt => $`<span class="styling-directive">\`</span><code>${txt}</code><span class="styling-directive">\`</span>`,
  38231. 'preformatted_block': txt => $`<div class="styling-directive">\`\`\`</div><code class="block">${txt}</code><div class="styling-directive">\`\`\`</div>`,
  38232. 'quote': (txt, i, options) => $`<blockquote>${renderStylingDirectiveBody(txt, i, options)}</blockquote>`,
  38233. 'strike': (txt, i, options) => $`<span class="styling-directive">~</span><del>${renderStylingDirectiveBody(txt, i, options)}</del><span class="styling-directive">~</span>`,
  38234. 'strong': (txt, i, options) => $`<span class="styling-directive">*</span><b>${renderStylingDirectiveBody(txt, i, options)}</b><span class="styling-directive">*</span>`
  38235. };
  38236. /**
  38237. * Checks whether a given character "d" at index "i" of "text" is a valid opening or closing directive.
  38238. * @param { String } d - The potential directive
  38239. * @param { String } text - The text in which the directive appears
  38240. * @param { Number } i - The directive index
  38241. * @param { Boolean } opening - Check for a valid opening or closing directive
  38242. */
  38243. function isValidDirective(d, text, i, opening) {
  38244. // Ignore directives that are parts of words
  38245. // More info on the Regexes used here: https://javascript.info/regexp-unicode#unicode-properties-p
  38246. if (opening) {
  38247. const regex = RegExp(dont_escape.includes(d) ? `^(\\p{L}|\\p{N})${d}` : `^(\\p{L}|\\p{N})\\${d}`, 'u');
  38248. if (i > 1 && regex.test(text.slice(i - 1))) {
  38249. return false;
  38250. }
  38251. const is_quote = isQuoteDirective(d);
  38252. if (is_quote && i > 0 && text[i - 1] !== '\n') {
  38253. // Quote directives must be on newlines
  38254. return false;
  38255. } else if (bracketing_directives.includes(d) && text[i + 1] === d) {
  38256. // Don't consider empty bracketing directives as valid (e.g. **, `` etc.)
  38257. return false;
  38258. }
  38259. } else {
  38260. const regex = RegExp(dont_escape.includes(d) ? `^${d}(\\p{L}|\\p{N})` : `^\\${d}(\\p{L}|\\p{N})`, 'u');
  38261. if (i < text.length - 1 && regex.test(text.slice(i))) {
  38262. return false;
  38263. }
  38264. if (bracketing_directives.includes(d) && text[i - 1] === d) {
  38265. // Don't consider empty directives as valid (e.g. **, `` etc.)
  38266. return false;
  38267. }
  38268. }
  38269. return true;
  38270. }
  38271. /**
  38272. * Given a specific index "i" of "text", return the directive it matches or
  38273. * null otherwise.
  38274. * @param { String } text - The text in which the directive appears
  38275. * @param { Number } i - The directive index
  38276. * @param { Boolean } opening - Whether we're looking for an opening or closing directive
  38277. */
  38278. function getDirective(text, i) {
  38279. let opening = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  38280. let d;
  38281. if (/(^```\s*\n|^```\s*$)/.test(text.slice(i)) && (i === 0 || text[i - 1] === '\n' || text[i - 1] === '>')) {
  38282. d = text.slice(i, i + 3);
  38283. } else if (styling_directives.includes(text.slice(i, i + 1))) {
  38284. d = text.slice(i, i + 1);
  38285. if (!isValidDirective(d, text, i, opening)) return null;
  38286. } else {
  38287. return null;
  38288. }
  38289. return d;
  38290. }
  38291. /**
  38292. * Given a directive "d", which occurs in "text" at index "i", check that it
  38293. * has a valid closing directive and return the length from start to end of the
  38294. * directive.
  38295. * @param { String } d -The directive
  38296. * @param { Number } i - The directive index
  38297. * @param { String } text -The text in which the directive appears
  38298. */
  38299. function getDirectiveLength(d, text, i) {
  38300. if (!d) {
  38301. return 0;
  38302. }
  38303. const begin = i;
  38304. i += d.length;
  38305. if (isQuoteDirective(d)) {
  38306. i += text.slice(i).split(/\n[^>]/).shift().length;
  38307. return i - begin;
  38308. } else if (styling_map[d].type === 'span') {
  38309. const line = text.slice(i).split('\n').shift();
  38310. let j = 0;
  38311. let idx = line.indexOf(d);
  38312. while (idx !== -1) {
  38313. if (getDirective(text, i + idx, false) === d) {
  38314. return idx + 2 * d.length;
  38315. }
  38316. idx = line.indexOf(d, j++);
  38317. }
  38318. return 0;
  38319. } else {
  38320. // block directives
  38321. const substring = text.slice(i + 1);
  38322. let j = 0;
  38323. let idx = substring.indexOf(d);
  38324. while (idx !== -1) {
  38325. if (getDirective(text, i + 1 + idx, false) === d) {
  38326. return idx + 1 + 2 * d.length;
  38327. }
  38328. idx = substring.indexOf(d, j++);
  38329. }
  38330. return 0;
  38331. }
  38332. }
  38333. function getDirectiveAndLength(text, i) {
  38334. const d = getDirective(text, i);
  38335. const length = d ? getDirectiveLength(d, text, i) : 0;
  38336. return length > 0 ? {
  38337. d,
  38338. length
  38339. } : {};
  38340. }
  38341. const isQuoteDirective = d => ['>', '&gt;'].includes(d);
  38342. function getDirectiveTemplate(d, text, offset, options) {
  38343. const template = styling_templates[styling_map[d].name];
  38344. if (isQuoteDirective(d)) {
  38345. const newtext = text.replace(/\n>/g, '\n') // Don't show the directive itself
  38346. .replace(/\n$/, ''); // Trim line-break at the end
  38347. return template(newtext, offset, options);
  38348. } else {
  38349. return template(text, offset, options);
  38350. }
  38351. }
  38352. function containsDirectives(text) {
  38353. for (let i = 0; i < styling_directives.length; i++) {
  38354. if (text.includes(styling_directives[i])) {
  38355. return true;
  38356. }
  38357. }
  38358. }
  38359. // EXTERNAL MODULE: ./node_modules/lodash/debounce.js
  38360. var lodash_debounce = __webpack_require__(3279);
  38361. var debounce_default = /*#__PURE__*/__webpack_require__.n(lodash_debounce);
  38362. ;// CONCATENATED MODULE: ./src/shared/chat/templates/new-day.js
  38363. /* harmony default export */ const new_day = (o => $`
  38364. <div class="message date-separator" data-isodate="${o.time}">
  38365. <hr class="separator"/>
  38366. <time class="separator-text" datetime="${o.time}"><span>${o.datestring}</span></time>
  38367. </div>
  38368. `);
  38369. ;// CONCATENATED MODULE: ./src/headless/plugins/emoji/regexes.js
  38370. const ASCII_REGEX = '(\\*\\\\0\\/\\*|\\*\\\\O\\/\\*|\\-___\\-|\\:\'\\-\\)|\'\\:\\-\\)|\'\\:\\-D|\\>\\:\\-\\)|>\\:\\-\\)|\'\\:\\-\\(|\\>\\:\\-\\(|>\\:\\-\\(|\\:\'\\-\\(|O\\:\\-\\)|0\\:\\-3|0\\:\\-\\)|0;\\^\\)|O;\\-\\)|0;\\-\\)|O\\:\\-3|\\-__\\-|\\:\\-Þ|\\:\\-Þ|\\<\\/3|<\\/3|\\:\'\\)|\\:\\-D|\'\\:\\)|\'\\=\\)|\'\\:D|\'\\=D|\\>\\:\\)|>\\:\\)|\\>;\\)|>;\\)|\\>\\=\\)|>\\=\\)|;\\-\\)|\\*\\-\\)|;\\-\\]|;\\^\\)|\'\\:\\(|\'\\=\\(|\\:\\-\\*|\\:\\^\\*|\\>\\:P|>\\:P|X\\-P|\\>\\:\\[|>\\:\\[|\\:\\-\\(|\\:\\-\\[|\\>\\:\\(|>\\:\\(|\\:\'\\(|;\\-\\(|\\>\\.\\<|>\\.<|#\\-\\)|%\\-\\)|X\\-\\)|\\\\0\\/|\\\\O\\/|0\\:3|0\\:\\)|O\\:\\)|O\\=\\)|O\\:3|B\\-\\)|8\\-\\)|B\\-D|8\\-D|\\-_\\-|\\>\\:\\\\|>\\:\\\\|\\>\\:\\/|>\\:\\/|\\:\\-\\/|\\:\\-\\.|\\:\\-P|\\:Þ|\\:Þ|\\:\\-b|\\:\\-O|O_O|\\>\\:O|>\\:O|\\:\\-X|\\:\\-#|\\:\\-\\)|\\(y\\)|\\<3|<3|\\:D|\\=D|;\\)|\\*\\)|;\\]|;D|\\:\\*|\\=\\*|\\:\\(|\\:\\[|\\=\\(|\\:@|;\\(|D\\:|\\:\\$|\\=\\$|#\\)|%\\)|X\\)|B\\)|8\\)|\\:\\/|\\:\\\\|\\=\\/|\\=\\\\|\\:L|\\=L|\\:P|\\=P|\\:b|\\:O|\\:X|\\:#|\\=X|\\=#|\\:\\)|\\=\\]|\\=\\)|\\:\\])';
  38371. const ASCII_REPLACE_REGEX = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|((\\s|^)" + ASCII_REGEX + "(?=\\s|$|[!,.?]))", "gi");
  38372. const CODEPOINTS_REGEX = /(?:\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d])|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5\udeeb\udeec\udef4-\udefa\udfe0-\udfeb]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd71\udd73-\udd76\udd7a-\udda2\udda5-\uddaa\uddae-\uddb4\uddb7\uddba\uddbc-\uddca\uddd0\uddde-\uddff\ude70-\ude73\ude78-\ude7a\ude80-\ude82\ude90-\ude95]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g;
  38373. ;// CONCATENATED MODULE: ./src/headless/plugins/emoji/utils.js
  38374. const {
  38375. u: emoji_utils_u
  38376. } = core_converse.env; // Closured cache
  38377. const emojis_by_attribute = {};
  38378. const ASCII_LIST = {
  38379. '*\\0/*': '1f646',
  38380. '*\\O/*': '1f646',
  38381. '-___-': '1f611',
  38382. ':\'-)': '1f602',
  38383. '\':-)': '1f605',
  38384. '\':-D': '1f605',
  38385. '>:-)': '1f606',
  38386. '\':-(': '1f613',
  38387. '>:-(': '1f620',
  38388. ':\'-(': '1f622',
  38389. 'O:-)': '1f607',
  38390. '0:-3': '1f607',
  38391. '0:-)': '1f607',
  38392. '0;^)': '1f607',
  38393. 'O;-)': '1f607',
  38394. '0;-)': '1f607',
  38395. 'O:-3': '1f607',
  38396. '-__-': '1f611',
  38397. ':-Þ': '1f61b',
  38398. '</3': '1f494',
  38399. ':\')': '1f602',
  38400. ':-D': '1f603',
  38401. '\':)': '1f605',
  38402. '\'=)': '1f605',
  38403. '\':D': '1f605',
  38404. '\'=D': '1f605',
  38405. '>:)': '1f606',
  38406. '>;)': '1f606',
  38407. '>=)': '1f606',
  38408. ';-)': '1f609',
  38409. '*-)': '1f609',
  38410. ';-]': '1f609',
  38411. ';^)': '1f609',
  38412. '\':(': '1f613',
  38413. '\'=(': '1f613',
  38414. ':-*': '1f618',
  38415. ':^*': '1f618',
  38416. '>:P': '1f61c',
  38417. 'X-P': '1f61c',
  38418. '>:[': '1f61e',
  38419. ':-(': '1f61e',
  38420. ':-[': '1f61e',
  38421. '>:(': '1f620',
  38422. ':\'(': '1f622',
  38423. ';-(': '1f622',
  38424. '>.<': '1f623',
  38425. '#-)': '1f635',
  38426. '%-)': '1f635',
  38427. 'X-)': '1f635',
  38428. '\\0/': '1f646',
  38429. '\\O/': '1f646',
  38430. '0:3': '1f607',
  38431. '0:)': '1f607',
  38432. 'O:)': '1f607',
  38433. 'O=)': '1f607',
  38434. 'O:3': '1f607',
  38435. 'B-)': '1f60e',
  38436. '8-)': '1f60e',
  38437. 'B-D': '1f60e',
  38438. '8-D': '1f60e',
  38439. '-_-': '1f611',
  38440. '>:\\': '1f615',
  38441. '>:/': '1f615',
  38442. ':-/': '1f615',
  38443. ':-.': '1f615',
  38444. ':-P': '1f61b',
  38445. ':Þ': '1f61b',
  38446. ':-b': '1f61b',
  38447. ':-O': '1f62e',
  38448. 'O_O': '1f62e',
  38449. '>:O': '1f62e',
  38450. ':-X': '1f636',
  38451. ':-#': '1f636',
  38452. ':-)': '1f642',
  38453. '(y)': '1f44d',
  38454. '<3': '2764',
  38455. ':D': '1f603',
  38456. '=D': '1f603',
  38457. ';)': '1f609',
  38458. '*)': '1f609',
  38459. ';]': '1f609',
  38460. ';D': '1f609',
  38461. ':*': '1f618',
  38462. '=*': '1f618',
  38463. ':(': '1f61e',
  38464. ':[': '1f61e',
  38465. '=(': '1f61e',
  38466. ':@': '1f620',
  38467. ';(': '1f622',
  38468. 'D:': '1f628',
  38469. ':$': '1f633',
  38470. '=$': '1f633',
  38471. '#)': '1f635',
  38472. '%)': '1f635',
  38473. 'X)': '1f635',
  38474. 'B)': '1f60e',
  38475. '8)': '1f60e',
  38476. ':/': '1f615',
  38477. ':\\': '1f615',
  38478. '=/': '1f615',
  38479. '=\\': '1f615',
  38480. ':L': '1f615',
  38481. '=L': '1f615',
  38482. ':P': '1f61b',
  38483. '=P': '1f61b',
  38484. ':b': '1f61b',
  38485. ':O': '1f62e',
  38486. ':X': '1f636',
  38487. ':#': '1f636',
  38488. '=X': '1f636',
  38489. '=#': '1f636',
  38490. ':)': '1f642',
  38491. '=]': '1f642',
  38492. '=)': '1f642',
  38493. ':]': '1f642'
  38494. };
  38495. function toCodePoint(unicode_surrogates) {
  38496. const r = [];
  38497. let p = 0;
  38498. let i = 0;
  38499. while (i < unicode_surrogates.length) {
  38500. const c = unicode_surrogates.charCodeAt(i++);
  38501. if (p) {
  38502. r.push((0x10000 + (p - 0xD800 << 10) + (c - 0xDC00)).toString(16));
  38503. p = 0;
  38504. } else if (0xD800 <= c && c <= 0xDBFF) {
  38505. p = c;
  38506. } else {
  38507. r.push(c.toString(16));
  38508. }
  38509. }
  38510. return r.join('-');
  38511. }
  38512. function fromCodePoint(codepoint) {
  38513. let code = typeof codepoint === 'string' ? parseInt(codepoint, 16) : codepoint;
  38514. if (code < 0x10000) {
  38515. return String.fromCharCode(code);
  38516. }
  38517. code -= 0x10000;
  38518. return String.fromCharCode(0xD800 + (code >> 10), 0xDC00 + (code & 0x3FF));
  38519. }
  38520. function convert(unicode) {
  38521. // Converts unicode code points and code pairs to their respective characters
  38522. if (unicode.indexOf("-") > -1) {
  38523. const parts = [],
  38524. s = unicode.split('-');
  38525. for (let i = 0; i < s.length; i++) {
  38526. let part = parseInt(s[i], 16);
  38527. if (part >= 0x10000 && part <= 0x10FFFF) {
  38528. const hi = Math.floor((part - 0x10000) / 0x400) + 0xD800;
  38529. const lo = (part - 0x10000) % 0x400 + 0xDC00;
  38530. part = String.fromCharCode(hi) + String.fromCharCode(lo);
  38531. } else {
  38532. part = String.fromCharCode(part);
  38533. }
  38534. parts.push(part);
  38535. }
  38536. return parts.join('');
  38537. }
  38538. return fromCodePoint(unicode);
  38539. }
  38540. function convertASCII2Emoji(str) {
  38541. // Replace ASCII smileys
  38542. return str.replace(ASCII_REPLACE_REGEX, (entire, _, m2, m3) => {
  38543. if (typeof m3 === 'undefined' || m3 === '' || !(emoji_utils_u.unescapeHTML(m3) in ASCII_LIST)) {
  38544. // if the ascii doesnt exist just return the entire match
  38545. return entire;
  38546. }
  38547. m3 = emoji_utils_u.unescapeHTML(m3);
  38548. const unicode = ASCII_LIST[m3].toUpperCase();
  38549. return m2 + convert(unicode);
  38550. });
  38551. }
  38552. function getShortnameReferences(text) {
  38553. if (!core_converse.emojis.initialized) {
  38554. throw new Error('getShortnameReferences called before emojis are initialized. ' + 'To avoid this problem, first await the converse.emojis.initilaized_promise.');
  38555. }
  38556. const references = [...text.matchAll(core_converse.emojis.shortnames_regex)].filter(ref => ref[0].length > 0);
  38557. return references.map(ref => {
  38558. const cp = core_converse.emojis.by_sn[ref[0]].cp;
  38559. return {
  38560. cp,
  38561. 'begin': ref.index,
  38562. 'end': ref.index + ref[0].length,
  38563. 'shortname': ref[0],
  38564. 'emoji': cp ? convert(cp) : null
  38565. };
  38566. });
  38567. }
  38568. function parseStringForEmojis(str, callback) {
  38569. const UFE0Fg = /\uFE0F/g;
  38570. const U200D = String.fromCharCode(0x200D);
  38571. return String(str).replace(CODEPOINTS_REGEX, (emoji, _, offset) => {
  38572. const icon_id = toCodePoint(emoji.indexOf(U200D) < 0 ? emoji.replace(UFE0Fg, '') : emoji);
  38573. if (icon_id) callback(icon_id, emoji, offset);
  38574. });
  38575. }
  38576. function getCodePointReferences(text) {
  38577. const references = [];
  38578. parseStringForEmojis(text, (icon_id, emoji, offset) => {
  38579. var _getEmojisByAtrribute;
  38580. references.push({
  38581. 'begin': offset,
  38582. 'cp': icon_id,
  38583. 'emoji': emoji,
  38584. 'end': offset + emoji.length,
  38585. 'shortname': ((_getEmojisByAtrribute = getEmojisByAtrribute('cp')[icon_id]) === null || _getEmojisByAtrribute === void 0 ? void 0 : _getEmojisByAtrribute.sn) || ''
  38586. });
  38587. });
  38588. return references;
  38589. }
  38590. function addEmojisMarkup(text) {
  38591. let list = [text];
  38592. [...getShortnameReferences(text), ...getCodePointReferences(text)].sort((a, b) => b.begin - a.begin).forEach(ref => {
  38593. const text = list.shift();
  38594. const emoji = ref.emoji || ref.shortname;
  38595. list = [text.slice(0, ref.begin) + emoji + text.slice(ref.end), ...list];
  38596. });
  38597. return list;
  38598. }
  38599. /**
  38600. * Replaces all shortnames in the passed in string with their
  38601. * unicode (emoji) representation.
  38602. * @namespace u
  38603. * @method u.shortnamesToUnicode
  38604. * @param { String } str - String containing the shortname(s)
  38605. * @returns { String }
  38606. */
  38607. function shortnamesToUnicode(str) {
  38608. return addEmojisMarkup(convertASCII2Emoji(str)).pop();
  38609. }
  38610. /**
  38611. * Determines whether the passed in string is just a single emoji shortname;
  38612. * @namespace u
  38613. * @method u.isOnlyEmojis
  38614. * @param { String } shortname - A string which migh be just an emoji shortname
  38615. * @returns { Boolean }
  38616. */
  38617. function isOnlyEmojis(text) {
  38618. const words = text.trim().split(/\s+/);
  38619. if (words.length === 0 || words.length > 3) {
  38620. return false;
  38621. }
  38622. const emojis = words.filter(text => {
  38623. const refs = getCodePointReferences(emoji_utils_u.shortnamesToUnicode(text));
  38624. return refs.length === 1 && (text === refs[0]['shortname'] || text === refs[0]['emoji']);
  38625. });
  38626. return emojis.length === words.length;
  38627. }
  38628. /**
  38629. * @namespace u
  38630. * @method u.getEmojisByAtrribute
  38631. * @param { 'category'|'cp'|'sn' } attr
  38632. * The attribute according to which the returned map should be keyed.
  38633. * @returns { Object }
  38634. * Map of emojis with the passed in `attr` used as key and a list of emojis as values.
  38635. */
  38636. function getEmojisByAtrribute(attr) {
  38637. if (emojis_by_attribute[attr]) {
  38638. return emojis_by_attribute[attr];
  38639. }
  38640. if (attr === 'category') {
  38641. return core_converse.emojis.json;
  38642. }
  38643. const all_variants = core_converse.emojis.list.map(e => e[attr]).filter((c, i, arr) => arr.indexOf(c) == i);
  38644. emojis_by_attribute[attr] = {};
  38645. all_variants.forEach(v => emojis_by_attribute[attr][v] = core_converse.emojis.list.find(i => i[attr] === v));
  38646. return emojis_by_attribute[attr];
  38647. }
  38648. Object.assign(emoji_utils_u, {
  38649. getEmojisByAtrribute,
  38650. isOnlyEmojis,
  38651. shortnamesToUnicode
  38652. });
  38653. ;// CONCATENATED MODULE: ./src/shared/chat/utils.js
  38654. const {
  38655. dayjs: utils_dayjs,
  38656. u: shared_chat_utils_u
  38657. } = core_converse.env;
  38658. function onScrolledDown(model) {
  38659. if (!model.isHidden()) {
  38660. if (core_api.settings.get('allow_url_history_change')) {
  38661. // Clear location hash if set to one of the messages in our history
  38662. const hash = window.location.hash;
  38663. hash && model.messages.get(hash.slice(1)) && shared_converse.router.history.navigate();
  38664. }
  38665. }
  38666. }
  38667. /**
  38668. * Called when the chat content is scrolled up or down.
  38669. * We want to record when the user has scrolled away from
  38670. * the bottom, so that we don't automatically scroll away
  38671. * from what the user is reading when new messages are received.
  38672. *
  38673. * Don't call this method directly, instead, call `markScrolled`,
  38674. * which debounces this method.
  38675. */
  38676. function _markScrolled(ev) {
  38677. const el = ev.target;
  38678. if (el.nodeName.toLowerCase() !== 'converse-chat-content') {
  38679. return;
  38680. }
  38681. let scrolled = true;
  38682. const is_at_bottom = Math.floor(el.scrollTop) === 0;
  38683. const is_at_top = Math.ceil(el.clientHeight - el.scrollTop) >= el.scrollHeight - Math.ceil(el.scrollHeight / 20);
  38684. if (is_at_bottom) {
  38685. scrolled = false;
  38686. onScrolledDown(el.model);
  38687. } else if (is_at_top) {
  38688. /**
  38689. * Triggered once the chat's message area has been scrolled to the top
  38690. * @event _converse#chatBoxScrolledUp
  38691. * @property { _converse.ChatBoxView | _converse.ChatRoomView } view
  38692. * @example _converse.api.listen.on('chatBoxScrolledUp', obj => { ... });
  38693. */
  38694. core_api.trigger('chatBoxScrolledUp', el);
  38695. }
  38696. if (el.model.get('scolled') !== scrolled) {
  38697. el.model.ui.set({
  38698. scrolled
  38699. });
  38700. }
  38701. }
  38702. const markScrolled = debounce_default()(ev => _markScrolled(ev), 50);
  38703. /**
  38704. * Given a message object, returns a TemplateResult indicating a new day if
  38705. * the passed in message is more than a day later than its predecessor.
  38706. * @param { _converse.Message }
  38707. */
  38708. function getDayIndicator(message) {
  38709. var _message$collection;
  38710. const messages = (_message$collection = message.collection) === null || _message$collection === void 0 ? void 0 : _message$collection.models;
  38711. if (!messages) {
  38712. return;
  38713. }
  38714. const idx = messages.indexOf(message);
  38715. const prev_message = messages[idx - 1];
  38716. if (!prev_message || utils_dayjs(message.get('time')).isAfter(utils_dayjs(prev_message.get('time')), 'day')) {
  38717. const day_date = utils_dayjs(message.get('time')).startOf('day');
  38718. return new_day({
  38719. 'type': 'date',
  38720. 'time': day_date.toISOString(),
  38721. 'datestring': day_date.format("dddd MMM Do YYYY")
  38722. });
  38723. }
  38724. }
  38725. function getHats(message) {
  38726. if (message.get('type') === 'groupchat') {
  38727. var _message$occupant;
  38728. const allowed_hats = core_api.settings.get('muc_hats').filter(hat => hat).map(hat => hat.toLowerCase());
  38729. let vcard_roles = [];
  38730. if (allowed_hats.includes('vcard_roles')) {
  38731. vcard_roles = message.vcard ? message.vcard.get('role') : null;
  38732. vcard_roles = vcard_roles ? vcard_roles.split(',').filter(hat => hat).map(hat => ({
  38733. title: hat
  38734. })) : [];
  38735. }
  38736. const muc_role = message.occupant ? [message.occupant.get('role')] : [];
  38737. const muc_affiliation = message.occupant ? [message.occupant.get('affiliation')] : [];
  38738. const affiliation_role_hats = [...muc_role, ...muc_affiliation].filter(hat => hat).filter(hat => allowed_hats.includes(hat.toLowerCase())).map(hat => ({
  38739. title: hat
  38740. }));
  38741. const hats = allowed_hats.includes('xep317') ? ((_message$occupant = message.occupant) === null || _message$occupant === void 0 ? void 0 : _message$occupant.get('hats')) || [] : [];
  38742. return [...hats, ...vcard_roles, ...affiliation_role_hats];
  38743. }
  38744. return [];
  38745. }
  38746. function unique(arr) {
  38747. return [...new Set(arr)];
  38748. }
  38749. function getTonedEmojis() {
  38750. if (!core_converse.emojis.toned) {
  38751. core_converse.emojis.toned = unique(Object.values(core_converse.emojis.json.people).filter(person => person.sn.includes('_tone')).map(person => person.sn.replace(/_tone[1-5]/, '')));
  38752. }
  38753. return core_converse.emojis.toned;
  38754. }
  38755. function getEmojiMarkup(data) {
  38756. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  38757. unicode_only: false,
  38758. add_title_wrapper: false
  38759. };
  38760. const emoji = data.emoji;
  38761. const shortname = data.shortname;
  38762. if (emoji) {
  38763. if (options.unicode_only) {
  38764. return emoji;
  38765. } else if (core_api.settings.get('use_system_emojis')) {
  38766. if (options.add_title_wrapper) {
  38767. return shortname ? $`<span title="${shortname}">${emoji}</span>` : emoji;
  38768. } else {
  38769. return emoji;
  38770. }
  38771. } else {
  38772. const path = core_api.settings.get('emoji_image_path');
  38773. return $`<img class="emoji"
  38774. loading="lazy"
  38775. draggable="false"
  38776. title="${shortname}"
  38777. alt="${emoji}"
  38778. src="${path}/72x72/${data.cp}.png"/>`;
  38779. }
  38780. } else if (options.unicode_only) {
  38781. return shortname;
  38782. } else {
  38783. return $`<img class="emoji"
  38784. loading="lazy"
  38785. draggable="false"
  38786. title="${shortname}"
  38787. alt="${shortname}"
  38788. src="${core_converse.emojis.by_sn[shortname].url}">`;
  38789. }
  38790. }
  38791. function utils_addEmojisMarkup(text, options) {
  38792. let list = [text];
  38793. [...getShortnameReferences(text), ...getCodePointReferences(text)].sort((a, b) => b.begin - a.begin).forEach(ref => {
  38794. const text = list.shift();
  38795. const emoji = getEmojiMarkup(ref, options);
  38796. if (typeof emoji === 'string') {
  38797. list = [text.slice(0, ref.begin) + emoji + text.slice(ref.end), ...list];
  38798. } else {
  38799. list = [text.slice(0, ref.begin), emoji, text.slice(ref.end), ...list];
  38800. }
  38801. });
  38802. return list;
  38803. }
  38804. /**
  38805. * Returns an emoji represented by the passed in shortname.
  38806. * Scans the passed in text for shortnames and replaces them with
  38807. * emoji unicode glyphs or alternatively if it's a custom emoji
  38808. * without unicode representation then a lit TemplateResult
  38809. * which represents image tag markup is returned.
  38810. *
  38811. * The shortname needs to be defined in `emojis.json`
  38812. * and needs to have either a `cp` attribute for the codepoint, or
  38813. * an `url` attribute which points to the source for the image.
  38814. *
  38815. * @namespace u
  38816. * @method u.shortnamesToEmojis
  38817. * @param { String } str - String containg the shortname(s)
  38818. * @param { Object } options
  38819. * @param { Boolean } options.unicode_only - Whether emojis are rendered as
  38820. * unicode codepoints. If so, the returned result will be an array
  38821. * with containing one string, because the emojis themselves will
  38822. * also be strings. If set to false, emojis will be represented by
  38823. * lit TemplateResult objects.
  38824. * @param { Boolean } options.add_title_wrapper - Whether unicode
  38825. * codepoints should be wrapped with a `<span>` element with a
  38826. * title, so that the shortname is shown upon hovering with the
  38827. * mouse.
  38828. * @returns {Array} An array of at least one string, or otherwise
  38829. * strings and lit TemplateResult objects.
  38830. */
  38831. function shortnamesToEmojis(str) {
  38832. let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  38833. unicode_only: false,
  38834. add_title_wrapper: false
  38835. };
  38836. str = convertASCII2Emoji(str);
  38837. return utils_addEmojisMarkup(str, options);
  38838. }
  38839. Object.assign(shared_chat_utils_u, {
  38840. shortnamesToEmojis
  38841. });
  38842. ;// CONCATENATED MODULE: ./src/shared/rich-text.js
  38843. const rich_text_isString = s => typeof s === 'string'; // We don't render more than two line-breaks, replace extra line-breaks with
  38844. // the zero-width whitespace character
  38845. const collapseLineBreaks = text => text.replace(/\n\n+/g, m => `\n${'\u200B'.repeat(m.length - 2)}\n`);
  38846. const tpl_mention_with_nick = o => $`<span class="mention mention--self badge badge-info">${o.mention}</span>`;
  38847. const tpl_mention = o => $`<span class="mention">${o.mention}</span>`;
  38848. /**
  38849. * @class RichText
  38850. * A String subclass that is used to render rich text (i.e. text that contains
  38851. * hyperlinks, images, mentions, styling etc.).
  38852. *
  38853. * The "rich" parts of the text is represented by lit TemplateResult
  38854. * objects which are added via the {@link RichText.addTemplateResult}
  38855. * method and saved as metadata.
  38856. *
  38857. * By default Converse adds TemplateResults to support emojis, hyperlinks,
  38858. * images, map URIs and mentions.
  38859. *
  38860. * 3rd party plugins can listen for the `beforeMessageBodyTransformed`
  38861. * and/or `afterMessageBodyTransformed` events and then call
  38862. * `addTemplateResult` on the RichText instance in order to add their own
  38863. * rich features.
  38864. */
  38865. class RichText extends String {
  38866. /**
  38867. * Create a new {@link RichText} instance.
  38868. * @param { String } text - The text to be annotated
  38869. * @param { Integer } offset - The offset of this particular piece of text
  38870. * from the start of the original message text. This is necessary because
  38871. * RichText instances can be nested when templates call directives
  38872. * which create new RichText instances (as happens with XEP-393 styling directives).
  38873. * @param { Object } options
  38874. * @param { String } options.nick - The current user's nickname (only relevant if the message is in a XEP-0045 MUC)
  38875. * @param { Boolean } options.render_styling - Whether XEP-0393 message styling should be applied to the message
  38876. * @param { Boolean } [options.embed_audio] - Whether audio URLs should be rendered as <audio> elements.
  38877. * If set to `true`, then audio files will always be rendered with an
  38878. * audio player. If set to `false`, they won't, and if not defined, then the `embed_audio` setting
  38879. * is used to determine whether they should be rendered as playable audio or as hyperlinks.
  38880. * @param { Boolean } [options.embed_videos] - Whether video URLs should be rendered as <video> elements.
  38881. * If set to `true`, then videos will always be rendered with a video
  38882. * player. If set to `false`, they won't, and if not defined, then the `embed_videos` setting
  38883. * is used to determine whether they should be rendered as videos or as hyperlinks.
  38884. * @param { Array } [options.mentions] - An array of mention references
  38885. * @param { Array } [options.media_urls] - An array of {@link MediaURLMetadata} objects,
  38886. * used to render media such as images, videos and audio. It might not be
  38887. * possible to have the media metadata available, so if this value is
  38888. * `undefined` then the passed-in `text` will be parsed for URLs. If you
  38889. * don't want this parsing to happen, pass in an empty array for this
  38890. * option.
  38891. * @param { Boolean } [options.show_images] - Whether image URLs should be rendered as <img> elements.
  38892. * @param { Boolean } options.show_me_message - Whether /me messages should be rendered differently
  38893. * @param { Function } options.onImgClick - Callback for when an inline rendered image has been clicked
  38894. * @param { Function } options.onImgLoad - Callback for when an inline rendered image has been loaded
  38895. */
  38896. constructor(text) {
  38897. let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  38898. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  38899. super(text);
  38900. this.embed_audio = options === null || options === void 0 ? void 0 : options.embed_audio;
  38901. this.embed_videos = options === null || options === void 0 ? void 0 : options.embed_videos;
  38902. this.mentions = (options === null || options === void 0 ? void 0 : options.mentions) || [];
  38903. this.media_urls = options === null || options === void 0 ? void 0 : options.media_urls;
  38904. this.nick = options === null || options === void 0 ? void 0 : options.nick;
  38905. this.offset = offset;
  38906. this.onImgClick = options === null || options === void 0 ? void 0 : options.onImgClick;
  38907. this.onImgLoad = options === null || options === void 0 ? void 0 : options.onImgLoad;
  38908. this.options = options;
  38909. this.payload = [];
  38910. this.references = [];
  38911. this.render_styling = options === null || options === void 0 ? void 0 : options.render_styling;
  38912. this.show_images = options === null || options === void 0 ? void 0 : options.show_images;
  38913. this.hide_media_urls = options === null || options === void 0 ? void 0 : options.hide_media_urls;
  38914. }
  38915. shouldRenderMedia(url_text, type) {
  38916. let override;
  38917. if (type === 'image') {
  38918. override = this.show_images;
  38919. } else if (type === 'audio') {
  38920. override = this.embed_audio;
  38921. } else if (type === 'video') {
  38922. override = this.embed_videos;
  38923. }
  38924. if (typeof override === 'boolean') {
  38925. return override;
  38926. }
  38927. return shouldRenderMediaFromURL(url_text, type);
  38928. }
  38929. /**
  38930. * Look for `http` URIs and return templates that render them as URL links
  38931. * @param { String } text
  38932. * @param { Integer } local_offset - The index of the passed in text relative to
  38933. * the start of this RichText instance (which is not necessarily the same as the
  38934. * offset from the start of the original message stanza's body text).
  38935. */
  38936. addHyperlinks(text, local_offset) {
  38937. const full_offset = local_offset + this.offset;
  38938. const urls_meta = this.media_urls || getMediaURLsMetadata(text, local_offset).media_urls || [];
  38939. const media_urls = getMediaURLs(urls_meta, text, full_offset);
  38940. media_urls.filter(o => !o.is_encrypted).forEach(url_obj => {
  38941. const url_text = url_obj.url;
  38942. const filtered_url = filterQueryParamsFromURL(url_text);
  38943. let template;
  38944. if (isGIFURL(url_text) && this.shouldRenderMedia(url_text, 'image')) {
  38945. template = templates_gif(filtered_url, this.hide_media_urls);
  38946. } else if (isImageURL(url_text) && this.shouldRenderMedia(url_text, 'image')) {
  38947. template = src_templates_image({
  38948. 'src': filtered_url,
  38949. // XXX: bit of an abuse of `hide_media_urls`, might want a dedicated option here
  38950. 'href': this.hide_media_urls ? null : filtered_url,
  38951. 'onClick': this.onImgClick,
  38952. 'onLoad': this.onImgLoad
  38953. });
  38954. } else if (isVideoURL(url_text) && this.shouldRenderMedia(url_text, 'video')) {
  38955. template = video(filtered_url, this.hide_media_urls);
  38956. } else if (isAudioURL(url_text) && this.shouldRenderMedia(url_text, 'audio')) {
  38957. template = audio(filtered_url, this.hide_media_urls);
  38958. } else {
  38959. template = getHyperlinkTemplate(filtered_url);
  38960. }
  38961. this.addTemplateResult(url_obj.start + local_offset, url_obj.end + local_offset, template);
  38962. });
  38963. }
  38964. /**
  38965. * Look for `geo` URIs and return templates that render them as URL links
  38966. * @param { String } text
  38967. * @param { Integer } offset - The index of the passed in text relative to
  38968. * the start of the message body text.
  38969. */
  38970. addMapURLs(text, offset) {
  38971. const regex = /geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g;
  38972. const matches = text.matchAll(regex);
  38973. for (const m of matches) {
  38974. this.addTemplateResult(m.index + offset, m.index + m[0].length + offset, getHyperlinkTemplate(m[0].replace(regex, core_api.settings.get('geouri_replacement'))));
  38975. }
  38976. }
  38977. /**
  38978. * Look for emojis (shortnames or unicode) and add templates for rendering them.
  38979. * @param { String } text
  38980. * @param { Integer } offset - The index of the passed in text relative to
  38981. * the start of the message body text.
  38982. */
  38983. addEmojis(text, offset) {
  38984. const references = [...getShortnameReferences(text.toString()), ...getCodePointReferences(text.toString())];
  38985. references.forEach(e => {
  38986. this.addTemplateResult(e.begin + offset, e.end + offset, getEmojiMarkup(e, {
  38987. 'add_title_wrapper': true
  38988. }));
  38989. });
  38990. }
  38991. /**
  38992. * Look for mentions included as XEP-0372 references and add templates for
  38993. * rendering them.
  38994. * @param { String } text
  38995. * @param { Integer } local_offset - The index of the passed in text relative to
  38996. * the start of this RichText instance (which is not necessarily the same as the
  38997. * offset from the start of the original message stanza's body text).
  38998. */
  38999. addMentions(text, local_offset) {
  39000. var _this$mentions;
  39001. const full_offset = local_offset + this.offset;
  39002. (_this$mentions = this.mentions) === null || _this$mentions === void 0 ? void 0 : _this$mentions.forEach(ref => {
  39003. const begin = Number(ref.begin) - full_offset;
  39004. if (begin < 0 || begin >= full_offset + text.length) {
  39005. return;
  39006. }
  39007. const end = Number(ref.end) - full_offset;
  39008. const mention = text.slice(begin, end);
  39009. if (mention === this.nick) {
  39010. this.addTemplateResult(begin + local_offset, end + local_offset, tpl_mention_with_nick({
  39011. mention
  39012. }));
  39013. } else {
  39014. this.addTemplateResult(begin + local_offset, end + local_offset, tpl_mention({
  39015. mention
  39016. }));
  39017. }
  39018. });
  39019. }
  39020. /**
  39021. * Look for XEP-0393 styling directives and add templates for rendering
  39022. * them.
  39023. */
  39024. addStyling() {
  39025. const references = [];
  39026. if (containsDirectives(this, this.mentions)) {
  39027. const mention_ranges = this.mentions.map(m => Array.from({
  39028. 'length': Number(m.end)
  39029. }, (v, i) => Number(m.begin) + i));
  39030. let i = 0;
  39031. while (i < this.length) {
  39032. if (mention_ranges.filter(r => r.includes(i)).length) {
  39033. // eslint-disable-line no-loop-func
  39034. // Don't treat potential directives if they fall within a
  39035. // declared XEP-0372 reference
  39036. i++;
  39037. continue;
  39038. }
  39039. const {
  39040. d,
  39041. length
  39042. } = getDirectiveAndLength(this, i);
  39043. if (d && length) {
  39044. const is_quote = isQuoteDirective(d);
  39045. const end = i + length;
  39046. const slice_end = is_quote ? end : end - d.length;
  39047. let slice_begin = d === '```' ? i + d.length + 1 : i + d.length;
  39048. if (is_quote && this[slice_begin] === ' ') {
  39049. // Trim leading space inside codeblock
  39050. slice_begin += 1;
  39051. }
  39052. const offset = slice_begin;
  39053. const text = this.slice(slice_begin, slice_end);
  39054. references.push({
  39055. 'begin': i,
  39056. 'template': getDirectiveTemplate(d, text, offset, this.options),
  39057. end
  39058. });
  39059. i = end;
  39060. }
  39061. i++;
  39062. }
  39063. }
  39064. references.forEach(ref => this.addTemplateResult(ref.begin, ref.end, ref.template));
  39065. }
  39066. trimMeMessage() {
  39067. if (this.offset === 0) {
  39068. // Subtract `/me ` from 3rd person messages
  39069. if (this.isMeCommand()) {
  39070. this.payload[0] = this.payload[0].substring(4);
  39071. }
  39072. }
  39073. }
  39074. /**
  39075. * Look for plaintext (i.e. non-templated) sections of this RichText
  39076. * instance and add references via the passed in function.
  39077. * @param { Function } func
  39078. */
  39079. addAnnotations(func) {
  39080. const payload = this.marshall();
  39081. let idx = 0; // The text index of the element in the payload
  39082. for (const text of payload) {
  39083. if (!text) {
  39084. continue;
  39085. } else if (rich_text_isString(text)) {
  39086. func.call(this, text, idx);
  39087. idx += text.length;
  39088. } else {
  39089. idx = text.end;
  39090. }
  39091. }
  39092. }
  39093. /**
  39094. * Parse the text and add template references for rendering the "rich" parts.
  39095. *
  39096. * @param { RichText } text
  39097. * @param { Boolean } show_images - Should URLs of images be rendered as `<img>` tags?
  39098. * @param { Function } onImgLoad
  39099. * @param { Function } onImgClick
  39100. **/
  39101. async addTemplates() {
  39102. /**
  39103. * Synchronous event which provides a hook for transforming a chat message's body text
  39104. * before the default transformations have been applied.
  39105. * @event _converse#beforeMessageBodyTransformed
  39106. * @param { RichText } text - A {@link RichText } instance. You
  39107. * can call {@link RichText#addTemplateResult } on it in order to
  39108. * add TemplateResult objects meant to render rich parts of the message.
  39109. * @example _converse.api.listen.on('beforeMessageBodyTransformed', (view, text) => { ... });
  39110. */
  39111. await core_api.trigger('beforeMessageBodyTransformed', this, {
  39112. 'Synchronous': true
  39113. });
  39114. this.render_styling && this.addStyling();
  39115. this.addAnnotations(this.addMentions);
  39116. this.addAnnotations(this.addHyperlinks);
  39117. this.addAnnotations(this.addMapURLs);
  39118. await core_api.emojis.initialize();
  39119. this.addAnnotations(this.addEmojis);
  39120. /**
  39121. * Synchronous event which provides a hook for transforming a chat message's body text
  39122. * after the default transformations have been applied.
  39123. * @event _converse#afterMessageBodyTransformed
  39124. * @param { RichText } text - A {@link RichText } instance. You
  39125. * can call {@link RichText#addTemplateResult} on it in order to
  39126. * add TemplateResult objects meant to render rich parts of the message.
  39127. * @example _converse.api.listen.on('afterMessageBodyTransformed', (view, text) => { ... });
  39128. */
  39129. await core_api.trigger('afterMessageBodyTransformed', this, {
  39130. 'Synchronous': true
  39131. });
  39132. this.payload = this.marshall();
  39133. this.options.show_me_message && this.trimMeMessage();
  39134. this.payload = this.payload.map(item => rich_text_isString(item) ? item : item.template);
  39135. }
  39136. /**
  39137. * The "rich" markup parts of a chat message are represented by lit
  39138. * TemplateResult objects.
  39139. *
  39140. * This method can be used to add new template results to this message's
  39141. * text.
  39142. *
  39143. * @method RichText.addTemplateResult
  39144. * @param { Number } begin - The starting index of the plain message text
  39145. * which is being replaced with markup.
  39146. * @param { Number } end - The ending index of the plain message text
  39147. * which is being replaced with markup.
  39148. * @param { Object } template - The lit TemplateResult instance
  39149. */
  39150. addTemplateResult(begin, end, template) {
  39151. this.references.push({
  39152. begin,
  39153. end,
  39154. template
  39155. });
  39156. }
  39157. isMeCommand() {
  39158. const text = this.toString();
  39159. if (!text) {
  39160. return false;
  39161. }
  39162. return text.startsWith('/me ');
  39163. }
  39164. /**
  39165. * Take the annotations and return an array of text and TemplateResult
  39166. * instances to be rendered to the DOM.
  39167. * @method RichText#marshall
  39168. */
  39169. marshall() {
  39170. let list = [this.toString()];
  39171. this.references.sort((a, b) => b.begin - a.begin).forEach(ref => {
  39172. const text = list.shift();
  39173. list = [text.slice(0, ref.begin), ref, text.slice(ref.end), ...list];
  39174. });
  39175. return list.reduce((acc, i) => rich_text_isString(i) ? [...acc, convertASCII2Emoji(collapseLineBreaks(i))] : [...acc, i], []);
  39176. }
  39177. }
  39178. ;// CONCATENATED MODULE: ./src/shared/directives/rich-text.js
  39179. class RichTextRenderer {
  39180. constructor(text, offset) {
  39181. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  39182. this.offset = offset;
  39183. this.options = options;
  39184. this.text = text;
  39185. }
  39186. async transform() {
  39187. const text = new RichText(this.text, this.offset, this.options);
  39188. try {
  39189. await text.addTemplates();
  39190. } catch (e) {
  39191. headless_log.error(e);
  39192. }
  39193. return text.payload;
  39194. }
  39195. render() {
  39196. return $`${until_c(this.transform(), $`${this.text}`)}`;
  39197. }
  39198. }
  39199. class RichTextDirective extends directive_i {
  39200. render(text, offset, options, callback) {
  39201. // eslint-disable-line class-methods-use-this
  39202. const renderer = new RichTextRenderer(text, offset, options);
  39203. const result = renderer.render();
  39204. callback === null || callback === void 0 ? void 0 : callback();
  39205. return result;
  39206. }
  39207. }
  39208. const renderRichText = directive_e(RichTextDirective);
  39209. /* harmony default export */ const rich_text = (renderRichText);
  39210. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/message-body.scss
  39211. var message_body = __webpack_require__(6278);
  39212. ;// CONCATENATED MODULE: ./src/shared/chat/styles/message-body.scss
  39213. var message_body_options = {};
  39214. message_body_options.styleTagTransform = (styleTagTransform_default());
  39215. message_body_options.setAttributes = (setAttributesWithoutAttributes_default());
  39216. message_body_options.insert = insertBySelector_default().bind(null, "head");
  39217. message_body_options.domAPI = (styleDomAPI_default());
  39218. message_body_options.insertStyleElement = (insertStyleElement_default());
  39219. var message_body_update = injectStylesIntoStyleTag_default()(message_body/* default */.Z, message_body_options);
  39220. /* harmony default export */ const styles_message_body = (message_body/* default */.Z && message_body/* default.locals */.Z.locals ? message_body/* default.locals */.Z.locals : undefined);
  39221. ;// CONCATENATED MODULE: ./src/shared/chat/message-body.js
  39222. class MessageBody extends CustomElement {
  39223. static get properties() {
  39224. return {
  39225. // We make this a string instead of a boolean, since we want to
  39226. // distinguish between true, false and undefined states
  39227. hide_url_previews: {
  39228. type: String
  39229. },
  39230. is_me_message: {
  39231. type: Boolean
  39232. },
  39233. model: {
  39234. type: Object
  39235. },
  39236. text: {
  39237. type: String
  39238. }
  39239. };
  39240. }
  39241. initialize() {
  39242. const settings = getAppSettings();
  39243. this.listenTo(settings, 'change:allowed_audio_domains', () => this.requestUpdate());
  39244. this.listenTo(settings, 'change:allowed_image_domains', () => this.requestUpdate());
  39245. this.listenTo(settings, 'change:allowed_video_domains', () => this.requestUpdate());
  39246. this.listenTo(settings, 'change:render_media', () => this.requestUpdate());
  39247. }
  39248. onImgClick(ev) {
  39249. // eslint-disable-line class-methods-use-this
  39250. ev.preventDefault();
  39251. core_api.modal.create(modals_image, {
  39252. 'src': ev.target.src
  39253. }, ev).show(ev);
  39254. }
  39255. onImgLoad() {
  39256. this.dispatchEvent(new CustomEvent('imageLoaded', {
  39257. detail: this,
  39258. 'bubbles': true
  39259. }));
  39260. }
  39261. render() {
  39262. const callback = () => {
  39263. var _this$model$collectio;
  39264. return (_this$model$collectio = this.model.collection) === null || _this$model$collectio === void 0 ? void 0 : _this$model$collectio.trigger('rendered', this.model);
  39265. };
  39266. const offset = 0;
  39267. const options = {
  39268. 'media_urls': this.model.get('media_urls'),
  39269. 'mentions': this.model.get('references'),
  39270. 'nick': this.model.collection.chatbox.get('nick'),
  39271. 'onImgClick': ev => this.onImgClick(ev),
  39272. 'onImgLoad': () => this.onImgLoad(),
  39273. 'render_styling': !this.model.get('is_unstyled') && core_api.settings.get('allow_message_styling'),
  39274. 'show_me_message': true
  39275. };
  39276. if (this.hide_url_previews === "false") {
  39277. options.embed_audio = true;
  39278. options.embed_videos = true;
  39279. options.show_images = true;
  39280. } else if (this.hide_url_previews === "true") {
  39281. options.embed_audio = false;
  39282. options.embed_videos = false;
  39283. options.show_images = false;
  39284. }
  39285. return rich_text(this.text, offset, options, callback);
  39286. }
  39287. }
  39288. core_api.elements.define('converse-chat-message-body', MessageBody);
  39289. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/components/styles/icon.scss
  39290. var icon = __webpack_require__(6450);
  39291. ;// CONCATENATED MODULE: ./src/shared/components/styles/icon.scss
  39292. var icon_options = {};
  39293. icon_options.styleTagTransform = (styleTagTransform_default());
  39294. icon_options.setAttributes = (setAttributesWithoutAttributes_default());
  39295. icon_options.insert = insertBySelector_default().bind(null, "head");
  39296. icon_options.domAPI = (styleDomAPI_default());
  39297. icon_options.insertStyleElement = (insertStyleElement_default());
  39298. var icon_update = injectStylesIntoStyleTag_default()(icon/* default */.Z, icon_options);
  39299. /* harmony default export */ const styles_icon = (icon/* default */.Z && icon/* default.locals */.Z.locals ? icon/* default.locals */.Z.locals : undefined);
  39300. ;// CONCATENATED MODULE: ./src/shared/components/icons.js
  39301. /**
  39302. * @copyright Alfredo Medrano Sánchez and the Converse.js contributors
  39303. * @description
  39304. * Component inspired by the one from fa-icons
  39305. * https://github.com/obsidiansoft-io/fa-icons/blob/master/LICENSE
  39306. * @license Mozilla Public License (MPLv2)
  39307. */
  39308. class ConverseIcon extends CustomElement {
  39309. static get properties() {
  39310. return {
  39311. color: String,
  39312. class_name: {
  39313. attribute: "class"
  39314. },
  39315. style: String,
  39316. size: String
  39317. };
  39318. }
  39319. constructor() {
  39320. super();
  39321. this.class_name = "";
  39322. this.style = "";
  39323. this.size = "";
  39324. this.color = "";
  39325. }
  39326. getSource() {
  39327. return `#icon-${this.class_name.trim().split(" ")[1].replace("fa-", "")}`;
  39328. }
  39329. getStyles() {
  39330. var _this$color$match;
  39331. const cssprop = (_this$color$match = this.color.match(/var\((--.*)\)/)) === null || _this$color$match === void 0 ? void 0 : _this$color$match[1];
  39332. const color = cssprop ? getComputedStyle(this).getPropertyValue(cssprop) : this.color;
  39333. return `
  39334. ${this.size ? `width: ${this.size};` : ''}
  39335. ${this.size ? `height: ${this.size};` : ''}
  39336. ${color ? `fill: ${color};` : ''}
  39337. ${this.style}
  39338. `;
  39339. }
  39340. render() {
  39341. return $`<svg .style="${this.getStyles()}"> <use href="${this.getSource()}"> </use> </svg>`;
  39342. }
  39343. }
  39344. customElements.define("converse-icon", ConverseIcon);
  39345. ;// CONCATENATED MODULE: ./src/shared/dom-navigator.js
  39346. /**
  39347. * @module dom-navigator
  39348. * @description A class for navigating the DOM with the keyboard
  39349. * This module started as a fork of Rubens Mariuzzo's dom-navigator.
  39350. * @copyright Rubens Mariuzzo, JC Brand
  39351. */
  39352. const {
  39353. keycodes
  39354. } = core_converse;
  39355. /**
  39356. * Indicates if a given element is fully visible in the viewport.
  39357. * @param { Element } el The element to check.
  39358. * @return { Boolean } True if the given element is fully visible in the viewport, otherwise false.
  39359. */
  39360. function inViewport(el) {
  39361. const rect = el.getBoundingClientRect();
  39362. return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
  39363. }
  39364. /**
  39365. * Return the absolute offset top of an element.
  39366. * @param el { Element } The element.
  39367. * @return { Number } The offset top.
  39368. */
  39369. function absoluteOffsetTop(el) {
  39370. let offsetTop = 0;
  39371. do {
  39372. if (!isNaN(el.offsetTop)) {
  39373. offsetTop += el.offsetTop;
  39374. }
  39375. } while (el = el.offsetParent);
  39376. return offsetTop;
  39377. }
  39378. /**
  39379. * Return the absolute offset left of an element.
  39380. * @param el { Element } The element.
  39381. * @return { Number } The offset left.
  39382. */
  39383. function absoluteOffsetLeft(el) {
  39384. let offsetLeft = 0;
  39385. do {
  39386. if (!isNaN(el.offsetLeft)) {
  39387. offsetLeft += el.offsetLeft;
  39388. }
  39389. } while (el = el.offsetParent);
  39390. return offsetLeft;
  39391. }
  39392. /**
  39393. * Adds the ability to navigate the DOM with the arrow keys
  39394. * @class DOMNavigator
  39395. */
  39396. class DOMNavigator {
  39397. /**
  39398. * Directions.
  39399. * @returns {{left: string, up: string, right: string, down: string}}
  39400. * @constructor
  39401. */
  39402. static get DIRECTION() {
  39403. return {
  39404. down: 'down',
  39405. end: 'end',
  39406. home: 'home',
  39407. left: 'left',
  39408. right: 'right',
  39409. up: 'up'
  39410. };
  39411. }
  39412. /**
  39413. * The default options for the DOM navigator.
  39414. * @returns {{
  39415. * down: number,
  39416. * getSelector: null,
  39417. * jump_to_picked: null,
  39418. * jump_to_picked_direction: null,
  39419. * jump_to_picked_selector: string,
  39420. * left: number,
  39421. * onSelected: null,
  39422. * right: number,
  39423. * selected: string,
  39424. * up: number
  39425. * }}
  39426. */
  39427. static get DEFAULTS() {
  39428. return {
  39429. home: [`${keycodes.SHIFT}+${keycodes.UP_ARROW}`],
  39430. end: [`${keycodes.SHIFT}+${keycodes.DOWN_ARROW}`],
  39431. up: [keycodes.UP_ARROW],
  39432. down: [keycodes.DOWN_ARROW],
  39433. left: [keycodes.LEFT_ARROW, `${keycodes.SHIFT}+${keycodes.TAB}`],
  39434. right: [keycodes.RIGHT_ARROW, keycodes.TAB],
  39435. getSelector: null,
  39436. jump_to_picked: null,
  39437. jump_to_picked_direction: null,
  39438. jump_to_picked_selector: 'picked',
  39439. onSelected: null,
  39440. selected: 'selected',
  39441. selector: 'li'
  39442. };
  39443. }
  39444. static getClosestElement(els, getDistance) {
  39445. const next = els.reduce((prev, curr) => {
  39446. const current_distance = getDistance(curr);
  39447. if (current_distance < prev.distance) {
  39448. return {
  39449. distance: current_distance,
  39450. element: curr
  39451. };
  39452. }
  39453. return prev;
  39454. }, {
  39455. distance: Infinity
  39456. });
  39457. return next.element;
  39458. }
  39459. /**
  39460. * Create a new DOM Navigator.
  39461. * @param { Element } container The container of the element to navigate.
  39462. * @param { Object } options The options to configure the DOM navigator.
  39463. * @param { Function } options.getSelector
  39464. * @param { Number } [options.down] - The keycode for navigating down
  39465. * @param { Number } [options.left] - The keycode for navigating left
  39466. * @param { Number } [options.right] - The keycode for navigating right
  39467. * @param { Number } [options.up] - The keycode for navigating up
  39468. * @param { String } [options.selected] - The class that should be added to the currently selected DOM element.
  39469. * @param { String } [options.jump_to_picked] - A selector, which if
  39470. * matched by the next element being navigated to, based on the direction
  39471. * given by `jump_to_picked_direction`, will cause navigation
  39472. * to jump to the element that matches the `jump_to_picked_selector`.
  39473. * For example, this is useful when navigating to tabs. You want to
  39474. * immediately navigate to the currently active tab instead of just
  39475. * navigating to the first tab.
  39476. * @param { String } [options.jump_to_picked_selector=picked] - The selector
  39477. * indicating the currently picked element to jump to.
  39478. * @param { String } [options.jump_to_picked_direction] - The direction for
  39479. * which jumping to the picked element should be enabled.
  39480. * @param { Function } [options.onSelected] - The callback function which
  39481. * should be called when en element gets selected.
  39482. * @constructor
  39483. */
  39484. constructor(container, options) {
  39485. this.doc = window.document;
  39486. this.container = container;
  39487. this.scroll_container = options.scroll_container || container;
  39488. this.options = Object.assign({}, DOMNavigator.DEFAULTS, options);
  39489. this.init();
  39490. }
  39491. /**
  39492. * Initialize the navigator.
  39493. */
  39494. init() {
  39495. this.selected = null;
  39496. this.keydownHandler = null;
  39497. this.elements = {}; // Create hotkeys map.
  39498. this.keys = {};
  39499. this.options.down.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.down);
  39500. this.options.end.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.end);
  39501. this.options.home.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.home);
  39502. this.options.left.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.left);
  39503. this.options.right.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.right);
  39504. this.options.up.forEach(key => this.keys[key] = DOMNavigator.DIRECTION.up);
  39505. }
  39506. /**
  39507. * Enable this navigator.
  39508. */
  39509. enable() {
  39510. this.getElements();
  39511. this.keydownHandler = event => this.handleKeydown(event);
  39512. this.doc.addEventListener('keydown', this.keydownHandler);
  39513. this.enabled = true;
  39514. }
  39515. /**
  39516. * Disable this navigator.
  39517. */
  39518. disable() {
  39519. if (this.keydownHandler) {
  39520. this.doc.removeEventListener('keydown', this.keydownHandler);
  39521. }
  39522. this.unselect();
  39523. this.elements = {};
  39524. this.enabled = false;
  39525. }
  39526. /**
  39527. * Destroy this navigator removing any event registered and any other data.
  39528. */
  39529. destroy() {
  39530. this.disable();
  39531. if (this.container.domNavigator) {
  39532. delete this.container.domNavigator;
  39533. }
  39534. }
  39535. /**
  39536. * @param {'down'|'right'|'left'|'up'} direction
  39537. * @returns { HTMLElement }
  39538. */
  39539. getNextElement(direction) {
  39540. let el;
  39541. if (direction === DOMNavigator.DIRECTION.home) {
  39542. el = this.getElements(direction)[0];
  39543. } else if (direction === DOMNavigator.DIRECTION.end) {
  39544. el = Array.from(this.getElements(direction)).pop();
  39545. } else if (this.selected) {
  39546. if (direction === DOMNavigator.DIRECTION.right) {
  39547. const els = this.getElements(direction);
  39548. el = els.slice(els.indexOf(this.selected))[1];
  39549. } else if (direction == DOMNavigator.DIRECTION.left) {
  39550. const els = this.getElements(direction);
  39551. el = els.slice(0, els.indexOf(this.selected)).pop() || this.selected;
  39552. } else if (direction == DOMNavigator.DIRECTION.down) {
  39553. const left = this.selected.offsetLeft;
  39554. const top = this.selected.offsetTop + this.selected.offsetHeight;
  39555. const els = this.elementsAfter(0, top);
  39556. const getDistance = el => Math.abs(el.offsetLeft - left) + Math.abs(el.offsetTop - top);
  39557. el = DOMNavigator.getClosestElement(els, getDistance);
  39558. } else if (direction == DOMNavigator.DIRECTION.up) {
  39559. const left = this.selected.offsetLeft;
  39560. const top = this.selected.offsetTop - 1;
  39561. const els = this.elementsBefore(Infinity, top);
  39562. const getDistance = el => Math.abs(left - el.offsetLeft) + Math.abs(top - el.offsetTop);
  39563. el = DOMNavigator.getClosestElement(els, getDistance);
  39564. } else {
  39565. throw new Error("getNextElement: invalid direction value");
  39566. }
  39567. } else {
  39568. if (direction === DOMNavigator.DIRECTION.right || direction === DOMNavigator.DIRECTION.down) {
  39569. // If nothing is selected, we pretend that the first element is
  39570. // selected, so we return the next.
  39571. el = this.getElements(direction)[1];
  39572. } else {
  39573. el = this.getElements(direction)[0];
  39574. }
  39575. }
  39576. if (this.options.jump_to_picked && el && el.matches(this.options.jump_to_picked) && direction === this.options.jump_to_picked_direction) {
  39577. el = this.container.querySelector(this.options.jump_to_picked_selector) || el;
  39578. }
  39579. return el;
  39580. }
  39581. /**
  39582. * Select the given element.
  39583. * @param { Element } el The DOM element to select.
  39584. * @param { string } [direction] The direction.
  39585. */
  39586. select(el, direction) {
  39587. if (!el || el === this.selected) {
  39588. return;
  39589. }
  39590. this.unselect();
  39591. direction && this.scrollTo(el, direction);
  39592. if (el.matches('input')) {
  39593. el.focus();
  39594. } else {
  39595. html.addClass(this.options.selected, el);
  39596. }
  39597. this.selected = el;
  39598. this.options.onSelected && this.options.onSelected(el);
  39599. }
  39600. /**
  39601. * Remove the current selection
  39602. */
  39603. unselect() {
  39604. if (this.selected) {
  39605. html.removeClass(this.options.selected, this.selected);
  39606. delete this.selected;
  39607. }
  39608. }
  39609. /**
  39610. * Scroll the container to an element.
  39611. * @param { HTMLElement } el The destination element.
  39612. * @param { String } direction The direction of the current navigation.
  39613. * @return void.
  39614. */
  39615. scrollTo(el, direction) {
  39616. if (!this.inScrollContainerViewport(el)) {
  39617. const container = this.scroll_container;
  39618. if (!container.contains(el)) {
  39619. return;
  39620. }
  39621. switch (direction) {
  39622. case DOMNavigator.DIRECTION.left:
  39623. container.scrollLeft = el.offsetLeft - container.offsetLeft;
  39624. container.scrollTop = el.offsetTop - container.offsetTop;
  39625. break;
  39626. case DOMNavigator.DIRECTION.up:
  39627. container.scrollTop = el.offsetTop - container.offsetTop;
  39628. break;
  39629. case DOMNavigator.DIRECTION.right:
  39630. container.scrollLeft = el.offsetLeft - container.offsetLeft - (container.offsetWidth - el.offsetWidth);
  39631. container.scrollTop = el.offsetTop - container.offsetTop - (container.offsetHeight - el.offsetHeight);
  39632. break;
  39633. case DOMNavigator.DIRECTION.down:
  39634. container.scrollTop = el.offsetTop - container.offsetTop - (container.offsetHeight - el.offsetHeight);
  39635. break;
  39636. }
  39637. } else if (!inViewport(el)) {
  39638. switch (direction) {
  39639. case DOMNavigator.DIRECTION.left:
  39640. document.body.scrollLeft = absoluteOffsetLeft(el) - document.body.offsetLeft;
  39641. break;
  39642. case DOMNavigator.DIRECTION.up:
  39643. document.body.scrollTop = absoluteOffsetTop(el) - document.body.offsetTop;
  39644. break;
  39645. case DOMNavigator.DIRECTION.right:
  39646. document.body.scrollLeft = absoluteOffsetLeft(el) - document.body.offsetLeft - (document.documentElement.clientWidth - el.offsetWidth);
  39647. break;
  39648. case DOMNavigator.DIRECTION.down:
  39649. document.body.scrollTop = absoluteOffsetTop(el) - document.body.offsetTop - (document.documentElement.clientHeight - el.offsetHeight);
  39650. break;
  39651. }
  39652. }
  39653. }
  39654. /**
  39655. * Indicate if an element is in the container viewport.
  39656. * @param { HTMLElement } el The element to check.
  39657. * @return { Boolean } true if the given element is in the container viewport, otherwise false.
  39658. */
  39659. inScrollContainerViewport(el) {
  39660. const container = this.scroll_container; // Check on left side.
  39661. if (el.offsetLeft - container.scrollLeft < container.offsetLeft) {
  39662. return false;
  39663. } // Check on top side.
  39664. if (el.offsetTop - container.scrollTop < container.offsetTop) {
  39665. return false;
  39666. } // Check on right side.
  39667. if (el.offsetLeft + el.offsetWidth - container.scrollLeft > container.offsetLeft + container.offsetWidth) {
  39668. return false;
  39669. } // Check on down side.
  39670. if (el.offsetTop + el.offsetHeight - container.scrollTop > container.offsetTop + container.offsetHeight) {
  39671. return false;
  39672. }
  39673. return true;
  39674. }
  39675. /**
  39676. * Find and store the navigable elements
  39677. */
  39678. getElements(direction) {
  39679. const selector = this.options.getSelector ? this.options.getSelector(direction) : this.options.selector;
  39680. if (!this.elements[selector]) {
  39681. this.elements[selector] = Array.from(this.container.querySelectorAll(selector));
  39682. }
  39683. return this.elements[selector];
  39684. }
  39685. /**
  39686. * Return an array of navigable elements after an offset.
  39687. * @param { number } left The left offset.
  39688. * @param { number } top The top offset.
  39689. * @return { Array } An array of elements.
  39690. */
  39691. elementsAfter(left, top) {
  39692. return this.getElements(DOMNavigator.DIRECTION.down).filter(el => el.offsetLeft >= left && el.offsetTop >= top);
  39693. }
  39694. /**
  39695. * Return an array of navigable elements before an offset.
  39696. * @param { number } left The left offset.
  39697. * @param { number } top The top offset.
  39698. * @return { Array } An array of elements.
  39699. */
  39700. elementsBefore(left, top) {
  39701. return this.getElements(DOMNavigator.DIRECTION.up).filter(el => el.offsetLeft <= left && el.offsetTop <= top);
  39702. }
  39703. /**
  39704. * Handle the key down event.
  39705. * @param { Event } event The event object.
  39706. */
  39707. handleKeydown(ev) {
  39708. const keys = keycodes;
  39709. const direction = ev.shiftKey ? this.keys[`${keys.SHIFT}+${ev.which}`] : this.keys[ev.which];
  39710. if (direction) {
  39711. ev.preventDefault();
  39712. ev.stopPropagation();
  39713. const next = this.getNextElement(direction, ev);
  39714. this.select(next, direction);
  39715. }
  39716. }
  39717. }
  39718. /* harmony default export */ const dom_navigator = (DOMNavigator);
  39719. ;// CONCATENATED MODULE: ./src/shared/components/dropdownbase.js
  39720. const dropdownbase_u = core_converse.env.utils;
  39721. class DropdownBase extends CustomElement {
  39722. connectedCallback() {
  39723. super.connectedCallback();
  39724. this.registerEvents();
  39725. }
  39726. registerEvents() {
  39727. this.clickOutside = ev => this._clickOutside(ev);
  39728. document.addEventListener('click', this.clickOutside);
  39729. }
  39730. firstUpdated() {
  39731. super.firstUpdated();
  39732. this.menu = this.querySelector('.dropdown-menu');
  39733. this.button = this.querySelector('button');
  39734. this.addEventListener('click', ev => this.toggleMenu(ev));
  39735. this.addEventListener('keyup', ev => this.handleKeyUp(ev));
  39736. }
  39737. _clickOutside(ev) {
  39738. if (!this.contains(ev.composedPath()[0])) {
  39739. this.hideMenu(ev);
  39740. }
  39741. }
  39742. hideMenu() {
  39743. var _this$button, _this$button2;
  39744. dropdownbase_u.removeClass('show', this.menu);
  39745. (_this$button = this.button) === null || _this$button === void 0 ? void 0 : _this$button.setAttribute('aria-expanded', false);
  39746. (_this$button2 = this.button) === null || _this$button2 === void 0 ? void 0 : _this$button2.blur();
  39747. }
  39748. showMenu() {
  39749. dropdownbase_u.addClass('show', this.menu);
  39750. this.button.setAttribute('aria-expanded', true);
  39751. }
  39752. toggleMenu(ev) {
  39753. ev.preventDefault();
  39754. if (dropdownbase_u.hasClass('show', this.menu)) {
  39755. this.hideMenu();
  39756. } else {
  39757. this.showMenu();
  39758. }
  39759. }
  39760. handleKeyUp(ev) {
  39761. if (ev.keyCode === core_converse.keycodes.ESCAPE) {
  39762. this.hideMenu();
  39763. }
  39764. }
  39765. disconnectedCallback() {
  39766. document.removeEventListener('click', this.clickOutside);
  39767. super.disconnectedCallback();
  39768. }
  39769. }
  39770. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/components/styles/dropdown.scss
  39771. var dropdown = __webpack_require__(7631);
  39772. ;// CONCATENATED MODULE: ./src/shared/components/styles/dropdown.scss
  39773. var dropdown_options = {};
  39774. dropdown_options.styleTagTransform = (styleTagTransform_default());
  39775. dropdown_options.setAttributes = (setAttributesWithoutAttributes_default());
  39776. dropdown_options.insert = insertBySelector_default().bind(null, "head");
  39777. dropdown_options.domAPI = (styleDomAPI_default());
  39778. dropdown_options.insertStyleElement = (insertStyleElement_default());
  39779. var dropdown_update = injectStylesIntoStyleTag_default()(dropdown/* default */.Z, dropdown_options);
  39780. /* harmony default export */ const styles_dropdown = (dropdown/* default */.Z && dropdown/* default.locals */.Z.locals ? dropdown/* default.locals */.Z.locals : undefined);
  39781. ;// CONCATENATED MODULE: ./src/shared/components/dropdown.js
  39782. class Dropdown extends DropdownBase {
  39783. static get properties() {
  39784. return {
  39785. 'icon_classes': {
  39786. type: String
  39787. },
  39788. 'color': {
  39789. type: String
  39790. },
  39791. 'items': {
  39792. type: Array
  39793. }
  39794. };
  39795. }
  39796. constructor() {
  39797. super();
  39798. this.color = 'var(--text-color)';
  39799. this.icon_classes = 'fa fa-bars';
  39800. }
  39801. render() {
  39802. return $`
  39803. <button type="button" class="btn btn--transparent btn--standalone" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  39804. <converse-icon color="${this.color}" size="1em" class="${this.icon_classes}">
  39805. </button>
  39806. <div class="dropdown-menu">
  39807. ${this.items.map(b => until_c(b, ''))}
  39808. </div>
  39809. `;
  39810. }
  39811. firstUpdated() {
  39812. super.firstUpdated();
  39813. this.initArrowNavigation();
  39814. }
  39815. connectedCallback() {
  39816. super.connectedCallback();
  39817. this.hideOnEscape = ev => ev.keyCode === KEYCODES.ESCAPE && this.hideMenu();
  39818. document.addEventListener('keydown', this.hideOnEscape);
  39819. }
  39820. disconnectedCallback() {
  39821. document.removeEventListener('keydown', this.hideOnEscape);
  39822. super.disconnectedCallback();
  39823. }
  39824. hideMenu() {
  39825. var _this$navigator;
  39826. super.hideMenu();
  39827. (_this$navigator = this.navigator) === null || _this$navigator === void 0 ? void 0 : _this$navigator.disable();
  39828. }
  39829. initArrowNavigation() {
  39830. if (!this.navigator) {
  39831. const options = {
  39832. 'selector': '.dropdown-item',
  39833. 'onSelected': el => el.focus()
  39834. };
  39835. this.navigator = new dom_navigator(this.menu, options);
  39836. }
  39837. }
  39838. enableArrowNavigation(ev) {
  39839. if (ev) {
  39840. ev.preventDefault();
  39841. ev.stopPropagation();
  39842. }
  39843. this.navigator.enable();
  39844. this.navigator.select(this.menu.firstElementChild);
  39845. }
  39846. handleKeyUp(ev) {
  39847. super.handleKeyUp(ev);
  39848. if (ev.keyCode === KEYCODES.DOWN_ARROW && !this.navigator.enabled) {
  39849. this.enableArrowNavigation(ev);
  39850. }
  39851. }
  39852. }
  39853. core_api.elements.define('converse-dropdown', Dropdown);
  39854. ;// CONCATENATED MODULE: ./src/shared/avatar/templates/avatar.js
  39855. const getImgHref = (image, image_type) => {
  39856. return image.startsWith('data:') ? image : `data:${image_type};base64,${image}`;
  39857. };
  39858. /* harmony default export */ const avatar = (o => {
  39859. if (o.image) {
  39860. return $`
  39861. <svg xmlns="http://www.w3.org/2000/svg" class="avatar ${o.classes}" width="${o.width}" height="${o.height}">
  39862. <image width="${o.width}" height="${o.height}" preserveAspectRatio="xMidYMid meet" href="${getImgHref(o.image, o.image_type)}"/>
  39863. </svg>`;
  39864. } else {
  39865. return '';
  39866. }
  39867. });
  39868. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/avatar/avatar.scss
  39869. var avatar_avatar = __webpack_require__(5222);
  39870. ;// CONCATENATED MODULE: ./src/shared/avatar/avatar.scss
  39871. var avatar_options = {};
  39872. avatar_options.styleTagTransform = (styleTagTransform_default());
  39873. avatar_options.setAttributes = (setAttributesWithoutAttributes_default());
  39874. avatar_options.insert = insertBySelector_default().bind(null, "head");
  39875. avatar_options.domAPI = (styleDomAPI_default());
  39876. avatar_options.insertStyleElement = (insertStyleElement_default());
  39877. var avatar_update = injectStylesIntoStyleTag_default()(avatar_avatar/* default */.Z, avatar_options);
  39878. /* harmony default export */ const shared_avatar_avatar = (avatar_avatar/* default */.Z && avatar_avatar/* default.locals */.Z.locals ? avatar_avatar/* default.locals */.Z.locals : undefined);
  39879. ;// CONCATENATED MODULE: ./src/shared/avatar/avatar.js
  39880. class Avatar extends CustomElement {
  39881. static get properties() {
  39882. return {
  39883. data: {
  39884. type: Object
  39885. },
  39886. width: {
  39887. type: String
  39888. },
  39889. height: {
  39890. type: String
  39891. },
  39892. nonce: {
  39893. type: String
  39894. } // Used to trigger rerenders
  39895. };
  39896. }
  39897. constructor() {
  39898. super();
  39899. this.width = 36;
  39900. this.height = 36;
  39901. }
  39902. render() {
  39903. var _this$data, _this$data2;
  39904. const image_type = ((_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.image_type) || shared_converse.DEFAULT_IMAGE_TYPE;
  39905. let image;
  39906. if ((_this$data2 = this.data) !== null && _this$data2 !== void 0 && _this$data2.data_uri) {
  39907. var _this$data3;
  39908. image = (_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : _this$data3.data_uri;
  39909. } else {
  39910. var _this$data4;
  39911. const image_data = ((_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : _this$data4.image) || shared_converse.DEFAULT_IMAGE;
  39912. image = "data:" + image_type + ";base64," + image_data;
  39913. }
  39914. return avatar({
  39915. 'classes': this.getAttribute('class'),
  39916. 'height': this.height,
  39917. 'width': this.width,
  39918. image,
  39919. image_type
  39920. });
  39921. }
  39922. }
  39923. core_api.elements.define('converse-avatar', Avatar);
  39924. ;// CONCATENATED MODULE: ./src/shared/chat/templates/file-progress.js
  39925. /* harmony default export */ const file_progress = (el => {
  39926. var _el$model$vcard, _el$model$vcard2;
  39927. const i18n_uploading = __('Uploading file:');
  39928. const filename = el.model.file.name;
  39929. const size = filesize_min_default()(el.model.file.size);
  39930. return $`
  39931. <div class="message chat-msg">
  39932. ${el.shouldShowAvatar() ? $`<a class="show-msg-author-modal" @click=${el.showUserModal}>
  39933. <converse-avatar class="avatar align-self-center"
  39934. .data=${(_el$model$vcard = el.model.vcard) === null || _el$model$vcard === void 0 ? void 0 : _el$model$vcard.attributes}
  39935. nonce=${(_el$model$vcard2 = el.model.vcard) === null || _el$model$vcard2 === void 0 ? void 0 : _el$model$vcard2.get('vcard_updated')}
  39936. height="40" width="40"></converse-avatar>
  39937. </a>` : ''}
  39938. <div class="chat-msg__content">
  39939. <span class="chat-msg__text">${i18n_uploading} <strong>${filename}</strong>, ${size}</span>
  39940. <progress value="${el.model.get('progress')}"/>
  39941. </div>
  39942. </div>`;
  39943. });
  39944. ;// CONCATENATED MODULE: ./src/shared/components/message-versions.js
  39945. const {
  39946. dayjs: message_versions_dayjs
  39947. } = core_converse.env;
  39948. class MessageVersions extends CustomElement {
  39949. static get properties() {
  39950. return {
  39951. 'model': {
  39952. type: Object
  39953. }
  39954. };
  39955. }
  39956. render() {
  39957. const older_versions = this.model.get('older_versions');
  39958. return $`
  39959. <h4>Older versions</h4>
  39960. ${Object.keys(older_versions).map(k => $`<p class="older-msg"><time>${message_versions_dayjs(k).format('MMM D, YYYY, HH:mm:ss')}</time>: ${older_versions[k]}</p>`)}
  39961. <hr/>
  39962. <h4>Current version</h4>
  39963. <p>${this.model.getMessageText()}</p>`;
  39964. }
  39965. }
  39966. core_api.elements.define('converse-message-versions', MessageVersions);
  39967. ;// CONCATENATED MODULE: ./src/modals/templates/message-versions.js
  39968. /* harmony default export */ const message_versions = (model => $`
  39969. <div class="modal-dialog" role="document">
  39970. <div class="modal-content">
  39971. <div class="modal-header">
  39972. <h4 class="modal-title" id="message-versions-modal-label">${__('Message versions')}</h4>
  39973. ${modal_header_close_button}
  39974. </div>
  39975. <div class="modal-body">
  39976. <converse-message-versions .model=${model}></converse-message-versions>
  39977. </div>
  39978. <div class="modal-footer">${modal_close_button}</div>
  39979. </div>
  39980. </div>
  39981. `);
  39982. ;// CONCATENATED MODULE: ./src/modals/message-versions.js
  39983. /* harmony default export */ const modals_message_versions = (base.extend({
  39984. id: "message-versions-modal",
  39985. toHTML() {
  39986. return message_versions(this.model);
  39987. }
  39988. }));
  39989. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/templates/occupant.js
  39990. /* harmony default export */ const templates_occupant = (o => {
  39991. var _o$vcard, _o$vcard2;
  39992. return $`
  39993. <div class="modal-dialog" role="document">
  39994. <div class="modal-content">
  39995. <div class="modal-header">
  39996. <h5 class="modal-title" id="user-details-modal-label">${o.display_name}</h5>
  39997. ${modal_header_close_button}
  39998. </div>
  39999. <div class="modal-body" class="d-flex">
  40000. <div class="row">
  40001. <div class="col-auto">
  40002. <converse-avatar
  40003. class="avatar modal-avatar"
  40004. .data=${(_o$vcard = o.vcard) === null || _o$vcard === void 0 ? void 0 : _o$vcard.attributes}
  40005. nonce=${(_o$vcard2 = o.vcard) === null || _o$vcard2 === void 0 ? void 0 : _o$vcard2.get('vcard_updated')}
  40006. height="120" width="120"></converse-avatar>
  40007. </div>
  40008. <div class="col">
  40009. <ul class="occupant-details">
  40010. <li>
  40011. ${o.nick ? $`<div class="row"><strong>${__('Nickname')}:</strong></div><div class="row">${o.nick}</div>` : ''}
  40012. </li>
  40013. <li>
  40014. ${o.jid ? $`<div class="row"><strong>${__('XMPP Address')}:</strong></div><div class="row">${o.jid}</div>` : ''}
  40015. </li>
  40016. <li>
  40017. ${o.affiliation ? $`<div class="row"><strong>${__('Affiliation')}:</strong></div><div class="row">${o.affiliation}</div>` : ''}
  40018. </li>
  40019. <li>
  40020. ${o.role ? $`<div class="row"><strong>${__('Roles')}:</strong></div><div class="row">${o.role}</div>` : ''}
  40021. </li>
  40022. <li>
  40023. ${o.hats ? $`<div class="row"><strong>${__('Hats')}:</strong></div><div class="row">${o.hats}</div>` : ''}
  40024. </li>
  40025. <li>
  40026. ${o.occupant_id ? $`<div class="row"><strong>${__('Occupant Id')}:</strong></div><div class="row">${o.occupant_id}</div>` : ''}
  40027. </li>
  40028. </ul>
  40029. </div>
  40030. </div>
  40031. </div>
  40032. <div class="modal-footer">
  40033. ${modal_close_button}
  40034. </div>
  40035. </div>
  40036. </div>
  40037. `;
  40038. });
  40039. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/occupant.js
  40040. const OccupantModal = base.extend({
  40041. id: "muc-occupant",
  40042. initialize() {
  40043. base.prototype.initialize.apply(this, arguments);
  40044. if (this.model) {
  40045. this.listenTo(this.model, 'change', this.render);
  40046. }
  40047. /**
  40048. * Triggered once the OccupantModal has been initialized
  40049. * @event _converse#occupantModalInitialized
  40050. * @type { Object }
  40051. * @example _converse.api.listen.on('occupantModalInitialized', data);
  40052. */
  40053. core_api.trigger('occupantModalInitialized', {
  40054. 'model': this.model,
  40055. 'message': this.message
  40056. });
  40057. },
  40058. getVcard() {
  40059. const model = this.model ?? this.message;
  40060. if (model.vcard) {
  40061. return model.vcard;
  40062. }
  40063. const jid = (model === null || model === void 0 ? void 0 : model.get('jid')) || (model === null || model === void 0 ? void 0 : model.get('from'));
  40064. return jid ? shared_converse.vcards.get(jid) : null;
  40065. },
  40066. toHTML() {
  40067. var _this$model, _this$model2, _this$model3, _this$model3$get;
  40068. const model = this.model ?? this.message;
  40069. const jid = model === null || model === void 0 ? void 0 : model.get('jid');
  40070. const vcard = this.getVcard();
  40071. const display_name = model === null || model === void 0 ? void 0 : model.getDisplayName();
  40072. const nick = model.get('nick');
  40073. const occupant_id = model.get('occupant_id');
  40074. const role = (_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.get('role');
  40075. const affiliation = (_this$model2 = this.model) === null || _this$model2 === void 0 ? void 0 : _this$model2.get('affiliation');
  40076. const hats = (_this$model3 = this.model) !== null && _this$model3 !== void 0 && (_this$model3$get = _this$model3.get('hats')) !== null && _this$model3$get !== void 0 && _this$model3$get.length ? this.model.get('hats') : null;
  40077. return templates_occupant({
  40078. jid,
  40079. vcard,
  40080. display_name,
  40081. nick,
  40082. occupant_id,
  40083. role,
  40084. affiliation,
  40085. hats
  40086. });
  40087. }
  40088. });
  40089. shared_converse.OccupantModal = OccupantModal;
  40090. /* harmony default export */ const modals_occupant = (OccupantModal);
  40091. ;// CONCATENATED MODULE: ./src/modals/templates/user-details.js
  40092. const remove_button = o => {
  40093. const i18n_remove_contact = __('Remove as contact');
  40094. return $`
  40095. <button type="button" @click="${o.removeContact}" class="btn btn-danger remove-contact">
  40096. <converse-icon
  40097. class="fas fa-trash-alt"
  40098. color="var(--text-color-lighten-15-percent)"
  40099. size="1em"
  40100. ></converse-icon>
  40101. ${i18n_remove_contact}
  40102. </button>
  40103. `;
  40104. };
  40105. /* harmony default export */ const user_details = (o => {
  40106. const i18n_address = __('XMPP Address');
  40107. const i18n_email = __('Email');
  40108. const i18n_full_name = __('Full Name');
  40109. const i18n_nickname = __('Nickname');
  40110. const i18n_profile = __('The User\'s Profile Image');
  40111. const i18n_refresh = __('Refresh');
  40112. const i18n_role = __('Role');
  40113. const i18n_url = __('URL');
  40114. const avatar_data = {
  40115. 'alt_text': i18n_profile,
  40116. 'extra_classes': 'mb-3',
  40117. 'height': '120',
  40118. 'width': '120'
  40119. };
  40120. return $`
  40121. <div class="modal-dialog" role="document">
  40122. <div class="modal-content">
  40123. <div class="modal-header">
  40124. <h5 class="modal-title" id="user-details-modal-label">${o.display_name}</h5>
  40125. ${modal_header_close_button}
  40126. </div>
  40127. <div class="modal-body">
  40128. ${o.image ? $`<div class="mb-4">${avatar(Object.assign(o, avatar_data))}</div>` : ''}
  40129. ${o.fullname ? $`<p><label>${i18n_full_name}:</label> ${o.fullname}</p>` : ''}
  40130. <p><label>${i18n_address}:</label> <a href="xmpp:${o.jid}">${o.jid}</a></p>
  40131. ${o.nickname ? $`<p><label>${i18n_nickname}:</label> ${o.nickname}</p>` : ''}
  40132. ${o.url ? $`<p><label>${i18n_url}:</label> <a target="_blank" rel="noopener" href="${o.url}">${o.url}</a></p>` : ''}
  40133. ${o.email ? $`<p><label>${i18n_email}:</label> <a href="mailto:${o.email}">${o.email}</a></p>` : ''}
  40134. ${o.role ? $`<p><label>${i18n_role}:</label> ${o.role}</p>` : ''}
  40135. <converse-omemo-fingerprints jid=${o.jid}></converse-omemo-fingerprints>
  40136. </div>
  40137. <div class="modal-footer">
  40138. ${modal_close_button}
  40139. <button type="button" class="btn btn-info refresh-contact">
  40140. <converse-icon
  40141. class="fa fa-refresh"
  40142. color="var(--text-color-lighten-15-percent)"
  40143. size="1em"
  40144. ></converse-icon>
  40145. ${i18n_refresh}</button>
  40146. ${o.allow_contact_removal && o.is_roster_contact ? remove_button(o) : ''}
  40147. </div>
  40148. </div>
  40149. </div>
  40150. `;
  40151. });
  40152. ;// CONCATENATED MODULE: ./src/modals/user-details.js
  40153. const user_details_u = core_converse.env.utils;
  40154. function removeContact(contact) {
  40155. contact.removeFromRoster(() => contact.destroy(), e => {
  40156. e && headless_log.error(e);
  40157. core_api.alert('error', __('Error'), [__('Sorry, there was an error while trying to remove %1$s as a contact.', contact.getDisplayName())]);
  40158. });
  40159. }
  40160. const UserDetailsModal = base.extend({
  40161. id: 'user-details-modal',
  40162. persistent: true,
  40163. events: {
  40164. 'click button.refresh-contact': 'refreshContact'
  40165. },
  40166. initialize() {
  40167. base.prototype.initialize.apply(this, arguments);
  40168. this.model.rosterContactAdded.then(() => this.registerContactEventHandlers());
  40169. this.listenTo(this.model, 'change', this.render);
  40170. this.registerContactEventHandlers();
  40171. /**
  40172. * Triggered once the UserDetailsModal has been initialized
  40173. * @event _converse#userDetailsModalInitialized
  40174. * @type { _converse.ChatBox }
  40175. * @example _converse.api.listen.on('userDetailsModalInitialized', (chatbox) => { ... });
  40176. */
  40177. core_api.trigger('userDetailsModalInitialized', this.model);
  40178. },
  40179. toHTML() {
  40180. var _this$model;
  40181. const vcard = (_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.vcard;
  40182. const vcard_json = vcard ? vcard.toJSON() : {};
  40183. return user_details(Object.assign(this.model.toJSON(), vcard_json, {
  40184. '_converse': shared_converse,
  40185. 'allow_contact_removal': core_api.settings.get('allow_contact_removal'),
  40186. 'display_name': this.model.getDisplayName(),
  40187. 'is_roster_contact': this.model.contact !== undefined,
  40188. 'removeContact': ev => this.removeContact(ev),
  40189. 'view': this,
  40190. 'utils': user_details_u
  40191. }));
  40192. },
  40193. registerContactEventHandlers() {
  40194. if (this.model.contact !== undefined) {
  40195. this.listenTo(this.model.contact, 'change', this.render);
  40196. this.listenTo(this.model.contact.vcard, 'change', this.render);
  40197. this.model.contact.on('destroy', () => {
  40198. delete this.model.contact;
  40199. this.render();
  40200. });
  40201. }
  40202. },
  40203. async refreshContact(ev) {
  40204. if (ev && ev.preventDefault) {
  40205. ev.preventDefault();
  40206. }
  40207. const refresh_icon = this.el.querySelector('.fa-refresh');
  40208. user_details_u.addClass('fa-spin', refresh_icon);
  40209. try {
  40210. await core_api.vcard.update(this.model.contact.vcard, true);
  40211. } catch (e) {
  40212. headless_log.fatal(e);
  40213. this.alert(__('Sorry, something went wrong while trying to refresh'), 'danger');
  40214. }
  40215. user_details_u.removeClass('fa-spin', refresh_icon);
  40216. },
  40217. removeContact(ev) {
  40218. var _ev$preventDefault;
  40219. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  40220. if (!core_api.settings.get('allow_contact_removal')) {
  40221. return;
  40222. }
  40223. const result = confirm(__("Are you sure you want to remove this contact?"));
  40224. if (result === true) {
  40225. // XXX: The `dismissHandler` in bootstrap.native tries to
  40226. // reference the remove button after it's been cleared from
  40227. // the DOM, so we delay removing the contact to give it time.
  40228. setTimeout(() => removeContact(this.model.contact), 1);
  40229. this.modal.hide();
  40230. }
  40231. }
  40232. });
  40233. shared_converse.UserDetailsModal = UserDetailsModal;
  40234. /* harmony default export */ const modals_user_details = (UserDetailsModal);
  40235. ;// CONCATENATED MODULE: ./src/shared/chat/templates/info-message.js
  40236. const {
  40237. dayjs: info_message_dayjs
  40238. } = core_converse.env;
  40239. /* harmony default export */ const info_message = (el => {
  40240. const isodate = info_message_dayjs(el.model.get('time')).toISOString();
  40241. const i18n_retry = __('Retry');
  40242. return $`
  40243. <div class="message chat-info chat-${el.model.get('type')}"
  40244. data-isodate="${isodate}"
  40245. data-type="${el.data_name}"
  40246. data-value="${el.data_value}">
  40247. <div class="chat-info__message">
  40248. <converse-rich-text
  40249. .mentions=${el.model.get('references')}
  40250. render_styling
  40251. text=${el.model.getMessageText()}>
  40252. </converse-rich-text>
  40253. </div>
  40254. ${el.model.get('reason') ? $`<q class="reason">${el.model.get('reason')}</q>` : ``}
  40255. ${el.model.get('error_text') ? $`<q class="reason">${el.model.get('error_text')}</q>` : ``}
  40256. ${el.model.get('retry_event_id') ? $`<a class="retry" @click=${el.onRetryClicked}>${i18n_retry}</a>` : ''}
  40257. </div>`;
  40258. });
  40259. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/mep-message.js
  40260. const {
  40261. dayjs: mep_message_dayjs
  40262. } = core_converse.env;
  40263. /* harmony default export */ const mep_message = (el => {
  40264. const isodate = mep_message_dayjs(el.model.get('time')).toISOString();
  40265. return $`
  40266. <div class="message chat-info message--mep ${el.getExtraMessageClasses()}"
  40267. data-isodate="${isodate}"
  40268. data-type="${el.data_name}"
  40269. data-value="${el.data_value}">
  40270. <div class="chat-msg__content">
  40271. <div class="chat-msg__body chat-msg__body--${el.model.get('type')} ${el.model.get('is_delayed') ? 'chat-msg__body--delayed' : ''}">
  40272. <div class="chat-info__message">
  40273. ${el.isRetracted() ? el.renderRetraction() : $`
  40274. <converse-rich-text
  40275. .mentions=${el.model.get('references')}
  40276. render_styling
  40277. text=${el.model.getMessageText()}>
  40278. </converse-rich-text>
  40279. ${el.model.get('reason') ? $`<q class="reason"><converse-rich-text text=${el.model.get('reason')}></converse-rich-text></q>` : ``}
  40280. `}
  40281. </div>
  40282. <converse-message-actions
  40283. ?is_retracted=${el.isRetracted()}
  40284. .model=${el.model}></converse-message-actions>
  40285. </div>
  40286. </div>
  40287. </div>`;
  40288. });
  40289. ;// CONCATENATED MODULE: ./src/shared/components/image.js
  40290. class Image extends CustomElement {
  40291. static get properties() {
  40292. return {
  40293. 'src': {
  40294. type: String
  40295. },
  40296. 'onImgLoad': {
  40297. type: Function
  40298. },
  40299. // If specified, image is wrapped in a hyperlink that points to this URL.
  40300. 'href': {
  40301. type: String
  40302. }
  40303. };
  40304. }
  40305. render() {
  40306. if (isGIFURL(this.src) && shouldRenderMediaFromURL(this.src, 'image')) {
  40307. return templates_gif(filterQueryParamsFromURL(this.src), true);
  40308. } else {
  40309. return src_templates_image({
  40310. 'src': filterQueryParamsFromURL(this.src),
  40311. 'href': this.href,
  40312. 'onClick': this.onImgClick,
  40313. 'onLoad': this.onImgLoad
  40314. });
  40315. }
  40316. }
  40317. }
  40318. core_api.elements.define('converse-image', Image);
  40319. ;// CONCATENATED MODULE: ./src/shared/chat/templates/unfurl.js
  40320. function isValidURL(url) {
  40321. // We don't consider relative URLs as valid
  40322. return !!getURI(url).host();
  40323. }
  40324. function isValidImage(image) {
  40325. return image && isDomainAllowed(image, 'allowed_image_domains') && isValidURL(image);
  40326. }
  40327. const tpl_url_wrapper = (o, wrapped_template) => o.url && isValidURL(o.url) && !isGIFURL(o.image) ? $`<a href="${o.url}" target="_blank" rel="noopener">${wrapped_template(o)}</a>` : wrapped_template(o);
  40328. const tpl_image = o => $`<converse-image class="card-img-top" href="${o.url}" src="${o.image}" .onImgLoad=${o.onload}></converse-image>`;
  40329. /* harmony default export */ const unfurl = (o => {
  40330. const show_image = isValidImage(o.image);
  40331. const has_body_info = o.title || o.description || o.url;
  40332. if (show_image || has_body_info) {
  40333. return $`<div class="card card--unfurl">
  40334. ${show_image ? tpl_url_wrapper(o, tpl_image) : ''}
  40335. ${has_body_info ? $` <div class="card-body">
  40336. ${o.title ? tpl_url_wrapper(o, o => $`<h5 class="card-title">${o.title}</h5>`) : ''}
  40337. ${o.description ? $`<p class="card-text">
  40338. <converse-rich-text text=${o.description}></converse-rich-text>
  40339. </p>` : ''}
  40340. ${o.url ? $`<p class="card-text">
  40341. <a href="${o.url}" target="_blank" rel="noopener">${getURI(o.url).domain()}</a>
  40342. </p>` : ''}
  40343. </div>` : ''}
  40344. </div>`;
  40345. } else {
  40346. return '';
  40347. }
  40348. });
  40349. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/unfurl.scss
  40350. var styles_unfurl = __webpack_require__(5046);
  40351. ;// CONCATENATED MODULE: ./src/shared/chat/styles/unfurl.scss
  40352. var unfurl_options = {};
  40353. unfurl_options.styleTagTransform = (styleTagTransform_default());
  40354. unfurl_options.setAttributes = (setAttributesWithoutAttributes_default());
  40355. unfurl_options.insert = insertBySelector_default().bind(null, "head");
  40356. unfurl_options.domAPI = (styleDomAPI_default());
  40357. unfurl_options.insertStyleElement = (insertStyleElement_default());
  40358. var unfurl_update = injectStylesIntoStyleTag_default()(styles_unfurl/* default */.Z, unfurl_options);
  40359. /* harmony default export */ const chat_styles_unfurl = (styles_unfurl/* default */.Z && styles_unfurl/* default.locals */.Z.locals ? styles_unfurl/* default.locals */.Z.locals : undefined);
  40360. ;// CONCATENATED MODULE: ./src/shared/chat/unfurl.js
  40361. class MessageUnfurl extends CustomElement {
  40362. static get properties() {
  40363. return {
  40364. description: {
  40365. type: String
  40366. },
  40367. image: {
  40368. type: String
  40369. },
  40370. jid: {
  40371. type: String
  40372. },
  40373. title: {
  40374. type: String
  40375. },
  40376. url: {
  40377. type: String
  40378. }
  40379. };
  40380. }
  40381. initialize() {
  40382. const settings = getAppSettings();
  40383. this.listenTo(settings, 'change:allowed_image_domains', () => this.requestUpdate());
  40384. this.listenTo(settings, 'change:render_media', () => this.requestUpdate());
  40385. }
  40386. render() {
  40387. return unfurl(Object.assign({
  40388. 'onload': () => this.onImageLoad()
  40389. }, {
  40390. description: this.description || '',
  40391. image: this.image || '',
  40392. title: this.title || '',
  40393. url: this.url || ''
  40394. }));
  40395. }
  40396. onImageLoad() {
  40397. this.dispatchEvent(new CustomEvent('imageLoaded', {
  40398. detail: this,
  40399. 'bubbles': true
  40400. }));
  40401. }
  40402. }
  40403. core_api.elements.define('converse-message-unfurl', MessageUnfurl);
  40404. ;// CONCATENATED MODULE: ./src/shared/chat/templates/message.js
  40405. /* harmony default export */ const templates_message = ((el, o) => {
  40406. var _el$model$vcard, _el$model$vcard2, _el$model$get;
  40407. const i18n_new_messages = __('New messages');
  40408. const is_followup = el.model.isFollowup();
  40409. return $`
  40410. ${o.is_first_unread ? $`<div class="message separator"><hr class="separator"><span class="separator-text">${i18n_new_messages}</span></div>` : ''}
  40411. <div class="message chat-msg ${el.getExtraMessageClasses()}"
  40412. data-isodate="${o.time}"
  40413. data-msgid="${o.msgid}"
  40414. data-from="${o.from}"
  40415. data-encrypted="${o.is_encrypted}">
  40416. <!-- Anchor to allow us to scroll the message into view -->
  40417. <a id="${o.msgid}"></a>
  40418. ${o.should_show_avatar && !is_followup ? $`<a class="show-msg-author-modal" @click=${el.showUserModal}>
  40419. <converse-avatar
  40420. class="avatar align-self-center"
  40421. .data=${(_el$model$vcard = el.model.vcard) === null || _el$model$vcard === void 0 ? void 0 : _el$model$vcard.attributes}
  40422. nonce=${(_el$model$vcard2 = el.model.vcard) === null || _el$model$vcard2 === void 0 ? void 0 : _el$model$vcard2.get('vcard_updated')}
  40423. height="40" width="40"></converse-avatar>
  40424. </a>` : ''}
  40425. <div class="chat-msg__content chat-msg__content--${o.sender} ${o.is_me_message ? 'chat-msg__content--action' : ''}">
  40426. ${!o.is_me_message && !is_followup ? $`
  40427. <span class="chat-msg__heading">
  40428. <span class="chat-msg__author"><a class="show-msg-author-modal" @click=${el.showUserModal}>${o.username}</a></span>
  40429. ${o.hats.map(h => $`<span class="badge badge-secondary">${h.title}</span>`)}
  40430. <time timestamp="${el.model.get('edited') || el.model.get('time')}" class="chat-msg__time">${o.pretty_time}</time>
  40431. ${o.is_encrypted ? $`<converse-icon class="fa fa-lock" size="1.1em"></converse-icon>` : ''}
  40432. </span>` : ''}
  40433. <div class="chat-msg__body chat-msg__body--${o.message_type} ${o.received ? 'chat-msg__body--received' : ''} ${o.is_delayed ? 'chat-msg__body--delayed' : ''}">
  40434. <div class="chat-msg__message">
  40435. ${o.is_me_message ? $`
  40436. <time timestamp="${o.edited || o.time}" class="chat-msg__time">${o.pretty_time}</time>&nbsp;
  40437. <span class="chat-msg__author">${o.is_me_message ? '**' : ''}${o.username}</span>&nbsp;` : ''}
  40438. ${o.is_retracted ? el.renderRetraction() : el.renderMessageText()}
  40439. </div>
  40440. <converse-message-actions
  40441. .model=${el.model}
  40442. ?is_retracted=${o.is_retracted}></converse-message-actions>
  40443. </div>
  40444. ${(_el$model$get = el.model.get('ogp_metadata')) === null || _el$model$get === void 0 ? void 0 : _el$model$get.map(m => {
  40445. var _el$chatbox;
  40446. if (el.model.get('hide_url_previews') === true) {
  40447. return '';
  40448. }
  40449. if (!shouldRenderMediaFromURL(m['og:image'], 'image')) {
  40450. return '';
  40451. }
  40452. return $`<converse-message-unfurl
  40453. @animationend="${el.onUnfurlAnimationEnd}"
  40454. class="${el.model.get('url_preview_transition')}"
  40455. jid="${(_el$chatbox = el.chatbox) === null || _el$chatbox === void 0 ? void 0 : _el$chatbox.get('jid')}"
  40456. description="${m['og:description'] || ''}"
  40457. title="${m['og:title'] || ''}"
  40458. image="${m['og:image'] || ''}"
  40459. url="${m['og:url'] || ''}"></converse-message-unfurl>`;
  40460. })}
  40461. </div>
  40462. </div>`;
  40463. });
  40464. ;// CONCATENATED MODULE: ./src/shared/chat/templates/message-text.js
  40465. const tpl_edited_icon = el => {
  40466. const i18n_edited = __('This message has been edited');
  40467. return $`<converse-icon title="${i18n_edited}" class="fa fa-edit chat-msg__edit-modal" @click=${el.showMessageVersionsModal} size="1em"></converse-icon>`;
  40468. };
  40469. /* harmony default export */ const message_text = (el => {
  40470. const i18n_show = __('Show more');
  40471. const is_groupchat_message = el.model.get('type') === 'groupchat';
  40472. const i18n_show_less = __('Show less');
  40473. const tpl_spoiler_hint = $`
  40474. <div class="chat-msg__spoiler-hint">
  40475. <span class="spoiler-hint">${el.model.get('spoiler_hint')}</span>
  40476. <a class="badge badge-info spoiler-toggle" href="#" @click=${el.toggleSpoilerMessage}>
  40477. <converse-icon size="1em" color="var(--background)" class="fa ${el.model.get('is_spoiler_visible') ? 'fa-eye-slash' : 'fa-eye'}"></converse-icon>
  40478. ${el.model.get('is_spoiler_visible') ? i18n_show_less : i18n_show}
  40479. </a>
  40480. </div>
  40481. `;
  40482. const spoiler_classes = el.model.get('is_spoiler') ? `spoiler ${el.model.get('is_spoiler_visible') ? '' : 'hidden'}` : '';
  40483. const text = el.model.getMessageText();
  40484. const show_oob = el.model.get('oob_url') && text !== el.model.get('oob_url');
  40485. return $`
  40486. ${el.model.get('is_spoiler') ? tpl_spoiler_hint : ''}
  40487. ${el.model.get('subject') ? $`<div class="chat-msg__subject">${el.model.get('subject')}</div>` : ''}
  40488. <span>
  40489. <converse-chat-message-body
  40490. class="chat-msg__text ${el.model.get('is_only_emojis') ? 'chat-msg__text--larger' : ''} ${spoiler_classes}"
  40491. .model="${el.model}"
  40492. hide_url_previews=${el.model.get('hide_url_previews')}
  40493. ?is_me_message=${el.model.isMeCommand()}
  40494. text="${text}"></converse-chat-message-body>
  40495. ${el.model.get('received') && !el.model.isMeCommand() && !is_groupchat_message ? $`<span class="fa fa-check chat-msg__receipt"></span>` : ''}
  40496. ${el.model.get('edited') ? tpl_edited_icon(el) : ''}
  40497. </span>
  40498. ${show_oob ? $`<div class="chat-msg__media">${getOOBURLMarkup(el.model.get('oob_url'))}</div>` : ''}
  40499. <div class="chat-msg__error">${el.model.get('error_text') || el.model.get('error')}</div>
  40500. `;
  40501. });
  40502. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/retraction.scss
  40503. var retraction = __webpack_require__(9523);
  40504. ;// CONCATENATED MODULE: ./src/shared/chat/styles/retraction.scss
  40505. var retraction_options = {};
  40506. retraction_options.styleTagTransform = (styleTagTransform_default());
  40507. retraction_options.setAttributes = (setAttributesWithoutAttributes_default());
  40508. retraction_options.insert = insertBySelector_default().bind(null, "head");
  40509. retraction_options.domAPI = (styleDomAPI_default());
  40510. retraction_options.insertStyleElement = (insertStyleElement_default());
  40511. var retraction_update = injectStylesIntoStyleTag_default()(retraction/* default */.Z, retraction_options);
  40512. /* harmony default export */ const styles_retraction = (retraction/* default */.Z && retraction/* default.locals */.Z.locals ? retraction/* default.locals */.Z.locals : undefined);
  40513. ;// CONCATENATED MODULE: ./src/shared/chat/templates/retraction.js
  40514. /* harmony default export */ const templates_retraction = (el => {
  40515. const retraction_text = el.isRetracted() ? el.getRetractionText() : null;
  40516. return $`
  40517. <div class="retraction">${retraction_text}</div>
  40518. ${el.model.get('moderation_reason') ? $`<q class="chat-msg--retracted__reason">${el.model.get('moderation_reason')}</q>` : ''}`;
  40519. });
  40520. ;// CONCATENATED MODULE: ./src/templates/spinner.js
  40521. /* harmony default export */ const spinner = (function () {
  40522. var _o$classes;
  40523. let o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  40524. if ((_o$classes = o.classes) !== null && _o$classes !== void 0 && _o$classes.includes('hor_centered')) {
  40525. return $`<div class="spinner__container"><converse-icon size="1em" class="fa fa-spinner spinner centered ${o.classes || ''}"></converse-icon></div>`;
  40526. } else {
  40527. return $`<converse-icon size="1em" class="fa fa-spinner spinner centered ${o.classes || ''}"></converse-icon>`;
  40528. }
  40529. });
  40530. ;// CONCATENATED MODULE: ./src/shared/chat/message.js
  40531. const {
  40532. Strophe: chat_message_Strophe,
  40533. dayjs: message_dayjs
  40534. } = core_converse.env;
  40535. class Message extends CustomElement {
  40536. static get properties() {
  40537. return {
  40538. jid: {
  40539. type: String
  40540. },
  40541. mid: {
  40542. type: String
  40543. }
  40544. };
  40545. }
  40546. async initialize() {
  40547. await this.setModels();
  40548. if (!this.model) {
  40549. // Happen during tests due to a race condition
  40550. headless_log.error('Could not find module for converse-chat-message');
  40551. return;
  40552. }
  40553. const settings = getAppSettings();
  40554. this.listenTo(settings, 'change:render_media', () => {
  40555. // Reset individual show/hide state of media
  40556. this.model.save('hide_url_previews', undefined);
  40557. this.requestUpdate();
  40558. });
  40559. this.listenTo(this.chatbox, 'change:first_unread_id', () => this.requestUpdate());
  40560. this.listenTo(this.model, 'change', () => this.requestUpdate());
  40561. this.model.vcard && this.listenTo(this.model.vcard, 'change', () => this.requestUpdate());
  40562. if (this.model.get('type') === 'groupchat') {
  40563. if (this.model.occupant) {
  40564. this.listenTo(this.model.occupant, 'change', () => this.requestUpdate());
  40565. } else {
  40566. this.listenTo(this.model, 'occupantAdded', () => {
  40567. this.requestUpdate();
  40568. this.listenTo(this.model.occupant, 'change', () => this.requestUpdate());
  40569. });
  40570. }
  40571. }
  40572. }
  40573. async setModels() {
  40574. this.chatbox = await core_api.chatboxes.get(this.jid);
  40575. await this.chatbox.initialized;
  40576. await this.chatbox.messages.fetched;
  40577. this.model = this.chatbox.messages.get(this.mid);
  40578. this.model && this.requestUpdate();
  40579. }
  40580. render() {
  40581. if (!this.model) {
  40582. return '';
  40583. } else if (this.show_spinner) {
  40584. return spinner();
  40585. } else if (this.model.get('file') && this.model.get('upload') !== shared_converse.SUCCESS) {
  40586. return this.renderFileProgress();
  40587. } else if (['mep'].includes(this.model.get('type'))) {
  40588. return this.renderMEPMessage();
  40589. } else if (['error', 'info'].includes(this.model.get('type'))) {
  40590. return this.renderInfoMessage();
  40591. } else {
  40592. return this.renderChatMessage();
  40593. }
  40594. }
  40595. getProps() {
  40596. return Object.assign(this.model.toJSON(), this.getDerivedMessageProps());
  40597. }
  40598. renderRetraction() {
  40599. return templates_retraction(this);
  40600. }
  40601. renderMessageText() {
  40602. return message_text(this);
  40603. }
  40604. renderMEPMessage() {
  40605. return mep_message(this);
  40606. }
  40607. renderInfoMessage() {
  40608. return info_message(this);
  40609. }
  40610. renderFileProgress() {
  40611. if (!this.model.file) {
  40612. // Can happen when file upload failed and page was reloaded
  40613. return '';
  40614. }
  40615. return file_progress(this);
  40616. }
  40617. renderChatMessage() {
  40618. return templates_message(this, this.getProps());
  40619. }
  40620. shouldShowAvatar() {
  40621. return core_api.settings.get('show_message_avatar') && !this.model.isMeCommand() && ['chat', 'groupchat'].includes(this.model.get('type'));
  40622. }
  40623. onUnfurlAnimationEnd() {
  40624. if (this.model.get('url_preview_transition') === 'fade-out') {
  40625. this.model.save({
  40626. 'hide_url_previews': true,
  40627. 'url_preview_transition': 'fade-in'
  40628. });
  40629. }
  40630. }
  40631. async onRetryClicked() {
  40632. this.show_spinner = true;
  40633. this.requestUpdate();
  40634. await core_api.trigger(this.model.get('retry_event_id'), {
  40635. 'synchronous': true
  40636. });
  40637. this.model.destroy();
  40638. this.parentElement.removeChild(this);
  40639. }
  40640. isRetracted() {
  40641. return this.model.get('retracted') || this.model.get('moderated') === 'retracted';
  40642. }
  40643. hasMentions() {
  40644. const is_groupchat = this.model.get('type') === 'groupchat';
  40645. return is_groupchat && this.model.get('sender') === 'them' && this.chatbox.isUserMentioned(this.model);
  40646. }
  40647. getOccupantAffiliation() {
  40648. var _this$model$occupant;
  40649. return (_this$model$occupant = this.model.occupant) === null || _this$model$occupant === void 0 ? void 0 : _this$model$occupant.get('affiliation');
  40650. }
  40651. getOccupantRole() {
  40652. var _this$model$occupant2;
  40653. return (_this$model$occupant2 = this.model.occupant) === null || _this$model$occupant2 === void 0 ? void 0 : _this$model$occupant2.get('role');
  40654. }
  40655. getExtraMessageClasses() {
  40656. const extra_classes = [this.model.isFollowup() ? 'chat-msg--followup' : null, this.model.get('is_delayed') ? 'delayed' : null, this.model.isMeCommand() ? 'chat-msg--action' : null, this.isRetracted() ? 'chat-msg--retracted' : null, this.model.get('type'), this.shouldShowAvatar() ? 'chat-msg--with-avatar' : null].map(c => c);
  40657. if (this.model.get('type') === 'groupchat') {
  40658. extra_classes.push(this.getOccupantRole() ?? '');
  40659. extra_classes.push(this.getOccupantAffiliation() ?? '');
  40660. if (this.model.get('sender') === 'them' && this.hasMentions()) {
  40661. extra_classes.push('mentioned');
  40662. }
  40663. }
  40664. this.model.get('correcting') && extra_classes.push('correcting');
  40665. return extra_classes.filter(c => c).join(" ");
  40666. }
  40667. getDerivedMessageProps() {
  40668. const format = core_api.settings.get('time_format');
  40669. return {
  40670. 'pretty_time': message_dayjs(this.model.get('edited') || this.model.get('time')).format(format),
  40671. 'has_mentions': this.hasMentions(),
  40672. 'hats': getHats(this.model),
  40673. 'is_first_unread': this.chatbox.get('first_unread_id') === this.model.get('id'),
  40674. 'is_me_message': this.model.isMeCommand(),
  40675. 'is_retracted': this.isRetracted(),
  40676. 'username': this.model.getDisplayName(),
  40677. 'should_show_avatar': this.shouldShowAvatar()
  40678. };
  40679. }
  40680. getRetractionText() {
  40681. if (['groupchat', 'mep'].includes(this.model.get('type')) && this.model.get('moderated_by')) {
  40682. const retracted_by_mod = this.model.get('moderated_by');
  40683. const chatbox = this.model.collection.chatbox;
  40684. if (!this.model.mod) {
  40685. this.model.mod = chatbox.occupants.findOccupant({
  40686. 'jid': retracted_by_mod
  40687. }) || chatbox.occupants.findOccupant({
  40688. 'nick': chat_message_Strophe.getResourceFromJid(retracted_by_mod)
  40689. });
  40690. }
  40691. const modname = this.model.mod ? this.model.mod.getDisplayName() : 'A moderator';
  40692. return __('%1$s has removed this message', modname);
  40693. } else {
  40694. return __('%1$s has removed this message', this.model.getDisplayName());
  40695. }
  40696. }
  40697. showUserModal(ev) {
  40698. if (this.model.get('sender') === 'me') {
  40699. core_api.modal.show(shared_converse.ProfileModal, {
  40700. model: this.model
  40701. }, ev);
  40702. } else if (this.model.get('type') === 'groupchat') {
  40703. ev.preventDefault();
  40704. core_api.modal.show(modals_occupant, {
  40705. 'model': this.model.occupant,
  40706. 'message': this.model
  40707. }, ev);
  40708. } else {
  40709. ev.preventDefault();
  40710. const chatbox = this.model.collection.chatbox;
  40711. core_api.modal.show(modals_user_details, {
  40712. model: chatbox
  40713. }, ev);
  40714. }
  40715. }
  40716. showMessageVersionsModal(ev) {
  40717. ev.preventDefault();
  40718. core_api.modal.show(modals_message_versions, {
  40719. 'model': this.model
  40720. }, ev);
  40721. }
  40722. toggleSpoilerMessage(ev) {
  40723. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  40724. this.model.save({
  40725. 'is_spoiler_visible': !this.model.get('is_spoiler_visible')
  40726. });
  40727. }
  40728. }
  40729. core_api.elements.define('converse-chat-message', Message);
  40730. ;// CONCATENATED MODULE: ./src/shared/chat/message-history.js
  40731. class MessageHistory extends CustomElement {
  40732. static get properties() {
  40733. return {
  40734. model: {
  40735. type: Object
  40736. },
  40737. messages: {
  40738. type: Array
  40739. }
  40740. };
  40741. }
  40742. render() {
  40743. const msgs = this.messages;
  40744. if (msgs.length) {
  40745. return repeat_c(msgs, m => m.get('id'), m => $`${this.renderMessage(m)}`);
  40746. } else {
  40747. return '';
  40748. }
  40749. }
  40750. renderMessage(model) {
  40751. if (model.get('dangling_retraction') || model.get('is_only_key')) {
  40752. return '';
  40753. }
  40754. const template_hook = model.get('template_hook');
  40755. if (typeof template_hook === 'string') {
  40756. const template_promise = core_api.hook(template_hook, model, '');
  40757. return until_c(template_promise, '');
  40758. } else {
  40759. const template = $`<converse-chat-message
  40760. jid="${this.model.get('jid')}"
  40761. mid="${model.get('id')}"></converse-chat-message>`;
  40762. const day = getDayIndicator(model);
  40763. return day ? [day, template] : template;
  40764. }
  40765. }
  40766. }
  40767. core_api.elements.define('converse-message-history', MessageHistory);
  40768. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/chat-content.scss
  40769. var chat_content = __webpack_require__(8054);
  40770. ;// CONCATENATED MODULE: ./src/shared/chat/styles/chat-content.scss
  40771. var chat_content_options = {};
  40772. chat_content_options.styleTagTransform = (styleTagTransform_default());
  40773. chat_content_options.setAttributes = (setAttributesWithoutAttributes_default());
  40774. chat_content_options.insert = insertBySelector_default().bind(null, "head");
  40775. chat_content_options.domAPI = (styleDomAPI_default());
  40776. chat_content_options.insertStyleElement = (insertStyleElement_default());
  40777. var chat_content_update = injectStylesIntoStyleTag_default()(chat_content/* default */.Z, chat_content_options);
  40778. /* harmony default export */ const styles_chat_content = (chat_content/* default */.Z && chat_content/* default.locals */.Z.locals ? chat_content/* default.locals */.Z.locals : undefined);
  40779. ;// CONCATENATED MODULE: ./src/shared/chat/chat-content.js
  40780. class ChatContent extends CustomElement {
  40781. static get properties() {
  40782. return {
  40783. jid: {
  40784. type: String
  40785. }
  40786. };
  40787. }
  40788. disconnectedCallback() {
  40789. super.disconnectedCallback();
  40790. this.removeEventListener('scroll', markScrolled);
  40791. }
  40792. async initialize() {
  40793. await this.setModels();
  40794. this.listenTo(this.model, 'change:hidden_occupants', this.requestUpdate);
  40795. this.listenTo(this.model.messages, 'add', this.requestUpdate);
  40796. this.listenTo(this.model.messages, 'change', this.requestUpdate);
  40797. this.listenTo(this.model.messages, 'remove', this.requestUpdate);
  40798. this.listenTo(this.model.messages, 'rendered', this.requestUpdate);
  40799. this.listenTo(this.model.messages, 'reset', this.requestUpdate);
  40800. this.listenTo(this.model.notifications, 'change', this.requestUpdate);
  40801. this.listenTo(this.model.ui, 'change', this.requestUpdate);
  40802. this.listenTo(this.model.ui, 'change:scrolled', this.scrollDown);
  40803. if (this.model.occupants) {
  40804. this.listenTo(this.model.occupants, 'change', this.requestUpdate);
  40805. }
  40806. this.addEventListener('scroll', markScrolled);
  40807. }
  40808. async setModels() {
  40809. this.model = await core_api.chatboxes.get(this.jid);
  40810. await this.model.initialized;
  40811. this.requestUpdate();
  40812. }
  40813. render() {
  40814. var _this$model$ui;
  40815. if (!this.model) {
  40816. return '';
  40817. } // This element has "flex-direction: reverse", so elements here are
  40818. // shown in reverse order.
  40819. return $`
  40820. <div class="chat-content__notifications">${this.model.getNotificationsText()}</div>
  40821. <converse-message-history
  40822. .model=${this.model}
  40823. .messages=${[...this.model.messages.models]}>
  40824. </converse-message-history>
  40825. ${(_this$model$ui = this.model.ui) !== null && _this$model$ui !== void 0 && _this$model$ui.get('chat-content-spinner-top') ? spinner() : ''}
  40826. `;
  40827. }
  40828. scrollDown() {
  40829. if (this.model.ui.get('scrolled')) {
  40830. return;
  40831. }
  40832. if (this.scrollTo) {
  40833. const behavior = this.scrollTop ? 'smooth' : 'auto';
  40834. this.scrollTo({
  40835. 'top': 0,
  40836. behavior
  40837. });
  40838. } else {
  40839. this.scrollTop = 0;
  40840. }
  40841. /**
  40842. * Triggered once the converse-chat-content element has been scrolled down to the bottom.
  40843. * @event _converse#chatBoxScrolledDown
  40844. * @type {object}
  40845. * @property { _converse.ChatBox | _converse.ChatRoom } chatbox - The chat model
  40846. * @example _converse.api.listen.on('chatBoxScrolledDown', obj => { ... });
  40847. */
  40848. core_api.trigger('chatBoxScrolledDown', {
  40849. 'chatbox': this.model
  40850. });
  40851. }
  40852. }
  40853. core_api.elements.define('converse-chat-content', ChatContent);
  40854. ;// CONCATENATED MODULE: ./node_modules/lit-html/directives/unsafe-html.js
  40855. /**
  40856. * @license
  40857. * Copyright 2017 Google LLC
  40858. * SPDX-License-Identifier: BSD-3-Clause
  40859. */
  40860. class unsafe_html_e extends directive_i {
  40861. constructor(i) {
  40862. if (super(i), this.it = w, i.type !== directive_t.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
  40863. }
  40864. render(r) {
  40865. if (r === w || null == r) return this.ft = void 0, this.it = r;
  40866. if (r === b) return r;
  40867. if ("string" != typeof r) throw Error(this.constructor.directiveName + "() called with a non-string value");
  40868. if (r === this.it) return this.ft;
  40869. this.it = r;
  40870. const s = [r];
  40871. return s.raw = s, this.ft = {
  40872. _$litType$: this.constructor.resultType,
  40873. strings: s,
  40874. values: []
  40875. };
  40876. }
  40877. }
  40878. unsafe_html_e.directiveName = "unsafeHTML", unsafe_html_e.resultType = 1;
  40879. const unsafe_html_o = directive_e(unsafe_html_e);
  40880. ;// CONCATENATED MODULE: ./node_modules/lit/directives/unsafe-html.js
  40881. //# sourceMappingURL=unsafe-html.js.map
  40882. ;// CONCATENATED MODULE: ./src/shared/chat/help-messages.js
  40883. class ChatHelp extends CustomElement {
  40884. static get properties() {
  40885. return {
  40886. chat_type: {
  40887. type: String
  40888. },
  40889. messages: {
  40890. type: Array
  40891. },
  40892. model: {
  40893. type: Object
  40894. },
  40895. type: {
  40896. type: String
  40897. }
  40898. };
  40899. }
  40900. render() {
  40901. const isodate = new Date().toISOString();
  40902. return [$`<converse-icon class="fas fa-times close-chat-help"
  40903. @click=${this.close}
  40904. path-prefix="${core_api.settings.get("assets_path")}"
  40905. size="1em"></converse-icon>`, ...this.messages.map(m => this.renderHelpMessage({
  40906. isodate,
  40907. 'markup': purify_default().sanitize(m, {
  40908. 'ALLOWED_TAGS': ['strong']
  40909. })
  40910. }))];
  40911. }
  40912. close() {
  40913. this.model.set({
  40914. 'show_help_messages': false
  40915. });
  40916. }
  40917. renderHelpMessage(o) {
  40918. return $`<div class="message chat-${this.type}" data-isodate="${o.isodate}">${unsafe_html_o(o.markup)}</div>`;
  40919. }
  40920. }
  40921. core_api.elements.define('converse-chat-help', ChatHelp);
  40922. ;// CONCATENATED MODULE: ./src/shared/chat/templates/emoji-picker.js
  40923. const emoji_picker_u = core_converse.env.utils;
  40924. const emoji_category = o => {
  40925. return $`
  40926. <li data-category="${o.category}"
  40927. class="emoji-category ${o.category} ${o.current_category === o.category ? 'picked' : ''}"
  40928. title="${__(core_api.settings.get('emoji_category_labels')[o.category])}">
  40929. <a class="pick-category"
  40930. @click=${o.onCategoryPicked}
  40931. href="#emoji-picker-${o.category}"
  40932. data-category="${o.category}">${o.emoji} </a>
  40933. </li>
  40934. `;
  40935. };
  40936. const emoji_picker_header = o => {
  40937. const cats = core_api.settings.get('emoji_categories');
  40938. const transform = c => cats[c] ? emoji_category(Object.assign({
  40939. 'category': c,
  40940. 'emoji': o.sn2Emoji(cats[c])
  40941. }, o)) : '';
  40942. return $`<ul>${Object.keys(cats).map(transform)}</ul>`;
  40943. };
  40944. const emoji_item = o => {
  40945. return $`
  40946. <li class="emoji insert-emoji ${o.shouldBeHidden(o.emoji.sn) ? 'hidden' : ''}" data-emoji="${o.emoji.sn}" title="${o.emoji.sn}">
  40947. <a href="#" @click=${o.insertEmoji} data-emoji="${o.emoji.sn}">${emoji_picker_u.shortnamesToEmojis(o.emoji.sn)}</a>
  40948. </li>
  40949. `;
  40950. };
  40951. const tpl_search_results = o => {
  40952. const i18n_search_results = __('Search results');
  40953. return $`
  40954. <span ?hidden=${!o.query} class="emoji-lists__container emojis-lists__container--search">
  40955. <a id="emoji-picker-search-results" class="emoji-category__heading">${i18n_search_results}</a>
  40956. <ul class="emoji-picker">
  40957. ${o.search_results.map(emoji => emoji_item(Object.assign({
  40958. emoji
  40959. }, o)))}
  40960. </ul>
  40961. </span>
  40962. `;
  40963. };
  40964. const emojis_for_category = o => {
  40965. return $`
  40966. <a id="emoji-picker-${o.category}" class="emoji-category__heading" data-category="${o.category}">${__(core_api.settings.get('emoji_category_labels')[o.category])}</a>
  40967. <ul class="emoji-picker" data-category="${o.category}">
  40968. ${Object.values(core_converse.emojis.json[o.category]).map(emoji => emoji_item(Object.assign({
  40969. emoji
  40970. }, o)))}
  40971. </ul>`;
  40972. };
  40973. const tpl_all_emojis = o => {
  40974. const cats = core_api.settings.get('emoji_categories');
  40975. return $`
  40976. <span ?hidden=${o.query} class="emoji-lists__container emoji-lists__container--browse">
  40977. ${Object.keys(cats).map(c => cats[c] ? emojis_for_category(Object.assign({
  40978. 'category': c
  40979. }, o)) : '')}
  40980. </span>`;
  40981. };
  40982. const skintone_emoji = o => {
  40983. return $`
  40984. <li data-skintone="${o.skintone}" class="emoji-skintone ${o.current_skintone === o.skintone ? 'picked' : ''}">
  40985. <a class="pick-skintone" href="#" data-skintone="${o.skintone}" @click=${o.onSkintonePicked}>${emoji_picker_u.shortnamesToEmojis(':' + o.skintone + ':')}</a>
  40986. </li>`;
  40987. };
  40988. const tpl_emoji_picker = o => {
  40989. const i18n_search = __('Search');
  40990. const skintones = ['tone1', 'tone2', 'tone3', 'tone4', 'tone5'];
  40991. return $`
  40992. <div class="emoji-picker__header">
  40993. <input class="form-control emoji-search" name="emoji-search" placeholder="${i18n_search}"
  40994. .value=${o.query || ''}
  40995. @keydown=${o.onSearchInputKeyDown}
  40996. @blur=${o.onSearchInputBlurred}
  40997. @focus=${o.onSearchInputFocus}>
  40998. ${o.query ? '' : emoji_picker_header(o)}
  40999. </div>
  41000. ${o.render_emojis ? $`<converse-emoji-picker-content
  41001. .chatview=${o.chatview}
  41002. .model=${o.model}
  41003. .search_results="${o.search_results}"
  41004. current_skintone="${o.current_skintone}"
  41005. query="${o.query}"></converse-emoji-picker-content>` : ''}
  41006. <div class="emoji-skintone-picker">
  41007. <ul>${skintones.map(skintone => skintone_emoji(Object.assign({
  41008. skintone
  41009. }, o)))}</ul>
  41010. </div>`;
  41011. };
  41012. ;// CONCATENATED MODULE: ./src/shared/chat/emoji-picker-content.js
  41013. const {
  41014. sizzle: emoji_picker_content_sizzle
  41015. } = core_converse.env;
  41016. class EmojiPickerContent extends CustomElement {
  41017. static get properties() {
  41018. return {
  41019. 'chatview': {
  41020. type: Object
  41021. },
  41022. 'search_results': {
  41023. type: Array
  41024. },
  41025. 'current_skintone': {
  41026. type: String
  41027. },
  41028. 'model': {
  41029. type: Object
  41030. },
  41031. 'query': {
  41032. type: String
  41033. }
  41034. };
  41035. }
  41036. render() {
  41037. const props = {
  41038. 'current_skintone': this.current_skintone,
  41039. 'insertEmoji': ev => this.insertEmoji(ev),
  41040. 'query': this.query,
  41041. 'search_results': this.search_results,
  41042. 'shouldBeHidden': shortname => this.shouldBeHidden(shortname)
  41043. };
  41044. return $`
  41045. <div class="emoji-picker__lists">
  41046. ${tpl_search_results(props)}
  41047. ${tpl_all_emojis(props)}
  41048. </div>
  41049. `;
  41050. }
  41051. firstUpdated() {
  41052. this.initIntersectionObserver();
  41053. }
  41054. initIntersectionObserver() {
  41055. if (!window.IntersectionObserver) {
  41056. return;
  41057. }
  41058. if (this.observer) {
  41059. this.observer.disconnect();
  41060. } else {
  41061. const options = {
  41062. root: this.querySelector('.emoji-picker__lists'),
  41063. threshold: [0.1]
  41064. };
  41065. const handler = ev => this.setCategoryOnVisibilityChange(ev);
  41066. this.observer = new IntersectionObserver(handler, options);
  41067. }
  41068. emoji_picker_content_sizzle('.emoji-picker', this).forEach(a => this.observer.observe(a));
  41069. }
  41070. setCategoryOnVisibilityChange(entries) {
  41071. const selected = this.parentElement.navigator.selected;
  41072. const intersection_with_selected = entries.filter(i => i.target.contains(selected)).pop();
  41073. let current; // Choose the intersection that contains the currently selected
  41074. // element, or otherwise the one with the largest ratio.
  41075. if (intersection_with_selected) {
  41076. current = intersection_with_selected;
  41077. } else {
  41078. current = entries.reduce((p, c) => c.intersectionRatio >= ((p === null || p === void 0 ? void 0 : p.intersectionRatio) || 0) ? c : p, null);
  41079. }
  41080. if (current && current.isIntersecting) {
  41081. const category = current.target.getAttribute('data-category');
  41082. if (category !== this.model.get('current_category')) {
  41083. this.parentElement.preserve_scroll = true;
  41084. this.model.save({
  41085. 'current_category': category
  41086. });
  41087. }
  41088. }
  41089. }
  41090. insertEmoji(ev) {
  41091. ev.preventDefault();
  41092. ev.stopPropagation();
  41093. const target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
  41094. this.parentElement.insertIntoTextArea(target.getAttribute('data-emoji'));
  41095. }
  41096. shouldBeHidden(shortname) {
  41097. // Helper method for the template which decides whether an
  41098. // emoji should be hidden, based on which skin tone is
  41099. // currently being applied.
  41100. if (shortname.includes('_tone')) {
  41101. if (!this.current_skintone || !shortname.includes(this.current_skintone)) {
  41102. return true;
  41103. }
  41104. } else {
  41105. if (this.current_skintone && getTonedEmojis().includes(shortname)) {
  41106. return true;
  41107. }
  41108. }
  41109. if (this.query && !shared_converse.FILTER_CONTAINS(shortname, this.query)) {
  41110. return true;
  41111. }
  41112. return false;
  41113. }
  41114. }
  41115. core_api.elements.define('converse-emoji-picker-content', EmojiPickerContent);
  41116. ;// CONCATENATED MODULE: ./src/shared/chat/emoji-dropdown.js
  41117. const emoji_dropdown_u = core_converse.env.utils;
  41118. class EmojiDropdown extends Dropdown {
  41119. static get properties() {
  41120. return {
  41121. chatview: {
  41122. type: Object
  41123. }
  41124. };
  41125. }
  41126. constructor() {
  41127. super(); // This is an optimization, we lazily render the emoji picker, otherwise tests slow to a crawl.
  41128. this.render_emojis = false;
  41129. }
  41130. initModel() {
  41131. if (!this.init_promise) {
  41132. this.init_promise = (async () => {
  41133. await core_api.emojis.initialize();
  41134. const id = `converse.emoji-${shared_converse.bare_jid}-${this.chatview.model.get('jid')}`;
  41135. this.model = new shared_converse.EmojiPicker({
  41136. 'id': id
  41137. });
  41138. initStorage(this.model, id);
  41139. await new Promise(resolve => this.model.fetch({
  41140. 'success': resolve,
  41141. 'error': resolve
  41142. })); // We never want still be in the autocompleting state upon page load
  41143. this.model.set({
  41144. 'autocompleting': null,
  41145. 'ac_position': null
  41146. });
  41147. })();
  41148. }
  41149. return this.init_promise;
  41150. }
  41151. render() {
  41152. const is_groupchat = this.chatview.model.get('type') === shared_converse.CHATROOMS_TYPE;
  41153. const color = is_groupchat ? '--muc-toolbar-btn-color' : '--chat-toolbar-btn-color';
  41154. return $`
  41155. <div class="dropup">
  41156. <button class="toggle-emojis"
  41157. title="${__('Insert emojis')}"
  41158. data-toggle="dropdown"
  41159. aria-haspopup="true"
  41160. aria-expanded="false">
  41161. <converse-icon
  41162. color="var(${color})"
  41163. class="fa fa-smile "
  41164. path-prefix="${core_api.settings.get('assets_path')}"
  41165. size="1em"></converse-icon>
  41166. </button>
  41167. <div class="dropdown-menu">
  41168. ${until_c(this.initModel().then(() => $`
  41169. <converse-emoji-picker
  41170. .chatview=${this.chatview}
  41171. .model=${this.model}
  41172. @emojiSelected=${() => this.hideMenu()}
  41173. ?render_emojis=${this.render_emojis}
  41174. current_category="${this.model.get('current_category') || ''}"
  41175. current_skintone="${this.model.get('current_skintone') || ''}"
  41176. query="${this.model.get('query') || ''}"
  41177. ></converse-emoji-picker>`), '')}
  41178. </div>
  41179. </div>`;
  41180. }
  41181. connectedCallback() {
  41182. super.connectedCallback();
  41183. this.render_emojis = false;
  41184. }
  41185. toggleMenu(ev) {
  41186. ev.stopPropagation();
  41187. ev.preventDefault();
  41188. if (emoji_dropdown_u.hasClass('show', this.menu)) {
  41189. if (emoji_dropdown_u.ancestor(ev.target, '.toggle-emojis')) {
  41190. this.hideMenu();
  41191. }
  41192. } else {
  41193. this.showMenu();
  41194. }
  41195. }
  41196. async showMenu() {
  41197. await this.initModel();
  41198. if (!this.render_emojis) {
  41199. // Trigger an update so that emojis are rendered
  41200. this.render_emojis = true;
  41201. this.requestUpdate();
  41202. await this.updateComplete;
  41203. }
  41204. super.showMenu();
  41205. setTimeout(() => {
  41206. var _this$querySelector;
  41207. return (_this$querySelector = this.querySelector('.emoji-search')) === null || _this$querySelector === void 0 ? void 0 : _this$querySelector.focus();
  41208. });
  41209. }
  41210. }
  41211. core_api.elements.define('converse-emoji-dropdown', EmojiDropdown);
  41212. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/emoji.scss
  41213. var emoji = __webpack_require__(8125);
  41214. ;// CONCATENATED MODULE: ./src/shared/chat/styles/emoji.scss
  41215. var emoji_options = {};
  41216. emoji_options.styleTagTransform = (styleTagTransform_default());
  41217. emoji_options.setAttributes = (setAttributesWithoutAttributes_default());
  41218. emoji_options.insert = insertBySelector_default().bind(null, "head");
  41219. emoji_options.domAPI = (styleDomAPI_default());
  41220. emoji_options.insertStyleElement = (insertStyleElement_default());
  41221. var emoji_update = injectStylesIntoStyleTag_default()(emoji/* default */.Z, emoji_options);
  41222. /* harmony default export */ const styles_emoji = (emoji/* default */.Z && emoji/* default.locals */.Z.locals ? emoji/* default.locals */.Z.locals : undefined);
  41223. ;// CONCATENATED MODULE: ./src/shared/chat/emoji-picker.js
  41224. const chat_emoji_picker_u = core_converse.env.utils;
  41225. class EmojiPicker extends CustomElement {
  41226. static get properties() {
  41227. return {
  41228. 'chatview': {
  41229. type: Object
  41230. },
  41231. 'current_category': {
  41232. type: String,
  41233. 'reflect': true
  41234. },
  41235. 'current_skintone': {
  41236. type: String,
  41237. 'reflect': true
  41238. },
  41239. 'model': {
  41240. type: Object
  41241. },
  41242. 'query': {
  41243. type: String,
  41244. 'reflect': true
  41245. },
  41246. // This is an optimization, we lazily render the emoji picker, otherwise tests slow to a crawl.
  41247. 'render_emojis': {
  41248. type: Boolean
  41249. }
  41250. };
  41251. }
  41252. firstUpdated() {
  41253. super.firstUpdated();
  41254. this.listenTo(this.model, 'change', o => this.onModelChanged(o.changed));
  41255. this.initArrowNavigation();
  41256. }
  41257. constructor() {
  41258. super();
  41259. this.query = '';
  41260. this._search_results = [];
  41261. this.debouncedFilter = lodash_es_debounce(input => this.model.set({
  41262. 'query': input.value
  41263. }), 250);
  41264. }
  41265. get search_results() {
  41266. return this._search_results;
  41267. }
  41268. set search_results(value) {
  41269. this._search_results = value;
  41270. this.requestUpdate();
  41271. }
  41272. render() {
  41273. return tpl_emoji_picker({
  41274. 'chatview': this.chatview,
  41275. 'current_category': this.current_category,
  41276. 'current_skintone': this.current_skintone,
  41277. 'model': this.model,
  41278. 'onCategoryPicked': ev => this.chooseCategory(ev),
  41279. 'onSearchInputBlurred': ev => this.chatview.emitFocused(ev),
  41280. 'onSearchInputFocus': ev => this.onSearchInputFocus(ev),
  41281. 'onSearchInputKeyDown': ev => this.onSearchInputKeyDown(ev),
  41282. 'onSkintonePicked': ev => this.chooseSkinTone(ev),
  41283. 'query': this.query,
  41284. 'search_results': this.search_results,
  41285. 'render_emojis': this.render_emojis,
  41286. 'sn2Emoji': shortname => chat_emoji_picker_u.shortnamesToEmojis(this.getTonedShortname(shortname))
  41287. });
  41288. }
  41289. updated(changed) {
  41290. changed.has('query') && this.updateSearchResults(changed);
  41291. changed.has('current_category') && this.setScrollPosition();
  41292. }
  41293. onModelChanged(changed) {
  41294. if ('current_category' in changed) this.current_category = changed.current_category;
  41295. if ('current_skintone' in changed) this.current_skintone = changed.current_skintone;
  41296. if ('query' in changed) this.query = changed.query;
  41297. }
  41298. setScrollPosition() {
  41299. if (this.preserve_scroll) {
  41300. this.preserve_scroll = false;
  41301. return;
  41302. }
  41303. const el = this.querySelector('.emoji-lists__container--browse');
  41304. const heading = this.querySelector(`#emoji-picker-${this.current_category}`);
  41305. if (heading) {
  41306. // +4 due to 2px padding on list elements
  41307. el.scrollTop = heading.offsetTop - heading.offsetHeight * 3 + 4;
  41308. }
  41309. }
  41310. updateSearchResults(changed) {
  41311. const old_query = changed.get('query');
  41312. const contains = shared_converse.FILTER_CONTAINS;
  41313. if (this.query) {
  41314. if (this.query === old_query) {
  41315. return this.search_results;
  41316. } else if (old_query && this.query.includes(old_query)) {
  41317. this.search_results = this.search_results.filter(e => contains(e.sn, this.query));
  41318. } else {
  41319. this.search_results = core_converse.emojis.list.filter(e => contains(e.sn, this.query));
  41320. }
  41321. } else if (this.search_results.length) {
  41322. // Avoid re-rendering by only setting to new empty array if it wasn't empty before
  41323. this.search_results = [];
  41324. }
  41325. }
  41326. registerEvents() {
  41327. this.onGlobalKeyDown = ev => this._onGlobalKeyDown(ev);
  41328. const body = document.querySelector('body');
  41329. body.addEventListener('keydown', this.onGlobalKeyDown);
  41330. }
  41331. connectedCallback() {
  41332. super.connectedCallback();
  41333. this.registerEvents();
  41334. }
  41335. disconnectedCallback() {
  41336. const body = document.querySelector('body');
  41337. body.removeEventListener('keydown', this.onGlobalKeyDown);
  41338. this.disableArrowNavigation();
  41339. super.disconnectedCallback();
  41340. }
  41341. _onGlobalKeyDown(ev) {
  41342. if (!this.navigator) {
  41343. return;
  41344. }
  41345. if (ev.keyCode === KEYCODES.ENTER && chat_emoji_picker_u.isVisible(this)) {
  41346. this.onEnterPressed(ev);
  41347. } else if (ev.keyCode === KEYCODES.DOWN_ARROW && !this.navigator.enabled && chat_emoji_picker_u.isVisible(this)) {
  41348. this.enableArrowNavigation(ev);
  41349. } else if (ev.keyCode === KEYCODES.ESCAPE) {
  41350. this.disableArrowNavigation();
  41351. setTimeout(() => this.chatview.querySelector('.chat-textarea').focus(), 50);
  41352. }
  41353. }
  41354. setCategoryForElement(el) {
  41355. const old_category = this.current_category;
  41356. const category = (el === null || el === void 0 ? void 0 : el.getAttribute('data-category')) || old_category;
  41357. if (old_category !== category) {
  41358. this.model.save({
  41359. 'current_category': category
  41360. });
  41361. }
  41362. }
  41363. insertIntoTextArea(value) {
  41364. const autocompleting = this.model.get('autocompleting');
  41365. const ac_position = this.model.get('ac_position');
  41366. this.model.set({
  41367. 'autocompleting': null,
  41368. 'query': '',
  41369. 'ac_position': null
  41370. });
  41371. this.disableArrowNavigation();
  41372. const jid = this.chatview.model.get('jid');
  41373. const options = {
  41374. 'bubbles': true,
  41375. 'detail': {
  41376. value,
  41377. autocompleting,
  41378. ac_position,
  41379. jid
  41380. }
  41381. };
  41382. this.dispatchEvent(new CustomEvent("emojiSelected", options));
  41383. }
  41384. chooseSkinTone(ev) {
  41385. ev.preventDefault();
  41386. ev.stopPropagation();
  41387. const target = ev.target.nodeName === 'IMG' ? ev.target.parentElement : ev.target;
  41388. const skintone = target.getAttribute("data-skintone").trim();
  41389. if (this.current_skintone === skintone) {
  41390. this.model.save({
  41391. 'current_skintone': ''
  41392. });
  41393. } else {
  41394. this.model.save({
  41395. 'current_skintone': skintone
  41396. });
  41397. }
  41398. }
  41399. chooseCategory(ev) {
  41400. ev.preventDefault && ev.preventDefault();
  41401. ev.stopPropagation && ev.stopPropagation();
  41402. const el = ev.target.matches('li') ? ev.target : chat_emoji_picker_u.ancestor(ev.target, 'li');
  41403. this.setCategoryForElement(el);
  41404. this.navigator.select(el);
  41405. !this.navigator.enabled && this.navigator.enable();
  41406. }
  41407. onSearchInputKeyDown(ev) {
  41408. if (ev.keyCode === KEYCODES.TAB) {
  41409. if (ev.target.value) {
  41410. ev.preventDefault();
  41411. const match = core_converse.emojis.shortnames.find(sn => shared_converse.FILTER_CONTAINS(sn, ev.target.value));
  41412. match && this.model.set({
  41413. 'query': match
  41414. });
  41415. } else if (!this.navigator.enabled) {
  41416. this.enableArrowNavigation(ev);
  41417. }
  41418. } else if (ev.keyCode === KEYCODES.DOWN_ARROW && !this.navigator.enabled) {
  41419. this.enableArrowNavigation(ev);
  41420. } else if (ev.keyCode !== KEYCODES.ENTER && ev.keyCode !== KEYCODES.DOWN_ARROW) {
  41421. this.debouncedFilter(ev.target);
  41422. }
  41423. }
  41424. onEnterPressed(ev) {
  41425. ev.preventDefault();
  41426. ev.stopPropagation();
  41427. if (core_converse.emojis.shortnames.includes(ev.target.value)) {
  41428. this.insertIntoTextArea(ev.target.value);
  41429. } else if (this.search_results.length === 1) {
  41430. this.insertIntoTextArea(this.search_results[0].sn);
  41431. } else if (this.navigator.selected && this.navigator.selected.matches('.insert-emoji')) {
  41432. this.insertIntoTextArea(this.navigator.selected.getAttribute('data-emoji'));
  41433. } else if (this.navigator.selected && this.navigator.selected.matches('.emoji-category')) {
  41434. this.chooseCategory({
  41435. 'target': this.navigator.selected
  41436. });
  41437. }
  41438. }
  41439. onSearchInputFocus(ev) {
  41440. this.chatview.emitBlurred(ev);
  41441. this.disableArrowNavigation();
  41442. }
  41443. getTonedShortname(shortname) {
  41444. if (getTonedEmojis().includes(shortname) && this.current_skintone) {
  41445. return `${shortname.slice(0, shortname.length - 1)}_${this.current_skintone}:`;
  41446. }
  41447. return shortname;
  41448. }
  41449. initArrowNavigation() {
  41450. if (!this.navigator) {
  41451. const default_selector = 'li:not(.hidden):not(.emoji-skintone), .emoji-search';
  41452. const options = {
  41453. 'jump_to_picked': '.emoji-category',
  41454. 'jump_to_picked_selector': '.emoji-category.picked',
  41455. 'jump_to_picked_direction': dom_navigator.DIRECTION.down,
  41456. 'picked_selector': '.picked',
  41457. 'scroll_container': this.querySelector('.emoji-picker__lists'),
  41458. 'getSelector': direction => {
  41459. if (direction === dom_navigator.DIRECTION.down) {
  41460. const c = this.navigator.selected && this.navigator.selected.getAttribute('data-category');
  41461. return c ? `ul[data-category="${c}"] li:not(.hidden):not(.emoji-skintone), .emoji-search` : default_selector;
  41462. } else {
  41463. return default_selector;
  41464. }
  41465. },
  41466. 'onSelected': el => {
  41467. el.matches('.insert-emoji') && this.setCategoryForElement(el.parentElement);
  41468. el.matches('.insert-emoji, .emoji-category') && el.firstElementChild.focus();
  41469. el.matches('.emoji-search') && el.focus();
  41470. }
  41471. };
  41472. this.navigator = new dom_navigator(this, options);
  41473. }
  41474. }
  41475. disableArrowNavigation() {
  41476. var _this$navigator;
  41477. (_this$navigator = this.navigator) === null || _this$navigator === void 0 ? void 0 : _this$navigator.disable();
  41478. }
  41479. enableArrowNavigation(ev) {
  41480. var _ev$preventDefault, _ev$stopPropagation;
  41481. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  41482. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation = ev.stopPropagation) === null || _ev$stopPropagation === void 0 ? void 0 : _ev$stopPropagation.call(ev);
  41483. this.disableArrowNavigation();
  41484. this.navigator.enable();
  41485. this.navigator.handleKeydown(ev);
  41486. }
  41487. }
  41488. core_api.elements.define('converse-emoji-picker', EmojiPicker);
  41489. ;// CONCATENATED MODULE: ./src/shared/chat/templates/message-limit.js
  41490. /* harmony default export */ const message_limit = (counter => {
  41491. const i18n_chars_remaining = __('Message characters remaining');
  41492. return $`<span class="message-limit ${counter < 1 ? 'error' : ''}" title="${i18n_chars_remaining}">${counter}</span>`;
  41493. });
  41494. ;// CONCATENATED MODULE: ./src/shared/chat/message-limit.js
  41495. class MessageLimitIndicator extends CustomElement {
  41496. static get properties() {
  41497. return {
  41498. model: {
  41499. type: Object
  41500. }
  41501. };
  41502. }
  41503. connectedCallback() {
  41504. super.connectedCallback();
  41505. this.listenTo(this.model, 'change:draft', this.requestUpdate);
  41506. }
  41507. render() {
  41508. const limit = core_api.settings.get('message_limit');
  41509. if (!limit) return '';
  41510. const chars = this.model.get('draft') || '';
  41511. return message_limit(limit - chars.length);
  41512. }
  41513. }
  41514. core_api.elements.define('converse-message-limit-indicator', MessageLimitIndicator);
  41515. ;// CONCATENATED MODULE: ./src/shared/chat/templates/toolbar.js
  41516. function tpl_send_button() {
  41517. const i18n_send_message = __('Send the message');
  41518. return $`<button type="submit" class="btn send-button" title="${i18n_send_message}">
  41519. <converse-icon color="var(--toolbar-btn-text-color)" class="fa fa-paper-plane" size="1em"></converse-icon>
  41520. </button>`;
  41521. }
  41522. /* harmony default export */ const toolbar = (el => {
  41523. return $`
  41524. <span class="toolbar-buttons">${until_c(el.getButtons(), '')}</span>
  41525. ${el.show_send_button ? tpl_send_button() : ''}
  41526. `;
  41527. });
  41528. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/chat/styles/toolbar.scss
  41529. var styles_toolbar = __webpack_require__(6176);
  41530. ;// CONCATENATED MODULE: ./src/shared/chat/styles/toolbar.scss
  41531. var toolbar_options = {};
  41532. toolbar_options.styleTagTransform = (styleTagTransform_default());
  41533. toolbar_options.setAttributes = (setAttributesWithoutAttributes_default());
  41534. toolbar_options.insert = insertBySelector_default().bind(null, "head");
  41535. toolbar_options.domAPI = (styleDomAPI_default());
  41536. toolbar_options.insertStyleElement = (insertStyleElement_default());
  41537. var toolbar_update = injectStylesIntoStyleTag_default()(styles_toolbar/* default */.Z, toolbar_options);
  41538. /* harmony default export */ const chat_styles_toolbar = (styles_toolbar/* default */.Z && styles_toolbar/* default.locals */.Z.locals ? styles_toolbar/* default.locals */.Z.locals : undefined);
  41539. ;// CONCATENATED MODULE: ./src/shared/chat/toolbar.js
  41540. const toolbar_Strophe = core_converse.env.Strophe;
  41541. class ChatToolbar extends CustomElement {
  41542. static get properties() {
  41543. return {
  41544. hidden_occupants: {
  41545. type: Boolean
  41546. },
  41547. is_groupchat: {
  41548. type: Boolean
  41549. },
  41550. message_limit: {
  41551. type: Number
  41552. },
  41553. model: {
  41554. type: Object
  41555. },
  41556. show_call_button: {
  41557. type: Boolean
  41558. },
  41559. show_emoji_button: {
  41560. type: Boolean
  41561. },
  41562. show_send_button: {
  41563. type: Boolean
  41564. },
  41565. show_spoiler_button: {
  41566. type: Boolean
  41567. }
  41568. };
  41569. }
  41570. connectedCallback() {
  41571. super.connectedCallback();
  41572. this.listenTo(this.model, 'change:composing_spoiler', () => this.requestUpdate());
  41573. }
  41574. render() {
  41575. return toolbar(this);
  41576. }
  41577. firstUpdated() {
  41578. /**
  41579. * Triggered once the _converse.ChatBoxView's toolbar has been rendered
  41580. * @event _converse#renderToolbar
  41581. * @type { _converse.ChatBoxView }
  41582. * @example _converse.api.listen.on('renderToolbar', this => { ... });
  41583. */
  41584. core_api.trigger('renderToolbar', this);
  41585. }
  41586. getButtons() {
  41587. var _api$settings$get;
  41588. const buttons = [];
  41589. if (this.show_emoji_button) {
  41590. const chatview = shared_converse.chatboxviews.get(this.model.get('jid'));
  41591. buttons.push($`<converse-emoji-dropdown .chatview=${chatview}></converse-emoji-dropdown>`);
  41592. }
  41593. if (this.show_call_button) {
  41594. const color = this.is_groupchat ? '--muc-toolbar-btn-color' : '--chat-toolbar-btn-color';
  41595. const i18n_start_call = __('Start a call');
  41596. buttons.push($`
  41597. <button class="toggle-call" @click=${this.toggleCall} title="${i18n_start_call}">
  41598. <converse-icon color="var(${color})" class="fa fa-phone" size="1em"></converse-icon>
  41599. </button>`);
  41600. }
  41601. const message_limit = core_api.settings.get('message_limit');
  41602. if (message_limit) {
  41603. buttons.push($`
  41604. <converse-message-limit-indicator .model=${this.model} class="right">
  41605. </converse-message-limit-indicator>`);
  41606. }
  41607. if (this.show_spoiler_button) {
  41608. buttons.push(this.getSpoilerButton());
  41609. }
  41610. const http_upload_promise = core_api.disco.supports(toolbar_Strophe.NS.HTTPUPLOAD, shared_converse.domain);
  41611. buttons.push($`${until_c(http_upload_promise.then(is_supported => this.getHTTPUploadButton(is_supported)), '')}`);
  41612. if (this.is_groupchat && (_api$settings$get = core_api.settings.get('visible_toolbar_buttons')) !== null && _api$settings$get !== void 0 && _api$settings$get.toggle_occupants) {
  41613. const i18n_hide_occupants = __('Hide participants');
  41614. const i18n_show_occupants = __('Show participants');
  41615. buttons.push($`
  41616. <button class="toggle_occupants right"
  41617. title="${this.hidden_occupants ? i18n_show_occupants : i18n_hide_occupants}"
  41618. @click=${this.toggleOccupants}>
  41619. <converse-icon
  41620. color="var(--muc-toolbar-btn-color)"
  41621. class="fa ${this.hidden_occupants ? `fa-angle-double-left` : `fa-angle-double-right`}"
  41622. size="1em"></converse-icon>
  41623. </button>`);
  41624. }
  41625. /**
  41626. * *Hook* which allows plugins to add more buttons to a chat's toolbar
  41627. * @event _converse#getToolbarButtons
  41628. * @example
  41629. * api.listen.on('getToolbarButtons', (toolbar_el, buttons) {
  41630. * buttons.push(html`
  41631. * <button @click=${() => alert('Foo!')}>Foo</button>`
  41632. * );
  41633. * return buttons;
  41634. * }
  41635. */
  41636. return shared_converse.api.hook('getToolbarButtons', this, buttons);
  41637. }
  41638. getHTTPUploadButton(is_supported) {
  41639. if (is_supported) {
  41640. const i18n_choose_file = __('Choose a file to send');
  41641. const color = this.is_groupchat ? '--muc-toolbar-btn-color' : '--chat-toolbar-btn-color';
  41642. return $`
  41643. <button title="${i18n_choose_file}" @click=${this.toggleFileUpload}>
  41644. <converse-icon
  41645. color="var(${color})"
  41646. class="fa fa-paperclip"
  41647. size="1em"></converse-icon>
  41648. </button>
  41649. <input type="file" @change=${this.onFileSelection} class="fileupload" multiple="" style="display:none"/>`;
  41650. } else {
  41651. return '';
  41652. }
  41653. }
  41654. getSpoilerButton() {
  41655. var _model$presence;
  41656. const model = this.model;
  41657. if (!this.is_groupchat && !((_model$presence = model.presence) !== null && _model$presence !== void 0 && _model$presence.resources.length)) {
  41658. return;
  41659. }
  41660. let i18n_toggle_spoiler;
  41661. if (model.get('composing_spoiler')) {
  41662. i18n_toggle_spoiler = __("Click to write as a normal (non-spoiler) message");
  41663. } else {
  41664. i18n_toggle_spoiler = __("Click to write your message as a spoiler");
  41665. }
  41666. const color = this.is_groupchat ? '--muc-toolbar-btn-color' : '--chat-toolbar-btn-color';
  41667. const markup = $`
  41668. <button class="toggle-compose-spoiler"
  41669. title="${i18n_toggle_spoiler}"
  41670. @click=${this.toggleComposeSpoilerMessage}>
  41671. <converse-icon
  41672. color="var(${color})"
  41673. class="fa ${model.get('composing_spoiler') ? 'fa-eye-slash' : 'fa-eye'}"
  41674. size="1em"></converse-icon>
  41675. </button>`;
  41676. if (this.is_groupchat) {
  41677. return markup;
  41678. } else {
  41679. const contact_jid = model.get('jid');
  41680. const spoilers_promise = Promise.all(model.presence.resources.map(r => core_api.disco.supports(toolbar_Strophe.NS.SPOILER, `${contact_jid}/${r.get('name')}`))).then(results => results.reduce((acc, val) => acc && val, true));
  41681. return $`${until_c(spoilers_promise.then(() => markup), '')}`;
  41682. }
  41683. }
  41684. toggleFileUpload(ev) {
  41685. var _ev$preventDefault, _ev$stopPropagation;
  41686. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  41687. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation = ev.stopPropagation) === null || _ev$stopPropagation === void 0 ? void 0 : _ev$stopPropagation.call(ev);
  41688. this.querySelector('.fileupload').click();
  41689. }
  41690. onFileSelection(evt) {
  41691. this.model.sendFiles(evt.target.files);
  41692. }
  41693. toggleComposeSpoilerMessage(ev) {
  41694. var _ev$preventDefault2, _ev$stopPropagation2;
  41695. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  41696. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation2 = ev.stopPropagation) === null || _ev$stopPropagation2 === void 0 ? void 0 : _ev$stopPropagation2.call(ev);
  41697. this.model.set('composing_spoiler', !this.model.get('composing_spoiler'));
  41698. }
  41699. toggleOccupants(ev) {
  41700. var _ev$preventDefault3, _ev$stopPropagation3;
  41701. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault3 = ev.preventDefault) === null || _ev$preventDefault3 === void 0 ? void 0 : _ev$preventDefault3.call(ev);
  41702. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation3 = ev.stopPropagation) === null || _ev$stopPropagation3 === void 0 ? void 0 : _ev$stopPropagation3.call(ev);
  41703. this.model.save({
  41704. 'hidden_occupants': !this.model.get('hidden_occupants')
  41705. });
  41706. }
  41707. toggleCall(ev) {
  41708. var _ev$preventDefault4, _ev$stopPropagation4;
  41709. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault4 = ev.preventDefault) === null || _ev$preventDefault4 === void 0 ? void 0 : _ev$preventDefault4.call(ev);
  41710. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation4 = ev.stopPropagation) === null || _ev$stopPropagation4 === void 0 ? void 0 : _ev$stopPropagation4.call(ev);
  41711. /**
  41712. * When a call button (i.e. with class .toggle-call) on a chatbox has been clicked.
  41713. * @event _converse#callButtonClicked
  41714. * @type { object }
  41715. * @property { Strophe.Connection } _converse.connection - The XMPP Connection object
  41716. * @property { _converse.ChatBox | _converse.ChatRoom } _converse.connection - The XMPP Connection object
  41717. * @example _converse.api.listen.on('callButtonClicked', (connection, model) => { ... });
  41718. */
  41719. core_api.trigger('callButtonClicked', {
  41720. connection: shared_converse.connection,
  41721. model: this.model
  41722. });
  41723. }
  41724. }
  41725. window.customElements.define('converse-chat-toolbar', ChatToolbar);
  41726. ;// CONCATENATED MODULE: ./src/plugins/chatview/utils.js
  41727. function clearHistory(jid) {
  41728. if (shared_converse.router.history.getFragment() === `converse/chat?jid=${jid}`) {
  41729. shared_converse.router.navigate('');
  41730. }
  41731. }
  41732. async function getHeadingDropdownItem(promise_or_data) {
  41733. const data = await promise_or_data;
  41734. return data ? $`
  41735. <a href="#" class="dropdown-item ${data.a_class}" @click=${data.handler} title="${data.i18n_title}">
  41736. <converse-icon size="1em" color="var(--text-color-lighten-15-percent)" class="fa ${data.icon_class}"></converse-icon>
  41737. ${data.i18n_text}
  41738. </a>
  41739. ` : '';
  41740. }
  41741. async function getHeadingStandaloneButton(promise_or_data) {
  41742. const data = await promise_or_data;
  41743. return $`
  41744. <a
  41745. href="#"
  41746. class="chatbox-btn ${data.a_class} fa ${data.icon_class}"
  41747. @click=${data.handler}
  41748. title="${data.i18n_title}"
  41749. ></a>
  41750. `;
  41751. }
  41752. async function clearMessages(chat) {
  41753. const result = confirm(__('Are you sure you want to clear the messages from this conversation?'));
  41754. if (result === true) {
  41755. await chat.clearMessages();
  41756. }
  41757. }
  41758. async function parseMessageForCommands(chat, text) {
  41759. const match = text.replace(/^\s*/, '').match(/^\/(.*)\s*$/);
  41760. if (match) {
  41761. let handled = false;
  41762. /**
  41763. * *Hook* which allows plugins to add more commands to a chat's textbox.
  41764. * Data provided is the chatbox model and the text typed - {model, text}.
  41765. * Check `handled` to see if the hook was already handled.
  41766. * @event _converse#parseMessageForCommands
  41767. * @example
  41768. * api.listen.on('parseMessageForCommands', (data, handled) {
  41769. * if (!handled) {
  41770. * const command = (data.text.match(/^\/([a-zA-Z]*) ?/) || ['']).pop().toLowerCase();
  41771. * // custom code comes here
  41772. * }
  41773. * return handled;
  41774. * }
  41775. */
  41776. handled = await core_api.hook('parseMessageForCommands', {
  41777. model: chat,
  41778. text
  41779. }, handled);
  41780. if (handled) {
  41781. return true;
  41782. }
  41783. if (match[1] === 'clear') {
  41784. clearMessages(chat);
  41785. return true;
  41786. } else if (match[1] === 'close') {
  41787. var _converse$chatboxview;
  41788. (_converse$chatboxview = shared_converse.chatboxviews.get(chat.get('jid'))) === null || _converse$chatboxview === void 0 ? void 0 : _converse$chatboxview.close();
  41789. return true;
  41790. } else if (match[1] === 'help') {
  41791. chat.set({
  41792. 'show_help_messages': false
  41793. }, {
  41794. 'silent': true
  41795. });
  41796. chat.set({
  41797. 'show_help_messages': true
  41798. });
  41799. return true;
  41800. }
  41801. }
  41802. return false;
  41803. }
  41804. function resetElementHeight(ev) {
  41805. if (ev.target.value) {
  41806. const height = ev.target.scrollHeight + 'px';
  41807. if (ev.target.style.height != height) {
  41808. ev.target.style.height = 'auto';
  41809. ev.target.style.height = height;
  41810. }
  41811. } else {
  41812. ev.target.style = '';
  41813. }
  41814. }
  41815. ;// CONCATENATED MODULE: ./src/plugins/chatview/templates/chat-head.js
  41816. async function getStandaloneButtons(promise) {
  41817. const heading_btns = await promise;
  41818. const standalone_btns = heading_btns.filter(b => b.standalone);
  41819. return standalone_btns.map(b => getHeadingStandaloneButton(b));
  41820. }
  41821. async function getDropdownButtons(promise) {
  41822. const heading_btns = await promise;
  41823. const dropdown_btns = heading_btns.filter(b => !b.standalone);
  41824. return dropdown_btns.map(b => getHeadingDropdownItem(b));
  41825. }
  41826. /* harmony default export */ const chat_head = (o => {
  41827. var _o$model$vcard, _o$model$vcard2;
  41828. const i18n_profile = __("The User's Profile Image");
  41829. const avatar = $`<span title="${i18n_profile}">
  41830. <converse-avatar
  41831. class="avatar chat-msg__avatar"
  41832. .data=${(_o$model$vcard = o.model.vcard) === null || _o$model$vcard === void 0 ? void 0 : _o$model$vcard.attributes}
  41833. nonce=${(_o$model$vcard2 = o.model.vcard) === null || _o$model$vcard2 === void 0 ? void 0 : _o$model$vcard2.get('vcard_updated')}
  41834. height="40" width="40"></converse-avatar></span>`;
  41835. const display_name = o.model.getDisplayName();
  41836. const tpl_dropdown_btns = () => getDropdownButtons(o.heading_buttons_promise).then(btns => btns.length ? $`<converse-dropdown class="dropleft" color="var(--chat-head-text-color)" .items=${btns}></converse-dropdown>` : '');
  41837. const tpl_standalone_btns = () => getStandaloneButtons(o.heading_buttons_promise).then(btns => btns.reverse().map(b => until_c(b, '')));
  41838. return $`
  41839. <div class="chatbox-title ${o.status ? '' : "chatbox-title--no-desc"}">
  41840. <div class="chatbox-title--row">
  41841. ${!shared_converse.api.settings.get("singleton") ? $`<converse-controlbox-navback jid="${o.jid}"></converse-controlbox-navback>` : ''}
  41842. ${o.type !== shared_converse.HEADLINES_TYPE ? $`<a class="show-msg-author-modal" @click=${o.showUserDetailsModal}>${avatar}</a>` : ''}
  41843. <div class="chatbox-title__text" title="${o.jid}">
  41844. ${o.type !== shared_converse.HEADLINES_TYPE ? $`<a class="user show-msg-author-modal" @click=${o.showUserDetailsModal}>${display_name}</a>` : display_name}
  41845. </div>
  41846. </div>
  41847. <div class="chatbox-title__buttons row no-gutters">
  41848. ${until_c(tpl_dropdown_btns(), '')}
  41849. ${until_c(tpl_standalone_btns(), '')}
  41850. </div>
  41851. </div>
  41852. ${o.status ? $`<p class="chat-head__desc">${o.status}</p>` : ''}
  41853. `;
  41854. });
  41855. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/chatview/styles/chat-head.scss
  41856. var styles_chat_head = __webpack_require__(7802);
  41857. ;// CONCATENATED MODULE: ./src/plugins/chatview/styles/chat-head.scss
  41858. var chat_head_options = {};
  41859. chat_head_options.styleTagTransform = (styleTagTransform_default());
  41860. chat_head_options.setAttributes = (setAttributesWithoutAttributes_default());
  41861. chat_head_options.insert = insertBySelector_default().bind(null, "head");
  41862. chat_head_options.domAPI = (styleDomAPI_default());
  41863. chat_head_options.insertStyleElement = (insertStyleElement_default());
  41864. var chat_head_update = injectStylesIntoStyleTag_default()(styles_chat_head/* default */.Z, chat_head_options);
  41865. /* harmony default export */ const chatview_styles_chat_head = (styles_chat_head/* default */.Z && styles_chat_head/* default.locals */.Z.locals ? styles_chat_head/* default.locals */.Z.locals : undefined);
  41866. ;// CONCATENATED MODULE: ./src/plugins/chatview/heading.js
  41867. class ChatHeading extends CustomElement {
  41868. initialize() {
  41869. var _this$model$rosterCon;
  41870. this.model = shared_converse.chatboxes.get(this.getAttribute('jid'));
  41871. this.listenTo(this.model, 'change:status', this.requestUpdate);
  41872. this.listenTo(this.model, 'vcard:add', this.requestUpdate);
  41873. this.listenTo(this.model, 'vcard:change', this.requestUpdate);
  41874. if (this.model.contact) {
  41875. this.listenTo(this.model.contact, 'destroy', this.requestUpdate);
  41876. }
  41877. (_this$model$rosterCon = this.model.rosterContactAdded) === null || _this$model$rosterCon === void 0 ? void 0 : _this$model$rosterCon.then(() => {
  41878. this.listenTo(this.model.contact, 'change:nickname', this.requestUpdate);
  41879. this.requestUpdate();
  41880. });
  41881. }
  41882. render() {
  41883. return chat_head(Object.assign(this.model.toJSON(), {
  41884. 'heading_buttons_promise': this.getHeadingButtons(),
  41885. 'model': this.model,
  41886. 'showUserDetailsModal': ev => this.showUserDetailsModal(ev)
  41887. }));
  41888. }
  41889. showUserDetailsModal(ev) {
  41890. ev.preventDefault();
  41891. core_api.modal.show(modals_user_details, {
  41892. model: this.model
  41893. }, ev);
  41894. }
  41895. close(ev) {
  41896. ev.preventDefault();
  41897. this.model.close();
  41898. }
  41899. /**
  41900. * Returns a list of objects which represent buttons for the chat's header.
  41901. * @async
  41902. * @emits _converse#getHeadingButtons
  41903. */
  41904. getHeadingButtons() {
  41905. const buttons = [
  41906. /**
  41907. * @typedef { Object } HeadingButtonAttributes
  41908. * An object representing a chat heading button
  41909. * @property { Boolean } standalone
  41910. * True if shown on its own, false if it must be in the dropdown menu.
  41911. * @property { Function } handler
  41912. * A handler function to be called when the button is clicked.
  41913. * @property { String } a_class - HTML classes to show on the button
  41914. * @property { String } i18n_text - The user-visiible name of the button
  41915. * @property { String } i18n_title - The tooltip text for this button
  41916. * @property { String } icon_class - What kind of CSS class to use for the icon
  41917. * @property { String } name - The internal name of the button
  41918. */
  41919. {
  41920. 'a_class': 'show-user-details-modal',
  41921. 'handler': ev => this.showUserDetailsModal(ev),
  41922. 'i18n_text': __('Details'),
  41923. 'i18n_title': __('See more information about this person'),
  41924. 'icon_class': 'fa-id-card',
  41925. 'name': 'details',
  41926. 'standalone': core_api.settings.get('view_mode') === 'overlayed'
  41927. }];
  41928. if (!core_api.settings.get('singleton')) {
  41929. buttons.push({
  41930. 'a_class': 'close-chatbox-button',
  41931. 'handler': ev => this.close(ev),
  41932. 'i18n_text': __('Close'),
  41933. 'i18n_title': __('Close and end this conversation'),
  41934. 'icon_class': 'fa-times',
  41935. 'name': 'close',
  41936. 'standalone': core_api.settings.get('view_mode') === 'overlayed'
  41937. });
  41938. }
  41939. const el = shared_converse.chatboxviews.get(this.getAttribute('jid'));
  41940. if (el) {
  41941. /**
  41942. * *Hook* which allows plugins to add more buttons to a chat's heading.
  41943. *
  41944. * Note: This hook is fired for both 1 on 1 chats and groupchats.
  41945. * If you only care about one, you need to add a check in your code.
  41946. *
  41947. * @event _converse#getHeadingButtons
  41948. * @param { HTMLElement } el
  41949. * The `converse-chat` (or `converse-muc`) DOM element that represents the chat
  41950. * @param { Array.<HeadingButtonAttributes> }
  41951. * An array of the existing buttons. New buttons may be added,
  41952. * and existing ones removed or modified.
  41953. * @example
  41954. * api.listen.on('getHeadingButtons', (el, buttons) => {
  41955. * buttons.push({
  41956. * 'i18n_title': __('Foo'),
  41957. * 'i18n_text': __('Foo Bar'),
  41958. * 'handler': ev => alert('Foo!'),
  41959. * 'a_class': 'toggle-foo',
  41960. * 'icon_class': 'fa-foo',
  41961. * 'name': 'foo'
  41962. * });
  41963. * return buttons;
  41964. * });
  41965. */
  41966. return shared_converse.api.hook('getHeadingButtons', el, buttons);
  41967. } else {
  41968. return buttons; // Happens during tests
  41969. }
  41970. }
  41971. }
  41972. core_api.elements.define('converse-chat-heading', ChatHeading);
  41973. ;// CONCATENATED MODULE: ./src/plugins/chatview/templates/message-form.js
  41974. /* harmony default export */ const message_form = (o => {
  41975. const label_message = o.composing_spoiler ? __('Hidden message') : __('Message');
  41976. const label_spoiler_hint = __('Optional hint');
  41977. const show_send_button = core_api.settings.get('show_send_button');
  41978. return $`
  41979. <form class="sendXMPPMessage">
  41980. <input type="text"
  41981. enterkeyhint="send"
  41982. placeholder="${label_spoiler_hint || ''}"i
  41983. value="${o.hint_value || ''}"
  41984. class="${o.composing_spoiler ? '' : 'hidden'} spoiler-hint"/>
  41985. <textarea
  41986. autofocus
  41987. type="text"
  41988. enterkeyhint="send"
  41989. @drop=${o.onDrop}
  41990. @input=${resetElementHeight}
  41991. @keydown=${o.onKeyDown}
  41992. @keyup=${o.onKeyUp}
  41993. @paste=${o.onPaste}
  41994. @change=${o.onChange}
  41995. class="chat-textarea
  41996. ${show_send_button ? 'chat-textarea-send-button' : ''}
  41997. ${o.composing_spoiler ? 'spoiler' : ''}"
  41998. placeholder="${label_message}">${o.message_value || ''}</textarea>
  41999. </form>`;
  42000. });
  42001. ;// CONCATENATED MODULE: ./node_modules/@converse/skeletor/src/element.js
  42002. function element_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  42003. const element_paddedLt = /^\s*</; // Caches a local reference to `Element.prototype` for faster access.
  42004. const element_ElementProto = typeof Element !== 'undefined' && Element.prototype || {}; // Cached regex to split keys for `delegate`.
  42005. const element_delegateEventSplitter = /^(\S+)\s*(.*)$/; // List of view options to be set as properties.
  42006. const element_viewOptions = ['model', 'collection', 'events'];
  42007. class ElementView extends HTMLElement {
  42008. constructor(options) {
  42009. super(); // Creating a View creates its initial element outside of the DOM,
  42010. // if an existing element is not provided...
  42011. element_defineProperty(this, "events", {});
  42012. this.cid = lodash_es_uniqueId('view');
  42013. this._domEvents = [];
  42014. lodash_es_assignIn(this, lodash_es_pick(options, element_viewOptions));
  42015. }
  42016. createRenderRoot() {
  42017. // Render without the shadow DOM
  42018. return this;
  42019. }
  42020. connectedCallback() {
  42021. if (!this._initialized) {
  42022. this.preinitialize.apply(this, arguments);
  42023. this.initialize.apply(this, arguments);
  42024. this._initialized = true;
  42025. }
  42026. this.delegateEvents();
  42027. }
  42028. disconnectedCallback() {
  42029. this.undelegateEvents();
  42030. this.stopListening();
  42031. } // preinitialize is an empty function by default. You can override it with a function
  42032. // or object. preinitialize will run before any instantiation logic is run in the View
  42033. preinitialize() {// eslint-disable-line class-methods-use-this
  42034. } // Initialize is an empty function by default. Override it with your own
  42035. // initialization logic.
  42036. initialize() {} // eslint-disable-line class-methods-use-this
  42037. // **render** is the core function that your view should override, in order
  42038. // to populate its element (`this.el`), with the appropriate HTML. The
  42039. // convention is for **render** to always return `this`.
  42040. render() {
  42041. lodash_es_isFunction(this.beforeRender) && this.beforeRender();
  42042. lodash_es_isFunction(this.toHTML) && x(this.toHTML(), this);
  42043. lodash_es_isFunction(this.afterRender) && this.afterRender();
  42044. return this;
  42045. } // Set callbacks, where `this.events` is a hash of
  42046. //
  42047. // *{"event selector": "callback"}*
  42048. //
  42049. // {
  42050. // 'mousedown .title': 'edit',
  42051. // 'click .button': 'save',
  42052. // 'click .open': function(e) { ... }
  42053. // }
  42054. //
  42055. // pairs. Callbacks will be bound to the view, with `this` set properly.
  42056. // Uses event delegation for efficiency.
  42057. // Omitting the selector binds the event to `this.el`.
  42058. delegateEvents() {
  42059. if (!this.events) {
  42060. return this;
  42061. }
  42062. this.undelegateEvents();
  42063. for (const key in this.events) {
  42064. let method = this.events[key];
  42065. if (!lodash_es_isFunction(method)) method = this[method];
  42066. if (!method) continue;
  42067. const match = key.match(element_delegateEventSplitter);
  42068. this.delegate(match[1], match[2], method.bind(this));
  42069. }
  42070. return this;
  42071. } // Make a event delegation handler for the given `eventName` and `selector`
  42072. // and attach it to `this.el`.
  42073. // If selector is empty, the listener will be bound to `this.el`. If not, a
  42074. // new handler that will recursively traverse up the event target's DOM
  42075. // hierarchy looking for a node that matches the selector. If one is found,
  42076. // the event's `delegateTarget` property is set to it and the return the
  42077. // result of calling bound `listener` with the parameters given to the
  42078. // handler.
  42079. delegate(eventName, selector, listener) {
  42080. const root = this;
  42081. if (!root) {
  42082. return this;
  42083. }
  42084. if (typeof selector === 'function') {
  42085. listener = selector;
  42086. selector = null;
  42087. } // Given that `focus` and `blur` events do not bubble, do not delegate these events
  42088. if (['focus', 'blur'].indexOf(eventName) !== -1) {
  42089. const els = this.querySelectorAll(selector);
  42090. for (let i = 0, len = els.length; i < len; i++) {
  42091. const item = els[i];
  42092. item.addEventListener(eventName, listener, false);
  42093. this._domEvents.push({
  42094. el: item,
  42095. eventName: eventName,
  42096. handler: listener
  42097. });
  42098. }
  42099. return listener;
  42100. }
  42101. const handler = selector ? function (e) {
  42102. let node = e.target || e.srcElement;
  42103. for (; node && node != root; node = node.parentNode) {
  42104. if (node.matches(selector)) {
  42105. e.delegateTarget = node;
  42106. listener(e);
  42107. }
  42108. }
  42109. } : listener;
  42110. this.addEventListener(eventName, handler, false);
  42111. this._domEvents.push({
  42112. el: this,
  42113. eventName: eventName,
  42114. handler: handler,
  42115. listener: listener,
  42116. selector: selector
  42117. });
  42118. return this;
  42119. } // Clears all callbacks previously bound to the view by `delegateEvents`.
  42120. // You usually don't need to use this, but may wish to if you have multiple
  42121. // Backbone views attached to the same DOM element.
  42122. undelegateEvents() {
  42123. if (this) {
  42124. for (let i = 0, len = this._domEvents.length; i < len; i++) {
  42125. const item = this._domEvents[i];
  42126. item.el.removeEventListener(item.eventName, item.handler, false);
  42127. }
  42128. this._domEvents.length = 0;
  42129. }
  42130. return this;
  42131. } // A finer-grained `undelegateEvents` for removing a single delegated event.
  42132. // `selector` and `listener` are both optional.
  42133. undelegate(eventName, selector, listener) {
  42134. if (typeof selector === 'function') {
  42135. listener = selector;
  42136. selector = null;
  42137. }
  42138. if (this) {
  42139. const handlers = this._domEvents.slice();
  42140. let i = handlers.length;
  42141. while (i--) {
  42142. const item = handlers[i];
  42143. const match = item.eventName === eventName && (listener ? item.listener === listener : true) && (selector ? item.selector === selector : true);
  42144. if (!match) {
  42145. continue;
  42146. }
  42147. item.el.removeEventListener(item.eventName, item.handler, false);
  42148. this._domEvents.splice(i, 1);
  42149. }
  42150. }
  42151. return this;
  42152. }
  42153. } // Set up all inheritable **View** properties and methods.
  42154. Object.assign(ElementView.prototype, Events);
  42155. ;// CONCATENATED MODULE: ./src/plugins/chatview/message-form.js
  42156. const {
  42157. u: message_form_u
  42158. } = core_converse.env;
  42159. class MessageForm extends ElementView {
  42160. async connectedCallback() {
  42161. super.connectedCallback();
  42162. this.model = shared_converse.chatboxes.get(this.getAttribute('jid'));
  42163. await this.model.initialized;
  42164. this.listenTo(this.model.messages, 'change:correcting', this.onMessageCorrecting);
  42165. this.listenTo(this.model, 'change:composing_spoiler', () => this.render());
  42166. this.handleEmojiSelection = _ref => {
  42167. let {
  42168. detail
  42169. } = _ref;
  42170. if (this.model.get('jid') === detail.jid) {
  42171. this.insertIntoTextArea(detail.value, detail.autocompleting, false, detail.ac_position);
  42172. }
  42173. };
  42174. document.addEventListener("emojiSelected", this.handleEmojiSelection);
  42175. this.render();
  42176. }
  42177. disconnectedCallback() {
  42178. super.disconnectedCallback();
  42179. document.removeEventListener("emojiSelected", this.handleEmojiSelection);
  42180. }
  42181. toHTML() {
  42182. var _this$querySelector, _this$querySelector2;
  42183. return message_form(Object.assign(this.model.toJSON(), {
  42184. 'onDrop': ev => this.onDrop(ev),
  42185. 'hint_value': (_this$querySelector = this.querySelector('.spoiler-hint')) === null || _this$querySelector === void 0 ? void 0 : _this$querySelector.value,
  42186. 'message_value': (_this$querySelector2 = this.querySelector('.chat-textarea')) === null || _this$querySelector2 === void 0 ? void 0 : _this$querySelector2.value,
  42187. 'onChange': ev => this.model.set({
  42188. 'draft': ev.target.value
  42189. }),
  42190. 'onKeyDown': ev => this.onKeyDown(ev),
  42191. 'onKeyUp': ev => this.onKeyUp(ev),
  42192. 'onPaste': ev => this.onPaste(ev),
  42193. 'viewUnreadMessages': ev => this.viewUnreadMessages(ev)
  42194. }));
  42195. }
  42196. /**
  42197. * Insert a particular string value into the textarea of this chat box.
  42198. * @param {string} value - The value to be inserted.
  42199. * @param {(boolean|string)} [replace] - Whether an existing value
  42200. * should be replaced. If set to `true`, the entire textarea will
  42201. * be replaced with the new value. If set to a string, then only
  42202. * that string will be replaced *if* a position is also specified.
  42203. * @param {integer} [position] - The end index of the string to be
  42204. * replaced with the new value.
  42205. */
  42206. insertIntoTextArea(value) {
  42207. let replace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  42208. let correcting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  42209. let position = arguments.length > 3 ? arguments[3] : undefined;
  42210. const textarea = this.querySelector('.chat-textarea');
  42211. if (correcting) {
  42212. message_form_u.addClass('correcting', textarea);
  42213. } else {
  42214. message_form_u.removeClass('correcting', textarea);
  42215. }
  42216. if (replace) {
  42217. if (position && typeof replace == 'string') {
  42218. textarea.value = textarea.value.replace(new RegExp(replace, 'g'), (match, offset) => offset == position - replace.length ? value + ' ' : match);
  42219. } else {
  42220. textarea.value = value;
  42221. }
  42222. } else {
  42223. let existing = textarea.value;
  42224. if (existing && existing[existing.length - 1] !== ' ') {
  42225. existing = existing + ' ';
  42226. }
  42227. textarea.value = existing + value + ' ';
  42228. }
  42229. const ev = document.createEvent('HTMLEvents');
  42230. ev.initEvent('change', false, true);
  42231. textarea.dispatchEvent(ev);
  42232. message_form_u.placeCaretAtEnd(textarea);
  42233. }
  42234. onMessageCorrecting(message) {
  42235. if (message.get('correcting')) {
  42236. this.insertIntoTextArea(prefixMentions(message), true, true);
  42237. } else {
  42238. const currently_correcting = this.model.messages.findWhere('correcting');
  42239. if (currently_correcting && currently_correcting !== message) {
  42240. this.insertIntoTextArea(prefixMentions(message), true, true);
  42241. } else {
  42242. this.insertIntoTextArea('', true, false);
  42243. }
  42244. }
  42245. }
  42246. onEscapePressed(ev) {
  42247. const idx = this.model.messages.findLastIndex('correcting');
  42248. const message = idx >= 0 ? this.model.messages.at(idx) : null;
  42249. if (message) {
  42250. ev.preventDefault();
  42251. message.save('correcting', false);
  42252. this.insertIntoTextArea('', true, false);
  42253. }
  42254. }
  42255. onPaste(ev) {
  42256. ev.stopPropagation();
  42257. if (ev.clipboardData.files.length !== 0) {
  42258. ev.preventDefault(); // Workaround for quirk in at least Firefox 60.7 ESR:
  42259. // It seems that pasted files disappear from the event payload after
  42260. // the event has finished, which apparently happens during async
  42261. // processing in sendFiles(). So we copy the array here.
  42262. this.model.sendFiles(Array.from(ev.clipboardData.files));
  42263. return;
  42264. }
  42265. this.model.set({
  42266. 'draft': ev.clipboardData.getData('text/plain')
  42267. });
  42268. }
  42269. onKeyUp(ev) {
  42270. this.model.set({
  42271. 'draft': ev.target.value
  42272. });
  42273. }
  42274. onKeyDown(ev) {
  42275. if (ev.ctrlKey) {
  42276. // When ctrl is pressed, no chars are entered into the textarea.
  42277. return;
  42278. }
  42279. if (!ev.shiftKey && !ev.altKey && !ev.metaKey) {
  42280. if (ev.keyCode === core_converse.keycodes.TAB) {
  42281. const value = message_form_u.getCurrentWord(ev.target, null, /(:.*?:)/g);
  42282. if (value.startsWith(':')) {
  42283. ev.preventDefault();
  42284. ev.stopPropagation();
  42285. this.model.trigger('emoji-picker-autocomplete', ev.target, value);
  42286. }
  42287. } else if (ev.keyCode === core_converse.keycodes.FORWARD_SLASH) {
  42288. // Forward slash is used to run commands. Nothing to do here.
  42289. return;
  42290. } else if (ev.keyCode === core_converse.keycodes.ESCAPE) {
  42291. return this.onEscapePressed(ev, this);
  42292. } else if (ev.keyCode === core_converse.keycodes.ENTER) {
  42293. return this.onFormSubmitted(ev);
  42294. } else if (ev.keyCode === core_converse.keycodes.UP_ARROW && !ev.target.selectionEnd) {
  42295. const textarea = this.querySelector('.chat-textarea');
  42296. if (!textarea.value || message_form_u.hasClass('correcting', textarea)) {
  42297. return this.model.editEarlierMessage();
  42298. }
  42299. } else if (ev.keyCode === core_converse.keycodes.DOWN_ARROW && ev.target.selectionEnd === ev.target.value.length && message_form_u.hasClass('correcting', this.querySelector('.chat-textarea'))) {
  42300. return this.model.editLaterMessage();
  42301. }
  42302. }
  42303. if ([core_converse.keycodes.SHIFT, core_converse.keycodes.META, core_converse.keycodes.META_RIGHT, core_converse.keycodes.ESCAPE, core_converse.keycodes.ALT].includes(ev.keyCode)) {
  42304. return;
  42305. }
  42306. if (this.model.get('chat_state') !== shared_converse.COMPOSING) {
  42307. // Set chat state to composing if keyCode is not a forward-slash
  42308. // (which would imply an internal command and not a message).
  42309. this.model.setChatState(shared_converse.COMPOSING);
  42310. }
  42311. }
  42312. async onFormSubmitted(ev) {
  42313. var _ev$preventDefault, _this$querySelector3;
  42314. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  42315. const textarea = this.querySelector('.chat-textarea');
  42316. const message_text = textarea.value.trim();
  42317. if (core_api.settings.get('message_limit') && message_text.length > core_api.settings.get('message_limit') || !message_text.replace(/\s/g, '').length) {
  42318. return;
  42319. }
  42320. if (!shared_converse.connection.authenticated) {
  42321. const err_msg = __('Sorry, the connection has been lost, and your message could not be sent');
  42322. core_api.alert('error', __('Error'), err_msg);
  42323. core_api.connection.reconnect();
  42324. return;
  42325. }
  42326. let spoiler_hint,
  42327. hint_el = {};
  42328. if (this.model.get('composing_spoiler')) {
  42329. hint_el = this.querySelector('form.sendXMPPMessage input.spoiler-hint');
  42330. spoiler_hint = hint_el.value;
  42331. }
  42332. message_form_u.addClass('disabled', textarea);
  42333. textarea.setAttribute('disabled', 'disabled');
  42334. (_this$querySelector3 = this.querySelector('converse-emoji-dropdown')) === null || _this$querySelector3 === void 0 ? void 0 : _this$querySelector3.hideMenu();
  42335. const is_command = await parseMessageForCommands(this.model, message_text);
  42336. const message = is_command ? null : await this.model.sendMessage({
  42337. 'body': message_text,
  42338. spoiler_hint
  42339. });
  42340. if (is_command || message) {
  42341. hint_el.value = '';
  42342. textarea.value = '';
  42343. message_form_u.removeClass('correcting', textarea);
  42344. textarea.style.height = 'auto';
  42345. this.model.set({
  42346. 'draft': ''
  42347. });
  42348. }
  42349. if (core_api.settings.get('view_mode') === 'overlayed') {
  42350. // XXX: Chrome flexbug workaround. The .chat-content area
  42351. // doesn't resize when the textarea is resized to its original size.
  42352. const chatview = shared_converse.chatboxviews.get(this.getAttribute('jid'));
  42353. const msgs_container = chatview.querySelector('.chat-content__messages');
  42354. msgs_container.parentElement.style.display = 'none';
  42355. }
  42356. textarea.removeAttribute('disabled');
  42357. message_form_u.removeClass('disabled', textarea);
  42358. if (core_api.settings.get('view_mode') === 'overlayed') {
  42359. // XXX: Chrome flexbug workaround.
  42360. const chatview = shared_converse.chatboxviews.get(this.getAttribute('jid'));
  42361. const msgs_container = chatview.querySelector('.chat-content__messages');
  42362. msgs_container.parentElement.style.display = '';
  42363. } // Suppress events, otherwise superfluous CSN gets set
  42364. // immediately after the message, causing rate-limiting issues.
  42365. this.model.setChatState(shared_converse.ACTIVE, {
  42366. 'silent': true
  42367. });
  42368. textarea.focus();
  42369. }
  42370. }
  42371. core_api.elements.define('converse-message-form', MessageForm);
  42372. ;// CONCATENATED MODULE: ./src/plugins/chatview/templates/bottom-panel.js
  42373. /* harmony default export */ const bottom_panel = (o => {
  42374. const unread_msgs = __('You have unread messages');
  42375. const message_limit = core_api.settings.get('message_limit');
  42376. const show_call_button = core_api.settings.get('visible_toolbar_buttons').call;
  42377. const show_emoji_button = core_api.settings.get('visible_toolbar_buttons').emoji;
  42378. const show_send_button = core_api.settings.get('show_send_button');
  42379. const show_spoiler_button = core_api.settings.get('visible_toolbar_buttons').spoiler;
  42380. const show_toolbar = core_api.settings.get('show_toolbar');
  42381. return $`
  42382. ${o.model.ui.get('scrolled') && o.model.get('num_unread') ? $`<div class="new-msgs-indicator" @click=${ev => o.viewUnreadMessages(ev)}>▼ ${unread_msgs} ▼</div>` : ''}
  42383. ${core_api.settings.get('show_toolbar') ? $`
  42384. <converse-chat-toolbar
  42385. class="chat-toolbar no-text-select"
  42386. .model=${o.model}
  42387. ?composing_spoiler="${o.model.get('composing_spoiler')}"
  42388. ?show_call_button="${show_call_button}"
  42389. ?show_emoji_button="${show_emoji_button}"
  42390. ?show_send_button="${show_send_button}"
  42391. ?show_spoiler_button="${show_spoiler_button}"
  42392. ?show_toolbar="${show_toolbar}"
  42393. message_limit="${message_limit}"></converse-chat-toolbar>` : ''}
  42394. <converse-message-form jid="${o.model.get('jid')}"></converse-message-form>
  42395. `;
  42396. });
  42397. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/chatview/styles/chat-bottom-panel.scss
  42398. var chat_bottom_panel = __webpack_require__(352);
  42399. ;// CONCATENATED MODULE: ./src/plugins/chatview/styles/chat-bottom-panel.scss
  42400. var chat_bottom_panel_options = {};
  42401. chat_bottom_panel_options.styleTagTransform = (styleTagTransform_default());
  42402. chat_bottom_panel_options.setAttributes = (setAttributesWithoutAttributes_default());
  42403. chat_bottom_panel_options.insert = insertBySelector_default().bind(null, "head");
  42404. chat_bottom_panel_options.domAPI = (styleDomAPI_default());
  42405. chat_bottom_panel_options.insertStyleElement = (insertStyleElement_default());
  42406. var chat_bottom_panel_update = injectStylesIntoStyleTag_default()(chat_bottom_panel/* default */.Z, chat_bottom_panel_options);
  42407. /* harmony default export */ const styles_chat_bottom_panel = (chat_bottom_panel/* default */.Z && chat_bottom_panel/* default.locals */.Z.locals ? chat_bottom_panel/* default.locals */.Z.locals : undefined);
  42408. ;// CONCATENATED MODULE: ./src/plugins/chatview/bottom-panel.js
  42409. function bottom_panel_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  42410. class ChatBottomPanel extends ElementView {
  42411. constructor() {
  42412. super();
  42413. bottom_panel_defineProperty(this, "events", {
  42414. 'click .send-button': 'sendButtonClicked',
  42415. 'click .toggle-clear': 'clearMessages'
  42416. });
  42417. this.debouncedRender = lodash_es_debounce(this.render, 100);
  42418. }
  42419. async connectedCallback() {
  42420. super.connectedCallback();
  42421. await this.initialize();
  42422. this.render(); // don't call in initialize, since the MUCBottomPanel subclasses it
  42423. // and we want to render after it has finished as wel.
  42424. }
  42425. async initialize() {
  42426. this.model = await core_api.chatboxes.get(this.getAttribute('jid'));
  42427. await this.model.initialized;
  42428. this.listenTo(this.model, 'change:num_unread', this.debouncedRender);
  42429. this.listenTo(this.model, 'emoji-picker-autocomplete', this.autocompleteInPicker);
  42430. this.addEventListener('focusin', ev => this.emitFocused(ev));
  42431. this.addEventListener('focusout', ev => this.emitBlurred(ev));
  42432. }
  42433. render() {
  42434. x(bottom_panel({
  42435. 'model': this.model,
  42436. 'viewUnreadMessages': ev => this.viewUnreadMessages(ev)
  42437. }), this);
  42438. }
  42439. sendButtonClicked(ev) {
  42440. var _this$querySelector;
  42441. (_this$querySelector = this.querySelector('converse-message-form')) === null || _this$querySelector === void 0 ? void 0 : _this$querySelector.onFormSubmitted(ev);
  42442. }
  42443. viewUnreadMessages(ev) {
  42444. var _ev$preventDefault;
  42445. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  42446. this.model.ui.set({
  42447. 'scrolled': false
  42448. });
  42449. }
  42450. emitFocused(ev) {
  42451. var _converse$chatboxview;
  42452. (_converse$chatboxview = shared_converse.chatboxviews.get(this.getAttribute('jid'))) === null || _converse$chatboxview === void 0 ? void 0 : _converse$chatboxview.emitFocused(ev);
  42453. }
  42454. emitBlurred(ev) {
  42455. var _converse$chatboxview2;
  42456. (_converse$chatboxview2 = shared_converse.chatboxviews.get(this.getAttribute('jid'))) === null || _converse$chatboxview2 === void 0 ? void 0 : _converse$chatboxview2.emitBlurred(ev);
  42457. }
  42458. onDrop(evt) {
  42459. if (evt.dataTransfer.files.length == 0) {
  42460. // There are no files to be dropped, so this isn’t a file
  42461. // transfer operation.
  42462. return;
  42463. }
  42464. evt.preventDefault();
  42465. this.model.sendFiles(evt.dataTransfer.files);
  42466. }
  42467. onDragOver(ev) {
  42468. // eslint-disable-line class-methods-use-this
  42469. ev.preventDefault();
  42470. }
  42471. clearMessages(ev) {
  42472. var _ev$preventDefault2;
  42473. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  42474. clearMessages(this.model);
  42475. }
  42476. async autocompleteInPicker(input, value) {
  42477. await core_api.emojis.initialize();
  42478. const emoji_picker = this.querySelector('converse-emoji-picker');
  42479. if (emoji_picker) {
  42480. emoji_picker.model.set({
  42481. 'ac_position': input.selectionStart,
  42482. 'autocompleting': value,
  42483. 'query': value
  42484. });
  42485. const emoji_dropdown = this.querySelector('converse-emoji-dropdown');
  42486. emoji_dropdown === null || emoji_dropdown === void 0 ? void 0 : emoji_dropdown.showMenu();
  42487. }
  42488. }
  42489. }
  42490. core_api.elements.define('converse-chat-bottom-panel', ChatBottomPanel);
  42491. ;// CONCATENATED MODULE: ./src/shared/chat/baseview.js
  42492. class BaseChatView extends CustomElement {
  42493. static get properties() {
  42494. return {
  42495. jid: {
  42496. type: String
  42497. }
  42498. };
  42499. }
  42500. disconnectedCallback() {
  42501. super.disconnectedCallback();
  42502. shared_converse.chatboxviews.remove(this.jid, this);
  42503. }
  42504. updated() {
  42505. if (this.model && this.jid !== this.model.get('jid')) {
  42506. this.stopListening();
  42507. shared_converse.chatboxviews.remove(this.model.get('jid'), this);
  42508. delete this.model;
  42509. this.requestUpdate();
  42510. this.initialize();
  42511. }
  42512. }
  42513. close(ev) {
  42514. var _ev$preventDefault;
  42515. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  42516. return this.model.close(ev);
  42517. }
  42518. maybeFocus() {
  42519. core_api.settings.get('auto_focus') && this.focus();
  42520. }
  42521. focus() {
  42522. const textarea_el = this.getElementsByClassName('chat-textarea')[0];
  42523. if (textarea_el && document.activeElement !== textarea_el) {
  42524. textarea_el.focus();
  42525. }
  42526. return this;
  42527. }
  42528. emitBlurred(ev) {
  42529. if (this.contains(document.activeElement) || this.contains(ev.relatedTarget)) {
  42530. // Something else in this chatbox is still focused
  42531. return;
  42532. }
  42533. /**
  42534. * Triggered when the focus has been removed from a particular chat.
  42535. * @event _converse#chatBoxBlurred
  42536. * @type { _converse.ChatBoxView | _converse.ChatRoomView }
  42537. * @example _converse.api.listen.on('chatBoxBlurred', (view, event) => { ... });
  42538. */
  42539. core_api.trigger('chatBoxBlurred', this, ev);
  42540. }
  42541. emitFocused(ev) {
  42542. if (this.contains(ev.relatedTarget)) {
  42543. // Something else in this chatbox was already focused
  42544. return;
  42545. }
  42546. /**
  42547. * Triggered when the focus has been moved to a particular chat.
  42548. * @event _converse#chatBoxFocused
  42549. * @type { _converse.ChatBoxView | _converse.ChatRoomView }
  42550. * @example _converse.api.listen.on('chatBoxFocused', (view, event) => { ... });
  42551. */
  42552. core_api.trigger('chatBoxFocused', this, ev);
  42553. }
  42554. getBottomPanel() {
  42555. if (this.model.get('type') === shared_converse.CHATROOMS_TYPE) {
  42556. return this.querySelector('converse-muc-bottom-panel');
  42557. } else {
  42558. return this.querySelector('converse-chat-bottom-panel');
  42559. }
  42560. }
  42561. getMessageForm() {
  42562. if (this.model.get('type') === shared_converse.CHATROOMS_TYPE) {
  42563. return this.querySelector('converse-muc-message-form');
  42564. } else {
  42565. return this.querySelector('converse-message-form');
  42566. }
  42567. }
  42568. /**
  42569. * Scrolls the chat down.
  42570. *
  42571. * This method will always scroll the chat down, regardless of
  42572. * whether the user scrolled up manually or not.
  42573. * @param { Event } [ev] - An optional event that is the cause for needing to scroll down.
  42574. */
  42575. scrollDown(ev) {
  42576. var _ev$preventDefault2, _ev$stopPropagation;
  42577. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  42578. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation = ev.stopPropagation) === null || _ev$stopPropagation === void 0 ? void 0 : _ev$stopPropagation.call(ev);
  42579. if (this.model.ui.get('scrolled')) {
  42580. this.model.ui.set({
  42581. 'scrolled': false
  42582. });
  42583. }
  42584. onScrolledDown(this.model);
  42585. }
  42586. onWindowStateChanged(data) {
  42587. if (data.state === 'visible') {
  42588. if (!this.model.isHidden()) {
  42589. this.model.clearUnreadMsgCounter();
  42590. }
  42591. } else if (data.state === 'hidden') {
  42592. this.model.setChatState(shared_converse.INACTIVE, {
  42593. 'silent': true
  42594. });
  42595. this.model.sendChatState();
  42596. }
  42597. }
  42598. }
  42599. ;// CONCATENATED MODULE: ./src/plugins/chatview/templates/chat.js
  42600. /* harmony default export */ const chat = (o => $`
  42601. <div class="flyout box-flyout">
  42602. <converse-dragresize></converse-dragresize>
  42603. ${o.model ? $`
  42604. <converse-chat-heading jid="${o.jid}" class="chat-head chat-head-chatbox row no-gutters"></converse-chat-heading>
  42605. <div class="chat-body">
  42606. <div class="chat-content ${o.show_send_button ? 'chat-content-sendbutton' : ''}" aria-live="polite">
  42607. <converse-chat-content
  42608. class="chat-content__messages"
  42609. jid="${o.jid}"></converse-chat-content>
  42610. ${o.show_help_messages ? $`<div class="chat-content__help">
  42611. <converse-chat-help
  42612. .model=${o.model}
  42613. .messages=${o.help_messages}
  42614. ?hidden=${!o.show_help_messages}
  42615. type="info"
  42616. chat_type="${shared_converse.CHATROOMS_TYPE}"
  42617. ></converse-chat-help></div>` : ''}
  42618. </div>
  42619. <converse-chat-bottom-panel jid="${o.jid}" class="bottom-panel"> </converse-chat-bottom-panel>
  42620. </div>
  42621. ` : ''}
  42622. </div>
  42623. `);
  42624. ;// CONCATENATED MODULE: ./src/plugins/chatview/chat.js
  42625. function chat_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  42626. /**
  42627. * The view of an open/ongoing chat conversation.
  42628. * @class
  42629. * @namespace _converse.ChatBoxView
  42630. * @memberOf _converse
  42631. */
  42632. class ChatView extends BaseChatView {
  42633. constructor() {
  42634. super(...arguments);
  42635. chat_defineProperty(this, "length", 200);
  42636. }
  42637. async initialize() {
  42638. shared_converse.chatboxviews.add(this.jid, this);
  42639. this.model = shared_converse.chatboxes.get(this.jid);
  42640. this.listenTo(shared_converse, 'windowStateChanged', this.onWindowStateChanged);
  42641. this.listenTo(this.model, 'change:hidden', () => !this.model.get('hidden') && this.afterShown());
  42642. this.listenTo(this.model, 'change:show_help_messages', this.requestUpdate);
  42643. await this.model.messages.fetched;
  42644. !this.model.get('hidden') && this.afterShown();
  42645. /**
  42646. * Triggered once the {@link _converse.ChatBoxView} has been initialized
  42647. * @event _converse#chatBoxViewInitialized
  42648. * @type { _converse.HeadlinesBoxView }
  42649. * @example _converse.api.listen.on('chatBoxViewInitialized', view => { ... });
  42650. */
  42651. core_api.trigger('chatBoxViewInitialized', this);
  42652. }
  42653. render() {
  42654. return chat(Object.assign({
  42655. 'model': this.model,
  42656. 'help_messages': this.getHelpMessages(),
  42657. 'show_help_messages': this.model.get('show_help_messages')
  42658. }, this.model.toJSON()));
  42659. }
  42660. getHelpMessages() {
  42661. // eslint-disable-line class-methods-use-this
  42662. return [`<strong>/clear</strong>: ${__('Remove messages')}`, `<strong>/close</strong>: ${__('Close this chat')}`, `<strong>/me</strong>: ${__('Write in the third person')}`, `<strong>/help</strong>: ${__('Show this menu')}`];
  42663. }
  42664. showControlBox() {
  42665. var _converse$chatboxview;
  42666. // eslint-disable-line class-methods-use-this
  42667. // Used in mobile view, to navigate back to the controlbox
  42668. (_converse$chatboxview = shared_converse.chatboxviews.get('controlbox')) === null || _converse$chatboxview === void 0 ? void 0 : _converse$chatboxview.show();
  42669. }
  42670. afterShown() {
  42671. this.model.setChatState(shared_converse.ACTIVE);
  42672. this.model.clearUnreadMsgCounter();
  42673. this.maybeFocus();
  42674. }
  42675. }
  42676. core_api.elements.define('converse-chat', ChatView);
  42677. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/chatview/styles/index.scss
  42678. var chatview_styles = __webpack_require__(5599);
  42679. ;// CONCATENATED MODULE: ./src/plugins/chatview/styles/index.scss
  42680. var styles_options = {};
  42681. styles_options.styleTagTransform = (styleTagTransform_default());
  42682. styles_options.setAttributes = (setAttributesWithoutAttributes_default());
  42683. styles_options.insert = insertBySelector_default().bind(null, "head");
  42684. styles_options.domAPI = (styleDomAPI_default());
  42685. styles_options.insertStyleElement = (insertStyleElement_default());
  42686. var styles_update = injectStylesIntoStyleTag_default()(chatview_styles/* default */.Z, styles_options);
  42687. /* harmony default export */ const plugins_chatview_styles = (chatview_styles/* default */.Z && chatview_styles/* default.locals */.Z.locals ? chatview_styles/* default.locals */.Z.locals : undefined);
  42688. ;// CONCATENATED MODULE: ./src/plugins/chatview/index.js
  42689. /**
  42690. * @copyright 2022, the Converse.js contributors
  42691. * @license Mozilla Public License (MPLv2)
  42692. */
  42693. const {
  42694. Strophe: chatview_Strophe
  42695. } = core_converse.env;
  42696. core_converse.plugins.add('converse-chatview', {
  42697. /* Plugin dependencies are other plugins which might be
  42698. * overridden or relied upon, and therefore need to be loaded before
  42699. * this plugin.
  42700. *
  42701. * If the setting "strict_plugin_dependencies" is set to true,
  42702. * an error will be raised if the plugin is not found. By default it's
  42703. * false, which means these plugins are only loaded opportunistically.
  42704. *
  42705. * NB: These plugins need to have already been loaded via require.js.
  42706. */
  42707. dependencies: ['converse-chatboxviews', 'converse-chat', 'converse-disco', 'converse-modal'],
  42708. initialize() {
  42709. /* The initialize function gets called as soon as the plugin is
  42710. * loaded by converse.js's plugin machinery.
  42711. */
  42712. core_api.settings.extend({
  42713. 'allowed_audio_domains': null,
  42714. 'allowed_image_domains': null,
  42715. 'allowed_video_domains': null,
  42716. 'auto_focus': true,
  42717. 'debounced_content_rendering': true,
  42718. 'filter_url_query_params': null,
  42719. 'image_urls_regex': null,
  42720. 'message_limit': 0,
  42721. 'muc_hats': ['xep317'],
  42722. 'render_media': true,
  42723. 'show_message_avatar': true,
  42724. 'show_retraction_warning': true,
  42725. 'show_send_button': true,
  42726. 'show_toolbar': true,
  42727. 'time_format': 'HH:mm',
  42728. 'use_system_emojis': true,
  42729. 'visible_toolbar_buttons': {
  42730. 'call': false,
  42731. 'clear': true,
  42732. 'emoji': true,
  42733. 'spoiler': true
  42734. }
  42735. });
  42736. shared_converse.ChatBoxView = ChatView;
  42737. core_api.listen.on('connected', () => core_api.disco.own.features.add(chatview_Strophe.NS.SPOILER));
  42738. core_api.listen.on('chatBoxClosed', model => clearHistory(model.get('jid')));
  42739. }
  42740. });
  42741. ;// CONCATENATED MODULE: ./src/shared/components/brand-byline.js
  42742. class ConverseBrandByline extends CustomElement {
  42743. render() {
  42744. // eslint-disable-line class-methods-use-this
  42745. const is_fullscreen = core_api.settings.get('view_mode') === 'fullscreen';
  42746. return $`
  42747. ${is_fullscreen ? $`
  42748. <p class="brand-subtitle">${shared_converse.VERSION_NAME}</p>
  42749. <p class="brand-subtitle">
  42750. <a target="_blank" rel="nofollow" href="https://conversejs.org">Open Source</a> XMPP chat client
  42751. brought to you by <a target="_blank" rel="nofollow" href="https://opkode.com">Opkode</a>
  42752. </p>
  42753. <p class="brand-subtitle">
  42754. <a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages"
  42755. >Translate</a
  42756. >
  42757. it into your own language
  42758. </p>
  42759. ` : ''}
  42760. `;
  42761. }
  42762. }
  42763. core_api.elements.define('converse-brand-byline', ConverseBrandByline);
  42764. ;// CONCATENATED MODULE: ./src/shared/components/brand-logo.js
  42765. class ConverseBrandLogo extends CustomElement {
  42766. render() {
  42767. // eslint-disable-line class-methods-use-this
  42768. const is_fullscreen = core_api.settings.get('view_mode') === 'fullscreen';
  42769. return $`
  42770. <a class="brand-heading" href="https://conversejs.org" target="_blank" rel="noopener">
  42771. <span class="brand-name-wrapper ${is_fullscreen ? 'brand-name-wrapper--fullscreen' : ''}">
  42772. <svg
  42773. class="converse-svg-logo"
  42774. xmlns:svg="http://www.w3.org/2000/svg"
  42775. xmlns="http://www.w3.org/2000/svg"
  42776. xmlns:xlink="http://www.w3.org/1999/xlink"
  42777. viewBox="0 0 364 364">
  42778. <title>Converse</title>
  42779. <g class="cls-1" id="g904">
  42780. <g data-name="Layer 2">
  42781. <g data-name="Layer 7">
  42782. <path
  42783. class="cls-3"
  42784. d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z"
  42785. />
  42786. <path
  42787. class="cls-4"
  42788. d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z"
  42789. />
  42790. </g>
  42791. </g>
  42792. </g>
  42793. </svg>
  42794. <span class="brand-name">
  42795. <span class="brand-name__text">converse<span class="subdued">.js</span></span>
  42796. ${is_fullscreen ? $`
  42797. <p class="byline">messaging freedom</p>
  42798. ` : ''}
  42799. </span>
  42800. </span>
  42801. </a>
  42802. `;
  42803. }
  42804. }
  42805. core_api.elements.define('converse-brand-logo', ConverseBrandLogo);
  42806. ;// CONCATENATED MODULE: ./node_modules/lit/html.js
  42807. //# sourceMappingURL=html.js.map
  42808. ;// CONCATENATED MODULE: ./src/shared/components/brand-heading.js
  42809. class ConverseBrandHeading extends CustomElement {
  42810. render() {
  42811. // eslint-disable-line class-methods-use-this
  42812. return $`
  42813. <converse-brand-logo></converse-brand-logo>
  42814. <converse-brand-byline></converse-brand-byline>
  42815. `;
  42816. }
  42817. }
  42818. core_api.elements.define('converse-brand-heading', ConverseBrandHeading);
  42819. ;// CONCATENATED MODULE: ./src/plugins/controlbox/constants.js
  42820. const {
  42821. Strophe: constants_Strophe
  42822. } = core_converse.env;
  42823. const REPORTABLE_STATUSES = [constants_Strophe.Status.ERROR, constants_Strophe.Status.CONNECTING, constants_Strophe.Status.CONNFAIL, constants_Strophe.Status.AUTHENTICATING, constants_Strophe.Status.AUTHFAIL, constants_Strophe.Status.DISCONNECTING, constants_Strophe.Status.RECONNECTING];
  42824. const PRETTY_CONNECTION_STATUS = Object.fromEntries([[constants_Strophe.Status.ERROR, 'Error'], [constants_Strophe.Status.CONNECTING, 'Connecting'], [constants_Strophe.Status.CONNFAIL, 'Connection failure'], [constants_Strophe.Status.AUTHENTICATING, 'Authenticating'], [constants_Strophe.Status.AUTHFAIL, 'Authentication failure'], [constants_Strophe.Status.CONNECTED, 'Connected'], [constants_Strophe.Status.DISCONNECTED, 'Disconnected'], [constants_Strophe.Status.DISCONNECTING, 'Disconnecting'], [constants_Strophe.Status.ATTACHED, 'Attached'], [constants_Strophe.Status.REDIRECT, 'Redirect'], [constants_Strophe.Status.CONNTIMEOUT, 'Connection timeout'], [constants_Strophe.Status.RECONNECTING, 'Reconnecting']]);
  42825. const CONNECTION_STATUS_CSS_CLASS = Object.fromEntries([[constants_Strophe.Status.ERROR, 'error'], [constants_Strophe.Status.CONNECTING, 'info'], [constants_Strophe.Status.CONNFAIL, 'error'], [constants_Strophe.Status.AUTHENTICATING, 'info'], [constants_Strophe.Status.AUTHFAIL, 'error'], [constants_Strophe.Status.CONNECTED, 'info'], [constants_Strophe.Status.DISCONNECTED, 'error'], [constants_Strophe.Status.DISCONNECTING, 'warn'], [constants_Strophe.Status.ATTACHED, 'info'], [constants_Strophe.Status.REDIRECT, 'info'], [constants_Strophe.Status.RECONNECTING, 'warn']]);
  42826. ;// CONCATENATED MODULE: ./src/plugins/controlbox/templates/loginform.js
  42827. const trust_checkbox = checked => {
  42828. const i18n_hint_trusted = __('To improve performance, we cache your data in this browser. ' + 'Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. ' + 'It\'s important that you explicitly log out, otherwise not all cached data might be deleted. ' + 'Please note, when using an untrusted device, OMEMO encryption is NOT available.');
  42829. const i18n_trusted = __('This is a trusted device');
  42830. return $`
  42831. <div class="form-group form-check login-trusted">
  42832. <input id="converse-login-trusted" type="checkbox" class="form-check-input" name="trusted" ?checked=${checked}>
  42833. <label for="converse-login-trusted" class="form-check-label login-trusted__desc">${i18n_trusted}</label>
  42834. <i class="fa fa-info-circle" data-toggle="popover"
  42835. data-title="Trusted device?"
  42836. data-content="${i18n_hint_trusted}"></i>
  42837. </div>
  42838. `;
  42839. };
  42840. const connection_url_input = () => {
  42841. const i18n_connection_url = __('Connection URL');
  42842. const i18n_form_help = __('HTTP or websocket URL that is used to connect to your XMPP server');
  42843. const i18n_placeholder = __('e.g. wss://example.org/xmpp-websocket');
  42844. return $`
  42845. <div class="form-group fade-in">
  42846. <label for="converse-conn-url">${i18n_connection_url}</label>
  42847. <p class="form-help instructions">${i18n_form_help}</p>
  42848. <input id="converse-conn-url"
  42849. class="form-control"
  42850. type="url"
  42851. name="connection-url"
  42852. placeholder="${i18n_placeholder}"/>
  42853. </div>
  42854. `;
  42855. };
  42856. const password_input = () => {
  42857. const i18n_password = __('Password');
  42858. return $`
  42859. <div class="form-group">
  42860. <label for="converse-login-password">${i18n_password}</label>
  42861. <input id="converse-login-password"
  42862. class="form-control"
  42863. required="required"
  42864. value="${core_api.settings.get('password') ?? ''}"
  42865. type="password"
  42866. name="password"
  42867. placeholder="${i18n_password}"/>
  42868. </div>
  42869. `;
  42870. };
  42871. const register_link = () => {
  42872. const i18n_create_account = __("Create an account");
  42873. const i18n_hint_no_account = __("Don't have a chat account?");
  42874. return $`
  42875. <fieldset class="switch-form">
  42876. <p>${i18n_hint_no_account}</p>
  42877. <p><a class="register-account toggle-register-login" href="#converse/register">${i18n_create_account}</a></p>
  42878. </fieldset>
  42879. `;
  42880. };
  42881. const show_register_link = () => {
  42882. return core_api.settings.get('allow_registration') && !core_api.settings.get("auto_login") && shared_converse.pluggable.plugins["converse-register"].enabled(shared_converse);
  42883. };
  42884. const auth_fields = el => {
  42885. const authentication = core_api.settings.get('authentication');
  42886. const i18n_login = __('Log in');
  42887. const i18n_xmpp_address = __("XMPP Address");
  42888. const locked_domain = core_api.settings.get('locked_domain');
  42889. const default_domain = core_api.settings.get('default_domain');
  42890. const placeholder_username = (locked_domain || default_domain) && __('Username') || __('user@domain');
  42891. const show_trust_checkbox = core_api.settings.get('allow_user_trust_override');
  42892. return $`
  42893. <div class="form-group">
  42894. <label for="converse-login-jid">${i18n_xmpp_address}:</label>
  42895. <input id="converse-login-jid"
  42896. ?autofocus=${core_api.settings.get('auto_focus') ? true : false}
  42897. @changed=${el.validate}
  42898. value="${core_api.settings.get('jid') ?? ''}"
  42899. required
  42900. class="form-control"
  42901. type="text"
  42902. name="jid"
  42903. placeholder="${placeholder_username}"/>
  42904. </div>
  42905. ${authentication !== shared_converse.EXTERNAL ? password_input() : ''}
  42906. ${core_api.settings.get('show_connection_url_input') ? connection_url_input() : ''}
  42907. ${show_trust_checkbox ? trust_checkbox(show_trust_checkbox === 'off' ? false : true) : ''}
  42908. <fieldset class="form-group buttons">
  42909. <input class="btn btn-primary" type="submit" value="${i18n_login}"/>
  42910. </fieldset>
  42911. ${show_register_link() ? register_link() : ''}
  42912. `;
  42913. };
  42914. const form_fields = el => {
  42915. const authentication = core_api.settings.get('authentication');
  42916. const {
  42917. ANONYMOUS,
  42918. EXTERNAL,
  42919. LOGIN,
  42920. PREBIND
  42921. } = shared_converse;
  42922. const i18n_disconnected = __('Disconnected');
  42923. const i18n_anon_login = __('Click here to log in anonymously');
  42924. return $`
  42925. ${authentication == LOGIN || authentication == EXTERNAL ? auth_fields(el) : ''}
  42926. ${authentication == ANONYMOUS ? $`<input class="btn btn-primary login-anon" type="submit" value="${i18n_anon_login}">` : ''}
  42927. ${authentication == PREBIND ? $`<p>${i18n_disconnected}</p>` : ''}
  42928. `;
  42929. };
  42930. /* harmony default export */ const loginform = (el => {
  42931. const connection_status = shared_converse.connfeedback.get('connection_status');
  42932. let feedback_class, pretty_status;
  42933. if (REPORTABLE_STATUSES.includes(connection_status)) {
  42934. pretty_status = PRETTY_CONNECTION_STATUS[connection_status];
  42935. feedback_class = CONNECTION_STATUS_CSS_CLASS[connection_status];
  42936. }
  42937. const conn_feedback_message = shared_converse.connfeedback.get('message');
  42938. return $`
  42939. <converse-brand-heading></converse-brand-heading>
  42940. <form id="converse-login" class="converse-form" method="post" @submit=${el.onLoginFormSubmitted}>
  42941. <div class="conn-feedback fade-in ${!pretty_status ? 'hidden' : feedback_class}">
  42942. <p class="feedback-subject">${pretty_status}</p>
  42943. <p class="feedback-message ${!conn_feedback_message ? 'hidden' : ''}">${conn_feedback_message}</p>
  42944. </div>
  42945. ${shared_converse.CONNECTION_STATUS[connection_status] === 'CONNECTING' ? spinner({
  42946. 'classes': 'hor_centered'
  42947. }) : form_fields(el)}
  42948. </form>`;
  42949. });
  42950. ;// CONCATENATED MODULE: ./src/plugins/controlbox/utils.js
  42951. const {
  42952. Strophe: controlbox_utils_Strophe,
  42953. u: controlbox_utils_u
  42954. } = core_converse.env;
  42955. function addControlBox() {
  42956. var _converse$chatboxview;
  42957. const m = shared_converse.chatboxes.add(new shared_converse.ControlBox({
  42958. 'id': 'controlbox'
  42959. }));
  42960. (_converse$chatboxview = shared_converse.chatboxviews.get('controlbox')) === null || _converse$chatboxview === void 0 ? void 0 : _converse$chatboxview.setModel();
  42961. return m;
  42962. }
  42963. function showControlBox(ev) {
  42964. var _ev$preventDefault;
  42965. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  42966. const controlbox = shared_converse.chatboxes.get('controlbox') || addControlBox();
  42967. controlbox_utils_u.safeSave(controlbox, {
  42968. 'closed': false
  42969. });
  42970. }
  42971. function navigateToControlBox(jid) {
  42972. showControlBox();
  42973. const model = shared_converse.chatboxes.get(jid);
  42974. controlbox_utils_u.safeSave(model, {
  42975. 'hidden': true
  42976. });
  42977. }
  42978. function disconnect() {
  42979. /* Upon disconnection, set connected to `false`, so that if
  42980. * we reconnect, "onConnected" will be called,
  42981. * to fetch the roster again and to send out a presence stanza.
  42982. */
  42983. const view = shared_converse.chatboxviews.get('controlbox');
  42984. view.model.set({
  42985. 'connected': false
  42986. });
  42987. return view;
  42988. }
  42989. function controlbox_utils_clearSession() {
  42990. const chatboxviews = shared_converse === null || shared_converse === void 0 ? void 0 : shared_converse.chatboxviews;
  42991. const view = chatboxviews && chatboxviews.get('controlbox');
  42992. if (view) {
  42993. controlbox_utils_u.safeSave(view.model, {
  42994. 'connected': false
  42995. });
  42996. if (view !== null && view !== void 0 && view.controlbox_pane) {
  42997. view.controlbox_pane.remove();
  42998. delete view.controlbox_pane;
  42999. }
  43000. }
  43001. }
  43002. function onChatBoxesFetched() {
  43003. const controlbox = shared_converse.chatboxes.get('controlbox') || addControlBox();
  43004. controlbox.save({
  43005. 'connected': true
  43006. });
  43007. }
  43008. /**
  43009. * Given the login `<form>` element, parse its data and update the
  43010. * converse settings with the supplied JID, password and connection URL.
  43011. * @param { HTMLElement } form
  43012. * @param { Object } settings - Extra settings that may be passed in and will
  43013. * also be set together with the form settings.
  43014. */
  43015. function updateSettingsWithFormData(form) {
  43016. let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  43017. const form_data = new FormData(form);
  43018. const connection_url = form_data.get('connection-url');
  43019. if (connection_url !== null && connection_url !== void 0 && connection_url.startsWith('ws')) {
  43020. settings['websocket_url'] = connection_url;
  43021. } else if (connection_url !== null && connection_url !== void 0 && connection_url.startsWith('http')) {
  43022. settings['bosh_service_url'] = connection_url;
  43023. }
  43024. let jid = form_data.get('jid');
  43025. if (core_api.settings.get('locked_domain')) {
  43026. const last_part = '@' + core_api.settings.get('locked_domain');
  43027. if (jid.endsWith(last_part)) {
  43028. jid = jid.substr(0, jid.length - last_part.length);
  43029. }
  43030. jid = controlbox_utils_Strophe.escapeNode(jid) + last_part;
  43031. } else if (core_api.settings.get('default_domain') && !jid.includes('@')) {
  43032. jid = jid + '@' + core_api.settings.get('default_domain');
  43033. }
  43034. settings['jid'] = jid;
  43035. settings['password'] = form_data.get('password');
  43036. core_api.settings.set(settings);
  43037. shared_converse.config.save({
  43038. 'trusted': form_data.get('trusted') && true || false
  43039. });
  43040. }
  43041. function validateJID(form) {
  43042. const jid_element = form.querySelector('input[name=jid]');
  43043. if (jid_element.value && !core_api.settings.get('locked_domain') && !core_api.settings.get('default_domain') && !controlbox_utils_u.isValidJID(jid_element.value)) {
  43044. jid_element.setCustomValidity(__('Please enter a valid XMPP address'));
  43045. return false;
  43046. }
  43047. jid_element.setCustomValidity('');
  43048. return true;
  43049. }
  43050. ;// CONCATENATED MODULE: ./src/plugins/controlbox/loginform.js
  43051. const {
  43052. Strophe: loginform_Strophe,
  43053. u: loginform_u
  43054. } = core_converse.env;
  43055. class LoginForm extends CustomElement {
  43056. initialize() {
  43057. this.listenTo(shared_converse.connfeedback, 'change', () => this.requestUpdate());
  43058. this.handler = () => this.requestUpdate();
  43059. }
  43060. connectedCallback() {
  43061. super.connectedCallback();
  43062. core_api.settings.listen.on('change', this.handler);
  43063. }
  43064. disconnectedCallback() {
  43065. super.disconnectedCallback();
  43066. core_api.settings.listen.not('change', this.handler);
  43067. }
  43068. render() {
  43069. return loginform(this);
  43070. }
  43071. firstUpdated() {
  43072. this.initPopovers();
  43073. }
  43074. async onLoginFormSubmitted(ev) {
  43075. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  43076. if (core_api.settings.get('authentication') === shared_converse.ANONYMOUS) {
  43077. return this.connect(shared_converse.jid);
  43078. }
  43079. if (!validateJID(ev.target)) {
  43080. return;
  43081. }
  43082. updateSettingsWithFormData(ev.target);
  43083. if (!core_api.settings.get('bosh_service_url') && !core_api.settings.get('websocket_url')) {
  43084. // We don't have a connection URL available, so we try here to discover
  43085. // XEP-0156 connection methods now, and if not found we present the user
  43086. // with the option to enter their own connection URL
  43087. await this.discoverConnectionMethods(ev);
  43088. }
  43089. if (core_api.settings.get('bosh_service_url') || core_api.settings.get('websocket_url')) {
  43090. // FIXME: The connection class will still try to discover XEP-0156 connection methods
  43091. this.connect();
  43092. } else {
  43093. core_api.settings.set('show_connection_url_input', true);
  43094. }
  43095. } // eslint-disable-next-line class-methods-use-this
  43096. async discoverConnectionMethods(ev) {
  43097. var _converse$connection;
  43098. if (!core_api.settings.get("discover_connection_methods")) {
  43099. return;
  43100. }
  43101. const form_data = new FormData(ev.target);
  43102. const jid = form_data.get('jid');
  43103. const domain = loginform_Strophe.getDomainFromJid(jid);
  43104. if (!((_converse$connection = shared_converse.connection) !== null && _converse$connection !== void 0 && _converse$connection.jid) || jid && !loginform_u.isSameDomain(shared_converse.connection.jid, jid)) {
  43105. await shared_converse.initConnection();
  43106. }
  43107. return shared_converse.connection.discoverConnectionMethods(domain);
  43108. }
  43109. initPopovers() {
  43110. Array.from(this.querySelectorAll('[data-title]')).forEach(el => {
  43111. new (bootstrap_native_default()).Popover(el, {
  43112. 'trigger': core_api.settings.get('view_mode') === 'mobile' && 'click' || 'hover',
  43113. 'dismissible': core_api.settings.get('view_mode') === 'mobile' && true || false,
  43114. 'container': this.parentElement.parentElement.parentElement
  43115. });
  43116. });
  43117. } // eslint-disable-next-line class-methods-use-this
  43118. connect(jid) {
  43119. var _converse$connection2;
  43120. if (['converse/login', 'converse/register'].includes(shared_converse.router.history.getFragment())) {
  43121. shared_converse.router.navigate('', {
  43122. 'replace': true
  43123. });
  43124. }
  43125. (_converse$connection2 = shared_converse.connection) === null || _converse$connection2 === void 0 ? void 0 : _converse$connection2.reset();
  43126. core_api.user.login(jid);
  43127. }
  43128. }
  43129. core_api.elements.define('converse-login-form', LoginForm);
  43130. ;// CONCATENATED MODULE: ./src/plugins/controlbox/templates/navback.js
  43131. /* harmony default export */ const navback = (jid => {
  43132. return $`<converse-icon size="1em" class="fa fa-arrow-left" @click=${() => navigateToControlBox(jid)}></converse-icon>`;
  43133. });
  43134. ;// CONCATENATED MODULE: ./src/plugins/controlbox/navback.js
  43135. class ControlBoxNavback extends CustomElement {
  43136. static get properties() {
  43137. return {
  43138. 'jid': {
  43139. type: String
  43140. }
  43141. };
  43142. }
  43143. render() {
  43144. return navback(this.jid);
  43145. }
  43146. }
  43147. core_api.elements.define('converse-controlbox-navback', ControlBoxNavback);
  43148. /* harmony default export */ const controlbox_navback = ((/* unused pure expression or super */ null && (ControlBoxNavback)));
  43149. ;// CONCATENATED MODULE: ./src/plugins/controlbox/model.js
  43150. const {
  43151. dayjs: model_dayjs
  43152. } = core_converse.env;
  43153. /**
  43154. * The ControlBox is the section of the chat that contains the open groupchats,
  43155. * bookmarks and roster.
  43156. *
  43157. * In `overlayed` `view_mode` it's a box like the chat boxes, in `fullscreen`
  43158. * `view_mode` it's a left-aligned sidebar.
  43159. * @mixin
  43160. */
  43161. const ControlBox = Model.extend({
  43162. defaults() {
  43163. return {
  43164. 'bookmarked': false,
  43165. 'box_id': 'controlbox',
  43166. 'chat_state': undefined,
  43167. 'closed': !core_api.settings.get('show_controlbox_by_default'),
  43168. 'num_unread': 0,
  43169. 'time_opened': model_dayjs(0).valueOf(),
  43170. 'type': shared_converse.CONTROLBOX_TYPE,
  43171. 'url': ''
  43172. };
  43173. },
  43174. validate(attrs) {
  43175. if (attrs.type === shared_converse.CONTROLBOX_TYPE) {
  43176. if (core_api.settings.get('view_mode') === 'embedded' && core_api.settings.get('singleton')) {
  43177. return 'Controlbox not relevant in embedded view mode';
  43178. }
  43179. return;
  43180. }
  43181. return shared_converse.ChatBox.prototype.validate.call(this, attrs);
  43182. },
  43183. maybeShow(force) {
  43184. if (!force && this.get('id') === 'controlbox') {
  43185. // Must return the chatbox
  43186. return this;
  43187. }
  43188. return shared_converse.ChatBox.prototype.maybeShow.call(this, force);
  43189. },
  43190. onReconnection() {
  43191. this.save('connected', true);
  43192. }
  43193. });
  43194. /* harmony default export */ const controlbox_model = (ControlBox);
  43195. ;// CONCATENATED MODULE: ./src/plugins/controlbox/templates/toggle.js
  43196. /* harmony default export */ const toggle = (o => {
  43197. const i18n_toggle = core_api.connection.connected() ? __('Chat Contacts') : __('Toggle chat');
  43198. return $`<a id="toggle-controlbox" class="toggle-controlbox ${o.hide ? 'hidden' : ''}" @click=${o.onClick}><span class="toggle-feedback">${i18n_toggle}</span></a>`;
  43199. });
  43200. ;// CONCATENATED MODULE: ./src/plugins/controlbox/toggle.js
  43201. class ControlBoxToggle extends CustomElement {
  43202. async connectedCallback() {
  43203. super.connectedCallback();
  43204. await core_api.waitUntil('initialized');
  43205. this.model = shared_converse.chatboxes.get('controlbox');
  43206. this.listenTo(this.model, 'change:closed', () => this.requestUpdate());
  43207. this.requestUpdate();
  43208. }
  43209. render() {
  43210. var _this$model;
  43211. return toggle({
  43212. 'onClick': showControlBox,
  43213. 'hide': !((_this$model = this.model) !== null && _this$model !== void 0 && _this$model.get('closed'))
  43214. });
  43215. }
  43216. }
  43217. core_api.elements.define('converse-controlbox-toggle', ControlBoxToggle);
  43218. /* harmony default export */ const controlbox_toggle = (ControlBoxToggle);
  43219. ;// CONCATENATED MODULE: ./src/plugins/controlbox/templates/controlbox.js
  43220. const {
  43221. Strophe: controlbox_Strophe
  43222. } = core_converse.env;
  43223. function whenNotConnected(o) {
  43224. const connection_status = shared_converse.connfeedback.get('connection_status');
  43225. console.log("connection_status");
  43226. console.log(connection_status);
  43227. if ([controlbox_Strophe.Status.RECONNECTING, controlbox_Strophe.Status.CONNECTING].includes(connection_status)) {
  43228. return spinner();
  43229. }
  43230. if (o['active-form'] === 'register') {
  43231. return $`<converse-register-panel></converse-register-panel>`;
  43232. }
  43233. return $`<converse-login-form id="converse-login-panel" class="controlbox-pane fade-in row no-gutters"></converse-login-form>`;
  43234. }
  43235. /* harmony default export */ const controlbox = (el => {
  43236. const o = el.model.toJSON();
  43237. const sticky_controlbox = core_api.settings.get('sticky_controlbox');
  43238. return $`
  43239. <div class="flyout box-flyout">
  43240. <converse-dragresize></converse-dragresize>
  43241. <div class="chat-head controlbox-head">
  43242. ${sticky_controlbox ? '' : $`
  43243. <a class="chatbox-btn close-chatbox-button fa fa-times" @click=${ev => el.close(ev)}></a>
  43244. `}
  43245. </div>
  43246. <div class="controlbox-panes">
  43247. <div class="controlbox-pane">
  43248. ${o.connected ? $`
  43249. <converse-user-profile></converse-user-profile>
  43250. <converse-headlines-panel class="controlbox-section"></converse-headlines-panel>
  43251. <div id="chatrooms" class="controlbox-section">
  43252. <converse-rooms-list></converse-rooms-list>
  43253. <converse-bookmarks></converse-bookmarks>
  43254. </div>
  43255. ${core_api.settings.get("authentication") === shared_converse.ANONYMOUS ? '' : $`<div id="converse-roster" class="controlbox-section"><converse-roster></converse-roster></div>`}` : whenNotConnected(o)}
  43256. </div>
  43257. </div>
  43258. </div>`;
  43259. });
  43260. ;// CONCATENATED MODULE: ./src/plugins/controlbox/controlbox.js
  43261. const controlbox_u = core_converse.env.utils;
  43262. /**
  43263. * The ControlBox is the section of the chat that contains the open groupchats,
  43264. * bookmarks and roster.
  43265. *
  43266. * In `overlayed` `view_mode` it's a box like the chat boxes, in `fullscreen`
  43267. * `view_mode` it's a left-aligned sidebar.
  43268. */
  43269. class controlbox_ControlBox extends CustomElement {
  43270. initialize() {
  43271. this.setModel();
  43272. shared_converse.chatboxviews.add('controlbox', this);
  43273. if (this.model.get('connected') && this.model.get('closed') === undefined) {
  43274. this.model.set('closed', !core_api.settings.get('show_controlbox_by_default'));
  43275. }
  43276. this.requestUpdate();
  43277. /**
  43278. * Triggered when the _converse.ControlBoxView has been initialized and therefore
  43279. * exists. The controlbox contains the login and register forms when the user is
  43280. * logged out and a list of the user's contacts and group chats when logged in.
  43281. * @event _converse#controlBoxInitialized
  43282. * @type { _converse.ControlBoxView }
  43283. * @example _converse.api.listen.on('controlBoxInitialized', view => { ... });
  43284. */
  43285. core_api.trigger('controlBoxInitialized', this);
  43286. }
  43287. setModel() {
  43288. this.model = shared_converse.chatboxes.get('controlbox');
  43289. this.listenTo(shared_converse.connfeedback, 'change:connection_status', () => this.requestUpdate());
  43290. this.listenTo(this.model, 'change:active-form', () => this.requestUpdate());
  43291. this.listenTo(this.model, 'change:connected', () => this.requestUpdate());
  43292. this.listenTo(this.model, 'change:closed', () => !this.model.get('closed') && this.afterShown());
  43293. this.requestUpdate();
  43294. }
  43295. render() {
  43296. return this.model ? controlbox(this) : '';
  43297. }
  43298. close(ev) {
  43299. var _ev$preventDefault;
  43300. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  43301. if ((ev === null || ev === void 0 ? void 0 : ev.name) === 'closeAllChatBoxes' && (shared_converse.disconnection_cause !== shared_converse.LOGOUT || core_api.settings.get('show_controlbox_by_default'))) {
  43302. return;
  43303. }
  43304. if (core_api.settings.get('sticky_controlbox')) {
  43305. return;
  43306. }
  43307. controlbox_u.safeSave(this.model, {
  43308. 'closed': true
  43309. });
  43310. core_api.trigger('controlBoxClosed', this);
  43311. return this;
  43312. }
  43313. afterShown() {
  43314. /**
  43315. * Triggered once the controlbox has been opened
  43316. * @event _converse#controlBoxOpened
  43317. * @type {_converse.ControlBox}
  43318. */
  43319. core_api.trigger('controlBoxOpened', this);
  43320. return this;
  43321. }
  43322. }
  43323. core_api.elements.define('converse-controlbox', controlbox_ControlBox);
  43324. /* harmony default export */ const controlbox_controlbox = (controlbox_ControlBox);
  43325. ;// CONCATENATED MODULE: ./src/plugins/controlbox/api.js
  43326. const {
  43327. u: controlbox_api_u
  43328. } = core_converse.env;
  43329. /* harmony default export */ const controlbox_api = ({
  43330. /**
  43331. * The "controlbox" namespace groups methods pertaining to the
  43332. * controlbox view
  43333. *
  43334. * @namespace _converse.api.controlbox
  43335. * @memberOf _converse.api
  43336. */
  43337. controlbox: {
  43338. /**
  43339. * Opens the controlbox
  43340. * @method _converse.api.controlbox.open
  43341. * @returns { Promise<_converse.ControlBox> }
  43342. */
  43343. async open() {
  43344. await core_api.waitUntil('chatBoxesFetched');
  43345. const model = (await core_api.chatboxes.get('controlbox')) || core_api.chatboxes.create('controlbox', {}, shared_converse.Controlbox);
  43346. controlbox_api_u.safeSave(model, {
  43347. 'closed': false
  43348. });
  43349. return model;
  43350. },
  43351. /**
  43352. * Returns the controlbox view.
  43353. * @method _converse.api.controlbox.get
  43354. * @returns { View } View representing the controlbox
  43355. * @example const view = _converse.api.controlbox.get();
  43356. */
  43357. get() {
  43358. return shared_converse.chatboxviews.get('controlbox');
  43359. }
  43360. }
  43361. });
  43362. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/controlbox/styles/_controlbox.scss
  43363. var _controlbox = __webpack_require__(1875);
  43364. ;// CONCATENATED MODULE: ./src/plugins/controlbox/styles/_controlbox.scss
  43365. var _controlbox_options = {};
  43366. _controlbox_options.styleTagTransform = (styleTagTransform_default());
  43367. _controlbox_options.setAttributes = (setAttributesWithoutAttributes_default());
  43368. _controlbox_options.insert = insertBySelector_default().bind(null, "head");
  43369. _controlbox_options.domAPI = (styleDomAPI_default());
  43370. _controlbox_options.insertStyleElement = (insertStyleElement_default());
  43371. var _controlbox_update = injectStylesIntoStyleTag_default()(_controlbox/* default */.Z, _controlbox_options);
  43372. /* harmony default export */ const styles_controlbox = (_controlbox/* default */.Z && _controlbox/* default.locals */.Z.locals ? _controlbox/* default.locals */.Z.locals : undefined);
  43373. ;// CONCATENATED MODULE: ./src/plugins/controlbox/index.js
  43374. /**
  43375. * @copyright 2022, the Converse.js contributors
  43376. * @license Mozilla Public License (MPLv2)
  43377. */
  43378. core_converse.plugins.add('converse-controlbox', {
  43379. /* Plugin dependencies are other plugins which might be
  43380. * overridden or relied upon, and therefore need to be loaded before
  43381. * this plugin.
  43382. *
  43383. * If the setting "strict_plugin_dependencies" is set to true,
  43384. * an error will be raised if the plugin is not found. By default it's
  43385. * false, which means these plugins are only loaded opportunistically.
  43386. *
  43387. * NB: These plugins need to have already been loaded via require.js.
  43388. */
  43389. dependencies: ['converse-modal', 'converse-chatboxes', 'converse-chat', 'converse-rosterview', 'converse-chatview'],
  43390. enabled(_converse) {
  43391. return !_converse.api.settings.get('singleton');
  43392. },
  43393. overrides: {
  43394. // Overrides mentioned here will be picked up by converse.js's
  43395. // plugin architecture they will replace existing methods on the
  43396. // relevant objects or classes.
  43397. //
  43398. // New functions which don't exist yet can also be added.
  43399. ChatBoxes: {
  43400. model(attrs, options) {
  43401. if (attrs && attrs.id == 'controlbox') {
  43402. return new controlbox_model(attrs, options);
  43403. } else {
  43404. return this.__super__.model.apply(this, arguments);
  43405. }
  43406. }
  43407. }
  43408. },
  43409. initialize() {
  43410. core_api.settings.extend({
  43411. allow_logout: true,
  43412. allow_user_trust_override: true,
  43413. default_domain: undefined,
  43414. locked_domain: undefined,
  43415. show_connection_url_input: false,
  43416. show_controlbox_by_default: false,
  43417. sticky_controlbox: false
  43418. });
  43419. core_api.promises.add('controlBoxInitialized');
  43420. Object.assign(core_api, controlbox_api);
  43421. shared_converse.ControlBoxView = controlbox_controlbox;
  43422. shared_converse.ControlBox = controlbox_model;
  43423. shared_converse.ControlBoxToggle = controlbox_toggle;
  43424. core_api.listen.on('chatBoxesFetched', onChatBoxesFetched);
  43425. core_api.listen.on('clearSession', controlbox_utils_clearSession);
  43426. core_api.listen.on('will-reconnect', disconnect);
  43427. core_api.waitUntil('chatBoxViewsInitialized').then(addControlBox).catch(e => headless_log.fatal(e));
  43428. }
  43429. });
  43430. ;// CONCATENATED MODULE: ./src/plugins/dragresize/utils.js
  43431. const {
  43432. u: dragresize_utils_u
  43433. } = core_converse.env;
  43434. function onStartVerticalResize(ev) {
  43435. let trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  43436. if (!core_api.settings.get('allow_dragresize')) {
  43437. return true;
  43438. }
  43439. ev.preventDefault(); // Record element attributes for mouseMove().
  43440. const flyout = dragresize_utils_u.ancestor(ev.target, '.box-flyout');
  43441. const style = window.getComputedStyle(flyout);
  43442. const chatbox_el = flyout.parentElement;
  43443. chatbox_el.height = parseInt(style.height.replace(/px$/, ''), 10);
  43444. shared_converse.resizing = {
  43445. 'chatbox': chatbox_el,
  43446. 'direction': 'top'
  43447. };
  43448. chatbox_el.prev_pageY = ev.pageY;
  43449. if (trigger) {
  43450. /**
  43451. * Triggered once the user starts to vertically resize a {@link _converse.ChatBoxView}
  43452. * @event _converse#startVerticalResize
  43453. * @example _converse.api.listen.on('startVerticalResize', (view) => { ... });
  43454. */
  43455. core_api.trigger('startVerticalResize', chatbox_el);
  43456. }
  43457. }
  43458. function onStartHorizontalResize(ev) {
  43459. let trigger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  43460. if (!core_api.settings.get('allow_dragresize')) {
  43461. return true;
  43462. }
  43463. ev.preventDefault();
  43464. const flyout = dragresize_utils_u.ancestor(ev.target, '.box-flyout');
  43465. const style = window.getComputedStyle(flyout);
  43466. const chatbox_el = flyout.parentElement;
  43467. chatbox_el.width = parseInt(style.width.replace(/px$/, ''), 10);
  43468. shared_converse.resizing = {
  43469. 'chatbox': chatbox_el,
  43470. 'direction': 'left'
  43471. };
  43472. chatbox_el.prev_pageX = ev.pageX;
  43473. if (trigger) {
  43474. /**
  43475. * Triggered once the user starts to horizontally resize a {@link _converse.ChatBoxView}
  43476. * @event _converse#startHorizontalResize
  43477. * @example _converse.api.listen.on('startHorizontalResize', (view) => { ... });
  43478. */
  43479. core_api.trigger('startHorizontalResize', chatbox_el);
  43480. }
  43481. }
  43482. function onStartDiagonalResize(ev) {
  43483. onStartHorizontalResize(ev, false);
  43484. onStartVerticalResize(ev, false);
  43485. shared_converse.resizing.direction = 'topleft';
  43486. /**
  43487. * Triggered once the user starts to diagonally resize a {@link _converse.ChatBoxView}
  43488. * @event _converse#startDiagonalResize
  43489. * @example _converse.api.listen.on('startDiagonalResize', (view) => { ... });
  43490. */
  43491. core_api.trigger('startDiagonalResize', this);
  43492. }
  43493. /**
  43494. * Applies some resistance to `value` around the `default_value`.
  43495. * If value is close enough to `default_value`, then it is returned, otherwise
  43496. * `value` is returned.
  43497. * @param { Integer } value
  43498. * @param { Integer } default_value
  43499. * @returns { Integer }
  43500. */
  43501. function applyDragResistance(value, default_value) {
  43502. if (value === undefined) {
  43503. return undefined;
  43504. } else if (default_value === undefined) {
  43505. return value;
  43506. }
  43507. const resistance = 10;
  43508. if (value !== default_value && Math.abs(value - default_value) < resistance) {
  43509. return default_value;
  43510. }
  43511. return value;
  43512. }
  43513. function onMouseMove(ev) {
  43514. if (!shared_converse.resizing || !core_api.settings.get('allow_dragresize')) {
  43515. return true;
  43516. }
  43517. ev.preventDefault();
  43518. shared_converse.resizing.chatbox.resizeChatBox(ev);
  43519. }
  43520. function onMouseUp(ev) {
  43521. if (!shared_converse.resizing || !core_api.settings.get('allow_dragresize')) {
  43522. return true;
  43523. }
  43524. ev.preventDefault();
  43525. const height = applyDragResistance(shared_converse.resizing.chatbox.height, shared_converse.resizing.chatbox.model.get('default_height'));
  43526. const width = applyDragResistance(shared_converse.resizing.chatbox.width, shared_converse.resizing.chatbox.model.get('default_width'));
  43527. if (core_api.connection.connected()) {
  43528. shared_converse.resizing.chatbox.model.save({
  43529. 'height': height
  43530. });
  43531. shared_converse.resizing.chatbox.model.save({
  43532. 'width': width
  43533. });
  43534. } else {
  43535. shared_converse.resizing.chatbox.model.set({
  43536. 'height': height
  43537. });
  43538. shared_converse.resizing.chatbox.model.set({
  43539. 'width': width
  43540. });
  43541. }
  43542. shared_converse.resizing = null;
  43543. }
  43544. ;// CONCATENATED MODULE: ./src/plugins/dragresize/templates/dragresize.js
  43545. /* harmony default export */ const dragresize = (() => $`
  43546. <div class="dragresize dragresize-top" @mousedown="${onStartVerticalResize}"></div>
  43547. <div class="dragresize dragresize-topleft" @mousedown="${onStartDiagonalResize}"></div>
  43548. <div class="dragresize dragresize-left" @mousedown="${onStartHorizontalResize}"></div>
  43549. `);
  43550. ;// CONCATENATED MODULE: ./src/plugins/dragresize/components/dragresize.js
  43551. class ConverseDragResize extends CustomElement {
  43552. render() {
  43553. // eslint-disable-line class-methods-use-this
  43554. return dragresize();
  43555. }
  43556. }
  43557. customElements.define('converse-dragresize', ConverseDragResize);
  43558. ;// CONCATENATED MODULE: ./src/plugins/dragresize/mixin.js
  43559. const DragResizableMixin = {
  43560. initDragResize() {
  43561. var _converse$connection;
  43562. const view = this;
  43563. const debouncedSetDimensions = lodash_es_debounce(() => view.setDimensions());
  43564. window.addEventListener('resize', view.debouncedSetDimensions);
  43565. this.listenTo(this.model, 'destroy', () => window.removeEventListener('resize', debouncedSetDimensions)); // Determine and store the default box size.
  43566. // We need this information for the drag-resizing feature.
  43567. const flyout = this.querySelector('.box-flyout');
  43568. const style = window.getComputedStyle(flyout);
  43569. if (this.model.get('height') === undefined) {
  43570. const height = parseInt(style.height.replace(/px$/, ''), 10);
  43571. const width = parseInt(style.width.replace(/px$/, ''), 10);
  43572. this.model.set('height', height);
  43573. this.model.set('default_height', height);
  43574. this.model.set('width', width);
  43575. this.model.set('default_width', width);
  43576. }
  43577. const min_width = style['min-width'];
  43578. const min_height = style['min-height'];
  43579. this.model.set('min_width', min_width.endsWith('px') ? Number(min_width.replace(/px$/, '')) : 0);
  43580. this.model.set('min_height', min_height.endsWith('px') ? Number(min_height.replace(/px$/, '')) : 0); // Initialize last known mouse position
  43581. this.prev_pageY = 0;
  43582. this.prev_pageX = 0;
  43583. if ((_converse$connection = shared_converse.connection) !== null && _converse$connection !== void 0 && _converse$connection.connected) {
  43584. this.height = this.model.get('height');
  43585. this.width = this.model.get('width');
  43586. }
  43587. return this;
  43588. },
  43589. resizeChatBox(ev) {
  43590. let diff;
  43591. if (shared_converse.resizing.direction.indexOf('top') === 0) {
  43592. diff = ev.pageY - this.prev_pageY;
  43593. if (diff) {
  43594. this.height = this.height - diff > (this.model.get('min_height') || 0) ? this.height - diff : this.model.get('min_height');
  43595. this.prev_pageY = ev.pageY;
  43596. this.setChatBoxHeight(this.height);
  43597. }
  43598. }
  43599. if (shared_converse.resizing.direction.includes('left')) {
  43600. diff = this.prev_pageX - ev.pageX;
  43601. if (diff) {
  43602. this.width = this.width + diff > (this.model.get('min_width') || 0) ? this.width + diff : this.model.get('min_width');
  43603. this.prev_pageX = ev.pageX;
  43604. this.setChatBoxWidth(this.width);
  43605. }
  43606. }
  43607. },
  43608. setDimensions() {
  43609. // Make sure the chat box has the right height and width.
  43610. this.adjustToViewport();
  43611. this.setChatBoxHeight(this.model.get('height'));
  43612. this.setChatBoxWidth(this.model.get('width'));
  43613. },
  43614. setChatBoxHeight(height) {
  43615. if (height) {
  43616. height = applyDragResistance(height, this.model.get('default_height')) + 'px';
  43617. } else {
  43618. height = '';
  43619. }
  43620. const flyout_el = this.querySelector('.box-flyout');
  43621. if (flyout_el !== null) {
  43622. flyout_el.style.height = height;
  43623. }
  43624. },
  43625. setChatBoxWidth(width) {
  43626. if (width) {
  43627. width = applyDragResistance(width, this.model.get('default_width')) + 'px';
  43628. } else {
  43629. width = '';
  43630. }
  43631. this.style.width = width;
  43632. const flyout_el = this.querySelector('.box-flyout');
  43633. if (flyout_el !== null) {
  43634. flyout_el.style.width = width;
  43635. }
  43636. },
  43637. adjustToViewport() {
  43638. /* Event handler called when viewport gets resized. We remove
  43639. * custom width/height from chat boxes.
  43640. */
  43641. const viewport_width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  43642. const viewport_height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  43643. if (viewport_width <= 480) {
  43644. this.model.set('height', undefined);
  43645. this.model.set('width', undefined);
  43646. } else if (viewport_width <= this.model.get('width')) {
  43647. this.model.set('width', undefined);
  43648. } else if (viewport_height <= this.model.get('height')) {
  43649. this.model.set('height', undefined);
  43650. }
  43651. }
  43652. };
  43653. /* harmony default export */ const mixin = (DragResizableMixin);
  43654. ;// CONCATENATED MODULE: ./src/plugins/dragresize/index.js
  43655. /**
  43656. * @module converse-dragresize
  43657. * @copyright 2022, the Converse.js contributors
  43658. * @license Mozilla Public License (MPLv2)
  43659. */
  43660. core_converse.plugins.add('converse-dragresize', {
  43661. /* Plugin dependencies are other plugins which might be
  43662. * overridden or relied upon, and therefore need to be loaded before
  43663. * this plugin.
  43664. *
  43665. * If the setting "strict_plugin_dependencies" is set to true,
  43666. * an error will be raised if the plugin is not found. By default it's
  43667. * false, which means these plugins are only loaded opportunistically.
  43668. *
  43669. * NB: These plugins need to have already been loaded via require.js.
  43670. */
  43671. dependencies: ['converse-chatview', 'converse-headlines-view', 'converse-muc-views'],
  43672. enabled(_converse) {
  43673. return _converse.api.settings.get('view_mode') == 'overlayed';
  43674. },
  43675. overrides: {
  43676. // Overrides mentioned here will be picked up by converse.js's
  43677. // plugin architecture they will replace existing methods on the
  43678. // relevant objects or classes.
  43679. ChatBox: {
  43680. initialize() {
  43681. const result = this.__super__.initialize.apply(this, arguments);
  43682. const height = this.get('height');
  43683. const width = this.get('width');
  43684. const save = this.get('id') === 'controlbox' ? a => this.set(a) : a => this.save(a);
  43685. save({
  43686. 'height': applyDragResistance(height, this.get('default_height')),
  43687. 'width': applyDragResistance(width, this.get('default_width'))
  43688. });
  43689. return result;
  43690. }
  43691. }
  43692. },
  43693. initialize() {
  43694. /* The initialize function gets called as soon as the plugin is
  43695. * loaded by converse.js's plugin machinery.
  43696. */
  43697. core_api.settings.extend({
  43698. 'allow_dragresize': true
  43699. });
  43700. Object.assign(shared_converse.ChatBoxView.prototype, mixin);
  43701. Object.assign(shared_converse.ChatRoomView.prototype, mixin);
  43702. if (shared_converse.ControlBoxView) {
  43703. Object.assign(shared_converse.ControlBoxView.prototype, mixin);
  43704. }
  43705. /************************ BEGIN Event Handlers ************************/
  43706. function registerGlobalEventHandlers() {
  43707. document.addEventListener('mousemove', onMouseMove);
  43708. document.addEventListener('mouseup', onMouseUp);
  43709. }
  43710. function unregisterGlobalEventHandlers() {
  43711. document.removeEventListener('mousemove', onMouseMove);
  43712. document.removeEventListener('mouseup', onMouseUp);
  43713. }
  43714. core_api.listen.on('registeredGlobalEventHandlers', registerGlobalEventHandlers);
  43715. core_api.listen.on('unregisteredGlobalEventHandlers', unregisterGlobalEventHandlers);
  43716. core_api.listen.on('beforeShowingChatView', view => view.initDragResize().setDimensions());
  43717. }
  43718. });
  43719. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/singleton/singleton.scss
  43720. var singleton = __webpack_require__(1833);
  43721. ;// CONCATENATED MODULE: ./src/plugins/singleton/singleton.scss
  43722. var singleton_options = {};
  43723. singleton_options.styleTagTransform = (styleTagTransform_default());
  43724. singleton_options.setAttributes = (setAttributesWithoutAttributes_default());
  43725. singleton_options.insert = insertBySelector_default().bind(null, "head");
  43726. singleton_options.domAPI = (styleDomAPI_default());
  43727. singleton_options.insertStyleElement = (insertStyleElement_default());
  43728. var singleton_update = injectStylesIntoStyleTag_default()(singleton/* default */.Z, singleton_options);
  43729. /* harmony default export */ const singleton_singleton = (singleton/* default */.Z && singleton/* default.locals */.Z.locals ? singleton/* default.locals */.Z.locals : undefined);
  43730. ;// CONCATENATED MODULE: ./src/plugins/singleton/index.js
  43731. /**
  43732. * @copyright JC Brand
  43733. * @license Mozilla Public License (MPLv2)
  43734. * @description A plugin which restricts Converse to only one chat.
  43735. */
  43736. core_converse.plugins.add('converse-singleton', {
  43737. enabled(_converse) {
  43738. return _converse.api.settings.get("singleton");
  43739. },
  43740. initialize() {
  43741. core_api.settings.extend({
  43742. 'allow_logout': false,
  43743. // No point in logging out when we have auto_login as true.
  43744. 'allow_muc_invitations': false,
  43745. // Doesn't make sense to allow because only
  43746. // roster contacts can be invited
  43747. 'hide_muc_server': true
  43748. });
  43749. const auto_join_rooms = core_api.settings.get('auto_join_rooms');
  43750. const auto_join_private_chats = core_api.settings.get('auto_join_private_chats');
  43751. if (!Array.isArray(auto_join_rooms) && !Array.isArray(auto_join_private_chats)) {
  43752. throw new Error("converse-singleton: auto_join_rooms must be an Array");
  43753. }
  43754. if (auto_join_rooms.length === 0 && auto_join_private_chats.length === 0) {
  43755. throw new Error("If you set singleton set to true, you need " + "to specify auto_join_rooms or auto_join_private_chats");
  43756. }
  43757. if (auto_join_rooms.length > 0 && auto_join_private_chats.length > 0) {
  43758. throw new Error("It doesn't make sense to have singleton set to true and " + "auto_join_rooms or auto_join_private_chats set to more then one, " + "since only one chat room may be open at any time.");
  43759. }
  43760. }
  43761. });
  43762. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/fullscreen/styles/fullscreen.scss
  43763. var fullscreen = __webpack_require__(2791);
  43764. ;// CONCATENATED MODULE: ./src/plugins/fullscreen/styles/fullscreen.scss
  43765. var fullscreen_options = {};
  43766. fullscreen_options.styleTagTransform = (styleTagTransform_default());
  43767. fullscreen_options.setAttributes = (setAttributesWithoutAttributes_default());
  43768. fullscreen_options.insert = insertBySelector_default().bind(null, "head");
  43769. fullscreen_options.domAPI = (styleDomAPI_default());
  43770. fullscreen_options.insertStyleElement = (insertStyleElement_default());
  43771. var fullscreen_update = injectStylesIntoStyleTag_default()(fullscreen/* default */.Z, fullscreen_options);
  43772. /* harmony default export */ const styles_fullscreen = (fullscreen/* default */.Z && fullscreen/* default.locals */.Z.locals ? fullscreen/* default.locals */.Z.locals : undefined);
  43773. ;// CONCATENATED MODULE: ./src/plugins/fullscreen/index.js
  43774. /**
  43775. * @module converse-fullscreen
  43776. * @license Mozilla Public License (MPLv2)
  43777. * @copyright 2022, the Converse.js contributors
  43778. */
  43779. core_converse.plugins.add('converse-fullscreen', {
  43780. enabled() {
  43781. return isUniView();
  43782. },
  43783. initialize() {
  43784. core_api.settings.extend({
  43785. chatview_avatar_height: 50,
  43786. chatview_avatar_width: 50,
  43787. hide_open_bookmarks: true,
  43788. show_controlbox_by_default: true,
  43789. sticky_controlbox: true
  43790. });
  43791. }
  43792. });
  43793. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/templates/chat-head.js
  43794. /* harmony default export */ const templates_chat_head = (o => {
  43795. const tpl_standalone_btns = o => o.standalone_btns.reverse().map(b => until_c(b, ''));
  43796. return $`
  43797. <div class="chatbox-title ${o.status ? '' : "chatbox-title--no-desc"}">
  43798. <div class="chatbox-title--row">
  43799. ${!shared_converse.api.settings.get("singleton") ? $`<converse-controlbox-navback jid="${o.jid}"></converse-controlbox-navback>` : ''}
  43800. <div class="chatbox-title__text" title="${o.jid}">${o.display_name}</div>
  43801. </div>
  43802. <div class="chatbox-title__buttons row no-gutters">
  43803. ${o.dropdown_btns.length ? $`<converse-dropdown class="dropleft" .items=${o.dropdown_btns}></converse-dropdown>` : ''}
  43804. ${o.standalone_btns.length ? tpl_standalone_btns(o) : ''}
  43805. </div>
  43806. </div>
  43807. ${o.status ? $`<p class="chat-head__desc">${o.status}</p>` : ''}
  43808. `;
  43809. });
  43810. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/heading.js
  43811. class HeadlinesHeading extends ElementView {
  43812. async connectedCallback() {
  43813. super.connectedCallback();
  43814. this.model = shared_converse.chatboxes.get(this.getAttribute('jid'));
  43815. await this.model.initialized;
  43816. this.render();
  43817. }
  43818. async render() {
  43819. const tpl = await this.generateHeadingTemplate();
  43820. x(tpl, this);
  43821. }
  43822. async generateHeadingTemplate() {
  43823. const heading_btns = await this.getHeadingButtons();
  43824. const standalone_btns = heading_btns.filter(b => b.standalone);
  43825. const dropdown_btns = heading_btns.filter(b => !b.standalone);
  43826. return templates_chat_head(Object.assign(this.model.toJSON(), {
  43827. 'display_name': this.model.getDisplayName(),
  43828. 'dropdown_btns': dropdown_btns.map(b => getHeadingDropdownItem(b)),
  43829. 'standalone_btns': standalone_btns.map(b => getHeadingStandaloneButton(b))
  43830. }));
  43831. }
  43832. /**
  43833. * Returns a list of objects which represent buttons for the headlines header.
  43834. * @async
  43835. * @emits _converse#getHeadingButtons
  43836. * @method HeadlinesHeading#getHeadingButtons
  43837. */
  43838. getHeadingButtons() {
  43839. const buttons = [];
  43840. if (!core_api.settings.get('singleton')) {
  43841. buttons.push({
  43842. 'a_class': 'close-chatbox-button',
  43843. 'handler': ev => this.close(ev),
  43844. 'i18n_text': __('Close'),
  43845. 'i18n_title': __('Close these announcements'),
  43846. 'icon_class': 'fa-times',
  43847. 'name': 'close',
  43848. 'standalone': core_api.settings.get('view_mode') === 'overlayed'
  43849. });
  43850. }
  43851. return shared_converse.api.hook('getHeadingButtons', this, buttons);
  43852. }
  43853. close(ev) {
  43854. ev.preventDefault();
  43855. this.model.close();
  43856. }
  43857. }
  43858. core_api.elements.define('converse-headlines-heading', HeadlinesHeading);
  43859. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/templates/headlines.js
  43860. /* harmony default export */ const headlines = (model => $`
  43861. <div class="flyout box-flyout">
  43862. <converse-dragresize></converse-dragresize>
  43863. ${model ? $`
  43864. <converse-headlines-heading jid="${model.get('jid')}" class="chat-head chat-head-chatbox row no-gutters">
  43865. </converse-headlines-heading>
  43866. <div class="chat-body">
  43867. <div class="chat-content" aria-live="polite">
  43868. <converse-chat-content
  43869. class="chat-content__messages"
  43870. jid="${model.get('jid')}"></converse-chat-content>
  43871. </div>
  43872. </div>` : ''}
  43873. </div>
  43874. `);
  43875. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/view.js
  43876. class HeadlinesView extends BaseChatView {
  43877. async initialize() {
  43878. shared_converse.chatboxviews.add(this.jid, this);
  43879. this.model = shared_converse.chatboxes.get(this.jid);
  43880. this.model.disable_mam = true; // Don't do MAM queries for this box
  43881. this.listenTo(shared_converse, 'windowStateChanged', this.onWindowStateChanged);
  43882. this.listenTo(this.model, 'change:hidden', () => this.afterShown());
  43883. this.listenTo(this.model, 'destroy', this.remove);
  43884. this.listenTo(this.model.messages, 'add', this.requestUpdate);
  43885. this.listenTo(this.model.messages, 'remove', this.requestUpdate);
  43886. this.listenTo(this.model.messages, 'reset', this.requestUpdate);
  43887. await this.model.messages.fetched;
  43888. this.model.maybeShow();
  43889. /**
  43890. * Triggered once the {@link _converse.HeadlinesBoxView} has been initialized
  43891. * @event _converse#headlinesBoxViewInitialized
  43892. * @type { _converse.HeadlinesBoxView }
  43893. * @example _converse.api.listen.on('headlinesBoxViewInitialized', view => { ... });
  43894. */
  43895. core_api.trigger('headlinesBoxViewInitialized', this);
  43896. }
  43897. render() {
  43898. return headlines(this.model);
  43899. }
  43900. async close(ev) {
  43901. var _ev$preventDefault;
  43902. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  43903. if (shared_converse.router.history.getFragment() === 'converse/chat?jid=' + this.model.get('jid')) {
  43904. shared_converse.router.navigate('');
  43905. }
  43906. await this.model.close(ev);
  43907. return this;
  43908. }
  43909. getNotifications() {
  43910. // eslint-disable-line class-methods-use-this
  43911. // Override method in ChatBox. We don't show notifications for
  43912. // headlines boxes.
  43913. return [];
  43914. }
  43915. afterShown() {
  43916. this.model.clearUnreadMsgCounter();
  43917. }
  43918. }
  43919. core_api.elements.define('converse-headlines', HeadlinesView);
  43920. ;// CONCATENATED MODULE: ./src/templates/headline_list.js
  43921. const tpl_headline_box = o => $`
  43922. <div class="list-item controlbox-padded d-flex flex-row"
  43923. data-headline-jid="${o.headlinebox.get('jid')}">
  43924. <a class="list-item-link open-headline available-room w-100"
  43925. data-headline-jid="${o.headlinebox.get('jid')}"
  43926. title="${o.open_title}" href="#">${o.headlinebox.get('jid')}</a>
  43927. </div>
  43928. `;
  43929. /* harmony default export */ const headline_list = (o => $`
  43930. <div class="list-container list-container--headline ${o.headlineboxes.length ? '' : 'hidden'}">
  43931. <div class="items-list rooms-list headline-list">
  43932. ${o.headlineboxes.map(headlinebox => tpl_headline_box(Object.assign({
  43933. headlinebox
  43934. }, o)))}
  43935. </div>
  43936. </div>
  43937. `);
  43938. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/templates/panel.js
  43939. /* harmony default export */ const panel = (o => $`
  43940. <div class="controlbox-section" id="headline">
  43941. <div class="d-flex controlbox-padded ${o.headlineboxes.length ? '' : 'hidden'}">
  43942. <span class="w-100 controlbox-heading controlbox-heading--headline">${o.heading_headline}</span>
  43943. </div>
  43944. </div>
  43945. ${headline_list(o)}
  43946. `);
  43947. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/panel.js
  43948. function panel_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  43949. /**
  43950. * View which renders headlines section of the control box.
  43951. * @class
  43952. * @namespace _converse.HeadlinesPanel
  43953. * @memberOf _converse
  43954. */
  43955. class HeadlinesPanel extends ElementView {
  43956. constructor() {
  43957. super(...arguments);
  43958. panel_defineProperty(this, "events", {
  43959. 'click .open-headline': 'openHeadline'
  43960. });
  43961. }
  43962. initialize() {
  43963. this.model = shared_converse.chatboxes;
  43964. this.listenTo(this.model, 'add', this.renderIfHeadline);
  43965. this.listenTo(this.model, 'remove', this.renderIfHeadline);
  43966. this.listenTo(this.model, 'destroy', this.renderIfHeadline);
  43967. this.render();
  43968. }
  43969. toHTML() {
  43970. return panel({
  43971. 'heading_headline': __('Announcements'),
  43972. 'headlineboxes': this.model.filter(m => m.get('type') === shared_converse.HEADLINES_TYPE),
  43973. 'open_title': __('Click to open this server message')
  43974. });
  43975. }
  43976. renderIfHeadline(model) {
  43977. return model && model.get('type') === shared_converse.HEADLINES_TYPE && this.render();
  43978. }
  43979. openHeadline(ev) {
  43980. // eslint-disable-line class-methods-use-this
  43981. ev.preventDefault();
  43982. const jid = ev.target.getAttribute('data-headline-jid');
  43983. const chat = shared_converse.chatboxes.get(jid);
  43984. chat.maybeShow(true);
  43985. }
  43986. }
  43987. core_api.elements.define('converse-headlines-panel', HeadlinesPanel);
  43988. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/headlines-view/styles/headlines.scss
  43989. var styles_headlines = __webpack_require__(5956);
  43990. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/styles/headlines.scss
  43991. var headlines_options = {};
  43992. headlines_options.styleTagTransform = (styleTagTransform_default());
  43993. headlines_options.setAttributes = (setAttributesWithoutAttributes_default());
  43994. headlines_options.insert = insertBySelector_default().bind(null, "head");
  43995. headlines_options.domAPI = (styleDomAPI_default());
  43996. headlines_options.insertStyleElement = (insertStyleElement_default());
  43997. var headlines_update = injectStylesIntoStyleTag_default()(styles_headlines/* default */.Z, headlines_options);
  43998. /* harmony default export */ const headlines_view_styles_headlines = (styles_headlines/* default */.Z && styles_headlines/* default.locals */.Z.locals ? styles_headlines/* default.locals */.Z.locals : undefined);
  43999. ;// CONCATENATED MODULE: ./src/plugins/headlines-view/index.js
  44000. /**
  44001. * @module converse-headlines-view
  44002. * @copyright 2022, the Converse.js contributors
  44003. * @license Mozilla Public License (MPLv2)
  44004. */
  44005. core_converse.plugins.add('converse-headlines-view', {
  44006. /* Plugin dependencies are other plugins which might be
  44007. * overridden or relied upon, and therefore need to be loaded before
  44008. * this plugin.
  44009. *
  44010. * If the setting "strict_plugin_dependencies" is set to true,
  44011. * an error will be raised if the plugin is not found. By default it's
  44012. * false, which means these plugins are only loaded opportunistically.
  44013. *
  44014. * NB: These plugins need to have already been loaded by the bundler
  44015. */
  44016. dependencies: ['converse-headlines', 'converse-chatview'],
  44017. initialize() {
  44018. shared_converse.HeadlinesPanel = HeadlinesPanel;
  44019. }
  44020. });
  44021. ;// CONCATENATED MODULE: ./src/plugins/mam-views/templates/placeholder.js
  44022. /* harmony default export */ const placeholder = (el => {
  44023. return el.model.get('fetching') ? spinner({
  44024. 'classes': 'hor_centered'
  44025. }) : $`<a @click="${ev => el.fetchMissingMessages(ev)}" title="${__('Click to load missing messages')}">
  44026. <div class="message mam-placeholder"></div>
  44027. </a>`;
  44028. });
  44029. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/mam-views/styles/placeholder.scss
  44030. var styles_placeholder = __webpack_require__(9679);
  44031. ;// CONCATENATED MODULE: ./src/plugins/mam-views/styles/placeholder.scss
  44032. var placeholder_options = {};
  44033. placeholder_options.styleTagTransform = (styleTagTransform_default());
  44034. placeholder_options.setAttributes = (setAttributesWithoutAttributes_default());
  44035. placeholder_options.insert = insertBySelector_default().bind(null, "head");
  44036. placeholder_options.domAPI = (styleDomAPI_default());
  44037. placeholder_options.insertStyleElement = (insertStyleElement_default());
  44038. var placeholder_update = injectStylesIntoStyleTag_default()(styles_placeholder/* default */.Z, placeholder_options);
  44039. /* harmony default export */ const mam_views_styles_placeholder = (styles_placeholder/* default */.Z && styles_placeholder/* default.locals */.Z.locals ? styles_placeholder/* default.locals */.Z.locals : undefined);
  44040. ;// CONCATENATED MODULE: ./src/plugins/mam-views/placeholder.js
  44041. class Placeholder extends CustomElement {
  44042. static get properties() {
  44043. return {
  44044. 'model': {
  44045. type: Object
  44046. }
  44047. };
  44048. }
  44049. render() {
  44050. return placeholder(this);
  44051. }
  44052. async fetchMissingMessages(ev) {
  44053. var _ev$preventDefault;
  44054. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  44055. this.model.set('fetching', true);
  44056. const options = {
  44057. 'before': this.model.get('before'),
  44058. 'start': this.model.get('start')
  44059. };
  44060. await fetchArchivedMessages(this.model.collection.chatbox, options);
  44061. this.model.destroy();
  44062. }
  44063. }
  44064. core_api.elements.define('converse-mam-placeholder', Placeholder);
  44065. ;// CONCATENATED MODULE: ./src/plugins/mam-views/utils.js
  44066. function getPlaceholderTemplate(message, tpl) {
  44067. if (message instanceof MAMPlaceholderMessage) {
  44068. return $`<converse-mam-placeholder .model=${message}></converse-mam-placeholder>`;
  44069. } else {
  44070. return tpl;
  44071. }
  44072. }
  44073. async function fetchMessagesOnScrollUp(view) {
  44074. if (view.model.ui.get('chat-content-spinner-top')) {
  44075. return;
  44076. }
  44077. if (view.model.messages.length) {
  44078. const is_groupchat = view.model.get('type') === shared_converse.CHATROOMS_TYPE;
  44079. const oldest_message = view.model.getOldestMessage();
  44080. if (oldest_message) {
  44081. const by_jid = is_groupchat ? view.model.get('jid') : shared_converse.bare_jid;
  44082. const stanza_id = oldest_message && oldest_message.get(`stanza_id ${by_jid}`);
  44083. view.model.ui.set('chat-content-spinner-top', true);
  44084. try {
  44085. if (stanza_id) {
  44086. await fetchArchivedMessages(view.model, {
  44087. 'before': stanza_id
  44088. });
  44089. } else {
  44090. await fetchArchivedMessages(view.model, {
  44091. 'end': oldest_message.get('time')
  44092. });
  44093. }
  44094. } catch (e) {
  44095. headless_log.error(e);
  44096. view.model.ui.set('chat-content-spinner-top', false);
  44097. return;
  44098. }
  44099. if (core_api.settings.get('allow_url_history_change')) {
  44100. shared_converse.router.history.navigate(`#${oldest_message.get('msgid')}`);
  44101. }
  44102. setTimeout(() => view.model.ui.set('chat-content-spinner-top', false), 250);
  44103. }
  44104. }
  44105. }
  44106. ;// CONCATENATED MODULE: ./src/plugins/mam-views/index.js
  44107. /**
  44108. * @description UI code XEP-0313 Message Archive Management
  44109. * @copyright 2021, the Converse.js contributors
  44110. * @license Mozilla Public License (MPLv2)
  44111. */
  44112. core_converse.plugins.add('converse-mam-views', {
  44113. dependencies: ['converse-mam', 'converse-chatview', 'converse-muc-views'],
  44114. initialize() {
  44115. core_api.listen.on('chatBoxScrolledUp', fetchMessagesOnScrollUp);
  44116. core_api.listen.on('getMessageTemplate', getPlaceholderTemplate);
  44117. }
  44118. });
  44119. ;// CONCATENATED MODULE: ./src/plugins/minimize/toggle.js
  44120. const MinimizedChatsToggle = Model.extend({
  44121. defaults: {
  44122. 'collapsed': false
  44123. }
  44124. });
  44125. /* harmony default export */ const minimize_toggle = (MinimizedChatsToggle);
  44126. ;// CONCATENATED MODULE: ./src/plugins/minimize/templates/chats-panel.js
  44127. /* harmony default export */ const chats_panel = (o => $`<div id="minimized-chats" class="${o.chats.length ? '' : 'hidden'}">
  44128. <a id="toggle-minimized-chats" class="row no-gutters" @click=${o.toggle}>
  44129. ${o.num_minimized} ${__('Minimized')}
  44130. <span class="unread-message-count ${!o.num_unread ? 'unread-message-count-hidden' : ''}" href="#">${o.num_unread}</span>
  44131. </a>
  44132. <div class="flyout minimized-chats-flyout row no-gutters ${o.collapsed ? 'hidden' : ''}">
  44133. ${o.chats.map(chat => $`<converse-minimized-chat
  44134. .model=${chat}
  44135. title=${chat.getDisplayName()}
  44136. type=${chat.get('type')}
  44137. num_unread=${chat.get('num_unread')}></converse-minimized-chat>`)}
  44138. </div>
  44139. </div>`);
  44140. ;// CONCATENATED MODULE: ./src/plugins/minimize/view.js
  44141. class MinimizedChats extends CustomElement {
  44142. async initialize() {
  44143. this.model = shared_converse.chatboxes;
  44144. await this.initToggle();
  44145. this.listenTo(this.minchats, 'change:collapsed', this.requestUpdate);
  44146. this.listenTo(this.model, 'add', this.requestUpdate);
  44147. this.listenTo(this.model, 'change:fullname', this.requestUpdate);
  44148. this.listenTo(this.model, 'change:jid', this.requestUpdate);
  44149. this.listenTo(this.model, 'change:minimized', this.requestUpdate);
  44150. this.listenTo(this.model, 'change:name', this.requestUpdate);
  44151. this.listenTo(this.model, 'change:num_unread', this.requestUpdate);
  44152. this.listenTo(this.model, 'remove', this.requestUpdate);
  44153. this.listenTo(shared_converse, 'connected', this.requestUpdate);
  44154. this.listenTo(shared_converse, 'reconnected', this.requestUpdate);
  44155. this.listenTo(shared_converse, 'disconnected', this.requestUpdate);
  44156. }
  44157. render() {
  44158. const chats = this.model.where({
  44159. 'minimized': true
  44160. });
  44161. const num_unread = chats.reduce((acc, chat) => acc + chat.get('num_unread'), 0);
  44162. const num_minimized = chats.reduce((acc, chat) => acc + (chat.get('minimized') ? 1 : 0), 0);
  44163. const collapsed = this.minchats.get('collapsed');
  44164. const data = {
  44165. chats,
  44166. num_unread,
  44167. num_minimized,
  44168. collapsed
  44169. };
  44170. data.toggle = ev => this.toggle(ev);
  44171. return chats_panel(data);
  44172. }
  44173. async initToggle() {
  44174. const id = `converse.minchatstoggle-${shared_converse.bare_jid}`;
  44175. this.minchats = new minimize_toggle({
  44176. id
  44177. });
  44178. initStorage(this.minchats, id, 'session');
  44179. await new Promise(resolve => this.minchats.fetch({
  44180. 'success': resolve,
  44181. 'error': resolve
  44182. }));
  44183. }
  44184. toggle(ev) {
  44185. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  44186. this.minchats.save({
  44187. 'collapsed': !this.minchats.get('collapsed')
  44188. });
  44189. }
  44190. }
  44191. core_api.elements.define('converse-minimized-chats', MinimizedChats);
  44192. ;// CONCATENATED MODULE: ./src/plugins/minimize/templates/trimmed_chat.js
  44193. /* harmony default export */ const trimmed_chat = (o => {
  44194. const i18n_tooltip = __('Click to restore this chat');
  44195. const close_color = o.type === 'chatroom' ? "var(--chatroom-head-color)" : "var(--chat-head-text-color)";
  44196. return $`
  44197. <div class="chat-head-${o.type} chat-head row no-gutters">
  44198. <a class="restore-chat w-100 align-self-center" title="${i18n_tooltip}" @click=${o.restore}>
  44199. ${o.num_unread ? $`<span class="message-count badge badge-light">${o.num_unread}</span>` : ''}
  44200. ${o.title}
  44201. </a>
  44202. <a class="chatbox-btn close-chatbox-button" @click=${o.close}>
  44203. <converse-icon color=${close_color} class="fas fa-times" @click=${o.close} size="1em"></converse-icon>
  44204. </a>
  44205. </div>`;
  44206. });
  44207. ;// CONCATENATED MODULE: ./src/plugins/minimize/utils.js
  44208. const {
  44209. dayjs: minimize_utils_dayjs,
  44210. u: minimize_utils_u
  44211. } = core_converse.env;
  44212. function initializeChat(chat) {
  44213. chat.on('change:hidden', m => !m.get('hidden') && maximize(chat), chat);
  44214. if (chat.get('id') === 'controlbox') {
  44215. return;
  44216. }
  44217. chat.save({
  44218. 'minimized': chat.get('minimized') || false,
  44219. 'time_minimized': chat.get('time_minimized') || minimize_utils_dayjs()
  44220. });
  44221. }
  44222. function getChatBoxWidth(view) {
  44223. if (view.model.get('id') === 'controlbox') {
  44224. // We return the width of the controlbox or its toggle,
  44225. // depending on which is visible.
  44226. if (minimize_utils_u.isVisible(view)) {
  44227. return minimize_utils_u.getOuterWidth(view, true);
  44228. } else {
  44229. const toggle = document.querySelector('converse-controlbox-toggle');
  44230. return toggle ? minimize_utils_u.getOuterWidth(toggle, true) : 0;
  44231. }
  44232. } else if (!view.model.get('minimized') && minimize_utils_u.isVisible(view)) {
  44233. return minimize_utils_u.getOuterWidth(view, true);
  44234. }
  44235. return 0;
  44236. }
  44237. function getShownChats() {
  44238. return shared_converse.chatboxviews.filter(el => // The controlbox can take a while to close,
  44239. // so we need to check its state. That's why we checked the 'closed' state.
  44240. !el.model.get('minimized') && !el.model.get('closed') && minimize_utils_u.isVisible(el));
  44241. }
  44242. function getMinimizedWidth() {
  44243. const minimized_el = document.querySelector('converse-minimized-chats');
  44244. return shared_converse.chatboxes.pluck('minimized').includes(true) ? minimize_utils_u.getOuterWidth(minimized_el, true) : 0;
  44245. }
  44246. function getBoxesWidth(newchat) {
  44247. const new_id = newchat ? newchat.model.get('id') : null;
  44248. const newchat_width = newchat ? minimize_utils_u.getOuterWidth(newchat, true) : 0;
  44249. return Object.values(shared_converse.chatboxviews.xget(new_id)).reduce((memo, view) => memo + getChatBoxWidth(view), newchat_width);
  44250. }
  44251. /**
  44252. * This method is called when a newly created chat box will be shown.
  44253. * It checks whether there is enough space on the page to show
  44254. * another chat box. Otherwise it minimizes the oldest chat box
  44255. * to create space.
  44256. * @private
  44257. * @method _converse.ChatBoxViews#trimChats
  44258. * @param { _converse.ChatBoxView|_converse.ChatRoomView|_converse.ControlBoxView|_converse.HeadlinesBoxView } [newchat]
  44259. */
  44260. function trimChats(newchat) {
  44261. if (shared_converse.isTestEnv() || core_api.settings.get('no_trimming') || core_api.settings.get("view_mode") !== 'overlayed') {
  44262. return;
  44263. }
  44264. const shown_chats = getShownChats();
  44265. if (shown_chats.length <= 1) {
  44266. return;
  44267. }
  44268. const body_width = minimize_utils_u.getOuterWidth(document.querySelector('body'), true);
  44269. if (getChatBoxWidth(shown_chats[0]) === body_width) {
  44270. // If the chats shown are the same width as the body,
  44271. // then we're in responsive mode and the chats are
  44272. // fullscreen. In this case we don't trim.
  44273. return;
  44274. }
  44275. const minimized_el = document.querySelector('converse-minimized-chats');
  44276. if (minimized_el) {
  44277. while (getMinimizedWidth() + getBoxesWidth(newchat) > body_width) {
  44278. const new_id = newchat ? newchat.model.get('id') : null;
  44279. const oldest_chat = getOldestMaximizedChat([new_id]);
  44280. if (oldest_chat) {
  44281. const model = shared_converse.chatboxes.get(oldest_chat.get('id'));
  44282. model === null || model === void 0 ? void 0 : model.save('hidden', true);
  44283. minimize(oldest_chat);
  44284. } else {
  44285. break;
  44286. }
  44287. }
  44288. }
  44289. }
  44290. function getOldestMaximizedChat(exclude_ids) {
  44291. // Get oldest view (if its id is not excluded)
  44292. exclude_ids.push('controlbox');
  44293. let i = 0;
  44294. let model = shared_converse.chatboxes.sort().at(i);
  44295. while (exclude_ids.includes(model.get('id')) || model.get('minimized') === true) {
  44296. i++;
  44297. model = shared_converse.chatboxes.at(i);
  44298. if (!model) {
  44299. return null;
  44300. }
  44301. }
  44302. return model;
  44303. }
  44304. function addMinimizeButtonToChat(view, buttons) {
  44305. const data = {
  44306. 'a_class': 'toggle-chatbox-button',
  44307. 'handler': ev => minimize(ev, view.model),
  44308. 'i18n_text': __('Minimize'),
  44309. 'i18n_title': __('Minimize this chat'),
  44310. 'icon_class': "fa-minus",
  44311. 'name': 'minimize',
  44312. 'standalone': shared_converse.api.settings.get("view_mode") === 'overlayed'
  44313. };
  44314. const names = buttons.map(t => t.name);
  44315. const idx = names.indexOf('close');
  44316. return idx > -1 ? [...buttons.slice(0, idx), data, ...buttons.slice(idx)] : [data, ...buttons];
  44317. }
  44318. function addMinimizeButtonToMUC(view, buttons) {
  44319. const data = {
  44320. 'a_class': 'toggle-chatbox-button',
  44321. 'handler': ev => minimize(ev, view.model),
  44322. 'i18n_text': __('Minimize'),
  44323. 'i18n_title': __('Minimize this groupchat'),
  44324. 'icon_class': "fa-minus",
  44325. 'name': 'minimize',
  44326. 'standalone': shared_converse.api.settings.get("view_mode") === 'overlayed'
  44327. };
  44328. const names = buttons.map(t => t.name);
  44329. const idx = names.indexOf('signout');
  44330. return idx > -1 ? [...buttons.slice(0, idx), data, ...buttons.slice(idx)] : [data, ...buttons];
  44331. }
  44332. function maximize(ev, chatbox) {
  44333. if (ev !== null && ev !== void 0 && ev.preventDefault) {
  44334. ev.preventDefault();
  44335. } else {
  44336. chatbox = ev;
  44337. }
  44338. minimize_utils_u.safeSave(chatbox, {
  44339. 'hidden': false,
  44340. 'minimized': false,
  44341. 'time_opened': new Date().getTime()
  44342. });
  44343. }
  44344. function minimize(ev, model) {
  44345. if (ev !== null && ev !== void 0 && ev.preventDefault) {
  44346. ev.preventDefault();
  44347. } else {
  44348. model = ev;
  44349. }
  44350. model.setChatState(shared_converse.INACTIVE);
  44351. minimize_utils_u.safeSave(model, {
  44352. 'hidden': true,
  44353. 'minimized': true,
  44354. 'time_minimized': new Date().toISOString()
  44355. });
  44356. }
  44357. /**
  44358. * Handler which gets called when a {@link _converse#ChatBox} has it's
  44359. * `minimized` property set to false.
  44360. *
  44361. * Will trigger {@link _converse#chatBoxMaximized}
  44362. * @returns {_converse.ChatBoxView|_converse.ChatRoomView}
  44363. */
  44364. function onMaximized(model) {
  44365. if (!model.isScrolledUp()) {
  44366. model.clearUnreadMsgCounter();
  44367. }
  44368. model.setChatState(shared_converse.ACTIVE);
  44369. /**
  44370. * Triggered when a previously minimized chat gets maximized
  44371. * @event _converse#chatBoxMaximized
  44372. * @type { _converse.ChatBoxView }
  44373. * @example _converse.api.listen.on('chatBoxMaximized', view => { ... });
  44374. */
  44375. core_api.trigger('chatBoxMaximized', model);
  44376. }
  44377. /**
  44378. * Handler which gets called when a {@link _converse#ChatBox} has it's
  44379. * `minimized` property set to true.
  44380. *
  44381. * Will trigger {@link _converse#chatBoxMinimized}
  44382. * @returns {_converse.ChatBoxView|_converse.ChatRoomView}
  44383. */
  44384. function onMinimized(model) {
  44385. /**
  44386. * Triggered when a previously maximized chat gets Minimized
  44387. * @event _converse#chatBoxMinimized
  44388. * @type { _converse.ChatBoxView }
  44389. * @example _converse.api.listen.on('chatBoxMinimized', view => { ... });
  44390. */
  44391. core_api.trigger('chatBoxMinimized', model);
  44392. }
  44393. function onMinimizedChanged(model) {
  44394. if (model.get('minimized')) {
  44395. onMinimized(model);
  44396. } else {
  44397. onMaximized(model);
  44398. }
  44399. }
  44400. ;// CONCATENATED MODULE: ./src/plugins/minimize/components/minimized-chat.js
  44401. class MinimizedChat extends CustomElement {
  44402. static get properties() {
  44403. return {
  44404. model: {
  44405. type: Object
  44406. },
  44407. title: {
  44408. type: String
  44409. },
  44410. type: {
  44411. type: String
  44412. },
  44413. num_unread: {
  44414. type: Number
  44415. }
  44416. };
  44417. }
  44418. render() {
  44419. const data = {
  44420. 'close': ev => this.close(ev),
  44421. 'num_unread': this.num_unread,
  44422. 'restore': ev => this.restore(ev),
  44423. 'title': this.title,
  44424. 'type': this.type
  44425. };
  44426. return trimmed_chat(data);
  44427. }
  44428. close(ev) {
  44429. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  44430. this.model.close();
  44431. }
  44432. restore(ev) {
  44433. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  44434. maximize(this.model);
  44435. }
  44436. }
  44437. core_api.elements.define('converse-minimized-chat', MinimizedChat);
  44438. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/minimize/styles/minimize.scss
  44439. var styles_minimize = __webpack_require__(4915);
  44440. ;// CONCATENATED MODULE: ./src/plugins/minimize/styles/minimize.scss
  44441. var minimize_options = {};
  44442. minimize_options.styleTagTransform = (styleTagTransform_default());
  44443. minimize_options.setAttributes = (setAttributesWithoutAttributes_default());
  44444. minimize_options.insert = insertBySelector_default().bind(null, "head");
  44445. minimize_options.domAPI = (styleDomAPI_default());
  44446. minimize_options.insertStyleElement = (insertStyleElement_default());
  44447. var minimize_update = injectStylesIntoStyleTag_default()(styles_minimize/* default */.Z, minimize_options);
  44448. /* harmony default export */ const minimize_styles_minimize = (styles_minimize/* default */.Z && styles_minimize/* default.locals */.Z.locals ? styles_minimize/* default.locals */.Z.locals : undefined);
  44449. ;// CONCATENATED MODULE: ./src/plugins/minimize/index.js
  44450. /**
  44451. * @module converse-minimize
  44452. * @copyright 2022, the Converse.js contributors
  44453. * @license Mozilla Public License (MPLv2)
  44454. */
  44455. core_converse.plugins.add('converse-minimize', {
  44456. /* Optional dependencies are other plugins which might be
  44457. * overridden or relied upon, and therefore need to be loaded before
  44458. * this plugin. They are called "optional" because they might not be
  44459. * available, in which case any overrides applicable to them will be
  44460. * ignored.
  44461. *
  44462. * It's possible however to make optional dependencies non-optional.
  44463. * If the setting "strict_plugin_dependencies" is set to true,
  44464. * an error will be raised if the plugin is not found.
  44465. *
  44466. * NB: These plugins need to have already been loaded via require.js.
  44467. */
  44468. dependencies: ["converse-chatview", "converse-controlbox", "converse-muc-views", "converse-headlines-view", "converse-dragresize"],
  44469. enabled(_converse) {
  44470. return _converse.api.settings.get("view_mode") === 'overlayed';
  44471. },
  44472. overrides: {
  44473. // Overrides mentioned here will be picked up by converse.js's
  44474. // plugin architecture they will replace existing methods on the
  44475. // relevant objects or classes.
  44476. //
  44477. // New functions which don't exist yet can also be added.
  44478. ChatBox: {
  44479. maybeShow(force) {
  44480. if (!force && this.get('minimized')) {
  44481. // Must return the chatbox
  44482. return this;
  44483. }
  44484. return this.__super__.maybeShow.apply(this, arguments);
  44485. },
  44486. isHidden() {
  44487. return this.__super__.isHidden.call(this) || this.get('minimized');
  44488. }
  44489. },
  44490. ChatBoxView: {
  44491. isNewMessageHidden() {
  44492. return this.model.get('minimized') || this.__super__.isNewMessageHidden.apply(this, arguments);
  44493. },
  44494. setChatBoxHeight(height) {
  44495. if (!this.model.get('minimized')) {
  44496. return this.__super__.setChatBoxHeight.call(this, height);
  44497. }
  44498. },
  44499. setChatBoxWidth(width) {
  44500. if (!this.model.get('minimized')) {
  44501. return this.__super__.setChatBoxWidth.call(this, width);
  44502. }
  44503. }
  44504. }
  44505. },
  44506. initialize() {
  44507. core_api.settings.extend({
  44508. 'no_trimming': false
  44509. });
  44510. core_api.promises.add('minimizedChatsInitialized');
  44511. shared_converse.MinimizedChatsToggle = minimize_toggle;
  44512. shared_converse.minimize = {
  44513. trimChats: trimChats,
  44514. minimize: minimize,
  44515. maximize: maximize
  44516. };
  44517. function onChatInitialized(model) {
  44518. initializeChat(model);
  44519. model.on('change:minimized', () => onMinimizedChanged(model));
  44520. }
  44521. core_api.listen.on('chatBoxViewInitialized', view => shared_converse.minimize.trimChats(view));
  44522. core_api.listen.on('chatRoomViewInitialized', view => shared_converse.minimize.trimChats(view));
  44523. core_api.listen.on('controlBoxOpened', view => shared_converse.minimize.trimChats(view));
  44524. core_api.listen.on('chatBoxInitialized', onChatInitialized);
  44525. core_api.listen.on('chatRoomInitialized', onChatInitialized);
  44526. core_api.listen.on('getHeadingButtons', (view, buttons) => {
  44527. if (view.model.get('type') === shared_converse.CHATROOMS_TYPE) {
  44528. return addMinimizeButtonToMUC(view, buttons);
  44529. } else {
  44530. return addMinimizeButtonToChat(view, buttons);
  44531. }
  44532. });
  44533. const debouncedTrimChats = lodash_es_debounce(() => shared_converse.minimize.trimChats(), 250);
  44534. core_api.listen.on('registeredGlobalEventHandlers', () => window.addEventListener("resize", debouncedTrimChats));
  44535. core_api.listen.on('unregisteredGlobalEventHandlers', () => window.removeEventListener("resize", debouncedTrimChats));
  44536. }
  44537. });
  44538. ;// CONCATENATED MODULE: ./src/shared/autocomplete/utils.js
  44539. const autocomplete_utils_u = core_converse.env.utils;
  44540. const utils_helpers = {
  44541. getElement(expr, el) {
  44542. return typeof expr === 'string' ? (el || document).querySelector(expr) : expr || null;
  44543. },
  44544. bind(element, o) {
  44545. if (element) {
  44546. for (var event in o) {
  44547. if (!Object.prototype.hasOwnProperty.call(o, event)) {
  44548. continue;
  44549. }
  44550. const callback = o[event];
  44551. event.split(/\s+/).forEach(event => element.addEventListener(event, callback));
  44552. }
  44553. }
  44554. },
  44555. unbind(element, o) {
  44556. if (element) {
  44557. for (var event in o) {
  44558. if (!Object.prototype.hasOwnProperty.call(o, event)) {
  44559. continue;
  44560. }
  44561. const callback = o[event];
  44562. event.split(/\s+/).forEach(event => element.removeEventListener(event, callback));
  44563. }
  44564. }
  44565. },
  44566. regExpEscape(s) {
  44567. return s.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  44568. },
  44569. isMention(word, ac_triggers) {
  44570. return ac_triggers.includes(word[0]) || autocomplete_utils_u.isMentionBoundary(word[0]) && ac_triggers.includes(word[1]);
  44571. }
  44572. };
  44573. const FILTER_CONTAINS = function (text, input) {
  44574. return RegExp(utils_helpers.regExpEscape(input.trim()), 'i').test(text);
  44575. };
  44576. const FILTER_STARTSWITH = function (text, input) {
  44577. return RegExp('^' + utils_helpers.regExpEscape(input.trim()), 'i').test(text);
  44578. };
  44579. const SORT_BY_LENGTH = function (a, b) {
  44580. if (a.length !== b.length) {
  44581. return a.length - b.length;
  44582. }
  44583. return a < b ? -1 : 1;
  44584. };
  44585. const SORT_BY_QUERY_POSITION = function (a, b) {
  44586. const query = a.query.toLowerCase();
  44587. const x = a.label.toLowerCase().indexOf(query);
  44588. const y = b.label.toLowerCase().indexOf(query);
  44589. if (x === y) {
  44590. return SORT_BY_LENGTH(a, b);
  44591. }
  44592. return (x === -1 ? Infinity : x) < (y === -1 ? Infinity : y) ? -1 : 1;
  44593. };
  44594. const ITEM = (text, input) => {
  44595. input = input.trim();
  44596. const element = document.createElement('li');
  44597. element.setAttribute('aria-selected', 'false');
  44598. const regex = new RegExp('(' + input + ')', 'ig');
  44599. const parts = input ? text.split(regex) : [text];
  44600. parts.forEach(txt => {
  44601. if (input && txt.match(regex)) {
  44602. const match = document.createElement('mark');
  44603. match.textContent = txt;
  44604. element.appendChild(match);
  44605. } else {
  44606. element.appendChild(document.createTextNode(txt));
  44607. }
  44608. });
  44609. return element;
  44610. };
  44611. ;// CONCATENATED MODULE: ./src/shared/autocomplete/suggestion.js
  44612. /**
  44613. * An autocomplete suggestion
  44614. */
  44615. class Suggestion extends String {
  44616. /**
  44617. * @param { Any } data - The auto-complete data. Ideally an object e.g. { label, value },
  44618. * which specifies the value and human-presentable label of the suggestion.
  44619. * @param { string } query - The query string being auto-completed
  44620. */
  44621. constructor(data, query) {
  44622. super();
  44623. const o = Array.isArray(data) ? {
  44624. label: data[0],
  44625. value: data[1]
  44626. } : typeof data === 'object' && 'label' in data && 'value' in data ? data : {
  44627. label: data,
  44628. value: data
  44629. };
  44630. this.label = o.label || o.value;
  44631. this.value = o.value;
  44632. this.query = query;
  44633. }
  44634. get lenth() {
  44635. return this.label.length;
  44636. }
  44637. toString() {
  44638. return '' + this.label;
  44639. }
  44640. valueOf() {
  44641. return this.toString();
  44642. }
  44643. }
  44644. /* harmony default export */ const suggestion = (Suggestion);
  44645. ;// CONCATENATED MODULE: ./src/shared/autocomplete/autocomplete.js
  44646. /**
  44647. * @copyright Lea Verou and the Converse.js contributors
  44648. * @description
  44649. * Started as a fork of Lea Verou's "Awesomplete"
  44650. * https://leaverou.github.io/awesomplete/
  44651. * @license Mozilla Public License (MPLv2)
  44652. */
  44653. const autocomplete_u = core_converse.env.utils;
  44654. class AutoComplete {
  44655. constructor(el) {
  44656. let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  44657. this.suggestions = [];
  44658. this.is_opened = false;
  44659. if (autocomplete_u.hasClass('suggestion-box', el)) {
  44660. this.container = el;
  44661. } else {
  44662. this.container = el.querySelector('.suggestion-box');
  44663. }
  44664. this.input = this.container.querySelector('.suggestion-box__input');
  44665. this.input.setAttribute("aria-autocomplete", "list");
  44666. this.ul = this.container.querySelector('.suggestion-box__results');
  44667. this.status = this.container.querySelector('.suggestion-box__additions');
  44668. Object.assign(this, {
  44669. 'match_current_word': false,
  44670. // Match only the current word, otherwise all input is matched
  44671. 'ac_triggers': [],
  44672. // Array of keys (`ev.key`) values that will trigger auto-complete
  44673. 'include_triggers': [],
  44674. // Array of trigger keys which should be included in the returned value
  44675. 'min_chars': 2,
  44676. 'max_items': 10,
  44677. 'auto_evaluate': true,
  44678. // Should evaluation happen automatically without any particular key as trigger?
  44679. 'auto_first': false,
  44680. // Should the first element be automatically selected?
  44681. 'data': a => a,
  44682. 'filter': FILTER_CONTAINS,
  44683. 'sort': config.sort === false ? false : SORT_BY_QUERY_POSITION,
  44684. 'item': ITEM
  44685. }, config);
  44686. this.index = -1;
  44687. this.bindEvents();
  44688. if (this.input.hasAttribute("list")) {
  44689. this.list = "#" + this.input.getAttribute("list");
  44690. this.input.removeAttribute("list");
  44691. } else {
  44692. this.list = this.input.getAttribute("data-list") || config.list || [];
  44693. }
  44694. }
  44695. bindEvents() {
  44696. // Bind events
  44697. const input = {
  44698. "blur": () => this.close({
  44699. 'reason': 'blur'
  44700. })
  44701. };
  44702. if (this.auto_evaluate) {
  44703. input["input"] = () => this.evaluate();
  44704. }
  44705. this._events = {
  44706. 'input': input,
  44707. 'form': {
  44708. "submit": () => this.close({
  44709. 'reason': 'submit'
  44710. })
  44711. },
  44712. 'ul': {
  44713. "mousedown": ev => this.onMouseDown(ev),
  44714. "mouseover": ev => this.onMouseOver(ev)
  44715. }
  44716. };
  44717. utils_helpers.bind(this.input, this._events.input);
  44718. utils_helpers.bind(this.input.form, this._events.form);
  44719. utils_helpers.bind(this.ul, this._events.ul);
  44720. }
  44721. set list(list) {
  44722. if (Array.isArray(list) || typeof list === "function") {
  44723. this._list = list;
  44724. } else if (typeof list === "string" && list.includes(",")) {
  44725. this._list = list.split(/\s*,\s*/);
  44726. } else {
  44727. var _helpers$getElement;
  44728. // Element or CSS selector
  44729. const children = ((_helpers$getElement = utils_helpers.getElement(list)) === null || _helpers$getElement === void 0 ? void 0 : _helpers$getElement.children) || [];
  44730. this._list = Array.from(children).filter(el => !el.disabled).map(el => {
  44731. const text = el.textContent.trim();
  44732. const value = el.value || text;
  44733. const label = el.label || text;
  44734. return value !== "" ? {
  44735. label,
  44736. value
  44737. } : null;
  44738. }).filter(i => i);
  44739. }
  44740. if (document.activeElement === this.input) {
  44741. this.evaluate();
  44742. }
  44743. }
  44744. get list() {
  44745. return this._list;
  44746. }
  44747. get selected() {
  44748. return this.index > -1;
  44749. }
  44750. get opened() {
  44751. return this.is_opened;
  44752. }
  44753. close(o) {
  44754. if (!this.opened) {
  44755. return;
  44756. }
  44757. this.ul.setAttribute("hidden", "");
  44758. this.is_opened = false;
  44759. this.index = -1;
  44760. this.trigger("suggestion-box-close", o || {});
  44761. }
  44762. insertValue(suggestion) {
  44763. if (this.match_current_word) {
  44764. autocomplete_u.replaceCurrentWord(this.input, suggestion.value);
  44765. } else {
  44766. this.input.value = suggestion.value;
  44767. }
  44768. }
  44769. open() {
  44770. this.ul.removeAttribute("hidden");
  44771. this.is_opened = true;
  44772. if (this.auto_first && this.index === -1) {
  44773. this.goto(0);
  44774. }
  44775. this.trigger("suggestion-box-open");
  44776. }
  44777. destroy() {
  44778. //remove events from the input and its form
  44779. utils_helpers.unbind(this.input, this._events.input);
  44780. utils_helpers.unbind(this.input.form, this._events.form);
  44781. this.input.removeAttribute("aria-autocomplete");
  44782. }
  44783. next() {
  44784. const count = this.ul.children.length;
  44785. this.goto(this.index < count - 1 ? this.index + 1 : count ? 0 : -1);
  44786. }
  44787. previous() {
  44788. const count = this.ul.children.length,
  44789. pos = this.index - 1;
  44790. this.goto(this.selected && pos !== -1 ? pos : count - 1);
  44791. }
  44792. goto(i) {
  44793. // Should not be used directly, highlights specific item without any checks!
  44794. const list = this.ul.children;
  44795. if (this.selected) {
  44796. list[this.index].setAttribute("aria-selected", "false");
  44797. }
  44798. this.index = i;
  44799. if (i > -1 && list.length > 0) {
  44800. list[i].setAttribute("aria-selected", "true");
  44801. list[i].focus();
  44802. this.status.textContent = list[i].textContent; // scroll to highlighted element in case parent's height is fixed
  44803. this.ul.scrollTop = list[i].offsetTop - this.ul.clientHeight + list[i].clientHeight;
  44804. this.trigger("suggestion-box-highlight", {
  44805. 'text': this.suggestions[this.index]
  44806. });
  44807. }
  44808. }
  44809. select(selected) {
  44810. if (selected) {
  44811. this.index = autocomplete_u.siblingIndex(selected);
  44812. } else {
  44813. selected = this.ul.children[this.index];
  44814. }
  44815. if (selected) {
  44816. const suggestion = this.suggestions[this.index];
  44817. this.insertValue(suggestion);
  44818. this.close({
  44819. 'reason': 'select'
  44820. });
  44821. this.auto_completing = false;
  44822. this.trigger("suggestion-box-selectcomplete", {
  44823. 'text': suggestion
  44824. });
  44825. }
  44826. }
  44827. onMouseOver(ev) {
  44828. const li = autocomplete_u.ancestor(ev.target, 'li');
  44829. if (li) {
  44830. this.goto(Array.prototype.slice.call(this.ul.children).indexOf(li));
  44831. }
  44832. }
  44833. onMouseDown(ev) {
  44834. if (ev.button !== 0) {
  44835. return; // Only select on left click
  44836. }
  44837. const li = autocomplete_u.ancestor(ev.target, 'li');
  44838. if (li) {
  44839. ev.preventDefault();
  44840. this.select(li, ev.target);
  44841. }
  44842. }
  44843. onKeyDown(ev) {
  44844. if (this.opened) {
  44845. if ([core_converse.keycodes.ENTER, core_converse.keycodes.TAB].includes(ev.keyCode) && this.selected) {
  44846. ev.preventDefault();
  44847. ev.stopPropagation();
  44848. this.select();
  44849. return true;
  44850. } else if (ev.keyCode === core_converse.keycodes.ESCAPE) {
  44851. this.close({
  44852. 'reason': 'esc'
  44853. });
  44854. return true;
  44855. } else if ([core_converse.keycodes.UP_ARROW, core_converse.keycodes.DOWN_ARROW].includes(ev.keyCode)) {
  44856. ev.preventDefault();
  44857. ev.stopPropagation();
  44858. this[ev.keyCode === core_converse.keycodes.UP_ARROW ? "previous" : "next"]();
  44859. return true;
  44860. }
  44861. }
  44862. if ([core_converse.keycodes.SHIFT, core_converse.keycodes.META, core_converse.keycodes.META_RIGHT, core_converse.keycodes.ESCAPE, core_converse.keycodes.ALT].includes(ev.keyCode)) {
  44863. return;
  44864. }
  44865. if (this.ac_triggers.includes(ev.key)) {
  44866. if (ev.key === "Tab") {
  44867. ev.preventDefault();
  44868. }
  44869. this.auto_completing = true;
  44870. } else if (ev.key === "Backspace") {
  44871. const word = autocomplete_u.getCurrentWord(ev.target, ev.target.selectionEnd - 1);
  44872. if (utils_helpers.isMention(word, this.ac_triggers)) {
  44873. this.auto_completing = true;
  44874. }
  44875. }
  44876. }
  44877. async evaluate(ev) {
  44878. const selecting = this.selected && ev && (ev.keyCode === core_converse.keycodes.UP_ARROW || ev.keyCode === core_converse.keycodes.DOWN_ARROW);
  44879. if (!this.auto_evaluate && !this.auto_completing || selecting) {
  44880. return;
  44881. }
  44882. const list = typeof this._list === "function" ? await this._list() : this._list;
  44883. if (list.length === 0) {
  44884. return;
  44885. }
  44886. let value = this.match_current_word ? autocomplete_u.getCurrentWord(this.input) : this.input.value;
  44887. const contains_trigger = utils_helpers.isMention(value, this.ac_triggers);
  44888. if (contains_trigger) {
  44889. this.auto_completing = true;
  44890. if (!this.include_triggers.includes(ev.key)) {
  44891. value = autocomplete_u.isMentionBoundary(value[0]) ? value.slice('2') : value.slice('1');
  44892. }
  44893. }
  44894. if ((contains_trigger || value.length) && value.length >= this.min_chars) {
  44895. this.index = -1; // Populate list with options that match
  44896. this.ul.innerHTML = "";
  44897. this.suggestions = list.map(item => new suggestion(this.data(item, value), value)).filter(item => this.filter(item, value));
  44898. if (this.sort !== false) {
  44899. this.suggestions = this.suggestions.sort(this.sort);
  44900. }
  44901. this.suggestions = this.suggestions.slice(0, this.max_items);
  44902. this.suggestions.forEach(text => this.ul.appendChild(this.item(text, value)));
  44903. if (this.ul.children.length === 0) {
  44904. this.close({
  44905. 'reason': 'nomatches'
  44906. });
  44907. } else {
  44908. this.open();
  44909. }
  44910. } else {
  44911. this.close({
  44912. 'reason': 'nomatches'
  44913. });
  44914. if (!contains_trigger) {
  44915. this.auto_completing = false;
  44916. }
  44917. }
  44918. }
  44919. } // Make it an event emitter
  44920. Object.assign(AutoComplete.prototype, Events);
  44921. /* harmony default export */ const autocomplete = (AutoComplete);
  44922. ;// CONCATENATED MODULE: ./src/shared/autocomplete/component.js
  44923. class AutoCompleteComponent extends CustomElement {
  44924. static get properties() {
  44925. return {
  44926. 'getAutoCompleteList': {
  44927. type: Function
  44928. },
  44929. 'auto_evaluate': {
  44930. type: Boolean
  44931. },
  44932. 'auto_first': {
  44933. type: Boolean
  44934. },
  44935. // Should the first element be automatically selected?
  44936. 'filter': {
  44937. type: String
  44938. },
  44939. 'include_triggers': {
  44940. type: String
  44941. },
  44942. 'min_chars': {
  44943. type: Number
  44944. },
  44945. 'name': {
  44946. type: String
  44947. },
  44948. 'placeholder': {
  44949. type: String
  44950. },
  44951. 'triggers': {
  44952. type: String
  44953. }
  44954. };
  44955. }
  44956. constructor() {
  44957. super();
  44958. this.auto_evaluate = true; // Should evaluation happen automatically without any particular key as trigger?
  44959. this.auto_first = false; // Should the first element be automatically selected?
  44960. this.filter = 'contains';
  44961. this.include_triggers = ''; // Space separated chars which should be included in the returned value
  44962. this.match_current_word = false; // Match only the current word, otherwise all input is matched
  44963. this.max_items = 10;
  44964. this.min_chars = 1;
  44965. this.triggers = ''; // String of space separated chars
  44966. }
  44967. render() {
  44968. return $`
  44969. <div class="suggestion-box suggestion-box__name">
  44970. <ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
  44971. <input
  44972. type="text"
  44973. name="${this.name}"
  44974. autocomplete="off"
  44975. @keydown=${this.onKeyDown}
  44976. @keyup=${this.onKeyUp}
  44977. class="form-control suggestion-box__input"
  44978. placeholder="${this.placeholder}"
  44979. />
  44980. <span
  44981. class="suggestion-box__additions visually-hidden"
  44982. role="status"
  44983. aria-live="assertive"
  44984. aria-relevant="additions"
  44985. ></span>
  44986. </div>
  44987. `;
  44988. }
  44989. firstUpdated() {
  44990. this.auto_complete = new autocomplete(this.firstElementChild, {
  44991. 'ac_triggers': this.triggers.split(' '),
  44992. 'auto_evaluate': this.auto_evaluate,
  44993. 'auto_first': this.auto_first,
  44994. 'filter': this.filter == 'contains' ? FILTER_CONTAINS : FILTER_STARTSWITH,
  44995. 'include_triggers': [],
  44996. 'list': () => this.getAutoCompleteList(),
  44997. 'match_current_word': true,
  44998. 'max_items': this.max_items,
  44999. 'min_chars': this.min_chars
  45000. });
  45001. this.auto_complete.on('suggestion-box-selectcomplete', () => this.auto_completing = false);
  45002. }
  45003. onKeyDown(ev) {
  45004. this.auto_complete.onKeyDown(ev);
  45005. }
  45006. onKeyUp(ev) {
  45007. this.auto_complete.evaluate(ev);
  45008. }
  45009. }
  45010. core_api.elements.define('converse-autocomplete', AutoCompleteComponent);
  45011. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/autocomplete/styles/_autocomplete.scss
  45012. var _autocomplete = __webpack_require__(4921);
  45013. ;// CONCATENATED MODULE: ./src/shared/autocomplete/styles/_autocomplete.scss
  45014. var _autocomplete_options = {};
  45015. _autocomplete_options.styleTagTransform = (styleTagTransform_default());
  45016. _autocomplete_options.setAttributes = (setAttributesWithoutAttributes_default());
  45017. _autocomplete_options.insert = insertBySelector_default().bind(null, "head");
  45018. _autocomplete_options.domAPI = (styleDomAPI_default());
  45019. _autocomplete_options.insertStyleElement = (insertStyleElement_default());
  45020. var _autocomplete_update = injectStylesIntoStyleTag_default()(_autocomplete/* default */.Z, _autocomplete_options);
  45021. /* harmony default export */ const styles_autocomplete = (_autocomplete/* default */.Z && _autocomplete/* default.locals */.Z.locals ? _autocomplete/* default.locals */.Z.locals : undefined);
  45022. ;// CONCATENATED MODULE: ./src/shared/autocomplete/index.js
  45023. shared_converse.FILTER_CONTAINS = FILTER_CONTAINS;
  45024. shared_converse.FILTER_STARTSWITH = FILTER_STARTSWITH;
  45025. shared_converse.AutoComplete = autocomplete;
  45026. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/ad-hoc-command-form.js
  45027. /* harmony default export */ const ad_hoc_command_form = ((o, command) => {
  45028. const i18n_hide = __('Hide');
  45029. const i18n_run = __('Execute');
  45030. return $`
  45031. <form @submit=${o.runCommand}>
  45032. ${command.alert ? $`<div class="alert alert-${command.alert_type}" role="alert">${command.alert}</div>` : ''}
  45033. <fieldset class="form-group">
  45034. <input type="hidden" name="command_node" value="${command.node}"/>
  45035. <input type="hidden" name="command_jid" value="${command.jid}"/>
  45036. <p class="form-help">${command.instructions}</p>
  45037. ${command.fields}
  45038. </fieldset>
  45039. <fieldset>
  45040. <input type="submit" class="btn btn-primary" value="${i18n_run}">
  45041. <input type="button" class="btn btn-secondary button-cancel" value="${i18n_hide}" @click=${o.hideCommandForm}>
  45042. </fieldset>
  45043. </form>
  45044. `;
  45045. });
  45046. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/ad-hoc-command.js
  45047. /* harmony default export */ const ad_hoc_command = ((o, command) => $`
  45048. <li class="room-item list-group-item">
  45049. <div class="available-chatroom d-flex flex-row">
  45050. <a class="open-room available-room w-100"
  45051. @click=${o.toggleCommandForm}
  45052. data-command-node="${command.node}"
  45053. data-command-jid="${command.jid}"
  45054. data-command-name="${command.name}"
  45055. title="${command.name}"
  45056. href="#">${command.name || command.jid}</a>
  45057. </div>
  45058. ${command.node === o.showform ? ad_hoc_command_form(o, command) : ''}
  45059. </li>
  45060. `);
  45061. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/moderator-tools.js
  45062. function getRoleHelpText(role) {
  45063. if (role === 'moderator') {
  45064. return __("Moderators are privileged users who can change the roles of other users (except those with admin or owner affiliations.");
  45065. } else if (role === 'participant') {
  45066. return __("The default role, implies that you can read and write messages.");
  45067. } else if (role == 'visitor') {
  45068. return __("Visitors aren't allowed to write messages in a moderated multi-user chat.");
  45069. }
  45070. }
  45071. function getAffiliationHelpText(aff) {
  45072. if (aff === 'owner') {
  45073. return __("Owner is the highest affiliation. Owners can modify roles and affiliations of all other users.");
  45074. } else if (aff === 'admin') {
  45075. return __("Admin is the 2nd highest affiliation. Admins can modify roles and affiliations of all other users except owners.");
  45076. } else if (aff === 'outcast') {
  45077. return __("To ban a user, you give them the affiliation of \"outcast\".");
  45078. }
  45079. }
  45080. const role_option = o => $`
  45081. <option value="${o.item || ''}"
  45082. ?selected=${o.item === o.role}
  45083. title="${getRoleHelpText(o.item)}">${o.item}</option>
  45084. `;
  45085. const affiliation_option = o => $`
  45086. <option value="${o.item || ''}"
  45087. ?selected=${o.item === o.affiliation}
  45088. title="${getAffiliationHelpText(o.item)}">${o.item}</option>
  45089. `;
  45090. const tpl_set_role_form = o => {
  45091. const i18n_change_role = __('Change role');
  45092. const i18n_new_role = __('New Role');
  45093. const i18n_reason = __('Reason');
  45094. return $`
  45095. <form class="role-form hidden" @submit=${o.assignRole}>
  45096. <div class="form-group">
  45097. <input type="hidden" name="jid" value="${o.item.jid}"/>
  45098. <input type="hidden" name="nick" value="${o.item.nick}"/>
  45099. <div class="row">
  45100. <div class="col">
  45101. <label><strong>${i18n_new_role}:</strong></label>
  45102. <select class="custom-select select-role" name="role">
  45103. ${o.assignable_roles.map(role => $`<option value="${role}" ?selected=${role === o.item.role}>${role}</option>`)}
  45104. </select>
  45105. </div>
  45106. <div class="col">
  45107. <label><strong>${i18n_reason}:</strong></label>
  45108. <input class="form-control" type="text" name="reason"/>
  45109. </div>
  45110. </div>
  45111. </div>
  45112. <div class="form-group">
  45113. <input type="submit" class="btn btn-primary" value="${i18n_change_role}"/>
  45114. </div>
  45115. </form>
  45116. `;
  45117. };
  45118. const role_form_toggle = o => $`
  45119. <a href="#" data-form="role-form" class="toggle-form right" color="var(--subdued-color)" @click=${o.toggleForm}>
  45120. <converse-icon class="fa fa-wrench" size="1em"></converse-icon>
  45121. </a>`;
  45122. const role_list_item = o => $`
  45123. <li class="list-group-item" data-nick="${o.item.nick}">
  45124. <ul class="list-group">
  45125. <li class="list-group-item active">
  45126. <div><strong>JID:</strong> ${o.item.jid}</div>
  45127. </li>
  45128. <li class="list-group-item">
  45129. <div><strong>Nickname:</strong> ${o.item.nick}</div>
  45130. </li>
  45131. <li class="list-group-item">
  45132. <div><strong>Role:</strong> ${o.item.role} ${o.assignable_roles.length ? role_form_toggle(o) : ''}</div>
  45133. ${o.assignable_roles.length ? tpl_set_role_form(o) : ''}
  45134. </li>
  45135. </ul>
  45136. </li>
  45137. `;
  45138. const tpl_set_affiliation_form = o => {
  45139. const i18n_change_affiliation = __('Change affiliation');
  45140. const i18n_new_affiliation = __('New affiliation');
  45141. const i18n_reason = __('Reason');
  45142. return $`
  45143. <form class="affiliation-form hidden" @submit=${o.assignAffiliation}>
  45144. <div class="form-group">
  45145. <input type="hidden" name="jid" value="${o.item.jid}"/>
  45146. <input type="hidden" name="nick" value="${o.item.nick}"/>
  45147. <div class="row">
  45148. <div class="col">
  45149. <label><strong>${i18n_new_affiliation}:</strong></label>
  45150. <select class="custom-select select-affiliation" name="affiliation">
  45151. ${o.assignable_affiliations.map(aff => $`<option value="${aff}" ?selected=${aff === o.item.affiliation}>${aff}</option>`)}
  45152. </select>
  45153. </div>
  45154. <div class="col">
  45155. <label><strong>${i18n_reason}:</strong></label>
  45156. <input class="form-control" type="text" name="reason"/>
  45157. </div>
  45158. </div>
  45159. </div>
  45160. <div class="form-group">
  45161. <input type="submit" class="btn btn-primary" name="change" value="${i18n_change_affiliation}"/>
  45162. </div>
  45163. </form>
  45164. `;
  45165. };
  45166. const affiliation_form_toggle = o => $`
  45167. <a href="#" data-form="affiliation-form" class="toggle-form right" color="var(--subdued-color)" @click=${o.toggleForm}>
  45168. <converse-icon class="fa fa-wrench" size="1em"></converse-icon>
  45169. </a>`;
  45170. const affiliation_list_item = o => $`
  45171. <li class="list-group-item" data-nick="${o.item.nick}">
  45172. <ul class="list-group">
  45173. <li class="list-group-item active">
  45174. <div><strong>JID:</strong> ${o.item.jid}</div>
  45175. </li>
  45176. <li class="list-group-item">
  45177. <div><strong>Nickname:</strong> ${o.item.nick}</div>
  45178. </li>
  45179. <li class="list-group-item">
  45180. <div><strong>Affiliation:</strong> ${o.item.affiliation} ${o.assignable_affiliations.length ? affiliation_form_toggle(o) : ''}</div>
  45181. ${o.assignable_affiliations.length ? tpl_set_affiliation_form(o) : ''}
  45182. </li>
  45183. </ul>
  45184. </li>
  45185. `;
  45186. const tpl_navigation = () => $`
  45187. <ul class="nav nav-pills justify-content-center">
  45188. <li role="presentation" class="nav-item">
  45189. <a class="nav-link active" id="affiliations-tab" href="#affiliations-tabpanel" aria-controls="affiliations-tabpanel" role="tab" data-toggle="tab">Affiliations</a>
  45190. </li>
  45191. <li role="presentation" class="nav-item">
  45192. <a class="nav-link" id="roles-tab" href="#roles-tabpanel" aria-controls="roles-tabpanel" role="tab" data-toggle="tab">Roles</a>
  45193. </li>
  45194. </ul>
  45195. `;
  45196. /* harmony default export */ const moderator_tools = (o => {
  45197. const i18n_affiliation = __('Affiliation');
  45198. const i18n_no_users_with_aff = __('No users with that affiliation found.');
  45199. const i18n_no_users_with_role = __('No users with that role found.');
  45200. const i18n_filter = __('Type here to filter the search results');
  45201. const i18n_role = __('Role');
  45202. const i18n_show_users = __('Show users');
  45203. const i18n_helptext_role = __("Roles are assigned to users to grant or deny them certain abilities in a multi-user chat. " + "They're assigned either explicitly or implicitly as part of an affiliation. " + "A role that's not due to an affiliation, is only valid for the duration of the user's session.");
  45204. const i18n_helptext_affiliation = __("An affiliation is a long-lived entitlement which typically implies a certain role and which " + "grants privileges and responsibilities. For example admins and owners automatically have the " + "moderator role.");
  45205. const show_both_tabs = o.queryable_roles.length && o.queryable_affiliations.length;
  45206. return $`
  45207. ${o.alert_message ? $`<div class="alert alert-${o.alert_type}" role="alert">${o.alert_message}</div>` : ''}
  45208. ${show_both_tabs ? tpl_navigation() : ''}
  45209. <div class="tab-content">
  45210. ${o.queryable_affiliations.length ? $`
  45211. <div class="tab-pane tab-pane--columns ${o.queryable_affiliations.length ? 'active' : ''}" id="affiliations-tabpanel" role="tabpanel" aria-labelledby="affiliations-tab">
  45212. <form class="converse-form query-affiliation" @submit=${o.queryAffiliation}>
  45213. <p class="helptext pb-3">${i18n_helptext_affiliation}</p>
  45214. <div class="form-group">
  45215. <label for="affiliation">
  45216. <strong>${i18n_affiliation}:</strong>
  45217. </label>
  45218. <div class="row">
  45219. <div class="col">
  45220. <select class="custom-select select-affiliation" name="affiliation">
  45221. ${o.queryable_affiliations.map(item => affiliation_option(Object.assign({
  45222. item
  45223. }, o)))}
  45224. </select>
  45225. </div>
  45226. <div class="col">
  45227. <input type="submit" class="btn btn-primary" name="users_with_affiliation" value="${i18n_show_users}"/>
  45228. </div>
  45229. </div>
  45230. <div class="row">
  45231. <div class="col mt-3">
  45232. ${Array.isArray(o.users_with_affiliation) && o.users_with_affiliation.length > 5 ? $`<input class="form-control" .value="${o.affiliations_filter}" @keyup=${o.filterAffiliationResults} type="text" name="filter" placeholder="${i18n_filter}"/>` : ''}
  45233. </div>
  45234. </div>
  45235. ${getAffiliationHelpText(o.affiliation) ? $`<div class="row"><div class="col pt-2"><p class="helptext pb-3">${getAffiliationHelpText(o.affiliation)}</p></div></div>` : ''}
  45236. </div>
  45237. </form>
  45238. <div class="scrollable-container">
  45239. <ul class="list-group list-group--users">
  45240. ${o.loading_users_with_affiliation ? $`<li class="list-group-item"> ${spinner()} </li>` : ''}
  45241. ${Array.isArray(o.users_with_affiliation) && o.users_with_affiliation.length === 0 ? $`<li class="list-group-item">${i18n_no_users_with_aff}</li>` : ''}
  45242. ${o.users_with_affiliation instanceof Error ? $`<li class="list-group-item">${o.users_with_affiliation.message}</li>` : (o.users_with_affiliation || []).map(item => (item.nick || item.jid).match(new RegExp(o.affiliations_filter, 'i')) ? affiliation_list_item(Object.assign({
  45243. item
  45244. }, o)) : '')}
  45245. </ul>
  45246. </div>
  45247. </div>` : ''}
  45248. ${o.queryable_roles.length ? $`
  45249. <div class="tab-pane tab-pane--columns ${!show_both_tabs && o.queryable_roles.length ? 'active' : ''}" id="roles-tabpanel" role="tabpanel" aria-labelledby="roles-tab">
  45250. <form class="converse-form query-role" @submit=${o.queryRole}>
  45251. <p class="helptext pb-3">${i18n_helptext_role}</p>
  45252. <div class="form-group">
  45253. <label for="role"><strong>${i18n_role}:</strong></label>
  45254. <div class="row">
  45255. <div class="col">
  45256. <select class="custom-select select-role" name="role">
  45257. ${o.queryable_roles.map(item => role_option(Object.assign({
  45258. item
  45259. }, o)))}
  45260. </select>
  45261. </div>
  45262. <div class="col">
  45263. <input type="submit" class="btn btn-primary" name="users_with_role" value="${i18n_show_users}"/>
  45264. </div>
  45265. </div>
  45266. <div class="row">
  45267. <div class="col mt-3">
  45268. ${Array.isArray(o.users_with_role) && o.users_with_role.length > 5 ? $`<input class="form-control" .value="${o.roles_filter}" @keyup=${o.filterRoleResults} type="text" name="filter" placeholder="${i18n_filter}"/>` : ''}
  45269. </div>
  45270. </div>
  45271. ${getRoleHelpText(o.role) ? $`<div class="row"><div class="col pt-2"><p class="helptext pb-3">${getRoleHelpText(o.role)}</p></div></div>` : ''}
  45272. </div>
  45273. </form>
  45274. <div class="scrollable-container">
  45275. <ul class="list-group list-group--users">
  45276. ${o.loading_users_with_role ? $`<li class="list-group-item"> ${spinner()} </li>` : ''}
  45277. ${o.users_with_role && o.users_with_role.length === 0 ? $`<li class="list-group-item">${i18n_no_users_with_role}</li>` : ''}
  45278. ${(o.users_with_role || []).map(item => item.nick.match(o.roles_filter) ? role_list_item(Object.assign({
  45279. item
  45280. }, o)) : '')}
  45281. </ul>
  45282. </div>
  45283. </div>` : ''}
  45284. </div>`;
  45285. });
  45286. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modtools.js
  45287. const {
  45288. Strophe: modtools_Strophe,
  45289. sizzle: modtools_sizzle,
  45290. u: modtools_u
  45291. } = core_converse.env;
  45292. class ModeratorTools extends CustomElement {
  45293. static get properties() {
  45294. return {
  45295. affiliation: {
  45296. type: String
  45297. },
  45298. affiliations_filter: {
  45299. type: String,
  45300. attribute: false
  45301. },
  45302. alert_message: {
  45303. type: String,
  45304. attribute: false
  45305. },
  45306. alert_type: {
  45307. type: String,
  45308. attribute: false
  45309. },
  45310. jid: {
  45311. type: String
  45312. },
  45313. muc: {
  45314. type: Object,
  45315. attribute: false
  45316. },
  45317. role: {
  45318. type: String
  45319. },
  45320. roles_filter: {
  45321. type: String,
  45322. attribute: false
  45323. },
  45324. users_with_affiliation: {
  45325. type: Array,
  45326. attribute: false
  45327. },
  45328. users_with_role: {
  45329. type: Array,
  45330. attribute: false
  45331. }
  45332. };
  45333. }
  45334. constructor() {
  45335. super();
  45336. this.affiliation = '';
  45337. this.affiliations_filter = '';
  45338. this.role = '';
  45339. this.roles_filter = '';
  45340. }
  45341. updated(changed) {
  45342. changed.has('role') && this.onSearchRoleChange();
  45343. changed.has('affiliation') && this.onSearchAffiliationChange();
  45344. changed.has('jid') && changed.get('jid') && this.initialize();
  45345. }
  45346. async initialize() {
  45347. this.initialized = getOpenPromise();
  45348. const muc = await core_api.rooms.get(this.jid);
  45349. await muc.initialized;
  45350. this.muc = muc;
  45351. this.initialized.resolve();
  45352. }
  45353. render() {
  45354. var _this$muc;
  45355. if ((_this$muc = this.muc) !== null && _this$muc !== void 0 && _this$muc.occupants) {
  45356. const occupant = this.muc.occupants.findWhere({
  45357. 'jid': shared_converse.bare_jid
  45358. });
  45359. return moderator_tools({
  45360. 'affiliations_filter': this.affiliations_filter,
  45361. 'alert_message': this.alert_message,
  45362. 'alert_type': this.alert_type,
  45363. 'assignAffiliation': ev => this.assignAffiliation(ev),
  45364. 'assignRole': ev => this.assignRole(ev),
  45365. 'assignable_affiliations': getAssignableAffiliations(occupant),
  45366. 'assignable_roles': getAssignableRoles(occupant),
  45367. 'filterAffiliationResults': ev => this.filterAffiliationResults(ev),
  45368. 'filterRoleResults': ev => this.filterRoleResults(ev),
  45369. 'loading_users_with_affiliation': this.loading_users_with_affiliation,
  45370. 'queryAffiliation': ev => this.queryAffiliation(ev),
  45371. 'queryRole': ev => this.queryRole(ev),
  45372. 'queryable_affiliations': AFFILIATIONS.filter(a => !core_api.settings.get('modtools_disable_query').includes(a)),
  45373. 'queryable_roles': ROLES.filter(a => !core_api.settings.get('modtools_disable_query').includes(a)),
  45374. 'roles_filter': this.roles_filter,
  45375. 'switchTab': ev => this.switchTab(ev),
  45376. 'toggleForm': ev => this.toggleForm(ev),
  45377. 'users_with_affiliation': this.users_with_affiliation,
  45378. 'users_with_role': this.users_with_role
  45379. });
  45380. } else {
  45381. return '';
  45382. }
  45383. }
  45384. async onSearchAffiliationChange() {
  45385. if (!this.affiliation) {
  45386. return;
  45387. }
  45388. await this.initialized;
  45389. this.clearAlert();
  45390. this.loading_users_with_affiliation = true;
  45391. this.users_with_affiliation = null;
  45392. if (this.shouldFetchAffiliationsList()) {
  45393. const result = await getAffiliationList(this.affiliation, this.jid);
  45394. if (result instanceof Error) {
  45395. this.alert(result.message, 'danger');
  45396. this.users_with_affiliation = [];
  45397. } else {
  45398. this.users_with_affiliation = result;
  45399. }
  45400. } else {
  45401. this.users_with_affiliation = this.muc.getOccupantsWithAffiliation(this.affiliation);
  45402. }
  45403. this.loading_users_with_affiliation = false;
  45404. }
  45405. async onSearchRoleChange() {
  45406. if (!this.role) {
  45407. return;
  45408. }
  45409. await this.initialized;
  45410. this.clearAlert();
  45411. this.users_with_role = this.muc.getOccupantsWithRole(this.role);
  45412. }
  45413. shouldFetchAffiliationsList() {
  45414. const affiliation = this.affiliation;
  45415. if (affiliation === 'none') {
  45416. return false;
  45417. }
  45418. const auto_fetched_affs = getAutoFetchedAffiliationLists();
  45419. if (auto_fetched_affs.includes(affiliation)) {
  45420. return false;
  45421. } else {
  45422. return true;
  45423. }
  45424. }
  45425. toggleForm(ev) {
  45426. // eslint-disable-line class-methods-use-this
  45427. ev.stopPropagation();
  45428. ev.preventDefault();
  45429. const toggle = modtools_u.ancestor(ev.target, '.toggle-form');
  45430. const form_class = toggle.getAttribute('data-form');
  45431. const form = modtools_u.ancestor(toggle, '.list-group-item').querySelector(`.${form_class}`);
  45432. if (modtools_u.hasClass('hidden', form)) {
  45433. modtools_u.removeClass('hidden', form);
  45434. } else {
  45435. modtools_u.addClass('hidden', form);
  45436. }
  45437. }
  45438. filterRoleResults(ev) {
  45439. this.roles_filter = ev.target.value;
  45440. this.render();
  45441. }
  45442. filterAffiliationResults(ev) {
  45443. this.affiliations_filter = ev.target.value;
  45444. }
  45445. queryRole(ev) {
  45446. ev.stopPropagation();
  45447. ev.preventDefault();
  45448. const data = new FormData(ev.target);
  45449. const role = data.get('role');
  45450. this.role = null;
  45451. this.role = role;
  45452. }
  45453. queryAffiliation(ev) {
  45454. ev.stopPropagation();
  45455. ev.preventDefault();
  45456. const data = new FormData(ev.target);
  45457. const affiliation = data.get('affiliation');
  45458. this.affiliation = null;
  45459. this.affiliation = affiliation;
  45460. }
  45461. alert(message, type) {
  45462. this.alert_message = message;
  45463. this.alert_type = type;
  45464. }
  45465. clearAlert() {
  45466. this.alert_message = undefined;
  45467. this.alert_type = undefined;
  45468. }
  45469. async assignAffiliation(ev) {
  45470. ev.stopPropagation();
  45471. ev.preventDefault();
  45472. this.clearAlert();
  45473. const data = new FormData(ev.target);
  45474. const affiliation = data.get('affiliation');
  45475. const attrs = {
  45476. 'jid': data.get('jid'),
  45477. 'reason': data.get('reason')
  45478. };
  45479. const current_affiliation = this.affiliation;
  45480. const muc_jid = this.muc.get('jid');
  45481. try {
  45482. await setAffiliation(affiliation, muc_jid, [attrs]);
  45483. } catch (e) {
  45484. if (e === null) {
  45485. this.alert(__('Timeout error while trying to set the affiliation'), 'danger');
  45486. } else if (modtools_sizzle(`not-allowed[xmlns="${modtools_Strophe.NS.STANZAS}"]`, e).length) {
  45487. this.alert(__("Sorry, you're not allowed to make that change"), 'danger');
  45488. } else {
  45489. this.alert(__('Sorry, something went wrong while trying to set the affiliation'), 'danger');
  45490. }
  45491. headless_log.error(e);
  45492. return;
  45493. }
  45494. await this.muc.occupants.fetchMembers();
  45495. this.affiliation = null;
  45496. this.affiliation = current_affiliation;
  45497. this.alert(__('Affiliation changed'), 'primary');
  45498. }
  45499. assignRole(ev) {
  45500. ev.stopPropagation();
  45501. ev.preventDefault();
  45502. this.clearAlert();
  45503. const data = new FormData(ev.target);
  45504. const occupant = this.muc.getOccupant(data.get('jid') || data.get('nick'));
  45505. const role = data.get('role');
  45506. const reason = data.get('reason');
  45507. const current_role = this.role;
  45508. this.muc.setRole(occupant, role, reason, () => {
  45509. this.alert(__('Role changed'), 'primary');
  45510. this.role = null;
  45511. this.role = current_role;
  45512. }, e => {
  45513. if (modtools_sizzle(`not-allowed[xmlns="${modtools_Strophe.NS.STANZAS}"]`, e).length) {
  45514. this.alert(__("You're not allowed to make that change"), 'danger');
  45515. } else {
  45516. this.alert(__('Sorry, something went wrong while trying to set the role'), 'danger');
  45517. if (modtools_u.isErrorObject(e)) {
  45518. headless_log.error(e);
  45519. }
  45520. }
  45521. });
  45522. }
  45523. }
  45524. core_api.elements.define('converse-modtools', ModeratorTools);
  45525. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/templates/moderator-tools.js
  45526. /* harmony default export */ const templates_moderator_tools = (o => {
  45527. const i18n_moderator_tools = __('Moderator Tools');
  45528. return $`
  45529. <div class="modal-dialog" role="document">
  45530. <div class="modal-content">
  45531. <div class="modal-header">
  45532. <h5 class="modal-title" id="converse-modtools-modal-label">${i18n_moderator_tools}</h5>
  45533. ${modal_header_close_button}
  45534. </div>
  45535. <div class="modal-body d-flex flex-column">
  45536. <converse-modtools jid=${o.jid} affiliation=${o.affiliation}></converse-modtools>
  45537. </div>
  45538. </div>
  45539. </div>`;
  45540. });
  45541. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/moderator-tools.js
  45542. const ModeratorToolsModal = base.extend({
  45543. id: "converse-modtools-modal",
  45544. persistent: true,
  45545. initialize(attrs) {
  45546. this.jid = attrs.jid;
  45547. this.affiliation = attrs.affiliation;
  45548. base.prototype.initialize.apply(this, arguments);
  45549. },
  45550. toHTML() {
  45551. return templates_moderator_tools(this);
  45552. }
  45553. });
  45554. /* harmony default export */ const modals_moderator_tools = (ModeratorToolsModal);
  45555. ;// CONCATENATED MODULE: ./src/plugins/muc-views/utils.js
  45556. const {
  45557. Strophe: muc_views_utils_Strophe,
  45558. $iq: muc_views_utils_$iq,
  45559. sizzle: muc_views_utils_sizzle,
  45560. u: muc_views_utils_u
  45561. } = core_converse.env;
  45562. const COMMAND_TO_AFFILIATION = {
  45563. 'admin': 'admin',
  45564. 'ban': 'outcast',
  45565. 'member': 'member',
  45566. 'owner': 'owner',
  45567. 'revoke': 'none'
  45568. };
  45569. const COMMAND_TO_ROLE = {
  45570. 'deop': 'participant',
  45571. 'kick': 'none',
  45572. 'mute': 'visitor',
  45573. 'op': 'moderator',
  45574. 'voice': 'participant'
  45575. };
  45576. function utils_clearHistory(jid) {
  45577. if (shared_converse.router.history.getFragment() === `converse/room?jid=${jid}`) {
  45578. shared_converse.router.navigate('');
  45579. }
  45580. }
  45581. async function destroyMUC(model) {
  45582. const messages = [__('Are you sure you want to destroy this groupchat?')];
  45583. let fields = [{
  45584. 'name': 'challenge',
  45585. 'label': __('Please enter the XMPP address of this groupchat to confirm'),
  45586. 'challenge': model.get('jid'),
  45587. 'placeholder': __('name@example.org'),
  45588. 'required': true
  45589. }, {
  45590. 'name': 'reason',
  45591. 'label': __('Optional reason for destroying this groupchat'),
  45592. 'placeholder': __('Reason')
  45593. }, {
  45594. 'name': 'newjid',
  45595. 'label': __('Optional XMPP address for a new groupchat that replaces this one'),
  45596. 'placeholder': __('replacement@example.org')
  45597. }];
  45598. try {
  45599. var _fields$filter$pop, _fields$filter$pop2;
  45600. fields = await core_api.confirm(__('Confirm'), messages, fields);
  45601. const reason = (_fields$filter$pop = fields.filter(f => f.name === 'reason').pop()) === null || _fields$filter$pop === void 0 ? void 0 : _fields$filter$pop.value;
  45602. const newjid = (_fields$filter$pop2 = fields.filter(f => f.name === 'newjid').pop()) === null || _fields$filter$pop2 === void 0 ? void 0 : _fields$filter$pop2.value;
  45603. return model.sendDestroyIQ(reason, newjid).then(() => model.close());
  45604. } catch (e) {
  45605. headless_log.error(e);
  45606. }
  45607. }
  45608. function getNicknameRequiredTemplate(model) {
  45609. const jid = model.get('jid');
  45610. if (core_api.settings.get('muc_show_logs_before_join')) {
  45611. return $`<converse-muc-chatarea jid="${jid}"></converse-muc-chatarea>`;
  45612. } else {
  45613. return $`<converse-muc-nickname-form jid="${jid}"></converse-muc-nickname-form>`;
  45614. }
  45615. }
  45616. function getChatRoomBodyTemplate(o) {
  45617. const view = o.model.session.get('view');
  45618. const jid = o.model.get('jid');
  45619. const RS = core_converse.ROOMSTATUS;
  45620. const conn_status = o.model.session.get('connection_status');
  45621. if (view === core_converse.MUC.VIEWS.CONFIG) {
  45622. return $`<converse-muc-config-form class="muc-form-container" jid="${jid}"></converse-muc-config-form>`;
  45623. } else {
  45624. return $`
  45625. ${conn_status == RS.PASSWORD_REQUIRED ? $`<converse-muc-password-form class="muc-form-container" jid="${jid}"></converse-muc-password-form>` : ''}
  45626. ${conn_status == RS.ENTERED ? $`<converse-muc-chatarea jid="${jid}"></converse-muc-chatarea>` : ''}
  45627. ${conn_status == RS.CONNECTING ? spinner() : ''}
  45628. ${conn_status == RS.NICKNAME_REQUIRED ? getNicknameRequiredTemplate(o.model) : ''}
  45629. ${conn_status == RS.DISCONNECTED ? $`<converse-muc-disconnected jid="${jid}"></converse-muc-disconnected>` : ''}
  45630. ${conn_status == RS.BANNED ? $`<converse-muc-disconnected jid="${jid}"></converse-muc-disconnected>` : ''}
  45631. ${conn_status == RS.DESTROYED ? $`<converse-muc-destroyed jid="${jid}"></converse-muc-destroyed>` : ''}
  45632. `;
  45633. }
  45634. }
  45635. function getAutoCompleteListItem(text, input) {
  45636. input = input.trim();
  45637. const element = document.createElement('li');
  45638. element.setAttribute('aria-selected', 'false');
  45639. if (core_api.settings.get('muc_mention_autocomplete_show_avatar')) {
  45640. const img = document.createElement('img');
  45641. let dataUri = 'data:' + shared_converse.DEFAULT_IMAGE_TYPE + ';base64,' + shared_converse.DEFAULT_IMAGE;
  45642. if (shared_converse.vcards) {
  45643. const vcard = shared_converse.vcards.findWhere({
  45644. 'nickname': text
  45645. });
  45646. if (vcard) dataUri = 'data:' + vcard.get('image_type') + ';base64,' + vcard.get('image');
  45647. }
  45648. img.setAttribute('src', dataUri);
  45649. img.setAttribute('width', '22');
  45650. img.setAttribute('class', 'avatar avatar-autocomplete');
  45651. element.appendChild(img);
  45652. }
  45653. const regex = new RegExp('(' + input + ')', 'ig');
  45654. const parts = input ? text.split(regex) : [text];
  45655. parts.forEach(txt => {
  45656. if (input && txt.match(regex)) {
  45657. const match = document.createElement('mark');
  45658. match.textContent = txt;
  45659. element.appendChild(match);
  45660. } else {
  45661. element.appendChild(document.createTextNode(txt));
  45662. }
  45663. });
  45664. return element;
  45665. }
  45666. async function getAutoCompleteList() {
  45667. const models = [...(await core_api.rooms.get()), ...(await core_api.contacts.get())];
  45668. const jids = [...new Set(models.map(o => muc_views_utils_Strophe.getDomainFromJid(o.get('jid'))))];
  45669. return jids;
  45670. }
  45671. async function fetchCommandForm(command) {
  45672. const node = command.node;
  45673. const jid = command.jid;
  45674. const stanza = muc_views_utils_$iq({
  45675. 'type': 'set',
  45676. 'to': jid
  45677. }).c('command', {
  45678. 'xmlns': muc_views_utils_Strophe.NS.ADHOC,
  45679. 'node': node,
  45680. 'action': 'execute'
  45681. });
  45682. try {
  45683. var _sizzle$pop;
  45684. const iq = await core_api.sendIQ(stanza);
  45685. const cmd_el = muc_views_utils_sizzle(`command[xmlns="${muc_views_utils_Strophe.NS.ADHOC}"]`, iq).pop();
  45686. command.sessionid = cmd_el.getAttribute('sessionid');
  45687. command.instructions = (_sizzle$pop = muc_views_utils_sizzle('x[type="form"][xmlns="jabber:x:data"] instructions', cmd_el).pop()) === null || _sizzle$pop === void 0 ? void 0 : _sizzle$pop.textContent;
  45688. command.fields = muc_views_utils_sizzle('x[type="form"][xmlns="jabber:x:data"] field', cmd_el).map(f => muc_views_utils_u.xForm2TemplateResult(f, cmd_el));
  45689. } catch (e) {
  45690. if (e === null) {
  45691. headless_log.error(`Error: timeout while trying to execute command for ${jid}`);
  45692. } else {
  45693. headless_log.error(`Error while trying to execute command for ${jid}`);
  45694. headless_log.error(e);
  45695. }
  45696. command.fields = [];
  45697. }
  45698. }
  45699. function setRole(muc, command, args) {
  45700. let required_affiliations = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
  45701. let required_roles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
  45702. const role = COMMAND_TO_ROLE[command];
  45703. if (!role) {
  45704. throw Error(`ChatRoomView#setRole called with invalid command: ${command}`);
  45705. }
  45706. if (!muc.verifyAffiliations(required_affiliations) || !muc.verifyRoles(required_roles)) {
  45707. return false;
  45708. }
  45709. if (!muc.validateRoleOrAffiliationChangeArgs(command, args)) {
  45710. return false;
  45711. }
  45712. const nick_or_jid = muc.getNickOrJIDFromCommandArgs(args);
  45713. if (!nick_or_jid) {
  45714. return false;
  45715. }
  45716. const reason = args.split(nick_or_jid, 2)[1].trim(); // We're guaranteed to have an occupant due to getNickOrJIDFromCommandArgs
  45717. const occupant = muc.getOccupant(nick_or_jid);
  45718. muc.setRole(occupant, role, reason, undefined, e => muc.onCommandError(e));
  45719. return true;
  45720. }
  45721. function verifyAndSetAffiliation(muc, command, args, required_affiliations) {
  45722. const affiliation = COMMAND_TO_AFFILIATION[command];
  45723. if (!affiliation) {
  45724. throw Error(`verifyAffiliations called with invalid command: ${command}`);
  45725. }
  45726. if (!muc.verifyAffiliations(required_affiliations)) {
  45727. return false;
  45728. }
  45729. if (!muc.validateRoleOrAffiliationChangeArgs(command, args)) {
  45730. return false;
  45731. }
  45732. const nick_or_jid = muc.getNickOrJIDFromCommandArgs(args);
  45733. if (!nick_or_jid) {
  45734. return false;
  45735. }
  45736. let jid;
  45737. const reason = args.split(nick_or_jid, 2)[1].trim();
  45738. const occupant = muc.getOccupant(nick_or_jid);
  45739. if (occupant) {
  45740. jid = occupant.get('jid');
  45741. } else {
  45742. if (muc_views_utils_u.isValidJID(nick_or_jid)) {
  45743. jid = nick_or_jid;
  45744. } else {
  45745. const message = __("Couldn't find a participant with that nickname. " + 'They might have left the groupchat.');
  45746. muc.createMessage({
  45747. message,
  45748. 'type': 'error'
  45749. });
  45750. return;
  45751. }
  45752. }
  45753. const attrs = {
  45754. jid,
  45755. reason
  45756. };
  45757. if (occupant && core_api.settings.get('auto_register_muc_nickname')) {
  45758. attrs['nick'] = occupant.get('nick');
  45759. }
  45760. setAffiliation(affiliation, muc.get('jid'), [attrs]).then(() => muc.occupants.fetchMembers()).catch(err => muc.onCommandError(err));
  45761. }
  45762. function showModeratorToolsModal(muc, affiliation) {
  45763. if (!muc.verifyRoles(['moderator'])) {
  45764. return;
  45765. }
  45766. let modal = core_api.modal.get(modals_moderator_tools.id);
  45767. if (modal) {
  45768. modal.affiliation = affiliation;
  45769. modal.render();
  45770. } else {
  45771. modal = core_api.modal.create(modals_moderator_tools, {
  45772. affiliation,
  45773. 'jid': muc.get('jid')
  45774. });
  45775. }
  45776. modal.show();
  45777. }
  45778. function showOccupantModal(ev, occupant) {
  45779. core_api.modal.show(modals_occupant, {
  45780. 'model': occupant
  45781. }, ev);
  45782. }
  45783. function parseMessageForMUCCommands(data, handled) {
  45784. const model = data.model;
  45785. if (handled || model.get('type') !== shared_converse.CHATROOMS_TYPE || core_api.settings.get('muc_disable_slash_commands') && !Array.isArray(core_api.settings.get('muc_disable_slash_commands'))) {
  45786. return handled;
  45787. }
  45788. let text = data.text;
  45789. text = text.replace(/^\s*/, '');
  45790. const command = (text.match(/^\/([a-zA-Z]*) ?/) || ['']).pop().toLowerCase();
  45791. if (!command) {
  45792. return false;
  45793. }
  45794. const args = text.slice(('/' + command).length + 1).trim();
  45795. const allowed_commands = model.getAllowedCommands() ?? [];
  45796. if (command === 'admin' && allowed_commands.includes(command)) {
  45797. verifyAndSetAffiliation(model, command, args, ['owner']);
  45798. return true;
  45799. } else if (command === 'ban' && allowed_commands.includes(command)) {
  45800. verifyAndSetAffiliation(model, command, args, ['admin', 'owner']);
  45801. return true;
  45802. } else if (command === 'modtools' && allowed_commands.includes(command)) {
  45803. showModeratorToolsModal(model, args);
  45804. return true;
  45805. } else if (command === 'deop' && allowed_commands.includes(command)) {
  45806. // FIXME: /deop only applies to setting a moderators
  45807. // role to "participant" (which only admin/owner can
  45808. // do). Moderators can however set non-moderator's role
  45809. // to participant (e.g. visitor => participant).
  45810. // Currently we don't distinguish between these two
  45811. // cases.
  45812. setRole(model, command, args, ['admin', 'owner']);
  45813. return true;
  45814. } else if (command === 'destroy' && allowed_commands.includes(command)) {
  45815. if (!model.verifyAffiliations(['owner'])) {
  45816. return true;
  45817. }
  45818. destroyMUC(model).catch(e => model.onCommandError(e));
  45819. return true;
  45820. } else if (command === 'help' && allowed_commands.includes(command)) {
  45821. model.set({
  45822. 'show_help_messages': false
  45823. }, {
  45824. 'silent': true
  45825. });
  45826. model.set({
  45827. 'show_help_messages': true
  45828. });
  45829. return true;
  45830. } else if (command === 'kick' && allowed_commands.includes(command)) {
  45831. setRole(model, command, args, [], ['moderator']);
  45832. return true;
  45833. } else if (command === 'mute' && allowed_commands.includes(command)) {
  45834. setRole(model, command, args, [], ['moderator']);
  45835. return true;
  45836. } else if (command === 'member' && allowed_commands.includes(command)) {
  45837. verifyAndSetAffiliation(model, command, args, ['admin', 'owner']);
  45838. return true;
  45839. } else if (command === 'nick' && allowed_commands.includes(command)) {
  45840. if (!model.verifyRoles(['visitor', 'participant', 'moderator'])) {
  45841. return true;
  45842. } else if (args.length === 0) {
  45843. // e.g. Your nickname is "coolguy69"
  45844. const message = __('Your nickname is "%1$s"', model.get('nick'));
  45845. model.createMessage({
  45846. message,
  45847. 'type': 'error'
  45848. });
  45849. } else {
  45850. model.setNickname(args);
  45851. }
  45852. return true;
  45853. } else if (command === 'owner' && allowed_commands.includes(command)) {
  45854. verifyAndSetAffiliation(model, command, args, ['owner']);
  45855. return true;
  45856. } else if (command === 'op' && allowed_commands.includes(command)) {
  45857. setRole(model, command, args, ['admin', 'owner']);
  45858. return true;
  45859. } else if (command === 'register' && allowed_commands.includes(command)) {
  45860. if (args.length > 1) {
  45861. model.createMessage({
  45862. 'message': __('Error: invalid number of arguments'),
  45863. 'type': 'error'
  45864. });
  45865. } else {
  45866. model.registerNickname().then(err_msg => {
  45867. err_msg && model.createMessage({
  45868. 'message': err_msg,
  45869. 'type': 'error'
  45870. });
  45871. });
  45872. }
  45873. return true;
  45874. } else if (command === 'revoke' && allowed_commands.includes(command)) {
  45875. verifyAndSetAffiliation(model, command, args, ['admin', 'owner']);
  45876. return true;
  45877. } else if (command === 'topic' && allowed_commands.includes(command) || command === 'subject' && allowed_commands.includes(command)) {
  45878. model.setSubject(args);
  45879. return true;
  45880. } else if (command === 'voice' && allowed_commands.includes(command)) {
  45881. setRole(model, command, args, [], ['moderator']);
  45882. return true;
  45883. } else {
  45884. return false;
  45885. }
  45886. }
  45887. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/ad-hoc.js
  45888. /* harmony default export */ const ad_hoc = (o => {
  45889. const i18n_choose_service = __('On which entity do you want to run commands?');
  45890. const i18n_choose_service_instructions = __('Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them.');
  45891. const i18n_commands_found = __('Commands found');
  45892. const i18n_fetch_commands = __('List available commands');
  45893. const i18n_jid_placeholder = __('XMPP Address');
  45894. const i18n_no_commands_found = __('No commands found');
  45895. return $`
  45896. ${o.alert ? $`<div class="alert alert-${o.alert_type}" role="alert">${o.alert}</div>` : ''}
  45897. <form class="converse-form" @submit=${o.fetchCommands}>
  45898. <fieldset class="form-group">
  45899. <label>
  45900. ${i18n_choose_service}
  45901. <p class="form-help">${i18n_choose_service_instructions}</p>
  45902. <converse-autocomplete
  45903. .getAutoCompleteList="${getAutoCompleteList}"
  45904. placeholder="${i18n_jid_placeholder}"
  45905. name="jid"/>
  45906. </label>
  45907. </fieldset>
  45908. <fieldset class="form-group">
  45909. <input type="submit" class="btn btn-primary" value="${i18n_fetch_commands}">
  45910. </fieldset>
  45911. ${o.view === 'list-commands' ? $`
  45912. <fieldset class="form-group">
  45913. <ul class="list-group">
  45914. <li class="list-group-item active">${o.commands.length ? i18n_commands_found : i18n_no_commands_found}:</li>
  45915. ${o.commands.map(cmd => ad_hoc_command(o, cmd))}
  45916. </ul>
  45917. </fieldset>` : ''}
  45918. </form>
  45919. `;
  45920. });
  45921. ;// CONCATENATED MODULE: ./src/plugins/muc-views/adhoc-commands.js
  45922. const {
  45923. Strophe: adhoc_commands_Strophe,
  45924. $iq: adhoc_commands_$iq,
  45925. sizzle: adhoc_commands_sizzle,
  45926. u: adhoc_commands_u
  45927. } = core_converse.env;
  45928. class AdHocCommands extends CustomElement {
  45929. static get properties() {
  45930. return {
  45931. 'alert': {
  45932. type: String
  45933. },
  45934. 'alert_type': {
  45935. type: String
  45936. },
  45937. 'nonce': {
  45938. type: String
  45939. },
  45940. // Used to force re-rendering
  45941. 'showform': {
  45942. type: String
  45943. },
  45944. 'view': {
  45945. type: String
  45946. }
  45947. };
  45948. }
  45949. constructor() {
  45950. super();
  45951. this.view = 'choose-service';
  45952. this.showform = '';
  45953. this.commands = [];
  45954. }
  45955. render() {
  45956. return ad_hoc({
  45957. 'alert': this.alert,
  45958. 'alert_type': this.alert_type,
  45959. 'commands': this.commands,
  45960. 'fetchCommands': ev => this.fetchCommands(ev),
  45961. 'hideCommandForm': ev => this.hideCommandForm(ev),
  45962. 'runCommand': ev => this.runCommand(ev),
  45963. 'showform': this.showform,
  45964. 'toggleCommandForm': ev => this.toggleCommandForm(ev),
  45965. 'view': this.view
  45966. });
  45967. }
  45968. async fetchCommands(ev) {
  45969. ev.preventDefault();
  45970. delete this.alert_type;
  45971. delete this.alert;
  45972. const form_data = new FormData(ev.target);
  45973. const jid = form_data.get('jid').trim();
  45974. let supported;
  45975. try {
  45976. supported = await core_api.disco.supports(adhoc_commands_Strophe.NS.ADHOC, jid);
  45977. } catch (e) {
  45978. headless_log.error(e);
  45979. }
  45980. if (supported) {
  45981. try {
  45982. this.commands = await core_api.adhoc.getCommands(jid);
  45983. this.view = 'list-commands';
  45984. } catch (e) {
  45985. headless_log.error(e);
  45986. this.alert_type = 'danger';
  45987. this.alert = __('Sorry, an error occurred while looking for commands on that entity.');
  45988. this.commands = [];
  45989. headless_log.error(e);
  45990. return;
  45991. }
  45992. } else {
  45993. this.alert_type = 'danger';
  45994. this.alert = __("The specified entity doesn't support ad-hoc commands");
  45995. }
  45996. }
  45997. async toggleCommandForm(ev) {
  45998. ev.preventDefault();
  45999. const node = ev.target.getAttribute('data-command-node');
  46000. const cmd = this.commands.filter(c => c.node === node)[0];
  46001. this.showform !== node && (await fetchCommandForm(cmd));
  46002. this.showform = node;
  46003. }
  46004. hideCommandForm(ev) {
  46005. ev.preventDefault();
  46006. this.showform = '';
  46007. }
  46008. async runCommand(ev) {
  46009. ev.preventDefault();
  46010. const form_data = new FormData(ev.target);
  46011. const jid = form_data.get('command_jid').trim();
  46012. const node = form_data.get('command_node').trim();
  46013. const cmd = this.commands.filter(c => c.node === node)[0];
  46014. cmd.alert = null;
  46015. this.nonce = adhoc_commands_u.getUniqueId();
  46016. const inputs = adhoc_commands_sizzle(':input:not([type=button]):not([type=submit])', ev.target);
  46017. const config_array = inputs.filter(i => !['command_jid', 'command_node'].includes(i.getAttribute('name'))).map(adhoc_commands_u.webForm2xForm).filter(n => n);
  46018. const iq = adhoc_commands_$iq({
  46019. to: jid,
  46020. type: "set"
  46021. }).c("command", {
  46022. 'sessionid': cmd.sessionid,
  46023. 'node': cmd.node,
  46024. 'xmlns': adhoc_commands_Strophe.NS.ADHOC
  46025. }).c("x", {
  46026. xmlns: adhoc_commands_Strophe.NS.XFORM,
  46027. type: "submit"
  46028. });
  46029. config_array.forEach(node => iq.cnode(node).up());
  46030. let result;
  46031. try {
  46032. result = await core_api.sendIQ(iq);
  46033. } catch (e) {
  46034. cmd.alert_type = 'danger';
  46035. cmd.alert = __('Sorry, an error occurred while trying to execute the command. See the developer console for details');
  46036. headless_log.error('Error while trying to execute an ad-hoc command');
  46037. headless_log.error(e);
  46038. }
  46039. if (result) {
  46040. var _result$querySelector;
  46041. cmd.alert = (_result$querySelector = result.querySelector('note')) === null || _result$querySelector === void 0 ? void 0 : _result$querySelector.textContent;
  46042. } else {
  46043. cmd.alert = 'Done';
  46044. }
  46045. cmd.alert_type = 'primary';
  46046. this.nonce = adhoc_commands_u.getUniqueId();
  46047. }
  46048. }
  46049. core_api.elements.define('converse-adhoc-commands', AdHocCommands);
  46050. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/message-form.js
  46051. /* harmony default export */ const templates_message_form = (o => {
  46052. const label_message = o.composing_spoiler ? __('Hidden message') : __('Message');
  46053. const label_spoiler_hint = __('Optional hint');
  46054. const show_send_button = core_api.settings.get('show_send_button');
  46055. return $`
  46056. <form class="setNicknameButtonForm hidden">
  46057. <input type="submit" class="btn btn-primary" name="join" value="Join"/>
  46058. </form>
  46059. <form class="sendXMPPMessage">
  46060. <input type="text" placeholder="${label_spoiler_hint || ''}" value="${o.hint_value || ''}" class="${o.composing_spoiler ? '' : 'hidden'} spoiler-hint"/>
  46061. <div class="suggestion-box">
  46062. <ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
  46063. <textarea
  46064. autofocus
  46065. type="text"
  46066. @drop=${o.onDrop}
  46067. @input=${resetElementHeight}
  46068. @keydown=${o.onKeyDown}
  46069. @keyup=${o.onKeyUp}
  46070. @paste=${o.onPaste}
  46071. @change=${o.onChange}
  46072. class="chat-textarea suggestion-box__input
  46073. ${show_send_button ? 'chat-textarea-send-button' : ''}
  46074. ${o.composing_spoiler ? 'spoiler' : ''}"
  46075. placeholder="${label_message}">${o.message_value || ''}</textarea>
  46076. <span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
  46077. </div>
  46078. </form>`;
  46079. });
  46080. ;// CONCATENATED MODULE: ./src/plugins/muc-views/message-form.js
  46081. class MUCMessageForm extends MessageForm {
  46082. async connectedCallback() {
  46083. super.connectedCallback();
  46084. await this.model.initialized;
  46085. }
  46086. toHTML() {
  46087. var _this$querySelector, _this$querySelector2;
  46088. return templates_message_form(Object.assign(this.model.toJSON(), {
  46089. 'hint_value': (_this$querySelector = this.querySelector('.spoiler-hint')) === null || _this$querySelector === void 0 ? void 0 : _this$querySelector.value,
  46090. 'message_value': (_this$querySelector2 = this.querySelector('.chat-textarea')) === null || _this$querySelector2 === void 0 ? void 0 : _this$querySelector2.value,
  46091. 'onChange': ev => this.model.set({
  46092. 'draft': ev.target.value
  46093. }),
  46094. 'onDrop': ev => this.onDrop(ev),
  46095. 'onKeyDown': ev => this.onKeyDown(ev),
  46096. 'onKeyUp': ev => this.onKeyUp(ev),
  46097. 'onPaste': ev => this.onPaste(ev),
  46098. 'scrolled': this.model.ui.get('scrolled'),
  46099. 'viewUnreadMessages': ev => this.viewUnreadMessages(ev)
  46100. }));
  46101. }
  46102. afterRender() {
  46103. const entered = this.model.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED;
  46104. const can_edit = entered && !(this.model.features.get('moderated') && this.model.getOwnRole() === 'visitor');
  46105. if (entered && can_edit) {
  46106. this.initMentionAutoComplete();
  46107. }
  46108. }
  46109. initMentionAutoComplete() {
  46110. this.mention_auto_complete = new shared_converse.AutoComplete(this, {
  46111. 'auto_first': true,
  46112. 'auto_evaluate': false,
  46113. 'min_chars': core_api.settings.get('muc_mention_autocomplete_min_chars'),
  46114. 'match_current_word': true,
  46115. 'list': () => this.getAutoCompleteList(),
  46116. 'filter': core_api.settings.get('muc_mention_autocomplete_filter') == 'contains' ? shared_converse.FILTER_CONTAINS : shared_converse.FILTER_STARTSWITH,
  46117. 'ac_triggers': ['Tab', '@'],
  46118. 'include_triggers': [],
  46119. 'item': getAutoCompleteListItem
  46120. });
  46121. this.mention_auto_complete.on('suggestion-box-selectcomplete', () => this.auto_completing = false);
  46122. }
  46123. getAutoCompleteList() {
  46124. return this.model.getAllKnownNicknames().map(nick => ({
  46125. 'label': nick,
  46126. 'value': `@${nick}`
  46127. }));
  46128. }
  46129. onKeyDown(ev) {
  46130. if (this.mention_auto_complete.onKeyDown(ev)) {
  46131. return;
  46132. }
  46133. super.onKeyDown(ev);
  46134. }
  46135. onKeyUp(ev) {
  46136. this.mention_auto_complete.evaluate(ev);
  46137. super.onKeyUp(ev);
  46138. }
  46139. }
  46140. core_api.elements.define('converse-muc-message-form', MUCMessageForm);
  46141. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-nickname-form.js
  46142. /* harmony default export */ const muc_nickname_form = (el => {
  46143. var _el$model, _el$model2, _el$model3;
  46144. const i18n_nickname = __('Nickname');
  46145. const i18n_join = (_el$model = el.model) !== null && _el$model !== void 0 && _el$model.isEntered() ? __('Change nickname') : __('Enter groupchat');
  46146. const i18n_heading = core_api.settings.get('muc_show_logs_before_join') ? __('Choose a nickname to enter') : __('Please choose your nickname');
  46147. const validation_message = (_el$model2 = el.model) === null || _el$model2 === void 0 ? void 0 : _el$model2.get('nickname_validation_message');
  46148. return $`
  46149. <div class="chatroom-form-container muc-nickname-form"
  46150. @submit=${ev => el.submitNickname(ev)}>
  46151. <form class="converse-form chatroom-form converse-centered-form">
  46152. <fieldset class="form-group">
  46153. <label>${i18n_heading}</label>
  46154. <p class="validation-message">${validation_message}</p>
  46155. <input type="text"
  46156. required="required"
  46157. name="nick"
  46158. value="${((_el$model3 = el.model) === null || _el$model3 === void 0 ? void 0 : _el$model3.get('nick')) || ''}"
  46159. class="form-control ${validation_message ? 'error' : ''}"
  46160. placeholder="${i18n_nickname}"/>
  46161. </fieldset>
  46162. <fieldset class="form-group">
  46163. <input type="submit" class="btn btn-primary" name="join" value="${i18n_join}"/>
  46164. </fieldset>
  46165. </form>
  46166. </div>`;
  46167. });
  46168. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/nickname-form.scss
  46169. var nickname_form = __webpack_require__(6233);
  46170. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/nickname-form.scss
  46171. var nickname_form_options = {};
  46172. nickname_form_options.styleTagTransform = (styleTagTransform_default());
  46173. nickname_form_options.setAttributes = (setAttributesWithoutAttributes_default());
  46174. nickname_form_options.insert = insertBySelector_default().bind(null, "head");
  46175. nickname_form_options.domAPI = (styleDomAPI_default());
  46176. nickname_form_options.insertStyleElement = (insertStyleElement_default());
  46177. var nickname_form_update = injectStylesIntoStyleTag_default()(nickname_form/* default */.Z, nickname_form_options);
  46178. /* harmony default export */ const styles_nickname_form = (nickname_form/* default */.Z && nickname_form/* default.locals */.Z.locals ? nickname_form/* default.locals */.Z.locals : undefined);
  46179. ;// CONCATENATED MODULE: ./src/plugins/muc-views/nickname-form.js
  46180. class MUCNicknameForm extends CustomElement {
  46181. static get properties() {
  46182. return {
  46183. 'jid': {
  46184. type: String
  46185. }
  46186. };
  46187. }
  46188. connectedCallback() {
  46189. super.connectedCallback();
  46190. this.model = shared_converse.chatboxes.get(this.jid);
  46191. }
  46192. render() {
  46193. return muc_nickname_form(this);
  46194. }
  46195. submitNickname(ev) {
  46196. ev.preventDefault();
  46197. const nick = ev.target.nick.value.trim();
  46198. if (!nick) {
  46199. return;
  46200. }
  46201. if (this.model.isEntered()) {
  46202. this.model.setNickname(nick);
  46203. this.closeModal();
  46204. } else {
  46205. this.model.join(nick);
  46206. }
  46207. }
  46208. closeModal() {
  46209. const evt = document.createEvent('Event');
  46210. evt.initEvent('hide.bs.modal', true, true);
  46211. this.dispatchEvent(evt);
  46212. }
  46213. }
  46214. core_api.elements.define('converse-muc-nickname-form', MUCNicknameForm);
  46215. /* harmony default export */ const muc_views_nickname_form = ((/* unused pure expression or super */ null && (MUCNicknameForm)));
  46216. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-bottom-panel.js
  46217. const tpl_can_edit = o => {
  46218. const unread_msgs = __('You have unread messages');
  46219. const message_limit = core_api.settings.get('message_limit');
  46220. const show_call_button = core_api.settings.get('visible_toolbar_buttons').call;
  46221. const show_emoji_button = core_api.settings.get('visible_toolbar_buttons').emoji;
  46222. const show_send_button = core_api.settings.get('show_send_button');
  46223. const show_spoiler_button = core_api.settings.get('visible_toolbar_buttons').spoiler;
  46224. const show_toolbar = core_api.settings.get('show_toolbar');
  46225. return $`
  46226. ${o.model.ui.get('scrolled') && o.model.get('num_unread') ? $`<div class="new-msgs-indicator" @click=${ev => o.viewUnreadMessages(ev)}>▼ ${unread_msgs} ▼</div>` : ''}
  46227. ${show_toolbar ? $`
  46228. <converse-chat-toolbar
  46229. class="chat-toolbar no-text-select"
  46230. .model=${o.model}
  46231. ?hidden_occupants="${o.model.get('hidden_occupants')}"
  46232. ?is_groupchat="${o.is_groupchat}"
  46233. ?show_call_button="${show_call_button}"
  46234. ?show_emoji_button="${show_emoji_button}"
  46235. ?show_send_button="${show_send_button}"
  46236. ?show_spoiler_button="${show_spoiler_button}"
  46237. ?show_toolbar="${show_toolbar}"
  46238. message_limit="${message_limit}"></converse-chat-toolbar>` : ''}
  46239. <converse-muc-message-form jid=${o.model.get('jid')}></converse-muc-message-form>`;
  46240. };
  46241. /* harmony default export */ const muc_bottom_panel = (o => {
  46242. const unread_msgs = __('You have unread messages');
  46243. const conn_status = o.model.session.get('connection_status');
  46244. const i18n_not_allowed = __("You're not allowed to send messages in this room");
  46245. if (conn_status === core_converse.ROOMSTATUS.ENTERED) {
  46246. return $`
  46247. ${o.model.ui.get('scrolled') && o.model.get('num_unread_general') ? $`<div class="new-msgs-indicator" @click=${ev => o.viewUnreadMessages(ev)}>▼ ${unread_msgs} ▼</div>` : ''}
  46248. ${o.can_edit ? tpl_can_edit(o) : $`<span class="muc-bottom-panel muc-bottom-panel--muted">${i18n_not_allowed}</span>`}`;
  46249. } else if (conn_status == core_converse.ROOMSTATUS.NICKNAME_REQUIRED) {
  46250. if (core_api.settings.get('muc_show_logs_before_join')) {
  46251. return $`<span class="muc-bottom-panel muc-bottom-panel--nickname">
  46252. <converse-muc-nickname-form jid="${o.model.get('jid')}"></converse-muc-nickname-form>
  46253. </span>`;
  46254. }
  46255. } else {
  46256. return '';
  46257. }
  46258. });
  46259. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/muc-bottom-panel.scss
  46260. var styles_muc_bottom_panel = __webpack_require__(6916);
  46261. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/muc-bottom-panel.scss
  46262. var muc_bottom_panel_options = {};
  46263. muc_bottom_panel_options.styleTagTransform = (styleTagTransform_default());
  46264. muc_bottom_panel_options.setAttributes = (setAttributesWithoutAttributes_default());
  46265. muc_bottom_panel_options.insert = insertBySelector_default().bind(null, "head");
  46266. muc_bottom_panel_options.domAPI = (styleDomAPI_default());
  46267. muc_bottom_panel_options.insertStyleElement = (insertStyleElement_default());
  46268. var muc_bottom_panel_update = injectStylesIntoStyleTag_default()(styles_muc_bottom_panel/* default */.Z, muc_bottom_panel_options);
  46269. /* harmony default export */ const muc_views_styles_muc_bottom_panel = (styles_muc_bottom_panel/* default */.Z && styles_muc_bottom_panel/* default.locals */.Z.locals ? styles_muc_bottom_panel/* default.locals */.Z.locals : undefined);
  46270. ;// CONCATENATED MODULE: ./src/plugins/muc-views/bottom-panel.js
  46271. function muc_views_bottom_panel_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  46272. class MUCBottomPanel extends ChatBottomPanel {
  46273. constructor() {
  46274. super(...arguments);
  46275. muc_views_bottom_panel_defineProperty(this, "events", {
  46276. 'click .hide-occupants': 'hideOccupants',
  46277. 'click .send-button': 'sendButtonClicked'
  46278. });
  46279. }
  46280. async initialize() {
  46281. await super.initialize();
  46282. this.listenTo(this.model, 'change:hidden_occupants', this.debouncedRender);
  46283. this.listenTo(this.model, 'change:num_unread_general', this.debouncedRender);
  46284. this.listenTo(this.model.features, 'change:moderated', this.debouncedRender);
  46285. this.listenTo(this.model.occupants, 'add', this.renderIfOwnOccupant);
  46286. this.listenTo(this.model.occupants, 'change:role', this.renderIfOwnOccupant);
  46287. this.listenTo(this.model.session, 'change:connection_status', this.debouncedRender);
  46288. }
  46289. render() {
  46290. const entered = this.model.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED;
  46291. const can_edit = entered && !(this.model.features.get('moderated') && this.model.getOwnRole() === 'visitor');
  46292. x(muc_bottom_panel({
  46293. can_edit,
  46294. entered,
  46295. 'model': this.model,
  46296. 'is_groupchat': true,
  46297. 'viewUnreadMessages': ev => this.viewUnreadMessages(ev)
  46298. }), this);
  46299. }
  46300. renderIfOwnOccupant(o) {
  46301. o.get('jid') === shared_converse.bare_jid && this.debouncedRender();
  46302. }
  46303. sendButtonClicked(ev) {
  46304. var _this$querySelector;
  46305. (_this$querySelector = this.querySelector('converse-muc-message-form')) === null || _this$querySelector === void 0 ? void 0 : _this$querySelector.onFormSubmitted(ev);
  46306. }
  46307. hideOccupants(ev) {
  46308. var _ev$preventDefault, _ev$stopPropagation;
  46309. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  46310. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation = ev.stopPropagation) === null || _ev$stopPropagation === void 0 ? void 0 : _ev$stopPropagation.call(ev);
  46311. this.model.save({
  46312. 'hidden_occupants': true
  46313. });
  46314. }
  46315. }
  46316. core_api.elements.define('converse-muc-bottom-panel', MUCBottomPanel);
  46317. ;// CONCATENATED MODULE: ./src/plugins/muc-views/constants.js
  46318. const PRETTY_CHAT_STATUS = {
  46319. 'offline': 'Offline',
  46320. 'unavailable': 'Unavailable',
  46321. 'xa': 'Extended Away',
  46322. 'away': 'Away',
  46323. 'dnd': 'Do not disturb',
  46324. 'chat': 'Chattty',
  46325. 'online': 'Online'
  46326. };
  46327. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/occupant.js
  46328. const i18n_occupant_hint = o => __('Click to mention %1$s in your message.', o.get('nick'));
  46329. const occupant_title = o => {
  46330. const role = o.get('role');
  46331. const hint_occupant = i18n_occupant_hint(o);
  46332. const i18n_moderator_hint = __('This user is a moderator.');
  46333. const i18n_participant_hint = __('This user can send messages in this groupchat.');
  46334. const i18n_visitor_hint = __('This user can NOT send messages in this groupchat.');
  46335. const spaced_jid = o.get('jid') ? `${o.get('jid')} ` : '';
  46336. if (role === "moderator") {
  46337. return `${spaced_jid}${i18n_moderator_hint} ${hint_occupant}`;
  46338. } else if (role === "participant") {
  46339. return `${spaced_jid}${i18n_participant_hint} ${hint_occupant}`;
  46340. } else if (role === "visitor") {
  46341. return `${spaced_jid}${i18n_visitor_hint} ${hint_occupant}`;
  46342. } else if (!["visitor", "participant", "moderator"].includes(role)) {
  46343. return `${spaced_jid}${hint_occupant}`;
  46344. }
  46345. };
  46346. /* harmony default export */ const muc_views_templates_occupant = ((o, chat) => {
  46347. var _o$vcard, _o$vcard2;
  46348. const affiliation = o.get('affiliation');
  46349. const hint_show = PRETTY_CHAT_STATUS[o.get('show')];
  46350. const i18n_admin = __('Admin');
  46351. const i18n_member = __('Member');
  46352. const i18n_moderator = __('Moderator');
  46353. const i18n_owner = __('Owner');
  46354. const i18n_visitor = __('Visitor');
  46355. const role = o.get('role');
  46356. const show = o.get('show');
  46357. let classes, color;
  46358. if (show === 'online') {
  46359. [classes, color] = ['fa fa-circle', 'chat-status-online'];
  46360. } else if (show === 'dnd') {
  46361. [classes, color] = ['fa fa-minus-circle', 'chat-status-busy'];
  46362. } else if (show === 'away') {
  46363. [classes, color] = ['fa fa-circle', 'chat-status-away'];
  46364. } else {
  46365. [classes, color] = ['fa fa-circle', 'subdued-color'];
  46366. }
  46367. return $`
  46368. <li class="occupant" id="${o.id}" title="${occupant_title(o)}">
  46369. <div class="row no-gutters">
  46370. <div class="col-auto">
  46371. <a class="show-msg-author-modal" @click=${ev => showOccupantModal(ev, o)}>
  46372. <converse-avatar
  46373. class="avatar chat-msg__avatar"
  46374. .data=${(_o$vcard = o.vcard) === null || _o$vcard === void 0 ? void 0 : _o$vcard.attributes}
  46375. nonce=${(_o$vcard2 = o.vcard) === null || _o$vcard2 === void 0 ? void 0 : _o$vcard2.get('vcard_updated')}
  46376. height="30" width="30"></converse-avatar>
  46377. <converse-icon
  46378. title="${hint_show}"
  46379. color="var(--${color})"
  46380. style="margin-top: -0.1em"
  46381. size="0.82em"
  46382. class="${classes} chat-status chat-status--avatar"></converse-icon>
  46383. </a>
  46384. </div>
  46385. <div class="col occupant-nick-badge">
  46386. <span class="occupant-nick" @click=${chat.onOccupantClicked}>${o.getDisplayName()}</span>
  46387. <span class="occupant-badges">
  46388. ${affiliation === "owner" ? $`<span class="badge badge-groupchat">${i18n_owner}</span>` : ''}
  46389. ${affiliation === "admin" ? $`<span class="badge badge-info">${i18n_admin}</span>` : ''}
  46390. ${affiliation === "member" ? $`<span class="badge badge-info">${i18n_member}</span>` : ''}
  46391. ${role === "moderator" ? $`<span class="badge badge-info">${i18n_moderator}</span>` : ''}
  46392. ${role === "visitor" ? $`<span class="badge badge-secondary">${i18n_visitor}</span>` : ''}
  46393. </span>
  46394. </div>
  46395. </div>
  46396. </li>
  46397. `;
  46398. });
  46399. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-sidebar.js
  46400. /* harmony default export */ const muc_sidebar = (o => {
  46401. const i18n_participants = o.occupants.length === 1 ? __('Participant') : __('Participants');
  46402. return $`
  46403. <div class="occupants-header">
  46404. <div class="occupants-header--title">
  46405. <span class="occupants-heading">${o.occupants.length} ${i18n_participants}</span>
  46406. <i class="hide-occupants" @click=${o.closeSidebar}>
  46407. <converse-icon class="fa fa-times" size="1em"></converse-icon>
  46408. </i>
  46409. </div>
  46410. </div>
  46411. <div class="dragresize dragresize-occupants-left"></div>
  46412. <ul class="occupant-list">${o.occupants.map(occ => muc_views_templates_occupant(occ, o))}</ul>
  46413. `;
  46414. });
  46415. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/styles/status.scss
  46416. var styles_status = __webpack_require__(9959);
  46417. ;// CONCATENATED MODULE: ./src/shared/styles/status.scss
  46418. var status_options = {};
  46419. status_options.styleTagTransform = (styleTagTransform_default());
  46420. status_options.setAttributes = (setAttributesWithoutAttributes_default());
  46421. status_options.insert = insertBySelector_default().bind(null, "head");
  46422. status_options.domAPI = (styleDomAPI_default());
  46423. status_options.insertStyleElement = (insertStyleElement_default());
  46424. var status_update = injectStylesIntoStyleTag_default()(styles_status/* default */.Z, status_options);
  46425. /* harmony default export */ const shared_styles_status = (styles_status/* default */.Z && styles_status/* default.locals */.Z.locals ? styles_status/* default.locals */.Z.locals : undefined);
  46426. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/muc-occupants.scss
  46427. var muc_occupants = __webpack_require__(902);
  46428. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/muc-occupants.scss
  46429. var muc_occupants_options = {};
  46430. muc_occupants_options.styleTagTransform = (styleTagTransform_default());
  46431. muc_occupants_options.setAttributes = (setAttributesWithoutAttributes_default());
  46432. muc_occupants_options.insert = insertBySelector_default().bind(null, "head");
  46433. muc_occupants_options.domAPI = (styleDomAPI_default());
  46434. muc_occupants_options.insertStyleElement = (insertStyleElement_default());
  46435. var muc_occupants_update = injectStylesIntoStyleTag_default()(muc_occupants/* default */.Z, muc_occupants_options);
  46436. /* harmony default export */ const styles_muc_occupants = (muc_occupants/* default */.Z && muc_occupants/* default.locals */.Z.locals ? muc_occupants/* default.locals */.Z.locals : undefined);
  46437. ;// CONCATENATED MODULE: ./src/plugins/muc-views/sidebar.js
  46438. const {
  46439. u: sidebar_u
  46440. } = core_converse.env;
  46441. class MUCSidebar extends CustomElement {
  46442. static get properties() {
  46443. return {
  46444. jid: {
  46445. type: String
  46446. }
  46447. };
  46448. }
  46449. connectedCallback() {
  46450. super.connectedCallback();
  46451. this.model = shared_converse.chatboxes.get(this.jid);
  46452. this.listenTo(this.model.occupants, 'add', this.requestUpdate);
  46453. this.listenTo(this.model.occupants, 'remove', this.requestUpdate);
  46454. this.listenTo(this.model.occupants, 'change', this.requestUpdate);
  46455. this.listenTo(this.model.occupants, 'vcard:change', this.requestUpdate);
  46456. this.listenTo(this.model.occupants, 'vcard:add', this.requestUpdate);
  46457. this.model.initialized.then(() => this.requestUpdate());
  46458. }
  46459. render() {
  46460. const tpl = muc_sidebar(Object.assign(this.model.toJSON(), {
  46461. 'occupants': [...this.model.occupants.models],
  46462. 'closeSidebar': ev => this.closeSidebar(ev),
  46463. 'onOccupantClicked': ev => this.onOccupantClicked(ev)
  46464. }));
  46465. return tpl;
  46466. }
  46467. closeSidebar(ev) {
  46468. var _ev$preventDefault, _ev$stopPropagation;
  46469. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  46470. ev === null || ev === void 0 ? void 0 : (_ev$stopPropagation = ev.stopPropagation) === null || _ev$stopPropagation === void 0 ? void 0 : _ev$stopPropagation.call(ev);
  46471. sidebar_u.safeSave(this.model, {
  46472. 'hidden_occupants': true
  46473. });
  46474. }
  46475. onOccupantClicked(ev) {
  46476. var _ev$preventDefault2;
  46477. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  46478. const view = shared_converse.chatboxviews.get(this.getAttribute('jid'));
  46479. view === null || view === void 0 ? void 0 : view.getMessageForm().insertIntoTextArea(`@${ev.target.textContent}`);
  46480. }
  46481. }
  46482. core_api.elements.define('converse-muc-sidebar', MUCSidebar);
  46483. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-chatarea.js
  46484. /* harmony default export */ const muc_chatarea = (o => {
  46485. var _o$model;
  46486. return $`
  46487. <div class="chat-area">
  46488. <div class="chat-content ${o.show_send_button ? 'chat-content-sendbutton' : ''}" aria-live="polite">
  46489. <converse-chat-content
  46490. class="chat-content__messages"
  46491. jid="${o.jid}"></converse-chat-content>
  46492. ${(_o$model = o.model) !== null && _o$model !== void 0 && _o$model.get('show_help_messages') ? $`<div class="chat-content__help">
  46493. <converse-chat-help
  46494. .model=${o.model}
  46495. .messages=${o.getHelpMessages()}
  46496. type="info"
  46497. chat_type="${shared_converse.CHATROOMS_TYPE}"
  46498. ></converse-chat-help></div>` : ''}
  46499. </div>
  46500. <converse-muc-bottom-panel jid="${o.jid}" class="bottom-panel"></converse-muc-bottom-panel>
  46501. </div>
  46502. <div class="disconnect-container hidden"></div>
  46503. ${o.model ? $`
  46504. <converse-muc-sidebar
  46505. class="occupants col-md-3 col-4 ${o.shouldShowSidebar() ? '' : 'hidden'}"
  46506. style="flex: 0 0 ${o.model.get('occupants_width')}px"
  46507. jid=${o.jid}
  46508. @mousedown=${o.onMousedown}></converse-muc-sidebar>` : ''}
  46509. `;
  46510. });
  46511. ;// CONCATENATED MODULE: ./src/plugins/muc-views/chatarea.js
  46512. const {
  46513. u: chatarea_u
  46514. } = core_converse.env;
  46515. class MUCChatArea extends CustomElement {
  46516. static get properties() {
  46517. return {
  46518. jid: {
  46519. type: String
  46520. },
  46521. show_help_messages: {
  46522. type: Boolean
  46523. },
  46524. type: {
  46525. type: String
  46526. }
  46527. };
  46528. }
  46529. async initialize() {
  46530. this.model = await core_api.rooms.get(this.jid);
  46531. this.listenTo(this.model, 'change:show_help_messages', () => this.requestUpdate());
  46532. this.listenTo(this.model, 'change:hidden_occupants', () => this.requestUpdate());
  46533. this.listenTo(this.model.session, 'change:connection_status', () => this.requestUpdate()); // Bind so that we can pass it to addEventListener and removeEventListener
  46534. this.onMouseMove = this._onMouseMove.bind(this);
  46535. this.onMouseUp = this._onMouseUp.bind(this);
  46536. this.requestUpdate(); // Make sure we render again after the model has been attached
  46537. }
  46538. render() {
  46539. return muc_chatarea({
  46540. 'getHelpMessages': () => this.getHelpMessages(),
  46541. 'jid': this.jid,
  46542. 'model': this.model,
  46543. 'onMousedown': ev => this.onMousedown(ev),
  46544. 'show_send_button': core_api.settings.get('show_send_button'),
  46545. 'shouldShowSidebar': () => this.shouldShowSidebar(),
  46546. 'type': this.type
  46547. });
  46548. }
  46549. shouldShowSidebar() {
  46550. return !this.model.get('hidden_occupants') && this.model.session.get('connection_status') === core_converse.ROOMSTATUS.ENTERED;
  46551. }
  46552. getHelpMessages() {
  46553. const setting = core_api.settings.get('muc_disable_slash_commands');
  46554. const disabled_commands = Array.isArray(setting) ? setting : [];
  46555. return [`<strong>/admin</strong>: ${__("Change user's affiliation to admin")}`, `<strong>/ban</strong>: ${__('Ban user by changing their affiliation to outcast')}`, `<strong>/clear</strong>: ${__('Clear the chat area')}`, `<strong>/close</strong>: ${__('Close this groupchat')}`, `<strong>/deop</strong>: ${__('Change user role to participant')}`, `<strong>/destroy</strong>: ${__('Remove this groupchat')}`, `<strong>/help</strong>: ${__('Show this menu')}`, `<strong>/kick</strong>: ${__('Kick user from groupchat')}`, `<strong>/me</strong>: ${__('Write in 3rd person')}`, `<strong>/member</strong>: ${__('Grant membership to a user')}`, `<strong>/modtools</strong>: ${__('Opens up the moderator tools GUI')}`, `<strong>/mute</strong>: ${__("Remove user's ability to post messages")}`, `<strong>/nick</strong>: ${__('Change your nickname')}`, `<strong>/op</strong>: ${__('Grant moderator role to user')}`, `<strong>/owner</strong>: ${__('Grant ownership of this groupchat')}`, `<strong>/register</strong>: ${__('Register your nickname')}`, `<strong>/revoke</strong>: ${__("Revoke the user's current affiliation")}`, `<strong>/subject</strong>: ${__('Set groupchat subject')}`, `<strong>/topic</strong>: ${__('Set groupchat subject (alias for /subject)')}`, `<strong>/voice</strong>: ${__('Allow muted user to post messages')}`].filter(line => disabled_commands.every(c => !line.startsWith(c + '<', 9))).filter(line => this.model.getAllowedCommands().some(c => line.startsWith(c + '<', 9)));
  46556. }
  46557. onMousedown(ev) {
  46558. if (chatarea_u.hasClass('dragresize-occupants-left', ev.target)) {
  46559. this.onStartResizeOccupants(ev);
  46560. }
  46561. }
  46562. onStartResizeOccupants(ev) {
  46563. this.resizing = true;
  46564. this.addEventListener('mousemove', this.onMouseMove);
  46565. this.addEventListener('mouseup', this.onMouseUp);
  46566. const sidebar_el = this.querySelector('converse-muc-sidebar');
  46567. const style = window.getComputedStyle(sidebar_el);
  46568. this.width = parseInt(style.width.replace(/px$/, ''), 10);
  46569. this.prev_pageX = ev.pageX;
  46570. }
  46571. _onMouseMove(ev) {
  46572. if (this.resizing) {
  46573. ev.preventDefault();
  46574. const delta = this.prev_pageX - ev.pageX;
  46575. this.resizeSidebarView(delta, ev.pageX);
  46576. this.prev_pageX = ev.pageX;
  46577. }
  46578. }
  46579. _onMouseUp(ev) {
  46580. if (this.resizing) {
  46581. ev.preventDefault();
  46582. this.resizing = false;
  46583. this.removeEventListener('mousemove', this.onMouseMove);
  46584. this.removeEventListener('mouseup', this.onMouseUp);
  46585. const sidebar_el = this.querySelector('converse-muc-sidebar');
  46586. const element_position = sidebar_el.getBoundingClientRect();
  46587. const occupants_width = this.calculateSidebarWidth(element_position, 0);
  46588. chatarea_u.safeSave(this.model, {
  46589. occupants_width
  46590. });
  46591. }
  46592. }
  46593. calculateSidebarWidth(element_position, delta) {
  46594. let occupants_width = element_position.width + delta;
  46595. const room_width = this.clientWidth; // keeping display in boundaries
  46596. if (occupants_width < room_width * 0.2) {
  46597. // set pixel to 20% width
  46598. occupants_width = room_width * 0.2;
  46599. this.is_minimum = true;
  46600. } else if (occupants_width > room_width * 0.75) {
  46601. // set pixel to 75% width
  46602. occupants_width = room_width * 0.75;
  46603. this.is_maximum = true;
  46604. } else if (room_width - occupants_width < 250) {
  46605. // resize occupants if chat-area becomes smaller than 250px (min-width property set in css)
  46606. occupants_width = room_width - 250;
  46607. this.is_maximum = true;
  46608. } else {
  46609. this.is_maximum = false;
  46610. this.is_minimum = false;
  46611. }
  46612. return occupants_width;
  46613. }
  46614. resizeSidebarView(delta, current_mouse_position) {
  46615. const sidebar_el = this.querySelector('converse-muc-sidebar');
  46616. const element_position = sidebar_el.getBoundingClientRect();
  46617. if (this.is_minimum) {
  46618. this.is_minimum = element_position.left < current_mouse_position;
  46619. } else if (this.is_maximum) {
  46620. this.is_maximum = element_position.left > current_mouse_position;
  46621. } else {
  46622. const occupants_width = this.calculateSidebarWidth(element_position, delta);
  46623. sidebar_el.style.flex = '0 0 ' + occupants_width + 'px';
  46624. }
  46625. }
  46626. }
  46627. core_api.elements.define('converse-muc-chatarea', MUCChatArea);
  46628. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-config-form.js
  46629. const {
  46630. sizzle: muc_config_form_sizzle
  46631. } = core_converse.env;
  46632. const muc_config_form_u = core_converse.env.utils;
  46633. /* harmony default export */ const muc_config_form = (o => {
  46634. const whitelist = core_api.settings.get('roomconfig_whitelist');
  46635. const config_stanza = o.model.session.get('config_stanza');
  46636. let fields = [];
  46637. let instructions = '';
  46638. let title;
  46639. if (config_stanza) {
  46640. var _stanza$querySelector, _stanza$querySelector2;
  46641. const stanza = muc_config_form_u.toStanza(config_stanza);
  46642. fields = muc_config_form_sizzle('field', stanza);
  46643. if (whitelist.length) {
  46644. fields = fields.filter(f => whitelist.includes(f.getAttribute('var')));
  46645. }
  46646. const password_protected = o.model.features.get('passwordprotected');
  46647. const options = {
  46648. 'new_password': !password_protected,
  46649. 'fixed_username': o.model.get('jid')
  46650. };
  46651. fields = fields.map(f => muc_config_form_u.xForm2TemplateResult(f, stanza, options));
  46652. instructions = (_stanza$querySelector = stanza.querySelector('instructions')) === null || _stanza$querySelector === void 0 ? void 0 : _stanza$querySelector.textContent;
  46653. title = (_stanza$querySelector2 = stanza.querySelector('title')) === null || _stanza$querySelector2 === void 0 ? void 0 : _stanza$querySelector2.textContent;
  46654. } else {
  46655. title = __('Loading configuration form');
  46656. }
  46657. const i18n_save = __('Save');
  46658. const i18n_cancel = __('Cancel');
  46659. return $`
  46660. <form class="converse-form chatroom-form ${fields.length ? '' : 'converse-form--spinner'}"
  46661. autocomplete="off"
  46662. @submit=${o.submitConfigForm}>
  46663. <fieldset class="form-group">
  46664. <legend class="centered">${title}</legend>
  46665. ${title !== instructions ? $`<p class="form-help">${instructions}</p>` : ''}
  46666. ${fields.length ? fields : spinner({
  46667. 'classes': 'hor_centered'
  46668. })}
  46669. </fieldset>
  46670. ${fields.length ? $`
  46671. <fieldset>
  46672. <input type="submit" class="btn btn-primary" value="${i18n_save}">
  46673. <input type="button" class="btn btn-secondary button-cancel" value="${i18n_cancel}" @click=${o.closeConfigForm}>
  46674. </fieldset>` : ''}
  46675. </form>
  46676. `;
  46677. });
  46678. ;// CONCATENATED MODULE: ./src/plugins/muc-views/config-form.js
  46679. const {
  46680. sizzle: config_form_sizzle
  46681. } = core_converse.env;
  46682. const config_form_u = core_converse.env.utils;
  46683. class MUCConfigForm extends CustomElement {
  46684. static get properties() {
  46685. return {
  46686. 'jid': {
  46687. type: String
  46688. }
  46689. };
  46690. }
  46691. connectedCallback() {
  46692. super.connectedCallback();
  46693. this.model = shared_converse.chatboxes.get(this.jid);
  46694. this.listenTo(this.model.features, 'change:passwordprotected', this.requestUpdate);
  46695. this.listenTo(this.model.session, 'change:config_stanza', this.requestUpdate);
  46696. this.getConfig();
  46697. }
  46698. render() {
  46699. return muc_config_form({
  46700. 'model': this.model,
  46701. 'closeConfigForm': ev => this.closeForm(ev),
  46702. 'submitConfigForm': ev => this.submitConfigForm(ev)
  46703. });
  46704. }
  46705. async getConfig() {
  46706. const iq = await this.model.fetchRoomConfiguration();
  46707. this.model.session.set('config_stanza', iq.outerHTML);
  46708. }
  46709. async submitConfigForm(ev) {
  46710. ev.preventDefault();
  46711. const inputs = config_form_sizzle(':input:not([type=button]):not([type=submit])', ev.target);
  46712. const config_array = inputs.map(config_form_u.webForm2xForm).filter(f => f);
  46713. try {
  46714. await this.model.sendConfiguration(config_array);
  46715. } catch (e) {
  46716. headless_log.error(e);
  46717. const message = __("Sorry, an error occurred while trying to submit the config form.") + " " + __("Check your browser's developer console for details.");
  46718. core_api.alert('error', __('Error'), message);
  46719. }
  46720. await this.model.refreshDiscoInfo();
  46721. this.closeForm();
  46722. }
  46723. closeForm(ev) {
  46724. var _ev$preventDefault;
  46725. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  46726. this.model.session.set('view', null);
  46727. }
  46728. }
  46729. core_api.elements.define('converse-muc-config-form', MUCConfigForm);
  46730. /* harmony default export */ const config_form = ((/* unused pure expression or super */ null && (MUCConfigForm)));
  46731. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-destroyed.js
  46732. const tpl_moved = o => {
  46733. const i18n_moved = __('The conversation has moved to a new address. Click the link below to enter.');
  46734. return $`
  46735. <p class="moved-label">${i18n_moved}</p>
  46736. <p class="moved-link">
  46737. <a class="switch-chat" @click=${ev => o.onSwitch(ev)}>${o.moved_jid}</a>
  46738. </p>`;
  46739. };
  46740. /* harmony default export */ const muc_destroyed = (o => {
  46741. const i18n_non_existent = __('This groupchat no longer exists');
  46742. const i18n_reason = __('The following reason was given: "%1$s"', o.reason || '');
  46743. return $`
  46744. <div class="alert alert-danger">
  46745. <h3 class="alert-heading disconnect-msg">${i18n_non_existent}</h3>
  46746. </div>
  46747. ${o.reason ? $`<p class="destroyed-reason">${i18n_reason}</p>` : ''}
  46748. ${o.moved_jid ? tpl_moved(o) : ''}
  46749. `;
  46750. });
  46751. ;// CONCATENATED MODULE: ./src/plugins/muc-views/destroyed.js
  46752. class MUCDestroyed extends CustomElement {
  46753. static get properties() {
  46754. return {
  46755. 'jid': {
  46756. type: String
  46757. }
  46758. };
  46759. }
  46760. connectedCallback() {
  46761. super.connectedCallback();
  46762. this.model = shared_converse.chatboxes.get(this.jid);
  46763. }
  46764. render() {
  46765. const reason = this.model.get('destroyed_reason');
  46766. const moved_jid = this.model.get('moved_jid');
  46767. return muc_destroyed({
  46768. moved_jid,
  46769. reason,
  46770. 'onSwitch': ev => this.onSwitch(ev)
  46771. });
  46772. }
  46773. async onSwitch(ev) {
  46774. ev.preventDefault();
  46775. const moved_jid = this.model.get('moved_jid');
  46776. const room = await core_api.rooms.get(moved_jid, {}, true);
  46777. room.maybeShow(true);
  46778. this.model.destroy();
  46779. }
  46780. }
  46781. core_api.elements.define('converse-muc-destroyed', MUCDestroyed);
  46782. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-disconnect.js
  46783. /* harmony default export */ const muc_disconnect = (messages => {
  46784. return $`
  46785. <div class="alert alert-danger">
  46786. <h3 class="alert-heading disconnect-msg">${messages[0]}</h3>
  46787. ${messages.slice(1).map(m => $`<p class="disconnect-msg">${m}</p>`)}
  46788. </div>`;
  46789. });
  46790. ;// CONCATENATED MODULE: ./src/plugins/muc-views/disconnected.js
  46791. class MUCDisconnected extends CustomElement {
  46792. static get properties() {
  46793. return {
  46794. 'jid': {
  46795. type: String
  46796. }
  46797. };
  46798. }
  46799. connectedCallback() {
  46800. super.connectedCallback();
  46801. this.model = shared_converse.chatboxes.get(this.jid);
  46802. }
  46803. render() {
  46804. const message = this.model.session.get('disconnection_message');
  46805. if (!message) {
  46806. return;
  46807. }
  46808. const messages = [message];
  46809. const actor = this.model.session.get('disconnection_actor');
  46810. if (actor) {
  46811. messages.push(__('This action was done by %1$s.', actor));
  46812. }
  46813. const reason = this.model.session.get('disconnection_reason');
  46814. if (reason) {
  46815. messages.push(__('The reason given is: "%1$s".', reason));
  46816. }
  46817. return muc_disconnect(messages);
  46818. }
  46819. }
  46820. core_api.elements.define('converse-muc-disconnected', MUCDisconnected);
  46821. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/templates/muc-invite.js
  46822. /* harmony default export */ const muc_invite = (o => {
  46823. const i18n_invite = __('Invite');
  46824. const i18n_invite_heading = __('Invite someone to this groupchat');
  46825. const i18n_jid_placeholder = __('user@example.org');
  46826. const i18n_error_message = __('Please enter a valid XMPP address');
  46827. const i18n_invite_label = __('XMPP Address');
  46828. const i18n_reason = __('Optional reason for the invitation');
  46829. return $`
  46830. <div class="modal-dialog" role="document">
  46831. <div class="modal-content">
  46832. <div class="modal-header">
  46833. <h5 class="modal-title" id="add-chatroom-modal-label">${i18n_invite_heading}</h5>
  46834. ${modal_header_close_button}
  46835. </div>
  46836. <div class="modal-body">
  46837. <span class="modal-alert"></span>
  46838. <div class="suggestion-box room-invite">
  46839. <form @submit=${o.submitInviteForm}>
  46840. <div class="form-group">
  46841. <label class="clearfix" for="invitee_jids">${i18n_invite_label}:</label>
  46842. ${o.invalid_invite_jid ? $`<div class="error error-feedback">${i18n_error_message}</div>` : ''}
  46843. <input class="form-control suggestion-box__input"
  46844. required="required"
  46845. name="invitee_jids"
  46846. id="invitee_jids"
  46847. placeholder="${i18n_jid_placeholder}"
  46848. type="text"/>
  46849. <span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
  46850. <ul class="suggestion-box__results suggestion-box__results--below" hidden=""></ul>
  46851. </div>
  46852. <div class="form-group">
  46853. <label>${i18n_reason}:</label>
  46854. <textarea class="form-control" name="reason"></textarea>
  46855. </div>
  46856. <div class="form-group">
  46857. <button type="submit" class="btn btn-primary">${i18n_invite}</button>
  46858. </div>
  46859. </form>
  46860. </div>
  46861. </div>
  46862. </div>
  46863. </div>
  46864. `;
  46865. });
  46866. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/muc-invite.js
  46867. const muc_invite_u = core_converse.env.utils;
  46868. /* harmony default export */ const modals_muc_invite = (base.extend({
  46869. id: "muc-invite-modal",
  46870. initialize() {
  46871. base.prototype.initialize.apply(this, arguments);
  46872. this.listenTo(this.model, 'change', this.render);
  46873. this.initInviteWidget();
  46874. },
  46875. toHTML() {
  46876. return muc_invite(Object.assign(this.model.toJSON(), {
  46877. 'submitInviteForm': ev => this.submitInviteForm(ev)
  46878. }));
  46879. },
  46880. initInviteWidget() {
  46881. if (this.invite_auto_complete) {
  46882. this.invite_auto_complete.destroy();
  46883. }
  46884. const list = shared_converse.roster.map(i => ({
  46885. 'label': i.getDisplayName(),
  46886. 'value': i.get('jid')
  46887. }));
  46888. const el = this.el.querySelector('.suggestion-box').parentElement;
  46889. this.invite_auto_complete = new shared_converse.AutoComplete(el, {
  46890. 'min_chars': 1,
  46891. 'list': list
  46892. });
  46893. },
  46894. submitInviteForm(ev) {
  46895. ev.preventDefault(); // TODO: Add support for sending an invite to multiple JIDs
  46896. const data = new FormData(ev.target);
  46897. const jid = data.get('invitee_jids');
  46898. const reason = data.get('reason');
  46899. if (muc_invite_u.isValidJID(jid)) {
  46900. // TODO: Create and use API here
  46901. this.chatroomview.model.directInvite(jid, reason);
  46902. this.modal.hide();
  46903. } else {
  46904. this.model.set({
  46905. 'invalid_invite_jid': true
  46906. });
  46907. }
  46908. }
  46909. }));
  46910. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/templates/nickname.js
  46911. /* harmony default export */ const nickname = (modal => {
  46912. const jid = modal.model.get('jid');
  46913. const i18n_heading = __('Change your nickname');
  46914. return $`
  46915. <div class="modal-dialog" role="document">
  46916. <div class="modal-content">
  46917. <div class="modal-header">
  46918. <h5 class="modal-title" id="converse-modtools-modal-label">
  46919. ${i18n_heading}</h5>
  46920. ${modal_header_close_button}
  46921. </div>
  46922. <div class="modal-body d-flex flex-column">
  46923. <converse-muc-nickname-form jid="${jid}"></converse-muc-nickname-form>
  46924. </div>
  46925. </div>
  46926. </div>`;
  46927. });
  46928. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/nickname.js
  46929. /* harmony default export */ const modals_nickname = (base.extend({
  46930. id: 'change-nickname-modal',
  46931. initialize(attrs) {
  46932. this.model = attrs.model;
  46933. base.prototype.initialize.apply(this, arguments);
  46934. },
  46935. toHTML() {
  46936. return nickname(this);
  46937. }
  46938. }));
  46939. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/templates/muc-details.js
  46940. const subject = o => {
  46941. const i18n_topic = __('Topic');
  46942. const i18n_topic_author = __('Topic author');
  46943. return $`
  46944. <p class="room-info"><strong>${i18n_topic}</strong>: <converse-rich-text text=${o.subject.text} render_styling></converse-rich-text></p>
  46945. <p class="room-info"><strong>${i18n_topic_author}</strong>: ${o.subject && o.subject.author}</p>
  46946. `;
  46947. };
  46948. /* harmony default export */ const muc_details = (model => {
  46949. const o = model.toJSON();
  46950. const config = model.config.toJSON();
  46951. const display_name = __('Groupchat info for %1$s', model.getDisplayName());
  46952. const features = model.features.toJSON();
  46953. const num_occupants = model.occupants.filter(o => o.get('show') !== 'offline').length;
  46954. const i18n_address = __('XMPP address');
  46955. const i18n_archiving = __('Message archiving');
  46956. const i18n_archiving_help = __('Messages are archived on the server');
  46957. const i18n_desc = __('Description');
  46958. const i18n_features = __('Features');
  46959. const i18n_hidden = __('Hidden');
  46960. const i18n_hidden_help = __('This groupchat is not publicly searchable');
  46961. const i18n_members_help = __('This groupchat is restricted to members only');
  46962. const i18n_members_only = __('Members only');
  46963. const i18n_moderated = __('Moderated');
  46964. const i18n_moderated_help = __('Participants entering this groupchat need to request permission to write');
  46965. const i18n_name = __('Name');
  46966. const i18n_no_pass_help = __('This groupchat does not require a password upon entry');
  46967. const i18n_no_password_required = __('No password required');
  46968. const i18n_not_anonymous = __('Not anonymous');
  46969. const i18n_not_anonymous_help = __('All other groupchat participants can see your XMPP address');
  46970. const i18n_not_moderated = __('Not moderated');
  46971. const i18n_not_moderated_help = __('Participants entering this groupchat can write right away');
  46972. const i18n_online_users = __('Online users');
  46973. const i18n_open = __('Open');
  46974. const i18n_open_help = __('Anyone can join this groupchat');
  46975. const i18n_password_help = __('This groupchat requires a password before entry');
  46976. const i18n_password_protected = __('Password protected');
  46977. const i18n_persistent = __('Persistent');
  46978. const i18n_persistent_help = __('This groupchat persists even if it\'s unoccupied');
  46979. const i18n_public = __('Public');
  46980. const i18n_semi_anon = __('Semi-anonymous');
  46981. const i18n_semi_anon_help = __('Only moderators can see your XMPP address');
  46982. const i18n_temporary = __('Temporary');
  46983. const i18n_temporary_help = __('This groupchat will disappear once the last person leaves');
  46984. return $`
  46985. <div class="modal-dialog" role="document">
  46986. <div class="modal-content">
  46987. <div class="modal-header">
  46988. <h5 class="modal-title" id="muc-details-modal-label">${display_name}</h5>
  46989. ${modal_header_close_button}
  46990. </div>
  46991. <div class="modal-body">
  46992. <span class="modal-alert"></span>
  46993. <div class="room-info">
  46994. <p class="room-info"><strong>${i18n_name}</strong>: ${o.name}</p>
  46995. <p class="room-info"><strong>${i18n_address}</strong>: <converse-rich-text text="xmpp:${o.jid}?join"></converse-rich-text></p>
  46996. <p class="room-info"><strong>${i18n_desc}</strong>: <converse-rich-text text="${config.description}" render_styling></converse-rich-text></p>
  46997. ${o.subject ? subject(o) : ''}
  46998. <p class="room-info"><strong>${i18n_online_users}</strong>: ${num_occupants}</p>
  46999. <p class="room-info"><strong>${i18n_features}</strong>:
  47000. <div class="chatroom-features">
  47001. <ul class="features-list">
  47002. ${features.passwordprotected ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-lock"></converse-icon>${i18n_password_protected} - <em>${i18n_password_help}</em></li>` : ''}
  47003. ${features.unsecured ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-unlock"></converse-icon>${i18n_no_password_required} - <em>${i18n_no_pass_help}</em></li>` : ''}
  47004. ${features.hidden ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-eye-slash"></converse-icon>${i18n_hidden} - <em>${i18n_hidden_help}</em></li>` : ''}
  47005. ${features.public_room ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-eye"></converse-icon>${i18n_public} - <em>${o.__('This groupchat is publicly searchable')}</em></li>` : ''}
  47006. ${features.membersonly ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-address-book"></converse-icon>${i18n_members_only} - <em>${i18n_members_help}</em></li>` : ''}
  47007. ${features.open ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-globe"></converse-icon>${i18n_open} - <em>${i18n_open_help}</em></li>` : ''}
  47008. ${features.persistent ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-save"></converse-icon>${i18n_persistent} - <em>${i18n_persistent_help}</em></li>` : ''}
  47009. ${features.temporary ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-snowflake-o"></converse-icon>${i18n_temporary} - <em>${i18n_temporary_help}</em></li>` : ''}
  47010. ${features.nonanonymous ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-id-card"></converse-icon>${i18n_not_anonymous} - <em>${i18n_not_anonymous_help}</em></li>` : ''}
  47011. ${features.semianonymous ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-user-secret"></converse-icon>${i18n_semi_anon} - <em>${i18n_semi_anon_help}</em></li>` : ''}
  47012. ${features.moderated ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-gavel"></converse-icon>${i18n_moderated} - <em>${i18n_moderated_help}</em></li>` : ''}
  47013. ${features.unmoderated ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-info-circle"></converse-icon>${i18n_not_moderated} - <em>${i18n_not_moderated_help}</em></li>` : ''}
  47014. ${features.mam_enabled ? $`<li class="feature" ><converse-icon size="1em" class="fa fa-database"></converse-icon>${i18n_archiving} - <em>${i18n_archiving_help}</em></li>` : ''}
  47015. </ul>
  47016. </div>
  47017. </p>
  47018. </div>
  47019. </div>
  47020. <div class="modal-footer">${modal_close_button}</div>
  47021. </div>
  47022. </div>
  47023. `;
  47024. });
  47025. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/muc-details.scss
  47026. var styles_muc_details = __webpack_require__(7140);
  47027. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/muc-details.scss
  47028. var muc_details_options = {};
  47029. muc_details_options.styleTagTransform = (styleTagTransform_default());
  47030. muc_details_options.setAttributes = (setAttributesWithoutAttributes_default());
  47031. muc_details_options.insert = insertBySelector_default().bind(null, "head");
  47032. muc_details_options.domAPI = (styleDomAPI_default());
  47033. muc_details_options.insertStyleElement = (insertStyleElement_default());
  47034. var muc_details_update = injectStylesIntoStyleTag_default()(styles_muc_details/* default */.Z, muc_details_options);
  47035. /* harmony default export */ const muc_views_styles_muc_details = (styles_muc_details/* default */.Z && styles_muc_details/* default.locals */.Z.locals ? styles_muc_details/* default.locals */.Z.locals : undefined);
  47036. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/muc-details.js
  47037. /* harmony default export */ const modals_muc_details = (base.extend({
  47038. id: "muc-details-modal",
  47039. initialize() {
  47040. base.prototype.initialize.apply(this, arguments);
  47041. this.listenTo(this.model, 'change', this.render);
  47042. this.listenTo(this.model.features, 'change', this.render);
  47043. this.listenTo(this.model.occupants, 'add', this.render);
  47044. this.listenTo(this.model.occupants, 'change', this.render);
  47045. },
  47046. toHTML() {
  47047. return muc_details(this.model);
  47048. }
  47049. }));
  47050. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/shared/components/styles/rich-text.scss
  47051. var styles_rich_text = __webpack_require__(307);
  47052. ;// CONCATENATED MODULE: ./src/shared/components/styles/rich-text.scss
  47053. var rich_text_options = {};
  47054. rich_text_options.styleTagTransform = (styleTagTransform_default());
  47055. rich_text_options.setAttributes = (setAttributesWithoutAttributes_default());
  47056. rich_text_options.insert = insertBySelector_default().bind(null, "head");
  47057. rich_text_options.domAPI = (styleDomAPI_default());
  47058. rich_text_options.insertStyleElement = (insertStyleElement_default());
  47059. var rich_text_update = injectStylesIntoStyleTag_default()(styles_rich_text/* default */.Z, rich_text_options);
  47060. /* harmony default export */ const components_styles_rich_text = (styles_rich_text/* default */.Z && styles_rich_text/* default.locals */.Z.locals ? styles_rich_text/* default.locals */.Z.locals : undefined);
  47061. ;// CONCATENATED MODULE: ./src/shared/components/rich-text.js
  47062. /**
  47063. * The RichText custom element allows you to parse transform text into rich DOM elements.
  47064. * @example <converse-rich-text text="*_hello_ world!*"></converse-rich-text>
  47065. */
  47066. class rich_text_RichText extends CustomElement {
  47067. static get properties() {
  47068. /**
  47069. * @typedef { Object } RichTextComponentProperties
  47070. * @property { Boolean } embed_audio
  47071. * Whether URLs that point to audio files should render as audio players.
  47072. * @property { Boolean } embed_videos
  47073. * Whether URLs that point to video files should render as video players.
  47074. * @property { Array } mentions - An array of objects representing chat mentions
  47075. * @property { String } nick - The current user's nickname, relevant for mentions
  47076. * @property { Number } offset - The text offset, in case this is a nested RichText element.
  47077. * @property { Function } onImgClick
  47078. * @property { Function } onImgLoad
  47079. * @property { Boolean } render_styling
  47080. * Whether XEP-0393 message styling hints should be rendered
  47081. * @property { Boolean } show_images
  47082. * Whether URLs that point to image files should render as images
  47083. * @property { Boolean } hide_media_urls
  47084. * If media URLs are rendered as media, then this option determines
  47085. * whether the original URL is also still shown or not.
  47086. * Only relevant in conjunction with `show_images`, `embed_audio` and `embed_videos`.
  47087. * @property { Boolean } show_me_message
  47088. * Whether text that starts with /me should be rendered in the 3rd person.
  47089. * @property { String } text - The text that will get transformed.
  47090. */
  47091. return {
  47092. embed_audio: {
  47093. type: Boolean
  47094. },
  47095. embed_videos: {
  47096. type: Boolean
  47097. },
  47098. mentions: {
  47099. type: Array
  47100. },
  47101. nick: {
  47102. type: String
  47103. },
  47104. offset: {
  47105. type: Number
  47106. },
  47107. onImgClick: {
  47108. type: Function
  47109. },
  47110. onImgLoad: {
  47111. type: Function
  47112. },
  47113. render_styling: {
  47114. type: Boolean
  47115. },
  47116. show_images: {
  47117. type: Boolean
  47118. },
  47119. hide_media_urls: {
  47120. type: Boolean
  47121. },
  47122. show_me_message: {
  47123. type: Boolean
  47124. },
  47125. text: {
  47126. type: String
  47127. }
  47128. };
  47129. }
  47130. constructor() {
  47131. super();
  47132. this.embed_audio = false;
  47133. this.embed_videos = false;
  47134. this.hide_media_urls = false;
  47135. this.mentions = [];
  47136. this.offset = 0;
  47137. this.render_styling = false;
  47138. this.show_image_urls = true;
  47139. this.show_images = false;
  47140. this.show_me_message = false;
  47141. }
  47142. render() {
  47143. const options = {
  47144. embed_audio: this.embed_audio,
  47145. embed_videos: this.embed_videos,
  47146. hide_media_urls: this.hide_media_urls,
  47147. mentions: this.mentions,
  47148. nick: this.nick,
  47149. onImgClick: this.onImgClick,
  47150. onImgLoad: this.onImgLoad,
  47151. render_styling: this.render_styling,
  47152. show_images: this.show_images,
  47153. show_me_message: this.show_me_message
  47154. };
  47155. return rich_text(this.text, this.offset, options);
  47156. }
  47157. }
  47158. core_api.elements.define('converse-rich-text', rich_text_RichText);
  47159. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-head.js
  47160. /* harmony default export */ const muc_head = (el => {
  47161. var _el$user_settings, _el$user_settings$get, _el$model$vcard, _el$model$vcard2, _el$model$vcard3;
  47162. const o = el.model.toJSON();
  47163. const subject_hidden = (_el$user_settings = el.user_settings) === null || _el$user_settings === void 0 ? void 0 : (_el$user_settings$get = _el$user_settings.get('mucs_with_hidden_subject', [])) === null || _el$user_settings$get === void 0 ? void 0 : _el$user_settings$get.includes(el.model.get('jid'));
  47164. const i18n_hide_topic = __('Hide the groupchat topic');
  47165. const i18n_bookmarked = __('This groupchat is bookmarked');
  47166. const subject = o.subject ? o.subject.text : '';
  47167. const show_subject = subject && !subject_hidden;
  47168. const muc_vcard = (_el$model$vcard = el.model.vcard) === null || _el$model$vcard === void 0 ? void 0 : _el$model$vcard.get('image');
  47169. return $`
  47170. <div class="chatbox-title ${show_subject ? '' : "chatbox-title--no-desc"}">
  47171. ${muc_vcard && muc_vcard !== shared_converse.DEFAULT_IMAGE ? $`
  47172. <converse-avatar class="avatar align-self-center"
  47173. .data=${(_el$model$vcard2 = el.model.vcard) === null || _el$model$vcard2 === void 0 ? void 0 : _el$model$vcard2.attributes}
  47174. nonce=${(_el$model$vcard3 = el.model.vcard) === null || _el$model$vcard3 === void 0 ? void 0 : _el$model$vcard3.get('vcard_updated')}
  47175. height="40" width="40"></converse-avatar>` : ''}
  47176. <div class="chatbox-title--row">
  47177. ${!shared_converse.api.settings.get("singleton") ? $`<converse-controlbox-navback jid="${o.jid}"></converse-controlbox-navback>` : ''}
  47178. <div class="chatbox-title__text" title="${core_api.settings.get('locked_muc_domain') !== 'hidden' ? o.jid : ''}">${el.model.getDisplayName()}
  47179. ${o.bookmarked ? $`<i class="fa fa-bookmark chatbox-title__text--bookmarked" title="${i18n_bookmarked}"></i>` : ''}
  47180. </div>
  47181. </div>
  47182. <div class="chatbox-title__buttons row no-gutters">
  47183. ${until_c(el.getHeadingButtons(subject_hidden).then(buttons => {
  47184. const dropdown_btns = buttons.filter(b => !b.standalone).map(b => getHeadingDropdownItem(b));
  47185. return $`
  47186. ${buttons.filter(b => b.standalone).reverse().map(b => until_c(getHeadingStandaloneButton(b), ''))}
  47187. ${dropdown_btns.length ? $`<converse-dropdown class="dropleft" color="var(--chatroom-head-color)" .items=${dropdown_btns}></converse-dropdown>` : ''}`;
  47188. }), '')}
  47189. </div>
  47190. </div>
  47191. ${show_subject ? $`<p class="chat-head__desc" title="${i18n_hide_topic}">
  47192. <converse-rich-text text=${subject} render_styling></converse-rich-text>
  47193. </p>` : ''}
  47194. `;
  47195. });
  47196. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/muc-head.scss
  47197. var styles_muc_head = __webpack_require__(3288);
  47198. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/muc-head.scss
  47199. var muc_head_options = {};
  47200. muc_head_options.styleTagTransform = (styleTagTransform_default());
  47201. muc_head_options.setAttributes = (setAttributesWithoutAttributes_default());
  47202. muc_head_options.insert = insertBySelector_default().bind(null, "head");
  47203. muc_head_options.domAPI = (styleDomAPI_default());
  47204. muc_head_options.insertStyleElement = (insertStyleElement_default());
  47205. var muc_head_update = injectStylesIntoStyleTag_default()(styles_muc_head/* default */.Z, muc_head_options);
  47206. /* harmony default export */ const muc_views_styles_muc_head = (styles_muc_head/* default */.Z && styles_muc_head/* default.locals */.Z.locals ? styles_muc_head/* default.locals */.Z.locals : undefined);
  47207. ;// CONCATENATED MODULE: ./src/plugins/muc-views/heading.js
  47208. class MUCHeading extends CustomElement {
  47209. async initialize() {
  47210. this.model = shared_converse.chatboxes.get(this.getAttribute('jid'));
  47211. this.listenTo(this.model, 'change', () => this.requestUpdate());
  47212. this.listenTo(this.model, 'vcard:add', () => this.requestUpdate());
  47213. this.listenTo(this.model, 'vcard:change', () => this.requestUpdate());
  47214. this.user_settings = await shared_converse.api.user.settings.getModel();
  47215. this.listenTo(this.user_settings, 'change:mucs_with_hidden_subject', () => this.requestUpdate());
  47216. await this.model.initialized;
  47217. this.listenTo(this.model.features, 'change:open', () => this.requestUpdate());
  47218. this.model.occupants.forEach(o => this.onOccupantAdded(o));
  47219. this.listenTo(this.model.occupants, 'add', this.onOccupantAdded);
  47220. this.listenTo(this.model.occupants, 'change:affiliation', this.onOccupantAffiliationChanged);
  47221. this.requestUpdate();
  47222. }
  47223. render() {
  47224. return this.model && this.user_settings ? muc_head(this) : '';
  47225. }
  47226. onOccupantAdded(occupant) {
  47227. if (occupant.get('jid') === shared_converse.bare_jid) {
  47228. this.requestUpdate();
  47229. }
  47230. }
  47231. onOccupantAffiliationChanged(occupant) {
  47232. if (occupant.get('jid') === shared_converse.bare_jid) {
  47233. this.requestUpdate();
  47234. }
  47235. }
  47236. showRoomDetailsModal(ev) {
  47237. ev.preventDefault();
  47238. core_api.modal.show(modals_muc_details, {
  47239. 'model': this.model
  47240. }, ev);
  47241. }
  47242. showInviteModal(ev) {
  47243. ev.preventDefault();
  47244. core_api.modal.show(modals_muc_invite, {
  47245. 'model': new Model(),
  47246. 'chatroomview': this
  47247. }, ev);
  47248. }
  47249. toggleTopic(ev) {
  47250. var _ev$preventDefault;
  47251. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  47252. this.model.toggleSubjectHiddenState();
  47253. }
  47254. getAndRenderConfigurationForm() {
  47255. this.model.session.set('view', core_converse.MUC.VIEWS.CONFIG);
  47256. }
  47257. close(ev) {
  47258. ev.preventDefault();
  47259. this.model.close();
  47260. }
  47261. destroy(ev) {
  47262. ev.preventDefault();
  47263. destroyMUC(this.model);
  47264. }
  47265. /**
  47266. * Returns a list of objects which represent buttons for the groupchat header.
  47267. * @emits _converse#getHeadingButtons
  47268. */
  47269. getHeadingButtons(subject_hidden) {
  47270. const buttons = [];
  47271. buttons.push({
  47272. 'i18n_text': __('Details'),
  47273. 'i18n_title': __('Show more information about this groupchat'),
  47274. 'handler': ev => this.showRoomDetailsModal(ev),
  47275. 'a_class': 'show-muc-details-modal',
  47276. 'icon_class': 'fa-info-circle',
  47277. 'name': 'details'
  47278. });
  47279. if (this.model.getOwnAffiliation() === 'owner') {
  47280. buttons.push({
  47281. 'i18n_text': __('Configure'),
  47282. 'i18n_title': __('Configure this groupchat'),
  47283. 'handler': () => this.getAndRenderConfigurationForm(),
  47284. 'a_class': 'configure-chatroom-button',
  47285. 'icon_class': 'fa-wrench',
  47286. 'name': 'configure'
  47287. });
  47288. }
  47289. buttons.push({
  47290. 'i18n_text': __('Nickname'),
  47291. 'i18n_title': __("Change the nickname you're using in this groupchat"),
  47292. 'handler': ev => core_api.modal.show(modals_nickname, {
  47293. 'model': this.model
  47294. }, ev),
  47295. 'a_class': 'open-nickname-modal',
  47296. 'icon_class': 'fa-smile',
  47297. 'name': 'nickname'
  47298. });
  47299. if (this.model.invitesAllowed()) {
  47300. buttons.push({
  47301. 'i18n_text': __('Invite'),
  47302. 'i18n_title': __('Invite someone to join this groupchat'),
  47303. 'handler': ev => this.showInviteModal(ev),
  47304. 'a_class': 'open-invite-modal',
  47305. 'icon_class': 'fa-user-plus',
  47306. 'name': 'invite'
  47307. });
  47308. }
  47309. const subject = this.model.get('subject');
  47310. if (subject && subject.text) {
  47311. buttons.push({
  47312. 'i18n_text': subject_hidden ? __('Show topic') : __('Hide topic'),
  47313. 'i18n_title': subject_hidden ? __('Show the topic message in the heading') : __('Hide the topic in the heading'),
  47314. 'handler': ev => this.toggleTopic(ev),
  47315. 'a_class': 'hide-topic',
  47316. 'icon_class': 'fa-minus-square',
  47317. 'name': 'toggle-topic'
  47318. });
  47319. }
  47320. const conn_status = this.model.session.get('connection_status');
  47321. if (conn_status === core_converse.ROOMSTATUS.ENTERED) {
  47322. const allowed_commands = this.model.getAllowedCommands();
  47323. if (allowed_commands.includes('modtools')) {
  47324. buttons.push({
  47325. 'i18n_text': __('Moderate'),
  47326. 'i18n_title': __('Moderate this groupchat'),
  47327. 'handler': () => showModeratorToolsModal(this.model),
  47328. 'a_class': 'moderate-chatroom-button',
  47329. 'icon_class': 'fa-user-cog',
  47330. 'name': 'moderate'
  47331. });
  47332. }
  47333. if (allowed_commands.includes('destroy')) {
  47334. buttons.push({
  47335. 'i18n_text': __('Destroy'),
  47336. 'i18n_title': __('Remove this groupchat'),
  47337. 'handler': ev => this.destroy(ev),
  47338. 'a_class': 'destroy-chatroom-button',
  47339. 'icon_class': 'fa-trash',
  47340. 'name': 'destroy'
  47341. });
  47342. }
  47343. }
  47344. if (!core_api.settings.get('singleton')) {
  47345. buttons.push({
  47346. 'i18n_text': __('Leave'),
  47347. 'i18n_title': __('Leave and close this groupchat'),
  47348. 'handler': async ev => {
  47349. ev.stopPropagation();
  47350. const messages = [__('Are you sure you want to leave this groupchat?')];
  47351. const result = await core_api.confirm(__('Confirm'), messages);
  47352. result && this.close(ev);
  47353. },
  47354. 'a_class': 'close-chatbox-button',
  47355. 'standalone': core_api.settings.get('view_mode') === 'overlayed',
  47356. 'icon_class': 'fa-sign-out-alt',
  47357. 'name': 'signout'
  47358. });
  47359. }
  47360. const el = shared_converse.chatboxviews.get(this.getAttribute('jid'));
  47361. if (el) {
  47362. // This hook is described in src/plugins/chatview/heading.js
  47363. return shared_converse.api.hook('getHeadingButtons', el, buttons);
  47364. } else {
  47365. return Promise.resolve(buttons); // Happens during tests
  47366. }
  47367. }
  47368. }
  47369. core_api.elements.define('converse-muc-heading', MUCHeading);
  47370. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-password-form.js
  47371. /* harmony default export */ const muc_password_form = (o => {
  47372. const i18n_heading = __('This groupchat requires a password');
  47373. const i18n_password = __('Password: ');
  47374. const i18n_submit = __('Submit');
  47375. return $`
  47376. <form class="converse-form chatroom-form converse-centered-form" @submit=${o.submitPassword}>
  47377. <fieldset class="form-group">
  47378. <label>${i18n_heading}</label>
  47379. <p class="validation-message">${o.validation_message}</p>
  47380. <input class="hidden-username" type="text" autocomplete="username" value="${o.jid}"></input>
  47381. <input type="password"
  47382. name="password"
  47383. required="required"
  47384. class="form-control ${o.validation_message ? 'error' : ''}"
  47385. placeholder="${i18n_password}"/>
  47386. </fieldset>
  47387. <fieldset class="form-group">
  47388. <input class="btn btn-primary" type="submit" value="${i18n_submit}"/>
  47389. </fieldset>
  47390. </form>
  47391. `;
  47392. });
  47393. ;// CONCATENATED MODULE: ./src/plugins/muc-views/password-form.js
  47394. class MUCPasswordForm extends CustomElement {
  47395. static get properties() {
  47396. return {
  47397. 'jid': {
  47398. type: String
  47399. }
  47400. };
  47401. }
  47402. connectedCallback() {
  47403. super.connectedCallback();
  47404. this.model = shared_converse.chatboxes.get(this.jid);
  47405. this.listenTo(this.model, 'change:password_validation_message', this.render);
  47406. this.render();
  47407. }
  47408. render() {
  47409. return muc_password_form({
  47410. 'jid': this.model.get('jid'),
  47411. 'submitPassword': ev => this.submitPassword(ev),
  47412. 'validation_message': this.model.get('password_validation_message')
  47413. });
  47414. }
  47415. submitPassword(ev) {
  47416. ev.preventDefault();
  47417. const password = this.querySelector('input[type=password]').value;
  47418. this.model.join(this.model.get('nick'), password);
  47419. this.model.set('password_validation_message', null);
  47420. }
  47421. }
  47422. core_api.elements.define('converse-muc-password-form', MUCPasswordForm);
  47423. /* harmony default export */ const password_form = ((/* unused pure expression or super */ null && (MUCPasswordForm)));
  47424. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc.js
  47425. /* harmony default export */ const templates_muc = (o => {
  47426. return $`
  47427. <div class="flyout box-flyout">
  47428. <converse-dragresize></converse-dragresize>
  47429. ${o.model ? $`
  47430. <converse-muc-heading jid="${o.model.get('jid')}" class="chat-head chat-head-chatroom row no-gutters">
  47431. </converse-muc-heading>
  47432. <div class="chat-body chatroom-body row no-gutters">${getChatRoomBodyTemplate(o)}</div>
  47433. ` : ''}
  47434. </div>`;
  47435. });
  47436. ;// CONCATENATED MODULE: ./src/plugins/muc-views/muc.js
  47437. function muc_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  47438. class MUCView extends BaseChatView {
  47439. constructor() {
  47440. super(...arguments);
  47441. muc_defineProperty(this, "length", 300);
  47442. muc_defineProperty(this, "is_chatroom", true);
  47443. }
  47444. async initialize() {
  47445. this.model = await core_api.rooms.get(this.jid);
  47446. shared_converse.chatboxviews.add(this.jid, this);
  47447. this.setAttribute('id', this.model.get('box_id'));
  47448. this.listenTo(shared_converse, 'windowStateChanged', this.onWindowStateChanged);
  47449. this.listenTo(this.model, 'change:composing_spoiler', this.requestUpdateMessageForm);
  47450. this.listenTo(this.model.session, 'change:connection_status', this.onConnectionStatusChanged);
  47451. this.listenTo(this.model.session, 'change:view', this.requestUpdate);
  47452. this.onConnectionStatusChanged();
  47453. this.model.maybeShow();
  47454. /**
  47455. * Triggered once a {@link _converse.ChatRoomView} has been opened
  47456. * @event _converse#chatRoomViewInitialized
  47457. * @type { _converse.ChatRoomView }
  47458. * @example _converse.api.listen.on('chatRoomViewInitialized', view => { ... });
  47459. */
  47460. core_api.trigger('chatRoomViewInitialized', this);
  47461. }
  47462. render() {
  47463. return templates_muc({
  47464. 'model': this.model
  47465. });
  47466. }
  47467. onConnectionStatusChanged() {
  47468. const conn_status = this.model.session.get('connection_status');
  47469. if (conn_status === core_converse.ROOMSTATUS.CONNECTING) {
  47470. this.model.session.save({
  47471. 'disconnection_actor': undefined,
  47472. 'disconnection_message': undefined,
  47473. 'disconnection_reason': undefined
  47474. });
  47475. this.model.save({
  47476. 'moved_jid': undefined,
  47477. 'password_validation_message': undefined,
  47478. 'reason': undefined
  47479. });
  47480. }
  47481. this.requestUpdate();
  47482. }
  47483. }
  47484. core_api.elements.define('converse-muc', MUCView);
  47485. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/muc-views/styles/index.scss
  47486. var muc_views_styles = __webpack_require__(3076);
  47487. ;// CONCATENATED MODULE: ./src/plugins/muc-views/styles/index.scss
  47488. var muc_views_styles_options = {};
  47489. muc_views_styles_options.styleTagTransform = (styleTagTransform_default());
  47490. muc_views_styles_options.setAttributes = (setAttributesWithoutAttributes_default());
  47491. muc_views_styles_options.insert = insertBySelector_default().bind(null, "head");
  47492. muc_views_styles_options.domAPI = (styleDomAPI_default());
  47493. muc_views_styles_options.insertStyleElement = (insertStyleElement_default());
  47494. var muc_views_styles_update = injectStylesIntoStyleTag_default()(muc_views_styles/* default */.Z, muc_views_styles_options);
  47495. /* harmony default export */ const plugins_muc_views_styles = (muc_views_styles/* default */.Z && muc_views_styles/* default.locals */.Z.locals ? muc_views_styles/* default.locals */.Z.locals : undefined);
  47496. ;// CONCATENATED MODULE: ./src/plugins/muc-views/index.js
  47497. /**
  47498. * @copyright The Converse.js developers
  47499. * @description XEP-0045 Multi-User Chat Views
  47500. * @license Mozilla Public License (MPLv2)
  47501. */
  47502. const {
  47503. Strophe: muc_views_Strophe
  47504. } = core_converse.env;
  47505. core_converse.MUC.VIEWS = {
  47506. CONFIG: 'config-form'
  47507. };
  47508. core_converse.plugins.add('converse-muc-views', {
  47509. /* Dependencies are other plugins which might be
  47510. * overridden or relied upon, and therefore need to be loaded before
  47511. * this plugin. They are "optional" because they might not be
  47512. * available, in which case any overrides applicable to them will be
  47513. * ignored.
  47514. *
  47515. * NB: These plugins need to have already been loaded via require.js.
  47516. *
  47517. * It's possible to make these dependencies "non-optional".
  47518. * If the setting "strict_plugin_dependencies" is set to true,
  47519. * an error will be raised if the plugin is not found.
  47520. */
  47521. dependencies: ['converse-modal', 'converse-controlbox', 'converse-chatview'],
  47522. initialize() {
  47523. const {
  47524. _converse
  47525. } = this; // Configuration values for this plugin
  47526. // ====================================
  47527. // Refer to docs/source/configuration.rst for explanations of these
  47528. // configuration settings.
  47529. core_api.settings.extend({
  47530. 'auto_list_rooms': false,
  47531. 'cache_muc_messages': true,
  47532. 'locked_muc_nickname': false,
  47533. 'modtools_disable_query': [],
  47534. 'muc_disable_slash_commands': false,
  47535. 'muc_mention_autocomplete_filter': 'contains',
  47536. 'muc_mention_autocomplete_min_chars': 0,
  47537. 'muc_mention_autocomplete_show_avatar': true,
  47538. 'muc_roomid_policy': null,
  47539. 'muc_roomid_policy_hint': null,
  47540. 'roomconfig_whitelist': [],
  47541. 'show_retraction_warning': true,
  47542. 'visible_toolbar_buttons': {
  47543. 'toggle_occupants': true
  47544. }
  47545. });
  47546. _converse.ChatRoomView = MUCView;
  47547. if (!core_api.settings.get('muc_domain')) {
  47548. // Use service discovery to get the default MUC domain
  47549. core_api.listen.on('serviceDiscovered', async feature => {
  47550. if ((feature === null || feature === void 0 ? void 0 : feature.get('var')) === muc_views_Strophe.NS.MUC) {
  47551. if (feature.entity.get('jid').includes('@')) {
  47552. // Ignore full JIDs, we're only looking for a MUC service, not a room
  47553. return;
  47554. }
  47555. const identity = await feature.entity.getIdentity('conference', 'text');
  47556. if (identity) {
  47557. core_api.settings.set('muc_domain', muc_views_Strophe.getDomainFromJid(feature.get('from')));
  47558. }
  47559. }
  47560. });
  47561. }
  47562. core_api.listen.on('clearsession', () => {
  47563. const view = _converse.chatboxviews.get('controlbox');
  47564. if (view && view.roomspanel) {
  47565. view.roomspanel.model.destroy();
  47566. view.roomspanel.remove();
  47567. delete view.roomspanel;
  47568. }
  47569. });
  47570. core_api.listen.on('chatBoxClosed', model => {
  47571. if (model.get('type') === _converse.CHATROOMS_TYPE) {
  47572. utils_clearHistory(model.get('jid'));
  47573. }
  47574. });
  47575. core_api.listen.on('parseMessageForCommands', parseMessageForMUCCommands);
  47576. }
  47577. });
  47578. // EXTERNAL MODULE: ./node_modules/favico.js-slevomat/favico.js
  47579. var favico = __webpack_require__(4023);
  47580. var favico_default = /*#__PURE__*/__webpack_require__.n(favico);
  47581. ;// CONCATENATED MODULE: ./src/plugins/notifications/utils.js
  47582. const {
  47583. Strophe: notifications_utils_Strophe
  47584. } = core_converse.env;
  47585. const supports_html5_notification = ('Notification' in window);
  47586. core_converse.env.Favico = (favico_default());
  47587. let favicon;
  47588. function isMessageToHiddenChat(attrs) {
  47589. var _converse$chatboxes$g;
  47590. return shared_converse.isTestEnv() || (((_converse$chatboxes$g = shared_converse.chatboxes.get(attrs.from)) === null || _converse$chatboxes$g === void 0 ? void 0 : _converse$chatboxes$g.isHidden()) ?? false);
  47591. }
  47592. function areDesktopNotificationsEnabled() {
  47593. return shared_converse.isTestEnv() || supports_html5_notification && core_api.settings.get('show_desktop_notifications') && Notification.permission === 'granted';
  47594. }
  47595. function clearFavicon() {
  47596. var _navigator$clearAppBa, _navigator;
  47597. favicon = null;
  47598. (_navigator$clearAppBa = (_navigator = navigator).clearAppBadge) === null || _navigator$clearAppBa === void 0 ? void 0 : _navigator$clearAppBa.call(_navigator).catch(e => headless_log.error("Could not clear unread count in app badge " + e));
  47599. }
  47600. function updateUnreadFavicon() {
  47601. if (core_api.settings.get('show_tab_notifications')) {
  47602. var _navigator$setAppBadg, _navigator2;
  47603. favicon = favicon ?? new core_converse.env.Favico({
  47604. type: 'circle',
  47605. animation: 'pop'
  47606. });
  47607. const chats = shared_converse.chatboxes.models;
  47608. const num_unread = chats.reduce((acc, chat) => acc + (chat.get('num_unread') || 0), 0);
  47609. favicon.badge(num_unread);
  47610. (_navigator$setAppBadg = (_navigator2 = navigator).setAppBadge) === null || _navigator$setAppBadg === void 0 ? void 0 : _navigator$setAppBadg.call(_navigator2, num_unread).catch(e => headless_log.error("Could set unread count in app badge - " + e));
  47611. }
  47612. }
  47613. function isReferenced(references, muc_jid, nick) {
  47614. const check = r => [shared_converse.bare_jid, `${muc_jid}/${nick}`].includes(r.uri.replace(/^xmpp:/, ''));
  47615. return references.reduce((acc, r) => acc || check(r), false);
  47616. }
  47617. /**
  47618. * Is this a group message for which we should notify the user?
  47619. * @private
  47620. * @param { MUCMessageAttributes } attrs
  47621. */
  47622. async function shouldNotifyOfGroupMessage(attrs) {
  47623. if (!(attrs !== null && attrs !== void 0 && attrs.body) && !(attrs !== null && attrs !== void 0 && attrs.message)) {
  47624. // attrs.message is used by 'info' messages
  47625. return false;
  47626. }
  47627. const jid = attrs.from;
  47628. const muc_jid = attrs.from_muc;
  47629. const notify_all = core_api.settings.get('notify_all_room_messages');
  47630. const room = shared_converse.chatboxes.get(muc_jid);
  47631. const resource = notifications_utils_Strophe.getResourceFromJid(jid);
  47632. const sender = resource && notifications_utils_Strophe.unescapeNode(resource) || '';
  47633. let is_mentioned = false;
  47634. const nick = room.get('nick');
  47635. if (core_api.settings.get('notify_nicknames_without_references')) {
  47636. is_mentioned = new RegExp(`\\b${nick}\\b`).test(attrs.body);
  47637. }
  47638. const is_not_mine = sender !== nick;
  47639. const should_notify_user = notify_all === true || Array.isArray(notify_all) && notify_all.includes(muc_jid) || isReferenced(attrs.references, muc_jid, nick) || is_mentioned;
  47640. if (is_not_mine && !!should_notify_user) {
  47641. /**
  47642. * *Hook* which allows plugins to run further logic to determine
  47643. * whether a notification should be sent out for this message.
  47644. * @event _converse#shouldNotifyOfGroupMessage
  47645. * @example
  47646. * api.listen.on('shouldNotifyOfGroupMessage', (should_notify) => {
  47647. * return should_notify && flurb === floob;
  47648. * });
  47649. */
  47650. const should_notify = await core_api.hook('shouldNotifyOfGroupMessage', attrs, true);
  47651. return should_notify;
  47652. }
  47653. return false;
  47654. }
  47655. async function shouldNotifyOfInfoMessage(attrs) {
  47656. if (!attrs.from_muc) {
  47657. return false;
  47658. }
  47659. const room = await core_api.rooms.get(attrs.from_muc);
  47660. if (!room) {
  47661. return false;
  47662. }
  47663. const nick = room.get('nick');
  47664. const muc_jid = attrs.from_muc;
  47665. const notify_all = core_api.settings.get('notify_all_room_messages');
  47666. return notify_all === true || Array.isArray(notify_all) && notify_all.includes(muc_jid) || isReferenced(attrs.references, muc_jid, nick);
  47667. }
  47668. /**
  47669. * @private
  47670. * @async
  47671. * @method shouldNotifyOfMessage
  47672. * @param { MessageData|MUCMessageData } data
  47673. */
  47674. function shouldNotifyOfMessage(data) {
  47675. const {
  47676. attrs
  47677. } = data;
  47678. if (!attrs || attrs.is_forwarded) {
  47679. return false;
  47680. }
  47681. if (attrs['type'] === 'groupchat') {
  47682. return shouldNotifyOfGroupMessage(attrs);
  47683. } else if (attrs['type'] === 'info') {
  47684. return shouldNotifyOfInfoMessage(attrs);
  47685. } else if (attrs.is_headline) {
  47686. // We want to show notifications for headline messages.
  47687. return isMessageToHiddenChat(attrs);
  47688. }
  47689. const is_me = notifications_utils_Strophe.getBareJidFromJid(attrs.from) === shared_converse.bare_jid;
  47690. return !isEmptyMessage(attrs) && !is_me && (core_api.settings.get('show_desktop_notifications') === 'all' || isMessageToHiddenChat(attrs));
  47691. }
  47692. function showFeedbackNotification(data) {
  47693. if (data.klass === 'error' || data.klass === 'warn') {
  47694. const n = new Notification(data.subject, {
  47695. body: data.message,
  47696. lang: shared_converse.locale,
  47697. icon: core_api.settings.get('notification_icon')
  47698. });
  47699. setTimeout(n.close.bind(n), 5000);
  47700. }
  47701. }
  47702. /**
  47703. * Creates an HTML5 Notification to inform of a change in a
  47704. * contact's chat state.
  47705. */
  47706. function showChatStateNotification(contact) {
  47707. var _api$settings$get;
  47708. if ((_api$settings$get = core_api.settings.get('chatstate_notification_blacklist')) !== null && _api$settings$get !== void 0 && _api$settings$get.includes(contact.jid)) {
  47709. // Don't notify if the user is being ignored.
  47710. return;
  47711. }
  47712. const chat_state = contact.presence.get('show');
  47713. let message = null;
  47714. if (chat_state === 'offline') {
  47715. message = __('has gone offline');
  47716. } else if (chat_state === 'away') {
  47717. message = __('has gone away');
  47718. } else if (chat_state === 'dnd') {
  47719. message = __('is busy');
  47720. } else if (chat_state === 'online') {
  47721. message = __('has come online');
  47722. }
  47723. if (message === null) {
  47724. return;
  47725. }
  47726. const n = new Notification(contact.getDisplayName(), {
  47727. body: message,
  47728. lang: shared_converse.locale,
  47729. icon: core_api.settings.get('notification_icon')
  47730. });
  47731. setTimeout(() => n.close(), 5000);
  47732. }
  47733. /**
  47734. * Shows an HTML5 Notification with the passed in message
  47735. * @private
  47736. * @param { MessageData|MUCMessageData } data
  47737. */
  47738. function showMessageNotification(data) {
  47739. const {
  47740. attrs
  47741. } = data;
  47742. if (attrs.is_error) {
  47743. return;
  47744. }
  47745. if (!areDesktopNotificationsEnabled()) {
  47746. return;
  47747. }
  47748. let title, roster_item;
  47749. const full_from_jid = attrs.from;
  47750. const from_jid = notifications_utils_Strophe.getBareJidFromJid(full_from_jid);
  47751. if (attrs.type == 'info') {
  47752. title = attrs.message;
  47753. } else if (attrs.type === 'headline') {
  47754. if (!from_jid.includes('@') || core_api.settings.get('allow_non_roster_messaging')) {
  47755. title = __('Notification from %1$s', from_jid);
  47756. } else {
  47757. return;
  47758. }
  47759. } else if (!from_jid.includes('@')) {
  47760. // workaround for Prosody which doesn't give type "headline"
  47761. title = __('Notification from %1$s', from_jid);
  47762. } else if (attrs.type === 'groupchat') {
  47763. title = __('%1$s says', notifications_utils_Strophe.getResourceFromJid(full_from_jid));
  47764. } else {
  47765. if (shared_converse.roster === undefined) {
  47766. headless_log.error('Could not send notification, because roster is undefined');
  47767. return;
  47768. }
  47769. roster_item = shared_converse.roster.get(from_jid);
  47770. if (roster_item !== undefined) {
  47771. title = __('%1$s says', roster_item.getDisplayName());
  47772. } else {
  47773. if (core_api.settings.get('allow_non_roster_messaging')) {
  47774. title = __('%1$s says', from_jid);
  47775. } else {
  47776. return;
  47777. }
  47778. }
  47779. }
  47780. let body;
  47781. if (attrs.type == 'info') {
  47782. body = attrs.reason;
  47783. } else {
  47784. body = attrs.is_encrypted ? attrs.plaintext : attrs.body;
  47785. if (!body) {
  47786. return;
  47787. }
  47788. }
  47789. const n = new Notification(title, {
  47790. 'body': body,
  47791. 'lang': shared_converse.locale,
  47792. 'icon': core_api.settings.get('notification_icon'),
  47793. 'requireInteraction': !core_api.settings.get('notification_delay')
  47794. });
  47795. if (core_api.settings.get('notification_delay')) {
  47796. setTimeout(() => n.close(), core_api.settings.get('notification_delay'));
  47797. }
  47798. n.onclick = function (event) {
  47799. event.preventDefault();
  47800. window.focus();
  47801. const chat = shared_converse.chatboxes.get(from_jid);
  47802. chat.maybeShow(true);
  47803. };
  47804. }
  47805. function playSoundNotification() {
  47806. if (core_api.settings.get('play_sounds') && window.Audio !== undefined) {
  47807. const audioOgg = new Audio(core_api.settings.get('sounds_path') + 'msg_received.ogg');
  47808. const canPlayOgg = audioOgg.canPlayType('audio/ogg');
  47809. if (canPlayOgg === 'probably') {
  47810. return audioOgg.play();
  47811. }
  47812. const audioMp3 = new Audio(core_api.settings.get('sounds_path') + 'msg_received.mp3');
  47813. const canPlayMp3 = audioMp3.canPlayType('audio/mp3');
  47814. if (canPlayMp3 === 'probably') {
  47815. audioMp3.play();
  47816. } else if (canPlayOgg === 'maybe') {
  47817. audioOgg.play();
  47818. } else if (canPlayMp3 === 'maybe') {
  47819. audioMp3.play();
  47820. }
  47821. }
  47822. }
  47823. /**
  47824. * Event handler for the on('message') event. Will call methods
  47825. * to play sounds and show HTML5 notifications.
  47826. */
  47827. async function handleMessageNotification(data) {
  47828. if (!(await shouldNotifyOfMessage(data))) {
  47829. return false;
  47830. }
  47831. /**
  47832. * Triggered when a notification (sound or HTML5 notification) for a new
  47833. * message has will be made.
  47834. * @event _converse#messageNotification
  47835. * @type { MessageData|MUCMessageData}
  47836. * @example _converse.api.listen.on('messageNotification', data => { ... });
  47837. */
  47838. core_api.trigger('messageNotification', data);
  47839. playSoundNotification();
  47840. showMessageNotification(data);
  47841. }
  47842. function handleFeedback(data) {
  47843. if (areDesktopNotificationsEnabled(true)) {
  47844. showFeedbackNotification(data);
  47845. }
  47846. }
  47847. /**
  47848. * Event handler for on('contactPresenceChanged').
  47849. * Will show an HTML5 notification to indicate that the chat status has changed.
  47850. */
  47851. function handleChatStateNotification(contact) {
  47852. if (areDesktopNotificationsEnabled() && core_api.settings.get('show_chat_state_notifications')) {
  47853. showChatStateNotification(contact);
  47854. }
  47855. }
  47856. function showContactRequestNotification(contact) {
  47857. const n = new Notification(contact.getDisplayName(), {
  47858. body: __('wants to be your contact'),
  47859. lang: shared_converse.locale,
  47860. icon: core_api.settings.get('notification_icon')
  47861. });
  47862. setTimeout(() => n.close(), 5000);
  47863. }
  47864. function handleContactRequestNotification(contact) {
  47865. if (areDesktopNotificationsEnabled(true)) {
  47866. showContactRequestNotification(contact);
  47867. }
  47868. }
  47869. function requestPermission() {
  47870. if (supports_html5_notification && !['denied', 'granted'].includes(Notification.permission)) {
  47871. // Ask user to enable HTML5 notifications
  47872. Notification.requestPermission();
  47873. }
  47874. }
  47875. ;// CONCATENATED MODULE: ./src/plugins/notifications/index.js
  47876. /**
  47877. * @module converse-notification
  47878. * @copyright 2022, the Converse.js contributors
  47879. * @license Mozilla Public License (MPLv2)
  47880. */
  47881. core_converse.plugins.add('converse-notification', {
  47882. dependencies: ['converse-chatboxes'],
  47883. initialize() {
  47884. core_api.settings.extend({
  47885. // ^ a list of JIDs to ignore concerning chat state notifications
  47886. chatstate_notification_blacklist: [],
  47887. notification_delay: 5000,
  47888. notification_icon: 'logo/conversejs-filled.svg',
  47889. notify_all_room_messages: false,
  47890. notify_nicknames_without_references: false,
  47891. play_sounds: true,
  47892. show_chat_state_notifications: false,
  47893. show_desktop_notifications: true,
  47894. show_tab_notifications: true,
  47895. sounds_path: core_api.settings.get('assets_path') + '/sounds/'
  47896. });
  47897. /************************ Event Handlers ************************/
  47898. core_api.listen.on('clearSession', clearFavicon); // Needed for tests
  47899. core_api.waitUntil('chatBoxesInitialized').then(() => shared_converse.chatboxes.on('change:num_unread', updateUnreadFavicon));
  47900. core_api.listen.on('pluginsInitialized', function () {
  47901. // We only register event handlers after all plugins are
  47902. // registered, because other plugins might override some of our
  47903. // handlers.
  47904. core_api.listen.on('contactRequest', handleContactRequestNotification);
  47905. core_api.listen.on('contactPresenceChanged', handleChatStateNotification);
  47906. core_api.listen.on('message', handleMessageNotification);
  47907. core_api.listen.on('feedback', handleFeedback);
  47908. core_api.listen.on('connected', requestPermission);
  47909. });
  47910. }
  47911. });
  47912. ;// CONCATENATED MODULE: ./node_modules/lodash-es/concat.js
  47913. /**
  47914. * Creates a new array concatenating `array` with any additional arrays
  47915. * and/or values.
  47916. *
  47917. * @static
  47918. * @memberOf _
  47919. * @since 4.0.0
  47920. * @category Array
  47921. * @param {Array} array The array to concatenate.
  47922. * @param {...*} [values] The values to concatenate.
  47923. * @returns {Array} Returns the new concatenated array.
  47924. * @example
  47925. *
  47926. * var array = [1];
  47927. * var other = _.concat(array, 2, [3], [[4]]);
  47928. *
  47929. * console.log(other);
  47930. * // => [1, 2, 3, [4]]
  47931. *
  47932. * console.log(array);
  47933. * // => [1]
  47934. */
  47935. function concat() {
  47936. var length = arguments.length;
  47937. if (!length) {
  47938. return [];
  47939. }
  47940. var args = Array(length - 1),
  47941. array = arguments[0],
  47942. index = length;
  47943. while (index--) {
  47944. args[index - 1] = arguments[index];
  47945. }
  47946. return _arrayPush(lodash_es_isArray(array) ? _copyArray(array) : [array], _baseFlatten(args, 1));
  47947. }
  47948. /* harmony default export */ const lodash_es_concat = (concat);
  47949. ;// CONCATENATED MODULE: ./src/plugins/omemo/consts.js
  47950. const UNDECIDED = 0;
  47951. const TRUSTED = 1;
  47952. const UNTRUSTED = -1;
  47953. const TAG_LENGTH = 128;
  47954. const KEY_ALGO = {
  47955. 'name': 'AES-GCM',
  47956. 'length': 128
  47957. };
  47958. ;// CONCATENATED MODULE: ./src/utils/file.js
  47959. const MIMETYPES_MAP = {
  47960. 'aac': 'audio/aac',
  47961. 'abw': 'application/x-abiword',
  47962. 'arc': 'application/x-freearc',
  47963. 'avi': 'video/x-msvideo',
  47964. 'azw': 'application/vnd.amazon.ebook',
  47965. 'bin': 'application/octet-stream',
  47966. 'bmp': 'image/bmp',
  47967. 'bz': 'application/x-bzip',
  47968. 'bz2': 'application/x-bzip2',
  47969. 'cda': 'application/x-cdf',
  47970. 'csh': 'application/x-csh',
  47971. 'css': 'text/css',
  47972. 'csv': 'text/csv',
  47973. 'doc': 'application/msword',
  47974. 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  47975. 'eot': 'application/vnd.ms-fontobject',
  47976. 'epub': 'application/epub+zip',
  47977. 'gif': 'image/gif',
  47978. 'gz': 'application/gzip',
  47979. 'htm': 'text/html',
  47980. 'html': 'text/html',
  47981. 'ico': 'image/vnd.microsoft.icon',
  47982. 'ics': 'text/calendar',
  47983. 'jar': 'application/java-archive',
  47984. 'jpeg': 'image/jpeg',
  47985. 'jpg': 'image/jpeg',
  47986. 'js': 'text/javascript',
  47987. 'json': 'application/json',
  47988. 'jsonld': 'application/ld+json',
  47989. 'm4a': 'audio/mp4',
  47990. 'mid': 'audio/midi',
  47991. 'midi': 'audio/midi',
  47992. 'mjs': 'text/javascript',
  47993. 'mp3': 'audio/mpeg',
  47994. 'mp4': 'video/mp4',
  47995. 'mpeg': 'video/mpeg',
  47996. 'mpkg': 'application/vnd.apple.installer+xml',
  47997. 'odp': 'application/vnd.oasis.opendocument.presentation',
  47998. 'ods': 'application/vnd.oasis.opendocument.spreadsheet',
  47999. 'odt': 'application/vnd.oasis.opendocument.text',
  48000. 'oga': 'audio/ogg',
  48001. 'ogv': 'video/ogg',
  48002. 'ogx': 'application/ogg',
  48003. 'opus': 'audio/opus',
  48004. 'otf': 'font/otf',
  48005. 'png': 'image/png',
  48006. 'pdf': 'application/pdf',
  48007. 'php': 'application/x-httpd-php',
  48008. 'ppt': 'application/vnd.ms-powerpoint',
  48009. 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  48010. 'rar': 'application/vnd.rar',
  48011. 'rtf': 'application/rtf',
  48012. 'sh': 'application/x-sh',
  48013. 'svg': 'image/svg+xml',
  48014. 'swf': 'application/x-shockwave-flash',
  48015. 'tar': 'application/x-tar',
  48016. 'tif': 'image/tiff',
  48017. 'tiff': 'image/tiff',
  48018. 'ts': 'video/mp2t',
  48019. 'ttf': 'font/ttf',
  48020. 'txt': 'text/plain',
  48021. 'vsd': 'application/vnd.visio',
  48022. 'wav': 'audio/wav',
  48023. 'weba': 'audio/webm',
  48024. 'webm': 'video/webm',
  48025. 'webp': 'image/webp',
  48026. 'woff': 'font/woff',
  48027. 'woff2': 'font/woff2',
  48028. 'xhtml': 'application/xhtml+xml',
  48029. 'xls': 'application/vnd.ms-excel',
  48030. 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  48031. 'xml': 'text/xml',
  48032. 'xul': 'application/vnd.mozilla.xul+xml',
  48033. 'zip': 'application/zip',
  48034. '3gp': 'video/3gpp',
  48035. '3g2': 'video/3gpp2',
  48036. '7z': 'application/x-7z-compressed'
  48037. };
  48038. ;// CONCATENATED MODULE: ./src/headless/utils/arraybuffer.js
  48039. const {
  48040. u: arraybuffer_u
  48041. } = core_converse.env;
  48042. function appendArrayBuffer(buffer1, buffer2) {
  48043. const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
  48044. tmp.set(new Uint8Array(buffer1), 0);
  48045. tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
  48046. return tmp.buffer;
  48047. }
  48048. function arrayBufferToHex(ab) {
  48049. // https://stackoverflow.com/questions/40031688/javascript-arraybuffer-to-hex#40031979
  48050. return Array.prototype.map.call(new Uint8Array(ab), x => ('00' + x.toString(16)).slice(-2)).join('');
  48051. }
  48052. function arrayBufferToString(ab) {
  48053. return new TextDecoder("utf-8").decode(ab);
  48054. }
  48055. function stringToArrayBuffer(string) {
  48056. const bytes = new TextEncoder("utf-8").encode(string);
  48057. return bytes.buffer;
  48058. }
  48059. function arrayBufferToBase64(ab) {
  48060. return btoa(new Uint8Array(ab).reduce((data, byte) => data + String.fromCharCode(byte), ''));
  48061. }
  48062. function base64ToArrayBuffer(b64) {
  48063. const binary_string = window.atob(b64),
  48064. len = binary_string.length,
  48065. bytes = new Uint8Array(len);
  48066. for (let i = 0; i < len; i++) {
  48067. bytes[i] = binary_string.charCodeAt(i);
  48068. }
  48069. return bytes.buffer;
  48070. }
  48071. function hexToArrayBuffer(hex) {
  48072. const typedArray = new Uint8Array(hex.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16)));
  48073. return typedArray.buffer;
  48074. }
  48075. Object.assign(arraybuffer_u, {
  48076. arrayBufferToHex,
  48077. arrayBufferToString,
  48078. stringToArrayBuffer,
  48079. arrayBufferToBase64,
  48080. base64ToArrayBuffer
  48081. });
  48082. ;// CONCATENATED MODULE: ./src/plugins/omemo/utils.js
  48083. /* global libsignal */
  48084. const {
  48085. Strophe: omemo_utils_Strophe,
  48086. URI: utils_URI,
  48087. sizzle: omemo_utils_sizzle,
  48088. u: omemo_utils_u
  48089. } = core_converse.env;
  48090. function formatFingerprint(fp) {
  48091. fp = fp.replace(/^05/, '');
  48092. for (let i = 1; i < 8; i++) {
  48093. const idx = i * 8 + i - 1;
  48094. fp = fp.slice(0, idx) + ' ' + fp.slice(idx);
  48095. }
  48096. return fp;
  48097. }
  48098. function handleMessageSendError(e, chat) {
  48099. if (e.name === 'IQError') {
  48100. chat.save('omemo_supported', false);
  48101. const err_msgs = [];
  48102. if (omemo_utils_sizzle(`presence-subscription-required[xmlns="${omemo_utils_Strophe.NS.PUBSUB_ERROR}"]`, e.iq).length) {
  48103. err_msgs.push(__("Sorry, we're unable to send an encrypted message because %1$s " + 'requires you to be subscribed to their presence in order to see their OMEMO information', e.iq.getAttribute('from')));
  48104. } else if (omemo_utils_sizzle(`remote-server-not-found[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]`, e.iq).length) {
  48105. err_msgs.push(__("Sorry, we're unable to send an encrypted message because the remote server for %1$s could not be found", e.iq.getAttribute('from')));
  48106. } else {
  48107. err_msgs.push(__('Unable to send an encrypted message due to an unexpected error.'));
  48108. err_msgs.push(e.iq.outerHTML);
  48109. }
  48110. core_api.alert('error', __('Error'), err_msgs);
  48111. } else if (e.user_facing) {
  48112. core_api.alert('error', __('Error'), [e.message]);
  48113. }
  48114. throw e;
  48115. }
  48116. function getOutgoingMessageAttributes(chat, attrs) {
  48117. if (chat.get('omemo_active') && attrs.body) {
  48118. attrs['is_encrypted'] = true;
  48119. attrs['plaintext'] = attrs.body;
  48120. attrs['body'] = __('This is an OMEMO encrypted message which your client doesn’t seem to support. ' + 'Find more information on https://conversations.im/omemo');
  48121. }
  48122. return attrs;
  48123. }
  48124. async function encryptMessage(plaintext) {
  48125. // The client MUST use fresh, randomly generated key/IV pairs
  48126. // with AES-128 in Galois/Counter Mode (GCM).
  48127. // For GCM a 12 byte IV is strongly suggested as other IV lengths
  48128. // will require additional calculations. In principle any IV size
  48129. // can be used as long as the IV doesn't ever repeat. NIST however
  48130. // suggests that only an IV size of 12 bytes needs to be supported
  48131. // by implementations.
  48132. //
  48133. // https://crypto.stackexchange.com/questions/26783/ciphertext-and-tag-size-and-iv-transmission-with-aes-in-gcm-mode
  48134. const iv = crypto.getRandomValues(new window.Uint8Array(12));
  48135. const key = await crypto.subtle.generateKey(KEY_ALGO, true, ['encrypt', 'decrypt']);
  48136. const algo = {
  48137. 'name': 'AES-GCM',
  48138. 'iv': iv,
  48139. 'tagLength': TAG_LENGTH
  48140. };
  48141. const encrypted = await crypto.subtle.encrypt(algo, key, stringToArrayBuffer(plaintext));
  48142. const length = encrypted.byteLength - (128 + 7 >> 3);
  48143. const ciphertext = encrypted.slice(0, length);
  48144. const tag = encrypted.slice(length);
  48145. const exported_key = await crypto.subtle.exportKey('raw', key);
  48146. return {
  48147. 'key': exported_key,
  48148. 'tag': tag,
  48149. 'key_and_tag': appendArrayBuffer(exported_key, tag),
  48150. 'payload': arrayBufferToBase64(ciphertext),
  48151. 'iv': arrayBufferToBase64(iv)
  48152. };
  48153. }
  48154. async function decryptMessage(obj) {
  48155. const key_obj = await crypto.subtle.importKey('raw', obj.key, KEY_ALGO, true, ['encrypt', 'decrypt']);
  48156. const cipher = appendArrayBuffer(base64ToArrayBuffer(obj.payload), obj.tag);
  48157. const algo = {
  48158. 'name': 'AES-GCM',
  48159. 'iv': base64ToArrayBuffer(obj.iv),
  48160. 'tagLength': TAG_LENGTH
  48161. };
  48162. return arrayBufferToString(await crypto.subtle.decrypt(algo, key_obj, cipher));
  48163. }
  48164. async function encryptFile(file) {
  48165. const iv = crypto.getRandomValues(new Uint8Array(12));
  48166. const key = await crypto.subtle.generateKey({
  48167. name: 'AES-GCM',
  48168. length: 256
  48169. }, true, ['encrypt', 'decrypt']);
  48170. const encrypted = await crypto.subtle.encrypt({
  48171. name: 'AES-GCM',
  48172. iv
  48173. }, key, await file.arrayBuffer());
  48174. const exported_key = await window.crypto.subtle.exportKey('raw', key);
  48175. const encrypted_file = new File([encrypted], file.name, {
  48176. type: file.type,
  48177. lastModified: file.lastModified
  48178. });
  48179. encrypted_file.xep454_ivkey = arrayBufferToHex(iv) + arrayBufferToHex(exported_key);
  48180. return encrypted_file;
  48181. }
  48182. function setEncryptedFileURL(message, attrs) {
  48183. const url = attrs.oob_url.replace(/^https?:/, 'aesgcm:') + '#' + message.file.xep454_ivkey;
  48184. return Object.assign(attrs, {
  48185. 'oob_url': null,
  48186. // Since only the body gets encrypted, we don't set the oob_url
  48187. 'message': url,
  48188. 'body': url
  48189. });
  48190. }
  48191. async function decryptFile(iv, key, cipher) {
  48192. const key_obj = await crypto.subtle.importKey('raw', hexToArrayBuffer(key), 'AES-GCM', false, ['decrypt']);
  48193. const algo = {
  48194. 'name': 'AES-GCM',
  48195. 'iv': hexToArrayBuffer(iv)
  48196. };
  48197. return crypto.subtle.decrypt(algo, key_obj, cipher);
  48198. }
  48199. async function downloadFile(url) {
  48200. let response;
  48201. try {
  48202. response = await fetch(url);
  48203. } catch (e) {
  48204. headless_log.error(`${e.name}: Failed to download encrypted media: ${url}`);
  48205. headless_log.error(e);
  48206. return null;
  48207. }
  48208. if (response.status >= 200 && response.status < 400) {
  48209. return response.arrayBuffer();
  48210. }
  48211. }
  48212. async function getAndDecryptFile(uri) {
  48213. var _uri$filename;
  48214. const hash = uri.hash().slice(1);
  48215. const protocol = window.location.hostname === 'localhost' ? 'http' : 'https';
  48216. const http_url = uri.toString().replace(/^aesgcm/, protocol);
  48217. const cipher = await downloadFile(http_url);
  48218. if (cipher === null) {
  48219. headless_log.error(`Could not decrypt file ${uri.toString()} since it could not be downloaded`);
  48220. return null;
  48221. }
  48222. const iv = hash.slice(0, 24);
  48223. const key = hash.slice(24);
  48224. let content;
  48225. try {
  48226. content = await decryptFile(iv, key, cipher);
  48227. } catch (e) {
  48228. headless_log.error(`Could not decrypt file ${uri.toString()}`);
  48229. headless_log.error(e);
  48230. return null;
  48231. }
  48232. const [filename, extension] = (_uri$filename = uri.filename()) === null || _uri$filename === void 0 ? void 0 : _uri$filename.split('.');
  48233. const mimetype = MIMETYPES_MAP[extension];
  48234. try {
  48235. const file = new File([content], filename, {
  48236. 'type': mimetype
  48237. });
  48238. return URL.createObjectURL(file);
  48239. } catch (e) {
  48240. headless_log.error(`Could not decrypt file ${uri.toString()}`);
  48241. headless_log.error(e);
  48242. return null;
  48243. }
  48244. }
  48245. function getTemplateForObjectURL(uri, obj_url, richtext) {
  48246. const file_url = uri.toString();
  48247. if (obj_url === null) {
  48248. return file_url;
  48249. }
  48250. if (isImageURL(file_url)) {
  48251. return src_templates_image({
  48252. 'src': obj_url,
  48253. 'onClick': richtext.onImgClick,
  48254. 'onLoad': richtext.onImgLoad
  48255. });
  48256. } else if (isAudioURL(file_url)) {
  48257. return audio(obj_url);
  48258. } else if (isVideoURL(file_url)) {
  48259. return video(obj_url);
  48260. } else {
  48261. return file(obj_url, uri.filename());
  48262. }
  48263. }
  48264. function addEncryptedFiles(text, offset, richtext) {
  48265. const objs = [];
  48266. try {
  48267. const parse_options = {
  48268. 'start': /\b(aesgcm:\/\/)/gi
  48269. };
  48270. utils_URI.withinString(text, (url, start, end) => {
  48271. objs.push({
  48272. url,
  48273. start,
  48274. end
  48275. });
  48276. return url;
  48277. }, parse_options);
  48278. } catch (error) {
  48279. headless_log.debug(error);
  48280. return;
  48281. }
  48282. objs.forEach(o => {
  48283. const uri = getURI(text.slice(o.start, o.end));
  48284. const promise = getAndDecryptFile(uri).then(obj_url => getTemplateForObjectURL(uri, obj_url, richtext));
  48285. const template = $`${until_c(promise, '')}`;
  48286. richtext.addTemplateResult(o.start + offset, o.end + offset, template);
  48287. });
  48288. }
  48289. function handleEncryptedFiles(richtext) {
  48290. if (!shared_converse.config.get('trusted')) {
  48291. return;
  48292. }
  48293. richtext.addAnnotations((text, offset) => addEncryptedFiles(text, offset, richtext));
  48294. }
  48295. /**
  48296. * Hook handler for { @link parseMessage } and { @link parseMUCMessage }, which
  48297. * parses the passed in `message` stanza for OMEMO attributes and then sets
  48298. * them on the attrs object.
  48299. * @param { XMLElement } stanza - The message stanza
  48300. * @param { (MUCMessageAttributes|MessageAttributes) } attrs
  48301. * @returns (MUCMessageAttributes|MessageAttributes)
  48302. */
  48303. async function parseEncryptedMessage(stanza, attrs) {
  48304. var _api$omemo;
  48305. if (core_api.settings.get('clear_cache_on_logout') || !attrs.is_encrypted || attrs.encryption_namespace !== omemo_utils_Strophe.NS.OMEMO) {
  48306. return attrs;
  48307. }
  48308. const encrypted_el = omemo_utils_sizzle(`encrypted[xmlns="${omemo_utils_Strophe.NS.OMEMO}"]`, stanza).pop();
  48309. const header = encrypted_el.querySelector('header');
  48310. attrs.encrypted = {
  48311. 'device_id': header.getAttribute('sid')
  48312. };
  48313. const device_id = await ((_api$omemo = core_api.omemo) === null || _api$omemo === void 0 ? void 0 : _api$omemo.getDeviceID());
  48314. const key = device_id && omemo_utils_sizzle(`key[rid="${device_id}"]`, encrypted_el).pop();
  48315. if (key) {
  48316. var _encrypted_el$querySe;
  48317. Object.assign(attrs.encrypted, {
  48318. 'iv': header.querySelector('iv').textContent,
  48319. 'key': key.textContent,
  48320. 'payload': ((_encrypted_el$querySe = encrypted_el.querySelector('payload')) === null || _encrypted_el$querySe === void 0 ? void 0 : _encrypted_el$querySe.textContent) || null,
  48321. 'prekey': ['true', '1'].includes(key.getAttribute('prekey'))
  48322. });
  48323. } else {
  48324. return Object.assign(attrs, {
  48325. 'error_condition': 'not-encrypted-for-this-device',
  48326. 'error_type': 'Decryption',
  48327. 'is_ephemeral': true,
  48328. 'is_error': true,
  48329. 'type': 'error'
  48330. });
  48331. } // https://xmpp.org/extensions/xep-0384.html#usecases-receiving
  48332. if (attrs.encrypted.prekey === true) {
  48333. return decryptPrekeyWhisperMessage(attrs);
  48334. } else {
  48335. return decryptWhisperMessage(attrs);
  48336. }
  48337. }
  48338. function utils_onChatBoxesInitialized() {
  48339. shared_converse.chatboxes.on('add', chatbox => {
  48340. checkOMEMOSupported(chatbox);
  48341. if (chatbox.get('type') === shared_converse.CHATROOMS_TYPE) {
  48342. chatbox.occupants.on('add', o => onOccupantAdded(chatbox, o));
  48343. chatbox.features.on('change', () => checkOMEMOSupported(chatbox));
  48344. }
  48345. });
  48346. }
  48347. function onChatInitialized(el) {
  48348. el.listenTo(el.model.messages, 'add', message => {
  48349. if (message.get('is_encrypted') && !message.get('is_error')) {
  48350. el.model.save('omemo_supported', true);
  48351. }
  48352. });
  48353. el.listenTo(el.model, 'change:omemo_supported', () => {
  48354. if (!el.model.get('omemo_supported') && el.model.get('omemo_active')) {
  48355. el.model.set('omemo_active', false);
  48356. } else {
  48357. var _el$querySelector;
  48358. // Manually trigger an update, setting omemo_active to
  48359. // false above will automatically trigger one.
  48360. (_el$querySelector = el.querySelector('converse-chat-toolbar')) === null || _el$querySelector === void 0 ? void 0 : _el$querySelector.requestUpdate();
  48361. }
  48362. });
  48363. el.listenTo(el.model, 'change:omemo_active', () => {
  48364. el.querySelector('converse-chat-toolbar').requestUpdate();
  48365. });
  48366. }
  48367. function getSessionCipher(jid, id) {
  48368. const address = new libsignal.SignalProtocolAddress(jid, id);
  48369. return new window.libsignal.SessionCipher(shared_converse.omemo_store, address);
  48370. }
  48371. function getJIDForDecryption(attrs) {
  48372. const from_jid = attrs.from_muc ? attrs.from_real_jid : attrs.from;
  48373. if (!from_jid) {
  48374. Object.assign(attrs, {
  48375. 'error_text': __("Sorry, could not decrypt a received OMEMO " + "message because we don't have the XMPP address for that user."),
  48376. 'error_type': 'Decryption',
  48377. 'is_ephemeral': true,
  48378. 'is_error': true,
  48379. 'type': 'error'
  48380. });
  48381. throw new Error("Could not find JID to decrypt OMEMO message for");
  48382. }
  48383. return from_jid;
  48384. }
  48385. async function handleDecryptedWhisperMessage(attrs, key_and_tag) {
  48386. const from_jid = getJIDForDecryption(attrs);
  48387. const devicelist = await core_api.omemo.devicelists.get(from_jid, true);
  48388. const encrypted = attrs.encrypted;
  48389. let device = devicelist.devices.get(encrypted.device_id);
  48390. if (!device) {
  48391. device = await devicelist.devices.create({
  48392. 'id': encrypted.device_id,
  48393. 'jid': from_jid
  48394. }, {
  48395. 'promise': true
  48396. });
  48397. }
  48398. if (encrypted.payload) {
  48399. const key = key_and_tag.slice(0, 16);
  48400. const tag = key_and_tag.slice(16);
  48401. const result = await omemo.decryptMessage(Object.assign(encrypted, {
  48402. 'key': key,
  48403. 'tag': tag
  48404. }));
  48405. device.save('active', true);
  48406. return result;
  48407. }
  48408. }
  48409. function getDecryptionErrorAttributes(e) {
  48410. return {
  48411. 'error_text': __('Sorry, could not decrypt a received OMEMO message due to an error.') + ` ${e.name} ${e.message}`,
  48412. 'error_condition': e.name,
  48413. 'error_message': e.message,
  48414. 'error_type': 'Decryption',
  48415. 'is_ephemeral': true,
  48416. 'is_error': true,
  48417. 'type': 'error'
  48418. };
  48419. }
  48420. async function decryptPrekeyWhisperMessage(attrs) {
  48421. const from_jid = getJIDForDecryption(attrs);
  48422. const session_cipher = getSessionCipher(from_jid, parseInt(attrs.encrypted.device_id, 10));
  48423. const key = base64ToArrayBuffer(attrs.encrypted.key);
  48424. let key_and_tag;
  48425. try {
  48426. key_and_tag = await session_cipher.decryptPreKeyWhisperMessage(key, 'binary');
  48427. } catch (e) {
  48428. // TODO from the XEP:
  48429. // There are various reasons why decryption of an
  48430. // OMEMOKeyExchange or an OMEMOAuthenticatedMessage
  48431. // could fail. One reason is if the message was
  48432. // received twice and already decrypted once, in this
  48433. // case the client MUST ignore the decryption failure
  48434. // and not show any warnings/errors. In all other cases
  48435. // of decryption failure, clients SHOULD respond by
  48436. // forcibly doing a new key exchange and sending a new
  48437. // OMEMOKeyExchange with a potentially empty SCE
  48438. // payload. By building a new session with the original
  48439. // sender this way, the invalid session of the original
  48440. // sender will get overwritten with this newly created,
  48441. // valid session.
  48442. headless_log.error(`${e.name} ${e.message}`);
  48443. return Object.assign(attrs, getDecryptionErrorAttributes(e));
  48444. } // TODO from the XEP:
  48445. // When a client receives the first message for a given
  48446. // ratchet key with a counter of 53 or higher, it MUST send
  48447. // a heartbeat message. Heartbeat messages are normal OMEMO
  48448. // encrypted messages where the SCE payload does not include
  48449. // any elements. These heartbeat messages cause the ratchet
  48450. // to forward, thus consequent messages will have the
  48451. // counter restarted from 0.
  48452. try {
  48453. const plaintext = await handleDecryptedWhisperMessage(attrs, key_and_tag);
  48454. await shared_converse.omemo_store.generateMissingPreKeys();
  48455. await shared_converse.omemo_store.publishBundle();
  48456. if (plaintext) {
  48457. return Object.assign(attrs, {
  48458. 'plaintext': plaintext
  48459. });
  48460. } else {
  48461. return Object.assign(attrs, {
  48462. 'is_only_key': true
  48463. });
  48464. }
  48465. } catch (e) {
  48466. headless_log.error(`${e.name} ${e.message}`);
  48467. return Object.assign(attrs, getDecryptionErrorAttributes(e));
  48468. }
  48469. }
  48470. async function decryptWhisperMessage(attrs) {
  48471. const from_jid = getJIDForDecryption(attrs);
  48472. const session_cipher = getSessionCipher(from_jid, parseInt(attrs.encrypted.device_id, 10));
  48473. const key = base64ToArrayBuffer(attrs.encrypted.key);
  48474. try {
  48475. const key_and_tag = await session_cipher.decryptWhisperMessage(key, 'binary');
  48476. const plaintext = await handleDecryptedWhisperMessage(attrs, key_and_tag);
  48477. return Object.assign(attrs, {
  48478. 'plaintext': plaintext
  48479. });
  48480. } catch (e) {
  48481. headless_log.error(`${e.name} ${e.message}`);
  48482. return Object.assign(attrs, getDecryptionErrorAttributes(e));
  48483. }
  48484. }
  48485. function addKeysToMessageStanza(stanza, dicts, iv) {
  48486. for (const i in dicts) {
  48487. if (Object.prototype.hasOwnProperty.call(dicts, i)) {
  48488. const payload = dicts[i].payload;
  48489. const device = dicts[i].device;
  48490. const prekey = 3 == parseInt(payload.type, 10);
  48491. stanza.c('key', {
  48492. 'rid': device.get('id')
  48493. }).t(btoa(payload.body));
  48494. if (prekey) {
  48495. stanza.attrs({
  48496. 'prekey': prekey
  48497. });
  48498. }
  48499. stanza.up();
  48500. if (i == dicts.length - 1) {
  48501. stanza.c('iv').t(iv).up().up();
  48502. }
  48503. }
  48504. }
  48505. return Promise.resolve(stanza);
  48506. }
  48507. /**
  48508. * Given an XML element representing a user's OMEMO bundle, parse it
  48509. * and return a map.
  48510. */
  48511. function parseBundle(bundle_el) {
  48512. const signed_prekey_public_el = bundle_el.querySelector('signedPreKeyPublic');
  48513. const signed_prekey_signature_el = bundle_el.querySelector('signedPreKeySignature');
  48514. const prekeys = omemo_utils_sizzle(`prekeys > preKeyPublic`, bundle_el).map(el => ({
  48515. 'id': parseInt(el.getAttribute('preKeyId'), 10),
  48516. 'key': el.textContent
  48517. }));
  48518. return {
  48519. 'identity_key': bundle_el.querySelector('identityKey').textContent.trim(),
  48520. 'signed_prekey': {
  48521. 'id': parseInt(signed_prekey_public_el.getAttribute('signedPreKeyId'), 10),
  48522. 'public_key': signed_prekey_public_el.textContent,
  48523. 'signature': signed_prekey_signature_el.textContent
  48524. },
  48525. 'prekeys': prekeys
  48526. };
  48527. }
  48528. async function generateFingerprint(device) {
  48529. var _device$get;
  48530. if ((_device$get = device.get('bundle')) !== null && _device$get !== void 0 && _device$get.fingerprint) {
  48531. return;
  48532. }
  48533. const bundle = await device.getBundle();
  48534. bundle['fingerprint'] = arrayBufferToHex(base64ToArrayBuffer(bundle['identity_key']));
  48535. device.save('bundle', bundle);
  48536. device.trigger('change:bundle'); // Doesn't get triggered automatically due to pass-by-reference
  48537. }
  48538. async function getDevicesForContact(jid) {
  48539. await core_api.waitUntil('OMEMOInitialized');
  48540. const devicelist = await core_api.omemo.devicelists.get(jid, true);
  48541. await devicelist.fetchDevices();
  48542. return devicelist.devices;
  48543. }
  48544. async function generateDeviceID() {
  48545. /* Generates a device ID, making sure that it's unique */
  48546. const devicelist = await core_api.omemo.devicelists.get(shared_converse.bare_jid, true);
  48547. const existing_ids = devicelist.devices.pluck('id');
  48548. let device_id = libsignal.KeyHelper.generateRegistrationId(); // Before publishing a freshly generated device id for the first time,
  48549. // a device MUST check whether that device id already exists, and if so, generate a new one.
  48550. let i = 0;
  48551. while (existing_ids.includes(device_id)) {
  48552. device_id = libsignal.KeyHelper.generateRegistrationId();
  48553. i++;
  48554. if (i === 10) {
  48555. throw new Error('Unable to generate a unique device ID');
  48556. }
  48557. }
  48558. return device_id.toString();
  48559. }
  48560. async function buildSession(device) {
  48561. const address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id'));
  48562. const sessionBuilder = new libsignal.SessionBuilder(shared_converse.omemo_store, address);
  48563. const prekey = device.getRandomPreKey();
  48564. const bundle = await device.getBundle();
  48565. return sessionBuilder.processPreKey({
  48566. 'registrationId': parseInt(device.get('id'), 10),
  48567. 'identityKey': base64ToArrayBuffer(bundle.identity_key),
  48568. 'signedPreKey': {
  48569. 'keyId': bundle.signed_prekey.id,
  48570. // <Number>
  48571. 'publicKey': base64ToArrayBuffer(bundle.signed_prekey.public_key),
  48572. 'signature': base64ToArrayBuffer(bundle.signed_prekey.signature)
  48573. },
  48574. 'preKey': {
  48575. 'keyId': prekey.id,
  48576. // <Number>
  48577. 'publicKey': base64ToArrayBuffer(prekey.key)
  48578. }
  48579. });
  48580. }
  48581. async function getSession(device) {
  48582. if (!device.get('bundle')) {
  48583. headless_log.error(`Could not build an OMEMO session for device ${device.get('id')} because we don't have its bundle`);
  48584. return null;
  48585. }
  48586. const address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id'));
  48587. const session = await shared_converse.omemo_store.loadSession(address.toString());
  48588. if (session) {
  48589. return session;
  48590. } else {
  48591. try {
  48592. const session = await buildSession(device);
  48593. return session;
  48594. } catch (e) {
  48595. headless_log.error(`Could not build an OMEMO session for device ${device.get('id')}`);
  48596. headless_log.error(e);
  48597. return null;
  48598. }
  48599. }
  48600. }
  48601. async function updateBundleFromStanza(stanza) {
  48602. const items_el = omemo_utils_sizzle(`items`, stanza).pop();
  48603. if (!items_el || !items_el.getAttribute('node').startsWith(omemo_utils_Strophe.NS.OMEMO_BUNDLES)) {
  48604. return;
  48605. }
  48606. const device_id = items_el.getAttribute('node').split(':')[1];
  48607. const jid = stanza.getAttribute('from');
  48608. const bundle_el = omemo_utils_sizzle(`item > bundle`, items_el).pop();
  48609. const devicelist = await core_api.omemo.devicelists.get(jid, true);
  48610. const device = devicelist.devices.get(device_id) || devicelist.devices.create({
  48611. 'id': device_id,
  48612. jid
  48613. });
  48614. device.save({
  48615. 'bundle': parseBundle(bundle_el)
  48616. });
  48617. }
  48618. async function updateDevicesFromStanza(stanza) {
  48619. const items_el = omemo_utils_sizzle(`items[node="${omemo_utils_Strophe.NS.OMEMO_DEVICELIST}"]`, stanza).pop();
  48620. if (!items_el) {
  48621. return;
  48622. }
  48623. const device_selector = `item list[xmlns="${omemo_utils_Strophe.NS.OMEMO}"] device`;
  48624. const device_ids = omemo_utils_sizzle(device_selector, items_el).map(d => d.getAttribute('id'));
  48625. const jid = stanza.getAttribute('from');
  48626. const devicelist = await core_api.omemo.devicelists.get(jid, true);
  48627. const devices = devicelist.devices;
  48628. const removed_ids = lodash_es_difference(devices.pluck('id'), device_ids);
  48629. removed_ids.forEach(id => {
  48630. if (jid === shared_converse.bare_jid && id === shared_converse.omemo_store.get('device_id')) {
  48631. return; // We don't set the current device as inactive
  48632. }
  48633. devices.get(id).save('active', false);
  48634. });
  48635. device_ids.forEach(device_id => {
  48636. const device = devices.get(device_id);
  48637. if (device) {
  48638. device.save('active', true);
  48639. } else {
  48640. devices.create({
  48641. 'id': device_id,
  48642. 'jid': jid
  48643. });
  48644. }
  48645. });
  48646. if (omemo_utils_u.isSameBareJID(jid, shared_converse.bare_jid)) {
  48647. // Make sure our own device is on the list
  48648. // (i.e. if it was removed, add it again).
  48649. devicelist.publishCurrentDevice(device_ids);
  48650. }
  48651. }
  48652. function registerPEPPushHandler() {
  48653. // Add a handler for devices pushed from other connected clients
  48654. shared_converse.connection.addHandler(async message => {
  48655. try {
  48656. if (omemo_utils_sizzle(`event[xmlns="${omemo_utils_Strophe.NS.PUBSUB}#event"]`, message).length) {
  48657. await core_api.waitUntil('OMEMOInitialized');
  48658. await updateDevicesFromStanza(message);
  48659. await updateBundleFromStanza(message);
  48660. }
  48661. } catch (e) {
  48662. headless_log.error(e.message);
  48663. }
  48664. return true;
  48665. }, null, 'message', 'headline');
  48666. }
  48667. async function restoreOMEMOSession() {
  48668. if (shared_converse.omemo_store === undefined) {
  48669. const id = `converse.omemosession-${shared_converse.bare_jid}`;
  48670. shared_converse.omemo_store = new shared_converse.OMEMOStore({
  48671. id
  48672. });
  48673. initStorage(shared_converse.omemo_store, id);
  48674. }
  48675. await shared_converse.omemo_store.fetchSession();
  48676. }
  48677. async function fetchDeviceLists() {
  48678. shared_converse.devicelists = new shared_converse.DeviceLists();
  48679. const id = `converse.devicelists-${shared_converse.bare_jid}`;
  48680. initStorage(shared_converse.devicelists, id);
  48681. await new Promise(resolve => {
  48682. shared_converse.devicelists.fetch({
  48683. 'success': resolve,
  48684. 'error': (_m, e) => {
  48685. headless_log.error(e);
  48686. resolve();
  48687. }
  48688. });
  48689. }); // Call API method to wait for our own device list to be fetched from the
  48690. // server or to be created. If we have no pre-existing OMEMO session, this
  48691. // will cause a new device and bundle to be generated and published.
  48692. await core_api.omemo.devicelists.get(shared_converse.bare_jid, true);
  48693. }
  48694. async function initOMEMO(reconnecting) {
  48695. if (reconnecting) {
  48696. return;
  48697. }
  48698. if (!shared_converse.config.get('trusted') || core_api.settings.get('clear_cache_on_logout')) {
  48699. headless_log.warn('Not initializing OMEMO, since this browser is not trusted or clear_cache_on_logout is set to true');
  48700. return;
  48701. }
  48702. try {
  48703. await fetchDeviceLists();
  48704. await restoreOMEMOSession();
  48705. await shared_converse.omemo_store.publishBundle();
  48706. } catch (e) {
  48707. headless_log.error('Could not initialize OMEMO support');
  48708. headless_log.error(e);
  48709. return;
  48710. }
  48711. /**
  48712. * Triggered once OMEMO support has been initialized
  48713. * @event _converse#OMEMOInitialized
  48714. * @example _converse.api.listen.on('OMEMOInitialized', () => { ... });
  48715. */
  48716. core_api.trigger('OMEMOInitialized');
  48717. }
  48718. async function onOccupantAdded(chatroom, occupant) {
  48719. if (occupant.isSelf() || !chatroom.features.get('nonanonymous') || !chatroom.features.get('membersonly')) {
  48720. return;
  48721. }
  48722. if (chatroom.get('omemo_active')) {
  48723. const supported = await shared_converse.contactHasOMEMOSupport(occupant.get('jid'));
  48724. if (!supported) {
  48725. chatroom.createMessage({
  48726. 'message': __("%1$s doesn't appear to have a client that supports OMEMO. " + 'Encrypted chat will no longer be possible in this grouchat.', occupant.get('nick')),
  48727. 'type': 'error'
  48728. });
  48729. chatroom.save({
  48730. 'omemo_active': false,
  48731. 'omemo_supported': false
  48732. });
  48733. }
  48734. }
  48735. }
  48736. async function checkOMEMOSupported(chatbox) {
  48737. let supported;
  48738. if (chatbox.get('type') === shared_converse.CHATROOMS_TYPE) {
  48739. await core_api.waitUntil('OMEMOInitialized');
  48740. supported = chatbox.features.get('nonanonymous') && chatbox.features.get('membersonly');
  48741. } else if (chatbox.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  48742. supported = await shared_converse.contactHasOMEMOSupport(chatbox.get('jid'));
  48743. }
  48744. chatbox.set('omemo_supported', supported);
  48745. if (supported && core_api.settings.get('omemo_default')) {
  48746. chatbox.set('omemo_active', true);
  48747. }
  48748. }
  48749. function toggleOMEMO(ev) {
  48750. ev.stopPropagation();
  48751. ev.preventDefault();
  48752. const toolbar_el = omemo_utils_u.ancestor(ev.target, 'converse-chat-toolbar');
  48753. if (!toolbar_el.model.get('omemo_supported')) {
  48754. let messages;
  48755. if (toolbar_el.model.get('type') === shared_converse.CHATROOMS_TYPE) {
  48756. messages = [__('Cannot use end-to-end encryption in this groupchat, ' + 'either the groupchat has some anonymity or not all participants support OMEMO.')];
  48757. } else {
  48758. messages = [__("Cannot use end-to-end encryption because %1$s uses a client that doesn't support OMEMO.", toolbar_el.model.contact.getDisplayName())];
  48759. }
  48760. return core_api.alert('error', __('Error'), messages);
  48761. }
  48762. toolbar_el.model.save({
  48763. 'omemo_active': !toolbar_el.model.get('omemo_active')
  48764. });
  48765. }
  48766. function getOMEMOToolbarButton(toolbar_el, buttons) {
  48767. const model = toolbar_el.model;
  48768. const is_muc = model.get('type') === shared_converse.CHATROOMS_TYPE;
  48769. let title;
  48770. if (model.get('omemo_supported')) {
  48771. const i18n_plaintext = __('Messages are being sent in plaintext');
  48772. const i18n_encrypted = __('Messages are sent encrypted');
  48773. title = model.get('omemo_active') ? i18n_encrypted : i18n_plaintext;
  48774. } else if (is_muc) {
  48775. title = __('This groupchat needs to be members-only and non-anonymous in ' + 'order to support OMEMO encrypted messages');
  48776. } else {
  48777. title = __('OMEMO encryption is not supported');
  48778. }
  48779. let color;
  48780. if (model.get('omemo_supported')) {
  48781. if (model.get('omemo_active')) {
  48782. color = is_muc ? `var(--muc-color)` : `var(--chat-toolbar-btn-color)`;
  48783. } else {
  48784. color = `var(--error-color)`;
  48785. }
  48786. } else {
  48787. color = `var(--muc-toolbar-btn-disabled-color)`;
  48788. }
  48789. buttons.push($`
  48790. <button class="toggle-omemo" title="${title}" data-disabled=${!model.get('omemo_supported')} @click=${toggleOMEMO}>
  48791. <converse-icon
  48792. class="fa ${model.get('omemo_active') ? `fa-lock` : `fa-unlock`}"
  48793. path-prefix="${core_api.settings.get('assets_path')}"
  48794. size="1em"
  48795. color="${color}"
  48796. ></converse-icon>
  48797. </button>
  48798. `);
  48799. return buttons;
  48800. }
  48801. async function getBundlesAndBuildSessions(chatbox) {
  48802. const no_devices_err = __('Sorry, no devices found to which we can send an OMEMO encrypted message.');
  48803. let devices;
  48804. if (chatbox.get('type') === shared_converse.CHATROOMS_TYPE) {
  48805. const collections = await Promise.all(chatbox.occupants.map(o => getDevicesForContact(o.get('jid'))));
  48806. devices = collections.reduce((a, b) => lodash_es_concat(a, b.models), []);
  48807. } else if (chatbox.get('type') === shared_converse.PRIVATE_CHAT_TYPE) {
  48808. const their_devices = await getDevicesForContact(chatbox.get('jid'));
  48809. if (their_devices.length === 0) {
  48810. const err = new Error(no_devices_err);
  48811. err.user_facing = true;
  48812. throw err;
  48813. }
  48814. const own_list = await core_api.omemo.devicelists.get(shared_converse.bare_jid);
  48815. const own_devices = own_list.devices;
  48816. devices = [...own_devices.models, ...their_devices.models];
  48817. } // Filter out our own device
  48818. const id = shared_converse.omemo_store.get('device_id');
  48819. devices = devices.filter(d => d.get('id') !== id); // Fetch bundles if necessary
  48820. await Promise.all(devices.map(d => d.getBundle()));
  48821. const sessions = devices.filter(d => d).map(d => getSession(d));
  48822. await Promise.all(sessions);
  48823. if (sessions.includes(null)) {
  48824. // We couldn't build a session for certain devices.
  48825. devices = devices.filter(d => sessions[devices.indexOf(d)]);
  48826. if (devices.length === 0) {
  48827. const err = new Error(no_devices_err);
  48828. err.user_facing = true;
  48829. throw err;
  48830. }
  48831. }
  48832. return devices;
  48833. }
  48834. function encryptKey(key_and_tag, device) {
  48835. return getSessionCipher(device.get('jid'), device.get('id')).encrypt(key_and_tag).then(payload => ({
  48836. 'payload': payload,
  48837. 'device': device
  48838. }));
  48839. }
  48840. async function createOMEMOMessageStanza(chat, data) {
  48841. let {
  48842. stanza
  48843. } = data;
  48844. const {
  48845. message
  48846. } = data;
  48847. if (!message.get('is_encrypted')) {
  48848. return data;
  48849. }
  48850. if (!message.get('body')) {
  48851. throw new Error('No message body to encrypt!');
  48852. }
  48853. const devices = await getBundlesAndBuildSessions(chat); // An encrypted header is added to the message for
  48854. // each device that is supposed to receive it.
  48855. // These headers simply contain the key that the
  48856. // payload message is encrypted with,
  48857. // and they are separately encrypted using the
  48858. // session corresponding to the counterpart device.
  48859. stanza.c('encrypted', {
  48860. 'xmlns': omemo_utils_Strophe.NS.OMEMO
  48861. }).c('header', {
  48862. 'sid': shared_converse.omemo_store.get('device_id')
  48863. });
  48864. const {
  48865. key_and_tag,
  48866. iv,
  48867. payload
  48868. } = await omemo.encryptMessage(message.get('plaintext')); // The 16 bytes key and the GCM authentication tag (The tag
  48869. // SHOULD have at least 128 bit) are concatenated and for each
  48870. // intended recipient device, i.e. both own devices as well as
  48871. // devices associated with the contact, the result of this
  48872. // concatenation is encrypted using the corresponding
  48873. // long-standing SignalProtocol session.
  48874. const dicts = await Promise.all(devices.filter(device => device.get('trusted') != UNTRUSTED && device.get('active')).map(device => encryptKey(key_and_tag, device)));
  48875. stanza = await addKeysToMessageStanza(stanza, dicts, iv);
  48876. stanza.c('payload').t(payload).up().up();
  48877. stanza.c('store', {
  48878. 'xmlns': omemo_utils_Strophe.NS.HINTS
  48879. }).up();
  48880. stanza.c('encryption', {
  48881. 'xmlns': omemo_utils_Strophe.NS.EME,
  48882. namespace: omemo_utils_Strophe.NS.OMEMO
  48883. });
  48884. return {
  48885. message,
  48886. stanza
  48887. };
  48888. }
  48889. const omemo = {
  48890. decryptMessage,
  48891. encryptMessage,
  48892. formatFingerprint
  48893. };
  48894. ;// CONCATENATED MODULE: ./src/plugins/omemo/templates/fingerprints.js
  48895. const device_fingerprint = (el, device) => {
  48896. const i18n_trusted = __('Trusted');
  48897. const i18n_untrusted = __('Untrusted');
  48898. if (device.get('bundle') && device.get('bundle').fingerprint) {
  48899. return $`
  48900. <li class="list-group-item">
  48901. <form class="fingerprint-trust">
  48902. <div class="btn-group btn-group-toggle">
  48903. <label class="btn btn--small ${device.get('trusted') === 1 ? 'btn-primary active' : 'btn-secondary'}"
  48904. @click=${el.toggleDeviceTrust}>
  48905. <input type="radio" name="${device.get('id')}" value="1"
  48906. ?checked=${device.get('trusted') !== -1}>${i18n_trusted}
  48907. </label>
  48908. <label class="btn btn--small ${device.get('trusted') === -1 ? 'btn-primary active' : 'btn-secondary'}"
  48909. @click=${el.toggleDeviceTrust}>
  48910. <input type="radio" name="${device.get('id')}" value="-1"
  48911. ?checked=${device.get('trusted') === -1}>${i18n_untrusted}
  48912. </label>
  48913. </div>
  48914. <code class="fingerprint">${formatFingerprint(device.get('bundle').fingerprint)}</code>
  48915. </form>
  48916. </li>
  48917. `;
  48918. } else {
  48919. return '';
  48920. }
  48921. };
  48922. /* harmony default export */ const fingerprints = (el => {
  48923. const i18n_fingerprints = __('OMEMO Fingerprints');
  48924. const i18n_no_devices = __("No OMEMO-enabled devices found");
  48925. const devices = el.devicelist.devices;
  48926. return $`
  48927. <hr/>
  48928. <ul class="list-group fingerprints">
  48929. <li class="list-group-item active">${i18n_fingerprints}</li>
  48930. ${devices.length ? devices.map(device => device_fingerprint(el, device)) : $`<li class="list-group-item"> ${i18n_no_devices} </li>`}
  48931. </ul>
  48932. `;
  48933. });
  48934. ;// CONCATENATED MODULE: ./src/plugins/omemo/fingerprints.js
  48935. class Fingerprints extends CustomElement {
  48936. static get properties() {
  48937. return {
  48938. 'jid': {
  48939. type: String
  48940. }
  48941. };
  48942. }
  48943. async initialize() {
  48944. this.devicelist = await core_api.omemo.devicelists.get(this.jid, true);
  48945. this.listenTo(this.devicelist.devices, 'change:bundle', this.requestUpdate);
  48946. this.listenTo(this.devicelist.devices, 'change:trusted', this.requestUpdate);
  48947. this.listenTo(this.devicelist.devices, 'remove', this.requestUpdate);
  48948. this.listenTo(this.devicelist.devices, 'add', this.requestUpdate);
  48949. this.listenTo(this.devicelist.devices, 'reset', this.requestUpdate);
  48950. this.requestUpdate();
  48951. }
  48952. render() {
  48953. return this.devicelist ? fingerprints(this) : '';
  48954. }
  48955. toggleDeviceTrust(ev) {
  48956. const radio = ev.target;
  48957. const device = this.devicelist.devices.get(radio.getAttribute('name'));
  48958. device.save('trusted', parseInt(radio.value, 10));
  48959. }
  48960. }
  48961. core_api.elements.define('converse-omemo-fingerprints', Fingerprints);
  48962. ;// CONCATENATED MODULE: ./src/plugins/omemo/templates/profile.js
  48963. const fingerprint = el => $`
  48964. <span class="fingerprint">${formatFingerprint(el.current_device.get('bundle').fingerprint)}</span>`;
  48965. const device_with_fingerprint = el => {
  48966. const i18n_fingerprint_checkbox_label = __('Checkbox for selecting the following fingerprint');
  48967. return $`
  48968. <li class="fingerprint-removal-item list-group-item nopadding">
  48969. <label>
  48970. <input type="checkbox" value="${el.device.get('id')}"
  48971. aria-label="${i18n_fingerprint_checkbox_label}"/>
  48972. <span class="fingerprint">${formatFingerprint(el.device.get('bundle').fingerprint)}</span>
  48973. </label>
  48974. </li>
  48975. `;
  48976. };
  48977. const device_without_fingerprint = el => {
  48978. const i18n_device_without_fingerprint = __('Device without a fingerprint');
  48979. const i18n_fingerprint_checkbox_label = __('Checkbox for selecting the following device');
  48980. return $`
  48981. <li class="fingerprint-removal-item list-group-item nopadding">
  48982. <label>
  48983. <input type="checkbox" value="${el.device.get('id')}"
  48984. aria-label="${i18n_fingerprint_checkbox_label}"/>
  48985. <span>${i18n_device_without_fingerprint}</span>
  48986. </label>
  48987. </li>
  48988. `;
  48989. };
  48990. const device_item = el => $`
  48991. ${el.device.get('bundle') && el.device.get('bundle').fingerprint ? device_with_fingerprint(el) : device_without_fingerprint(el)}
  48992. `;
  48993. const device_list = el => {
  48994. var _el$other_devices;
  48995. const i18n_other_devices = __('Other OMEMO-enabled devices');
  48996. const i18n_other_devices_label = __('Checkbox to select fingerprints of all other OMEMO devices');
  48997. const i18n_remove_devices = __('Remove checked devices and close');
  48998. const i18n_select_all = __('Select all');
  48999. return $`
  49000. <ul class="list-group fingerprints">
  49001. <li class="list-group-item nopadding active">
  49002. <label>
  49003. <input type="checkbox" class="select-all" @change=${el.selectAll} title="${i18n_select_all}" aria-label="${i18n_other_devices_label}"/>
  49004. ${i18n_other_devices}
  49005. </label>
  49006. </li>
  49007. ${(_el$other_devices = el.other_devices) === null || _el$other_devices === void 0 ? void 0 : _el$other_devices.map(device => device_item(Object.assign({
  49008. device
  49009. }, el)))}
  49010. </ul>
  49011. <div class="form-group"><button type="submit" class="save-form btn btn-primary">${i18n_remove_devices}</button></div>
  49012. `;
  49013. };
  49014. /* harmony default export */ const profile = (el => {
  49015. var _el$other_devices2;
  49016. const i18n_fingerprint = __("This device's OMEMO fingerprint");
  49017. const i18n_generate = __('Generate new keys and fingerprint');
  49018. return $`
  49019. <form class="converse-form fingerprint-removal" @submit=${el.removeSelectedFingerprints}>
  49020. <ul class="list-group fingerprints">
  49021. <li class="list-group-item active">${i18n_fingerprint}</li>
  49022. <li class="list-group-item">
  49023. ${el.current_device && el.current_device.get('bundle') && el.current_device.get('bundle').fingerprint ? fingerprint(el) : spinner()}
  49024. </li>
  49025. </ul>
  49026. <div class="form-group">
  49027. <button type="button" class="generate-bundle btn btn-danger" @click=${el.generateOMEMODeviceBundle}>${i18n_generate}</button>
  49028. </div>
  49029. ${(_el$other_devices2 = el.other_devices) !== null && _el$other_devices2 !== void 0 && _el$other_devices2.length ? device_list(el) : ''}
  49030. </form>`;
  49031. });
  49032. ;// CONCATENATED MODULE: ./src/plugins/omemo/profile.js
  49033. const {
  49034. Strophe: profile_Strophe,
  49035. sizzle: profile_sizzle,
  49036. u: profile_u
  49037. } = core_converse.env;
  49038. class Profile extends CustomElement {
  49039. async initialize() {
  49040. this.devicelist = await core_api.omemo.devicelists.get(shared_converse.bare_jid, true);
  49041. await this.setAttributes();
  49042. this.listenTo(this.devicelist.devices, 'change:bundle', () => this.requestUpdate());
  49043. this.listenTo(this.devicelist.devices, 'reset', () => this.requestUpdate());
  49044. this.listenTo(this.devicelist.devices, 'reset', () => this.requestUpdate());
  49045. this.listenTo(this.devicelist.devices, 'remove', () => this.requestUpdate());
  49046. this.listenTo(this.devicelist.devices, 'add', () => this.requestUpdate());
  49047. this.requestUpdate();
  49048. }
  49049. async setAttributes() {
  49050. this.device_id = await core_api.omemo.getDeviceID();
  49051. this.current_device = this.devicelist.devices.get(this.device_id);
  49052. this.other_devices = this.devicelist.devices.filter(d => d.get('id') !== this.device_id);
  49053. }
  49054. render() {
  49055. return this.devicelist ? profile(this) : '';
  49056. }
  49057. selectAll(ev) {
  49058. // eslint-disable-line class-methods-use-this
  49059. let sibling = profile_u.ancestor(ev.target, 'li');
  49060. while (sibling) {
  49061. sibling.querySelector('input[type="checkbox"]').checked = ev.target.checked;
  49062. sibling = sibling.nextElementSibling;
  49063. }
  49064. }
  49065. async removeSelectedFingerprints(ev) {
  49066. ev.preventDefault();
  49067. ev.stopPropagation();
  49068. ev.target.querySelector('.select-all').checked = false;
  49069. const device_ids = profile_sizzle('.fingerprint-removal-item input[type="checkbox"]:checked', ev.target).map(c => c.value);
  49070. try {
  49071. await this.devicelist.removeOwnDevices(device_ids);
  49072. } catch (err) {
  49073. headless_log.error(err);
  49074. shared_converse.api.alert(profile_Strophe.LogLevel.ERROR, __('Error'), [__('Sorry, an error occurred while trying to remove the devices.')]);
  49075. }
  49076. await this.setAttributes();
  49077. this.requestUpdate();
  49078. }
  49079. async generateOMEMODeviceBundle(ev) {
  49080. ev.preventDefault();
  49081. if (confirm(__('Are you sure you want to generate new OMEMO keys? ' + 'This will remove your old keys and all previously encrypted messages will no longer be decryptable on this device.'))) {
  49082. await core_api.omemo.bundle.generate();
  49083. await this.setAttributes();
  49084. this.requestUpdate();
  49085. }
  49086. }
  49087. }
  49088. core_api.elements.define('converse-omemo-profile', Profile);
  49089. ;// CONCATENATED MODULE: ./src/modals/templates/user-settings.js
  49090. const user_settings_tpl_navigation = o => {
  49091. const i18n_about = __('About');
  49092. const i18n_commands = __('Commands');
  49093. return $`
  49094. <ul class="nav nav-pills justify-content-center">
  49095. <li role="presentation" class="nav-item">
  49096. <a class="nav-link active" id="about-tab" href="#about-tabpanel" aria-controls="about-tabpanel" role="tab" data-toggle="tab" @click=${o.switchTab}>${i18n_about}</a>
  49097. </li>
  49098. <li role="presentation" class="nav-item">
  49099. <a class="nav-link" id="commands-tab" href="#commands-tabpanel" aria-controls="commands-tabpanel" role="tab" data-toggle="tab" @click=${o.switchTab}>${i18n_commands}</a>
  49100. </li>
  49101. </ul>
  49102. `;
  49103. };
  49104. /* harmony default export */ const templates_user_settings = (o => {
  49105. const i18n_modal_title = __('Settings');
  49106. const first_subtitle = __('%1$s Open Source %2$s XMPP chat client brought to you by %3$s Opkode %2$s', '<a target="_blank" rel="nofollow" href="https://conversejs.org">', '</a>', '<a target="_blank" rel="nofollow" href="https://opkode.com">');
  49107. const second_subtitle = __('%1$s Translate %2$s it into your own language', '<a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages">', '</a>');
  49108. const show_client_info = core_api.settings.get('show_client_info');
  49109. const allow_adhoc_commands = core_api.settings.get('allow_adhoc_commands');
  49110. const show_both_tabs = show_client_info && allow_adhoc_commands;
  49111. return $`
  49112. <div class="modal-dialog" role="document">
  49113. <div class="modal-content">
  49114. <div class="modal-header">
  49115. <h5 class="modal-title" id="converse-modtools-modal-label">${i18n_modal_title}</h5>
  49116. ${modal_header_close_button}
  49117. </div>
  49118. <div class="modal-body">
  49119. ${show_both_tabs ? user_settings_tpl_navigation(o) : ''}
  49120. <div class="tab-content">
  49121. <div class="tab-pane tab-pane--columns ${show_client_info ? 'active' : ''}"
  49122. id="about-tabpanel" role="tabpanel" aria-labelledby="about-tab">
  49123. <span class="modal-alert"></span>
  49124. <br/>
  49125. <div class="container">
  49126. <h6 class="brand-heading">Converse</h6>
  49127. <p class="brand-subtitle">${o.version_name}</p>
  49128. <p class="brand-subtitle">${unsafe_html_o(purify_default().sanitize(first_subtitle))}</p>
  49129. <p class="brand-subtitle">${unsafe_html_o(purify_default().sanitize(second_subtitle))}</p>
  49130. </div>
  49131. </div>
  49132. <div class="tab-pane tab-pane--columns ${!show_client_info && allow_adhoc_commands ? 'active' : ''}"
  49133. id="commands-tabpanel"
  49134. role="tabpanel"
  49135. aria-labelledby="commands-tab">
  49136. <converse-adhoc-commands/>
  49137. </div>
  49138. </div>
  49139. </div>
  49140. </div>
  49141. </div>
  49142. `;
  49143. });
  49144. ;// CONCATENATED MODULE: ./src/modals/user-settings.js
  49145. let user_settings_converse;
  49146. /* harmony default export */ const modals_user_settings = (base.extend({
  49147. id: "converse-client-info-modal",
  49148. initialize(settings) {
  49149. user_settings_converse = settings._converse;
  49150. base.prototype.initialize.apply(this, arguments);
  49151. },
  49152. toHTML() {
  49153. return templates_user_settings(Object.assign(this.model.toJSON(), this.model.vcard.toJSON(), {
  49154. 'version_name': user_settings_converse.VERSION_NAME
  49155. }));
  49156. }
  49157. }));
  49158. ;// CONCATENATED MODULE: ./src/plugins/profile/utils.js
  49159. function getPrettyStatus(stat) {
  49160. if (stat === 'chat') {
  49161. return __('online');
  49162. } else if (stat === 'dnd') {
  49163. return __('busy');
  49164. } else if (stat === 'xa') {
  49165. return __('away for long');
  49166. } else if (stat === 'away') {
  49167. return __('away');
  49168. } else if (stat === 'offline') {
  49169. return __('offline');
  49170. } else {
  49171. return __(stat) || __('online');
  49172. }
  49173. }
  49174. async function logOut(ev) {
  49175. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  49176. const result = await core_api.confirm(__("Are you sure you want to log out?"));
  49177. if (result) {
  49178. core_api.user.logout();
  49179. }
  49180. }
  49181. ;// CONCATENATED MODULE: ./src/plugins/profile/templates/profile.js
  49182. function tpl_signout() {
  49183. const i18n_logout = __('Log out');
  49184. return $`<a class="controlbox-heading__btn logout align-self-center" title="${i18n_logout}" @click=${logOut}>
  49185. <converse-icon class="fa fa-sign-out-alt" size="1em"></converse-icon>
  49186. </a>`;
  49187. }
  49188. function tpl_user_settings_button(o) {
  49189. const i18n_details = __('Show details about this chat client');
  49190. return $`<a class="controlbox-heading__btn show-client-info align-self-center" title="${i18n_details}" @click=${o.showUserSettingsModal}>
  49191. <converse-icon class="fa fa-cog" size="1em"></converse-icon>
  49192. </a>`;
  49193. }
  49194. /* harmony default export */ const templates_profile = (el => {
  49195. var _el$model$vcard, _el$model$vcard2, _el$model$vcard3;
  49196. const chat_status = el.model.get('status') || 'offline';
  49197. const fullname = ((_el$model$vcard = el.model.vcard) === null || _el$model$vcard === void 0 ? void 0 : _el$model$vcard.get('fullname')) || shared_converse.bare_jid;
  49198. const status_message = el.model.get('status_message') || __("I am %1$s", getPrettyStatus(chat_status));
  49199. const i18n_change_status = __('Click to change your chat status');
  49200. const show_settings_button = core_api.settings.get('show_client_info') || core_api.settings.get('allow_adhoc_commands');
  49201. let classes, color;
  49202. if (chat_status === 'online') {
  49203. [classes, color] = ['fa fa-circle chat-status', 'chat-status-online'];
  49204. } else if (chat_status === 'dnd') {
  49205. [classes, color] = ['fa fa-minus-circle chat-status', 'chat-status-busy'];
  49206. } else if (chat_status === 'away') {
  49207. [classes, color] = ['fa fa-circle chat-status', 'chat-status-away'];
  49208. } else {
  49209. [classes, color] = ['fa fa-circle chat-status', 'subdued-color'];
  49210. }
  49211. return $`
  49212. <div class="userinfo controlbox-padded">
  49213. <div class="controlbox-section profile d-flex">
  49214. <a class="show-profile" href="#" @click=${el.showProfileModal}>
  49215. <converse-avatar class="avatar align-self-center"
  49216. .data=${(_el$model$vcard2 = el.model.vcard) === null || _el$model$vcard2 === void 0 ? void 0 : _el$model$vcard2.attributes}
  49217. nonce=${(_el$model$vcard3 = el.model.vcard) === null || _el$model$vcard3 === void 0 ? void 0 : _el$model$vcard3.get('vcard_updated')}
  49218. height="40" width="40"></converse-avatar>
  49219. </a>
  49220. <span class="username w-100 align-self-center">${fullname}</span>
  49221. ${show_settings_button ? tpl_user_settings_button(el) : ''}
  49222. ${core_api.settings.get('allow_logout') ? tpl_signout() : ''}
  49223. </div>
  49224. <div class="d-flex xmpp-status">
  49225. <a class="change-status" title="${i18n_change_status}" data-toggle="modal" data-target="#changeStatusModal" @click=${el.showStatusChangeModal}>
  49226. <span class="${chat_status} w-100 align-self-center" data-value="${chat_status}">
  49227. <converse-icon color="var(--${color})" style="margin-top: -0.1em" size="0.82em" class="${classes}"></converse-icon> ${status_message}</span>
  49228. </a>
  49229. </div>
  49230. </div>`;
  49231. });
  49232. ;// CONCATENATED MODULE: ./src/plugins/profile/statusview.js
  49233. class statusview_Profile extends CustomElement {
  49234. initialize() {
  49235. this.model = shared_converse.xmppstatus;
  49236. this.listenTo(this.model, "change", this.requestUpdate);
  49237. this.listenTo(this.model, "vcard:add", this.requestUpdate);
  49238. this.listenTo(this.model, "vcard:change", this.requestUpdate);
  49239. }
  49240. render() {
  49241. return templates_profile(this);
  49242. }
  49243. showProfileModal(ev) {
  49244. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  49245. core_api.modal.show(shared_converse.ProfileModal, {
  49246. model: this.model
  49247. }, ev);
  49248. }
  49249. showStatusChangeModal(ev) {
  49250. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  49251. core_api.modal.show(shared_converse.ChatStatusModal, {
  49252. model: this.model
  49253. }, ev);
  49254. }
  49255. showUserSettingsModal(ev) {
  49256. ev === null || ev === void 0 ? void 0 : ev.preventDefault();
  49257. core_api.modal.show(modals_user_settings, {
  49258. model: this.model,
  49259. _converse: shared_converse
  49260. }, ev);
  49261. }
  49262. }
  49263. core_api.elements.define('converse-user-profile', statusview_Profile);
  49264. ;// CONCATENATED MODULE: ./src/plugins/profile/templates/chat-status-modal.js
  49265. /* harmony default export */ const chat_status_modal = (o => $`
  49266. <div class="modal-dialog" role="document">
  49267. <div class="modal-content">
  49268. <div class="modal-header">
  49269. <h5 class="modal-title" id="changeStatusModalLabel">${o.modal_title}</h5>
  49270. ${modal_header_close_button}
  49271. </div>
  49272. <div class="modal-body">
  49273. <span class="modal-alert"></span>
  49274. <form class="converse-form set-xmpp-status" id="set-xmpp-status">
  49275. <div class="form-group">
  49276. <div class="custom-control custom-radio">
  49277. <input ?checked=${o.status === 'online'}
  49278. type="radio" id="radio-online" value="online" name="chat_status" class="custom-control-input"/>
  49279. <label class="custom-control-label" for="radio-online">
  49280. <converse-icon size="1em" class="fa fa-circle chat-status chat-status--online"></converse-icon>${o.label_online}</label>
  49281. </div>
  49282. <div class="custom-control custom-radio">
  49283. <input ?checked=${o.status === 'busy'}
  49284. type="radio" id="radio-busy" value="dnd" name="chat_status" class="custom-control-input"/>
  49285. <label class="custom-control-label" for="radio-busy">
  49286. <converse-icon size="1em" class="fa fa-minus-circle chat-status chat-status--busy"></converse-icon>${o.label_busy}</label>
  49287. </div>
  49288. <div class="custom-control custom-radio">
  49289. <input ?checked=${o.status === 'away'}
  49290. type="radio" id="radio-away" value="away" name="chat_status" class="custom-control-input"/>
  49291. <label class="custom-control-label" for="radio-away">
  49292. <converse-icon size="1em" class="fa fa-circle chat-status chat-status--away"></converse-icon>${o.label_away}</label>
  49293. </div>
  49294. <div class="custom-control custom-radio">
  49295. <input ?checked=${o.status === 'xa'}
  49296. type="radio" id="radio-xa" value="xa" name="chat_status" class="custom-control-input"/>
  49297. <label class="custom-control-label" for="radio-xa">
  49298. <converse-icon size="1em" class="far fa-circle chat-status chat-status--xa"></converse-icon>${o.label_xa}</label>
  49299. </div>
  49300. </div>
  49301. <div class="form-group">
  49302. <div class="btn-group w-100">
  49303. <input name="status_message" type="text" class="form-control"
  49304. value="${o.status_message || ''}" placeholder="${o.placeholder_status_message}"/>
  49305. <converse-icon size="1em" class="fa fa-times clear-input ${o.status_message ? '' : 'hidden'}"></converse-icon>
  49306. </div>
  49307. </div>
  49308. <button type="submit" class="btn btn-primary">${o.label_save}</button>
  49309. </form>
  49310. </div>
  49311. </div>
  49312. </div>
  49313. `);
  49314. ;// CONCATENATED MODULE: ./src/plugins/profile/modals/chat-status.js
  49315. const chat_status_u = core_converse.env.utils;
  49316. const ChatStatusModal = base.extend({
  49317. id: "modal-status-change",
  49318. events: {
  49319. "submit form#set-xmpp-status": "onFormSubmitted",
  49320. "click .clear-input": "clearStatusMessage"
  49321. },
  49322. toHTML() {
  49323. return chat_status_modal(Object.assign(this.model.toJSON(), this.model.vcard.toJSON(), {
  49324. 'label_away': __('Away'),
  49325. 'label_busy': __('Busy'),
  49326. 'label_cancel': __('Cancel'),
  49327. 'label_close': __('Close'),
  49328. 'label_custom_status': __('Custom status'),
  49329. 'label_offline': __('Offline'),
  49330. 'label_online': __('Online'),
  49331. 'label_save': __('Save'),
  49332. 'label_xa': __('Away for long'),
  49333. 'modal_title': __('Change chat status'),
  49334. 'placeholder_status_message': __('Personal status message')
  49335. }));
  49336. },
  49337. afterRender() {
  49338. this.el.addEventListener('shown.bs.modal', () => {
  49339. this.el.querySelector('input[name="status_message"]').focus();
  49340. }, false);
  49341. },
  49342. clearStatusMessage(ev) {
  49343. if (ev && ev.preventDefault) {
  49344. ev.preventDefault();
  49345. chat_status_u.hideElement(this.el.querySelector('.clear-input'));
  49346. }
  49347. const roster_filter = this.el.querySelector('input[name="status_message"]');
  49348. roster_filter.value = '';
  49349. },
  49350. onFormSubmitted(ev) {
  49351. ev.preventDefault();
  49352. const data = new FormData(ev.target);
  49353. this.model.save({
  49354. 'status_message': data.get('status_message'),
  49355. 'status': data.get('chat_status')
  49356. });
  49357. this.modal.hide();
  49358. }
  49359. });
  49360. shared_converse.ChatStatusModal = ChatStatusModal;
  49361. /* harmony default export */ const chat_status = ((/* unused pure expression or super */ null && (ChatStatusModal)));
  49362. ;// CONCATENATED MODULE: ./src/shared/components/image-picker.js
  49363. const i18n_profile_picture = __('Your profile picture');
  49364. class ImagePicker extends CustomElement {
  49365. static get properties() {
  49366. return {
  49367. 'height': {
  49368. type: Number
  49369. },
  49370. 'data': {
  49371. type: Object
  49372. },
  49373. 'width': {
  49374. type: Number
  49375. }
  49376. };
  49377. }
  49378. render() {
  49379. return $`
  49380. <a class="change-avatar" @click=${this.openFileSelection} title="${i18n_profile_picture}">
  49381. <converse-avatar class="avatar" .data=${this.data} height="${this.height}" width="${this.width}"></converse-avatar>
  49382. </a>
  49383. <input @change=${this.updateFilePreview} class="hidden" name="image" type="file"/>
  49384. `;
  49385. }
  49386. openFileSelection(ev) {
  49387. ev.preventDefault();
  49388. this.querySelector('input[type="file"]').click();
  49389. }
  49390. updateFilePreview(ev) {
  49391. const file = ev.target.files[0];
  49392. const reader = new FileReader();
  49393. reader.onloadend = () => {
  49394. this.data = {
  49395. 'data_uri': reader.result,
  49396. 'image_type': file.type
  49397. };
  49398. };
  49399. reader.readAsDataURL(file);
  49400. }
  49401. }
  49402. core_api.elements.define('converse-image-picker', ImagePicker);
  49403. ;// CONCATENATED MODULE: ./src/plugins/profile/templates/profile_modal.js
  49404. const omemo_page = () => $`
  49405. <div class="tab-pane" id="omemo-tabpanel" role="tabpanel" aria-labelledby="omemo-tab">
  49406. <converse-omemo-profile></converse-omemo-profile>
  49407. </div>`;
  49408. /* harmony default export */ const profile_modal = (o => {
  49409. var _converse$pluggable$p, _converse$pluggable$p2;
  49410. const heading_profile = __('Your Profile');
  49411. const i18n_email = __('Email');
  49412. const i18n_fullname = __('Full Name');
  49413. const i18n_jid = __('XMPP Address');
  49414. const i18n_nickname = __('Nickname');
  49415. const i18n_role = __('Role');
  49416. const i18n_save = __('Save and close');
  49417. const i18n_role_help = __('Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages.');
  49418. const i18n_url = __('URL');
  49419. const i18n_omemo = __('OMEMO');
  49420. const i18n_profile = __('Profile');
  49421. const navigation = $`<ul class="nav nav-pills justify-content-center">
  49422. <li role="presentation" class="nav-item">
  49423. <a class="nav-link active" id="profile-tab" href="#profile-tabpanel" aria-controls="profile-tabpanel" role="tab" data-toggle="tab">${i18n_profile}</a>
  49424. </li>
  49425. <li role="presentation" class="nav-item">
  49426. <a class="nav-link" id="omemo-tab" href="#omemo-tabpanel" aria-controls="omemo-tabpanel" role="tab" data-toggle="tab">${i18n_omemo}</a>
  49427. </li>
  49428. </ul>`;
  49429. return $`
  49430. <div class="modal-dialog" role="document">
  49431. <div class="modal-content">
  49432. <div class="modal-header">
  49433. <h5 class="modal-title" id="user-profile-modal-label">${heading_profile}</h5>
  49434. ${modal_header_close_button}
  49435. </div>
  49436. <div class="modal-body">
  49437. <span class="modal-alert"></span>
  49438. ${(_converse$pluggable$p = shared_converse.pluggable.plugins["converse-omemo"]) !== null && _converse$pluggable$p !== void 0 && _converse$pluggable$p.enabled(shared_converse) ? navigation : ''}
  49439. <div class="tab-content">
  49440. <div class="tab-pane active" id="profile-tabpanel" role="tabpanel" aria-labelledby="profile-tab">
  49441. <form class="converse-form converse-form--modal profile-form" action="#">
  49442. <div class="row">
  49443. <div class="col-auto">
  49444. <converse-image-picker .data="${{
  49445. image: o.image,
  49446. image_type: o.image_type
  49447. }}" width="128" height="128"></converse-image-picker>
  49448. </div>
  49449. <div class="col">
  49450. <div class="form-group">
  49451. <label class="col-form-label">${i18n_jid}:</label>
  49452. <div>${o.jid}</div>
  49453. </div>
  49454. </div>
  49455. </div>
  49456. <div class="form-group">
  49457. <label for="vcard-fullname" class="col-form-label">${i18n_fullname}:</label>
  49458. <input id="vcard-fullname" type="text" class="form-control" name="fn" value="${o.fullname || ''}"/>
  49459. </div>
  49460. <div class="form-group">
  49461. <label for="vcard-nickname" class="col-form-label">${i18n_nickname}:</label>
  49462. <input id="vcard-nickname" type="text" class="form-control" name="nickname" value="${o.nickname || ''}"/>
  49463. </div>
  49464. <div class="form-group">
  49465. <label for="vcard-url" class="col-form-label">${i18n_url}:</label>
  49466. <input id="vcard-url" type="url" class="form-control" name="url" value="${o.url || ''}"/>
  49467. </div>
  49468. <div class="form-group">
  49469. <label for="vcard-email" class="col-form-label">${i18n_email}:</label>
  49470. <input id="vcard-email" type="email" class="form-control" name="email" value="${o.email || ''}"/>
  49471. </div>
  49472. <div class="form-group">
  49473. <label for="vcard-role" class="col-form-label">${i18n_role}:</label>
  49474. <input id="vcard-role" type="text" class="form-control" name="role" value="${o.role || ''}" aria-describedby="vcard-role-help"/>
  49475. <small id="vcard-role-help" class="form-text text-muted">${i18n_role_help}</small>
  49476. </div>
  49477. <hr/>
  49478. <div class="form-group">
  49479. <button type="submit" class="save-form btn btn-primary">${i18n_save}</button>
  49480. </div>
  49481. </form>
  49482. </div>
  49483. ${(_converse$pluggable$p2 = shared_converse.pluggable.plugins["converse-omemo"]) !== null && _converse$pluggable$p2 !== void 0 && _converse$pluggable$p2.enabled(shared_converse) ? omemo_page() : ''}
  49484. </div>
  49485. </div>
  49486. </div>
  49487. </div>
  49488. `;
  49489. });
  49490. // EXTERNAL MODULE: ./node_modules/client-compress/dist/index.js
  49491. var dist = __webpack_require__(577);
  49492. var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
  49493. ;// CONCATENATED MODULE: ./src/plugins/profile/modals/profile.js
  49494. const {
  49495. sizzle: modals_profile_sizzle
  49496. } = core_converse.env;
  49497. const profile_options = {
  49498. targetSize: 0.1,
  49499. quality: 0.75,
  49500. maxWidth: 256,
  49501. maxHeight: 256
  49502. };
  49503. const compress = new (dist_default())(profile_options);
  49504. const ProfileModal = base.extend({
  49505. id: "user-profile-modal",
  49506. events: {
  49507. 'submit .profile-form': 'onFormSubmitted'
  49508. },
  49509. initialize() {
  49510. this.listenTo(this.model, 'change', this.render);
  49511. base.prototype.initialize.apply(this, arguments);
  49512. /**
  49513. * Triggered when the _converse.ProfileModal has been created and initialized.
  49514. * @event _converse#profileModalInitialized
  49515. * @type { _converse.XMPPStatus }
  49516. * @example _converse.api.listen.on('profileModalInitialized', status => { ... });
  49517. */
  49518. core_api.trigger('profileModalInitialized', this.model);
  49519. },
  49520. toHTML() {
  49521. return profile_modal(Object.assign(this.model.toJSON(), this.model.vcard.toJSON(), {
  49522. 'view': this
  49523. }));
  49524. },
  49525. afterRender() {
  49526. this.tabs = modals_profile_sizzle('.nav-item .nav-link', this.el).map(e => new (bootstrap_native_default()).Tab(e));
  49527. },
  49528. async setVCard(data) {
  49529. try {
  49530. await core_api.vcard.set(shared_converse.bare_jid, data);
  49531. } catch (err) {
  49532. headless_log.fatal(err);
  49533. this.alert([__("Sorry, an error happened while trying to save your profile data."), __("You can check your browser's developer console for any error output.")].join(" "));
  49534. return;
  49535. }
  49536. this.modal.hide();
  49537. },
  49538. onFormSubmitted(ev) {
  49539. ev.preventDefault();
  49540. const reader = new FileReader();
  49541. const form_data = new FormData(ev.target);
  49542. const image_file = form_data.get('image');
  49543. const data = {
  49544. 'fn': form_data.get('fn'),
  49545. 'nickname': form_data.get('nickname'),
  49546. 'role': form_data.get('role'),
  49547. 'email': form_data.get('email'),
  49548. 'url': form_data.get('url')
  49549. };
  49550. if (!image_file.size) {
  49551. Object.assign(data, {
  49552. 'image': this.model.vcard.get('image'),
  49553. 'image_type': this.model.vcard.get('image_type')
  49554. });
  49555. this.setVCard(data);
  49556. } else {
  49557. const files = [image_file];
  49558. compress.compress(files).then(conversions => {
  49559. const {
  49560. photo
  49561. } = conversions[0];
  49562. reader.onloadend = () => {
  49563. Object.assign(data, {
  49564. 'image': btoa(reader.result),
  49565. 'image_type': image_file.type
  49566. });
  49567. this.setVCard(data);
  49568. };
  49569. reader.readAsBinaryString(photo.data);
  49570. });
  49571. }
  49572. }
  49573. });
  49574. shared_converse.ProfileModal = ProfileModal;
  49575. /* harmony default export */ const modals_profile = ((/* unused pure expression or super */ null && (ProfileModal)));
  49576. ;// CONCATENATED MODULE: ./src/plugins/profile/index.js
  49577. /**
  49578. * @copyright The Converse.js contributors
  49579. * @license Mozilla Public License (MPLv2)
  49580. */
  49581. core_converse.plugins.add('converse-profile', {
  49582. dependencies: ["converse-status", "converse-modal", "converse-vcard", "converse-chatboxviews"],
  49583. initialize() {
  49584. core_api.settings.extend({
  49585. 'allow_adhoc_commands': true,
  49586. 'show_client_info': true
  49587. });
  49588. }
  49589. });
  49590. ;// CONCATENATED MODULE: ./src/plugins/omemo/mixins/converse.js
  49591. const ConverseMixins = {
  49592. generateFingerprints: async function (jid) {
  49593. const devices = await getDevicesForContact(jid);
  49594. return Promise.all(devices.map(d => generateFingerprint(d)));
  49595. },
  49596. getDeviceForContact: function (jid, device_id) {
  49597. return getDevicesForContact(jid).then(devices => devices.get(device_id));
  49598. },
  49599. contactHasOMEMOSupport: async function (jid) {
  49600. /* Checks whether the contact advertises any OMEMO-compatible devices. */
  49601. const devices = await getDevicesForContact(jid);
  49602. return devices.length > 0;
  49603. }
  49604. };
  49605. /* harmony default export */ const mixins_converse = (ConverseMixins);
  49606. ;// CONCATENATED MODULE: ./src/plugins/omemo/errors.js
  49607. class IQError extends Error {
  49608. constructor(message, iq) {
  49609. super(message, iq);
  49610. this.name = 'IQError';
  49611. this.iq = iq;
  49612. }
  49613. }
  49614. ;// CONCATENATED MODULE: ./src/plugins/omemo/device.js
  49615. const {
  49616. Strophe: device_Strophe,
  49617. sizzle: device_sizzle,
  49618. u: device_u,
  49619. $iq: device_$iq
  49620. } = core_converse.env;
  49621. /**
  49622. * @class
  49623. * @namespace _converse.Device
  49624. * @memberOf _converse
  49625. */
  49626. const Device = Model.extend({
  49627. defaults: {
  49628. 'trusted': UNDECIDED,
  49629. 'active': true
  49630. },
  49631. getRandomPreKey() {
  49632. // XXX: assumes that the bundle has already been fetched
  49633. const bundle = this.get('bundle');
  49634. return bundle.prekeys[device_u.getRandomInt(bundle.prekeys.length)];
  49635. },
  49636. async fetchBundleFromServer() {
  49637. const stanza = device_$iq({
  49638. 'type': 'get',
  49639. 'from': shared_converse.bare_jid,
  49640. 'to': this.get('jid')
  49641. }).c('pubsub', {
  49642. 'xmlns': device_Strophe.NS.PUBSUB
  49643. }).c('items', {
  49644. 'node': `${device_Strophe.NS.OMEMO_BUNDLES}:${this.get('id')}`
  49645. });
  49646. let iq;
  49647. try {
  49648. iq = await core_api.sendIQ(stanza);
  49649. } catch (iq) {
  49650. headless_log.error(`Could not fetch bundle for device ${this.get('id')} from ${this.get('jid')}`);
  49651. headless_log.error(iq);
  49652. return null;
  49653. }
  49654. if (iq.querySelector('error')) {
  49655. throw new IQError('Could not fetch bundle', iq);
  49656. }
  49657. const publish_el = device_sizzle(`items[node="${device_Strophe.NS.OMEMO_BUNDLES}:${this.get('id')}"]`, iq).pop();
  49658. const bundle_el = device_sizzle(`bundle[xmlns="${device_Strophe.NS.OMEMO}"]`, publish_el).pop();
  49659. const bundle = parseBundle(bundle_el);
  49660. this.save('bundle', bundle);
  49661. return bundle;
  49662. },
  49663. /**
  49664. * Fetch and save the bundle information associated with
  49665. * this device, if the information is not cached already.
  49666. * @method _converse.Device#getBundle
  49667. */
  49668. getBundle() {
  49669. if (this.get('bundle')) {
  49670. return Promise.resolve(this.get('bundle'), this);
  49671. } else {
  49672. return this.fetchBundleFromServer();
  49673. }
  49674. }
  49675. });
  49676. /* harmony default export */ const device = (Device);
  49677. ;// CONCATENATED MODULE: ./src/plugins/omemo/devicelist.js
  49678. const {
  49679. Strophe: devicelist_Strophe,
  49680. $build: devicelist_$build,
  49681. $iq: devicelist_$iq,
  49682. sizzle: devicelist_sizzle
  49683. } = core_converse.env;
  49684. /**
  49685. * @class
  49686. * @namespace _converse.DeviceList
  49687. * @memberOf _converse
  49688. */
  49689. const DeviceList = Model.extend({
  49690. idAttribute: 'jid',
  49691. async initialize() {
  49692. this.initialized = getOpenPromise();
  49693. await this.initDevices();
  49694. this.initialized.resolve();
  49695. },
  49696. initDevices() {
  49697. this.devices = new shared_converse.Devices();
  49698. const id = `converse.devicelist-${shared_converse.bare_jid}-${this.get('jid')}`;
  49699. initStorage(this.devices, id);
  49700. return this.fetchDevices();
  49701. },
  49702. async onDevicesFound(collection) {
  49703. if (collection.length === 0) {
  49704. let ids = [];
  49705. try {
  49706. ids = await this.fetchDevicesFromServer();
  49707. } catch (e) {
  49708. if (e === null) {
  49709. headless_log.error(`Timeout error while fetching devices for ${this.get('jid')}`);
  49710. } else {
  49711. headless_log.error(`Could not fetch devices for ${this.get('jid')}`);
  49712. headless_log.error(e);
  49713. }
  49714. this.destroy();
  49715. }
  49716. if (this.get('jid') === shared_converse.bare_jid) {
  49717. this.publishCurrentDevice(ids);
  49718. }
  49719. }
  49720. },
  49721. fetchDevices() {
  49722. if (this._devices_promise === undefined) {
  49723. this._devices_promise = new Promise(resolve => {
  49724. this.devices.fetch({
  49725. 'success': c => resolve(this.onDevicesFound(c)),
  49726. 'error': (_, e) => {
  49727. headless_log.error(e);
  49728. resolve();
  49729. }
  49730. });
  49731. });
  49732. }
  49733. return this._devices_promise;
  49734. },
  49735. async getOwnDeviceId() {
  49736. let device_id = shared_converse.omemo_store.get('device_id');
  49737. if (!this.devices.get(device_id)) {
  49738. // Generate a new bundle if we cannot find our device
  49739. await shared_converse.omemo_store.generateBundle();
  49740. device_id = shared_converse.omemo_store.get('device_id');
  49741. }
  49742. return device_id;
  49743. },
  49744. async publishCurrentDevice(device_ids) {
  49745. if (this.get('jid') !== shared_converse.bare_jid) {
  49746. return; // We only publish for ourselves.
  49747. }
  49748. await restoreOMEMOSession();
  49749. if (!shared_converse.omemo_store) {
  49750. // Happens during tests. The connection gets torn down
  49751. // before publishCurrentDevice has time to finish.
  49752. headless_log.warn('publishCurrentDevice: omemo_store is not defined, likely a timing issue');
  49753. return;
  49754. }
  49755. if (!device_ids.includes(await this.getOwnDeviceId())) {
  49756. return this.publishDevices();
  49757. }
  49758. },
  49759. async fetchDevicesFromServer() {
  49760. const stanza = devicelist_$iq({
  49761. 'type': 'get',
  49762. 'from': shared_converse.bare_jid,
  49763. 'to': this.get('jid')
  49764. }).c('pubsub', {
  49765. 'xmlns': devicelist_Strophe.NS.PUBSUB
  49766. }).c('items', {
  49767. 'node': devicelist_Strophe.NS.OMEMO_DEVICELIST
  49768. });
  49769. const iq = await core_api.sendIQ(stanza);
  49770. const selector = `list[xmlns="${devicelist_Strophe.NS.OMEMO}"] device`;
  49771. const device_ids = devicelist_sizzle(selector, iq).map(d => d.getAttribute('id'));
  49772. const jid = this.get('jid');
  49773. return Promise.all(device_ids.map(id => this.devices.create({
  49774. id,
  49775. jid
  49776. }, {
  49777. 'promise': true
  49778. })));
  49779. },
  49780. /**
  49781. * Send an IQ stanza to the current user's "devices" PEP node to
  49782. * ensure that all devices are published for potential chat partners to see.
  49783. * See: https://xmpp.org/extensions/xep-0384.html#usecases-announcing
  49784. */
  49785. publishDevices() {
  49786. const item = devicelist_$build('item', {
  49787. 'id': 'current'
  49788. }).c('list', {
  49789. 'xmlns': devicelist_Strophe.NS.OMEMO
  49790. });
  49791. this.devices.filter(d => d.get('active')).forEach(d => item.c('device', {
  49792. 'id': d.get('id')
  49793. }).up());
  49794. const options = {
  49795. 'pubsub#access_model': 'open'
  49796. };
  49797. return core_api.pubsub.publish(null, devicelist_Strophe.NS.OMEMO_DEVICELIST, item, options, false);
  49798. },
  49799. async removeOwnDevices(device_ids) {
  49800. if (this.get('jid') !== shared_converse.bare_jid) {
  49801. throw new Error("Cannot remove devices from someone else's device list");
  49802. }
  49803. await Promise.all(device_ids.map(id => this.devices.get(id)).map(d => new Promise(resolve => d.destroy({
  49804. 'success': resolve,
  49805. 'error': (_, e) => {
  49806. headless_log.error(e);
  49807. resolve();
  49808. }
  49809. }))));
  49810. return this.publishDevices();
  49811. }
  49812. });
  49813. /* harmony default export */ const devicelist = (DeviceList);
  49814. ;// CONCATENATED MODULE: ./src/plugins/omemo/devicelists.js
  49815. /**
  49816. * @class
  49817. * @namespace _converse.DeviceLists
  49818. * @memberOf _converse
  49819. */
  49820. const DeviceLists = Collection.extend({
  49821. model: devicelist
  49822. });
  49823. /* harmony default export */ const devicelists = (DeviceLists);
  49824. ;// CONCATENATED MODULE: ./src/plugins/omemo/devices.js
  49825. /* harmony default export */ const devices = (Collection.extend({
  49826. model: device
  49827. }));
  49828. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_baseRange.js
  49829. /* Built-in method references for those with the same name as other `lodash` methods. */
  49830. var nativeCeil = Math.ceil,
  49831. _baseRange_nativeMax = Math.max;
  49832. /**
  49833. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  49834. * coerce arguments.
  49835. *
  49836. * @private
  49837. * @param {number} start The start of the range.
  49838. * @param {number} end The end of the range.
  49839. * @param {number} step The value to increment or decrement by.
  49840. * @param {boolean} [fromRight] Specify iterating from right to left.
  49841. * @returns {Array} Returns the range of numbers.
  49842. */
  49843. function baseRange(start, end, step, fromRight) {
  49844. var index = -1,
  49845. length = _baseRange_nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  49846. result = Array(length);
  49847. while (length--) {
  49848. result[fromRight ? length : ++index] = start;
  49849. start += step;
  49850. }
  49851. return result;
  49852. }
  49853. /* harmony default export */ const _baseRange = (baseRange);
  49854. ;// CONCATENATED MODULE: ./node_modules/lodash-es/_createRange.js
  49855. /**
  49856. * Creates a `_.range` or `_.rangeRight` function.
  49857. *
  49858. * @private
  49859. * @param {boolean} [fromRight] Specify iterating from right to left.
  49860. * @returns {Function} Returns the new range function.
  49861. */
  49862. function createRange(fromRight) {
  49863. return function(start, end, step) {
  49864. if (step && typeof step != 'number' && _isIterateeCall(start, end, step)) {
  49865. end = step = undefined;
  49866. }
  49867. // Ensure the sign of `-0` is preserved.
  49868. start = lodash_es_toFinite(start);
  49869. if (end === undefined) {
  49870. end = start;
  49871. start = 0;
  49872. } else {
  49873. end = lodash_es_toFinite(end);
  49874. }
  49875. step = step === undefined ? (start < end ? 1 : -1) : lodash_es_toFinite(step);
  49876. return _baseRange(start, end, step, fromRight);
  49877. };
  49878. }
  49879. /* harmony default export */ const _createRange = (createRange);
  49880. ;// CONCATENATED MODULE: ./node_modules/lodash-es/range.js
  49881. /**
  49882. * Creates an array of numbers (positive and/or negative) progressing from
  49883. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  49884. * `start` is specified without an `end` or `step`. If `end` is not specified,
  49885. * it's set to `start` with `start` then set to `0`.
  49886. *
  49887. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  49888. * floating-point values which can produce unexpected results.
  49889. *
  49890. * @static
  49891. * @since 0.1.0
  49892. * @memberOf _
  49893. * @category Util
  49894. * @param {number} [start=0] The start of the range.
  49895. * @param {number} end The end of the range.
  49896. * @param {number} [step=1] The value to increment or decrement by.
  49897. * @returns {Array} Returns the range of numbers.
  49898. * @see _.inRange, _.rangeRight
  49899. * @example
  49900. *
  49901. * _.range(4);
  49902. * // => [0, 1, 2, 3]
  49903. *
  49904. * _.range(-4);
  49905. * // => [0, -1, -2, -3]
  49906. *
  49907. * _.range(1, 5);
  49908. * // => [1, 2, 3, 4]
  49909. *
  49910. * _.range(0, 20, 5);
  49911. * // => [0, 5, 10, 15]
  49912. *
  49913. * _.range(0, -4, -1);
  49914. * // => [0, -1, -2, -3]
  49915. *
  49916. * _.range(1, 4, 0);
  49917. * // => [1, 1, 1]
  49918. *
  49919. * _.range(0);
  49920. * // => []
  49921. */
  49922. var range = _createRange();
  49923. /* harmony default export */ const lodash_es_range = (range);
  49924. ;// CONCATENATED MODULE: ./src/plugins/omemo/store.js
  49925. /* global libsignal */
  49926. const {
  49927. Strophe: store_Strophe,
  49928. $build: store_$build,
  49929. u: store_u
  49930. } = core_converse.env;
  49931. const OMEMOStore = Model.extend({
  49932. Direction: {
  49933. SENDING: 1,
  49934. RECEIVING: 2
  49935. },
  49936. getIdentityKeyPair() {
  49937. const keypair = this.get('identity_keypair');
  49938. return Promise.resolve({
  49939. 'privKey': store_u.base64ToArrayBuffer(keypair.privKey),
  49940. 'pubKey': store_u.base64ToArrayBuffer(keypair.pubKey)
  49941. });
  49942. },
  49943. getLocalRegistrationId() {
  49944. return Promise.resolve(parseInt(this.get('device_id'), 10));
  49945. },
  49946. isTrustedIdentity(identifier, identity_key, direction) {
  49947. // eslint-disable-line no-unused-vars
  49948. if (identifier === null || identifier === undefined) {
  49949. throw new Error("Can't check identity key for invalid key");
  49950. }
  49951. if (!(identity_key instanceof ArrayBuffer)) {
  49952. throw new Error('Expected identity_key to be an ArrayBuffer');
  49953. }
  49954. const trusted = this.get('identity_key' + identifier);
  49955. if (trusted === undefined) {
  49956. return Promise.resolve(true);
  49957. }
  49958. return Promise.resolve(store_u.arrayBufferToBase64(identity_key) === trusted);
  49959. },
  49960. loadIdentityKey(identifier) {
  49961. if (identifier === null || identifier === undefined) {
  49962. throw new Error("Can't load identity_key for invalid identifier");
  49963. }
  49964. return Promise.resolve(store_u.base64ToArrayBuffer(this.get('identity_key' + identifier)));
  49965. },
  49966. saveIdentity(identifier, identity_key) {
  49967. if (identifier === null || identifier === undefined) {
  49968. throw new Error("Can't save identity_key for invalid identifier");
  49969. }
  49970. const address = new libsignal.SignalProtocolAddress.fromString(identifier);
  49971. const existing = this.get('identity_key' + address.getName());
  49972. const b64_idkey = store_u.arrayBufferToBase64(identity_key);
  49973. this.save('identity_key' + address.getName(), b64_idkey);
  49974. if (existing && b64_idkey !== existing) {
  49975. return Promise.resolve(true);
  49976. } else {
  49977. return Promise.resolve(false);
  49978. }
  49979. },
  49980. getPreKeys() {
  49981. return this.get('prekeys') || {};
  49982. },
  49983. loadPreKey(key_id) {
  49984. const res = this.getPreKeys()[key_id];
  49985. if (res) {
  49986. return Promise.resolve({
  49987. 'privKey': store_u.base64ToArrayBuffer(res.privKey),
  49988. 'pubKey': store_u.base64ToArrayBuffer(res.pubKey)
  49989. });
  49990. }
  49991. return Promise.resolve();
  49992. },
  49993. storePreKey(key_id, key_pair) {
  49994. const prekey = {};
  49995. prekey[key_id] = {
  49996. 'pubKey': store_u.arrayBufferToBase64(key_pair.pubKey),
  49997. 'privKey': store_u.arrayBufferToBase64(key_pair.privKey)
  49998. };
  49999. this.save('prekeys', Object.assign(this.getPreKeys(), prekey));
  50000. return Promise.resolve();
  50001. },
  50002. removePreKey(key_id) {
  50003. this.save('prekeys', lodash_es_omit(this.getPreKeys(), key_id));
  50004. return Promise.resolve();
  50005. },
  50006. loadSignedPreKey(keyId) {
  50007. // eslint-disable-line no-unused-vars
  50008. const res = this.get('signed_prekey');
  50009. if (res) {
  50010. return Promise.resolve({
  50011. 'privKey': store_u.base64ToArrayBuffer(res.privKey),
  50012. 'pubKey': store_u.base64ToArrayBuffer(res.pubKey)
  50013. });
  50014. }
  50015. return Promise.resolve();
  50016. },
  50017. storeSignedPreKey(spk) {
  50018. if (typeof spk !== 'object') {
  50019. // XXX: We've changed the signature of this method from the
  50020. // example given in InMemorySignalProtocolStore.
  50021. // Should be fine because the libsignal code doesn't
  50022. // actually call this method.
  50023. throw new Error('storeSignedPreKey: expected an object');
  50024. }
  50025. this.save('signed_prekey', {
  50026. 'id': spk.keyId,
  50027. 'privKey': store_u.arrayBufferToBase64(spk.keyPair.privKey),
  50028. 'pubKey': store_u.arrayBufferToBase64(spk.keyPair.pubKey),
  50029. // XXX: The InMemorySignalProtocolStore does not pass
  50030. // in or store the signature, but we need it when we
  50031. // publish our bundle and this method isn't called from
  50032. // within libsignal code, so we modify it to also store
  50033. // the signature.
  50034. 'signature': store_u.arrayBufferToBase64(spk.signature)
  50035. });
  50036. return Promise.resolve();
  50037. },
  50038. removeSignedPreKey(key_id) {
  50039. if (this.get('signed_prekey')['id'] === key_id) {
  50040. this.unset('signed_prekey');
  50041. this.save();
  50042. }
  50043. return Promise.resolve();
  50044. },
  50045. loadSession(identifier) {
  50046. return Promise.resolve(this.get('session' + identifier));
  50047. },
  50048. storeSession(identifier, record) {
  50049. return Promise.resolve(this.save('session' + identifier, record));
  50050. },
  50051. removeSession(identifier) {
  50052. return Promise.resolve(this.unset('session' + identifier));
  50053. },
  50054. removeAllSessions(identifier) {
  50055. const keys = Object.keys(this.attributes).filter(key => key.startsWith('session' + identifier) ? key : false);
  50056. const attrs = {};
  50057. keys.forEach(key => {
  50058. attrs[key] = undefined;
  50059. });
  50060. this.save(attrs);
  50061. return Promise.resolve();
  50062. },
  50063. publishBundle() {
  50064. const signed_prekey = this.get('signed_prekey');
  50065. const node = `${store_Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`;
  50066. const item = store_$build('item').c('bundle', {
  50067. 'xmlns': store_Strophe.NS.OMEMO
  50068. }).c('signedPreKeyPublic', {
  50069. 'signedPreKeyId': signed_prekey.id
  50070. }).t(signed_prekey.pubKey).up().c('signedPreKeySignature').t(signed_prekey.signature).up().c('identityKey').t(this.get('identity_keypair').pubKey).up().c('prekeys');
  50071. Object.values(this.get('prekeys')).forEach((prekey, id) => item.c('preKeyPublic', {
  50072. 'preKeyId': id
  50073. }).t(prekey.pubKey).up());
  50074. const options = {
  50075. 'pubsub#access_model': 'open'
  50076. };
  50077. return core_api.pubsub.publish(null, node, item, options, false);
  50078. },
  50079. async generateMissingPreKeys() {
  50080. const missing_keys = lodash_es_difference(lodash_es_invokeMap(lodash_es_range(0, shared_converse.NUM_PREKEYS), Number.prototype.toString), Object.keys(this.getPreKeys()));
  50081. if (missing_keys.length < 1) {
  50082. headless_log.warn('No missing prekeys to generate for our own device');
  50083. return Promise.resolve();
  50084. }
  50085. const keys = await Promise.all(missing_keys.map(id => libsignal.KeyHelper.generatePreKey(parseInt(id, 10))));
  50086. keys.forEach(k => this.storePreKey(k.keyId, k.keyPair));
  50087. const marshalled_keys = Object.keys(this.getPreKeys()).map(k => ({
  50088. 'id': k.keyId,
  50089. 'key': store_u.arrayBufferToBase64(k.pubKey)
  50090. }));
  50091. const devicelist = await core_api.omemo.devicelists.get(shared_converse.bare_jid);
  50092. const device = devicelist.devices.get(this.get('device_id'));
  50093. const bundle = await device.getBundle();
  50094. device.save('bundle', Object.assign(bundle, {
  50095. 'prekeys': marshalled_keys
  50096. }));
  50097. },
  50098. /**
  50099. * Generates, stores and then returns pre-keys.
  50100. *
  50101. * Pre-keys are one half of a X3DH key exchange and are published as part
  50102. * of the device bundle.
  50103. *
  50104. * For a new contact or device to establish an encrypted session, it needs
  50105. * to use a pre-key, which it chooses randomly from the list of available
  50106. * ones.
  50107. */
  50108. async generatePreKeys() {
  50109. const amount = shared_converse.NUM_PREKEYS;
  50110. const {
  50111. KeyHelper
  50112. } = libsignal;
  50113. const keys = await Promise.all(lodash_es_range(0, amount).map(id => KeyHelper.generatePreKey(id)));
  50114. keys.forEach(k => this.storePreKey(k.keyId, k.keyPair));
  50115. return keys.map(k => ({
  50116. 'id': k.keyId,
  50117. 'key': store_u.arrayBufferToBase64(k.keyPair.pubKey)
  50118. }));
  50119. },
  50120. /**
  50121. * Generate the cryptographic data used by the X3DH key agreement protocol
  50122. * in order to build a session with other devices.
  50123. *
  50124. * By generating a bundle, and publishing it via PubSub, we allow other
  50125. * clients to download it and start asynchronous encrypted sessions with us,
  50126. * even if we're offline at that time.
  50127. */
  50128. async generateBundle() {
  50129. // The first thing that needs to happen if a client wants to
  50130. // start using OMEMO is they need to generate an IdentityKey
  50131. // and a Device ID.
  50132. // The IdentityKey is a Curve25519 public/private Key pair.
  50133. const identity_keypair = await libsignal.KeyHelper.generateIdentityKeyPair();
  50134. const identity_key = store_u.arrayBufferToBase64(identity_keypair.pubKey); // The Device ID is a randomly generated integer between 1 and 2^31 - 1.
  50135. const device_id = await generateDeviceID();
  50136. this.save({
  50137. 'device_id': device_id,
  50138. 'identity_keypair': {
  50139. 'privKey': store_u.arrayBufferToBase64(identity_keypair.privKey),
  50140. 'pubKey': identity_key
  50141. },
  50142. 'identity_key': identity_key
  50143. });
  50144. const signed_prekey = await libsignal.KeyHelper.generateSignedPreKey(identity_keypair, 0);
  50145. this.storeSignedPreKey(signed_prekey);
  50146. const prekeys = await this.generatePreKeys();
  50147. const bundle = {
  50148. identity_key,
  50149. device_id,
  50150. prekeys
  50151. };
  50152. bundle['signed_prekey'] = {
  50153. 'id': signed_prekey.keyId,
  50154. 'public_key': store_u.arrayBufferToBase64(signed_prekey.keyPair.pubKey),
  50155. 'signature': store_u.arrayBufferToBase64(signed_prekey.signature)
  50156. };
  50157. const devicelist = await core_api.omemo.devicelists.get(shared_converse.bare_jid);
  50158. const device = await devicelist.devices.create({
  50159. 'id': bundle.device_id,
  50160. 'jid': shared_converse.bare_jid
  50161. }, {
  50162. 'promise': true
  50163. });
  50164. device.save('bundle', bundle);
  50165. },
  50166. fetchSession() {
  50167. if (this._setup_promise === undefined) {
  50168. this._setup_promise = new Promise((resolve, reject) => {
  50169. this.fetch({
  50170. 'success': () => {
  50171. if (!this.get('device_id')) {
  50172. this.generateBundle().then(resolve).catch(reject);
  50173. } else {
  50174. resolve();
  50175. }
  50176. },
  50177. 'error': (model, resp) => {
  50178. headless_log.warn("Could not fetch OMEMO session from cache, we'll generate a new one.");
  50179. headless_log.warn(resp);
  50180. this.generateBundle().then(resolve).catch(reject);
  50181. }
  50182. });
  50183. });
  50184. }
  50185. return this._setup_promise;
  50186. }
  50187. });
  50188. /* harmony default export */ const store = (OMEMOStore);
  50189. ;// CONCATENATED MODULE: ./src/plugins/omemo/api.js
  50190. /* harmony default export */ const omemo_api = ({
  50191. /**
  50192. * The "omemo" namespace groups methods relevant to OMEMO
  50193. * encryption.
  50194. *
  50195. * @namespace _converse.api.omemo
  50196. * @memberOf _converse.api
  50197. */
  50198. 'omemo': {
  50199. /**
  50200. * Returns the device ID of the current device.
  50201. */
  50202. async getDeviceID() {
  50203. await core_api.waitUntil('OMEMOInitialized');
  50204. return shared_converse.omemo_store.get('device_id');
  50205. },
  50206. /**
  50207. * The "devicelists" namespace groups methods related to OMEMO device lists
  50208. *
  50209. * @namespace _converse.api.omemo.devicelists
  50210. * @memberOf _converse.api.omemo
  50211. */
  50212. 'devicelists': {
  50213. /**
  50214. * Returns the {@link _converse.DeviceList} for a particular JID.
  50215. * The device list will be created if it doesn't exist already.
  50216. * @method _converse.api.omemo.devicelists.get
  50217. * @param { String } jid - The Jabber ID for which the device list will be returned.
  50218. * @param { bool } create=false - Set to `true` if the device list
  50219. * should be created if it cannot be found.
  50220. */
  50221. async get(jid) {
  50222. let create = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  50223. const list = shared_converse.devicelists.get(jid) || (create ? shared_converse.devicelists.create({
  50224. jid
  50225. }) : null);
  50226. await (list === null || list === void 0 ? void 0 : list.initialized);
  50227. return list;
  50228. }
  50229. },
  50230. /**
  50231. * The "bundle" namespace groups methods relevant to the user's
  50232. * OMEMO bundle.
  50233. *
  50234. * @namespace _converse.api.omemo.bundle
  50235. * @memberOf _converse.api.omemo
  50236. */
  50237. 'bundle': {
  50238. /**
  50239. * Lets you generate a new OMEMO device bundle
  50240. *
  50241. * @method _converse.api.omemo.bundle.generate
  50242. * @returns {promise} Promise which resolves once we have a result from the server.
  50243. */
  50244. 'generate': async () => {
  50245. await core_api.waitUntil('OMEMOInitialized'); // Remove current device
  50246. const devicelist = await core_api.omemo.devicelists.get(shared_converse.bare_jid);
  50247. const device_id = shared_converse.omemo_store.get('device_id');
  50248. if (device_id) {
  50249. const device = devicelist.devices.get(device_id);
  50250. shared_converse.omemo_store.unset(device_id);
  50251. if (device) {
  50252. await new Promise(done => device.destroy({
  50253. 'success': done,
  50254. 'error': done
  50255. }));
  50256. }
  50257. devicelist.devices.trigger('remove');
  50258. } // Generate new device bundle and publish
  50259. // https://xmpp.org/extensions/attic/xep-0384-0.3.0.html#usecases-announcing
  50260. await shared_converse.omemo_store.generateBundle();
  50261. await devicelist.publishDevices();
  50262. const device = devicelist.devices.get(shared_converse.omemo_store.get('device_id'));
  50263. const fp = generateFingerprint(device);
  50264. await shared_converse.omemo_store.publishBundle();
  50265. return fp;
  50266. }
  50267. }
  50268. }
  50269. });
  50270. ;// CONCATENATED MODULE: ./src/plugins/omemo/index.js
  50271. /**
  50272. * @copyright The Converse.js contributors
  50273. * @license Mozilla Public License (MPLv2)
  50274. */
  50275. const {
  50276. Strophe: omemo_Strophe
  50277. } = core_converse.env;
  50278. core_converse.env.omemo = omemo;
  50279. omemo_Strophe.addNamespace('OMEMO_DEVICELIST', omemo_Strophe.NS.OMEMO + '.devicelist');
  50280. omemo_Strophe.addNamespace('OMEMO_VERIFICATION', omemo_Strophe.NS.OMEMO + '.verification');
  50281. omemo_Strophe.addNamespace('OMEMO_WHITELISTED', omemo_Strophe.NS.OMEMO + '.whitelisted');
  50282. omemo_Strophe.addNamespace('OMEMO_BUNDLES', omemo_Strophe.NS.OMEMO + '.bundles');
  50283. core_converse.plugins.add('converse-omemo', {
  50284. enabled(_converse) {
  50285. return window.libsignal && _converse.config.get('trusted') && !core_api.settings.get('clear_cache_on_logout') && !_converse.api.settings.get('blacklisted_plugins').includes('converse-omemo');
  50286. },
  50287. dependencies: ['converse-chatview', 'converse-pubsub'],
  50288. initialize() {
  50289. core_api.settings.extend({
  50290. 'omemo_default': false
  50291. });
  50292. core_api.promises.add(['OMEMOInitialized']);
  50293. shared_converse.NUM_PREKEYS = 100; // Set here so that tests can override
  50294. Object.assign(shared_converse, mixins_converse);
  50295. Object.assign(shared_converse.api, omemo_api);
  50296. shared_converse.OMEMOStore = store;
  50297. shared_converse.Device = device;
  50298. shared_converse.Devices = devices;
  50299. shared_converse.DeviceList = devicelist;
  50300. shared_converse.DeviceLists = devicelists;
  50301. /******************** Event Handlers ********************/
  50302. core_api.waitUntil('chatBoxesInitialized').then(utils_onChatBoxesInitialized);
  50303. core_api.listen.on('getOutgoingMessageAttributes', getOutgoingMessageAttributes);
  50304. core_api.listen.on('createMessageStanza', async (chat, data) => {
  50305. try {
  50306. data = await createOMEMOMessageStanza(chat, data);
  50307. } catch (e) {
  50308. handleMessageSendError(e, chat);
  50309. }
  50310. return data;
  50311. });
  50312. core_api.listen.on('afterFileUploaded', (msg, attrs) => msg.file.xep454_ivkey ? setEncryptedFileURL(msg, attrs) : attrs);
  50313. core_api.listen.on('beforeFileUpload', (chat, file) => chat.get('omemo_active') ? encryptFile(file) : file);
  50314. core_api.listen.on('parseMessage', parseEncryptedMessage);
  50315. core_api.listen.on('parseMUCMessage', parseEncryptedMessage);
  50316. core_api.listen.on('chatBoxViewInitialized', onChatInitialized);
  50317. core_api.listen.on('chatRoomViewInitialized', onChatInitialized);
  50318. core_api.listen.on('connected', registerPEPPushHandler);
  50319. core_api.listen.on('getToolbarButtons', getOMEMOToolbarButton);
  50320. core_api.listen.on('statusInitialized', initOMEMO);
  50321. core_api.listen.on('addClientFeatures', () => core_api.disco.own.features.add(`${omemo_Strophe.NS.OMEMO_DEVICELIST}+notify`));
  50322. core_api.listen.on('afterMessageBodyTransformed', handleEncryptedFiles);
  50323. core_api.listen.on('userDetailsModalInitialized', contact => {
  50324. const jid = contact.get('jid');
  50325. shared_converse.generateFingerprints(jid).catch(e => headless_log.error(e));
  50326. });
  50327. core_api.listen.on('profileModalInitialized', () => {
  50328. shared_converse.generateFingerprints(shared_converse.bare_jid).catch(e => headless_log.error(e));
  50329. });
  50330. core_api.listen.on('clearSession', () => {
  50331. delete shared_converse.omemo_store;
  50332. if (shared_converse.shouldClearCache() && shared_converse.devicelists) {
  50333. shared_converse.devicelists.clearStore();
  50334. delete shared_converse.devicelists;
  50335. }
  50336. });
  50337. }
  50338. });
  50339. ;// CONCATENATED MODULE: ./src/plugins/push/utils.js
  50340. const {
  50341. Strophe: push_utils_Strophe,
  50342. $iq: push_utils_$iq
  50343. } = core_converse.env;
  50344. async function disablePushAppServer(domain, push_app_server) {
  50345. if (!push_app_server.jid) {
  50346. return;
  50347. }
  50348. if (!(await core_api.disco.supports(push_utils_Strophe.NS.PUSH, domain || shared_converse.bare_jid))) {
  50349. headless_log.warn(`Not disabling push app server "${push_app_server.jid}", no disco support from your server.`);
  50350. return;
  50351. }
  50352. const stanza = push_utils_$iq({
  50353. 'type': 'set'
  50354. });
  50355. if (domain !== shared_converse.bare_jid) {
  50356. stanza.attrs({
  50357. 'to': domain
  50358. });
  50359. }
  50360. stanza.c('disable', {
  50361. 'xmlns': push_utils_Strophe.NS.PUSH,
  50362. 'jid': push_app_server.jid
  50363. });
  50364. if (push_app_server.node) {
  50365. stanza.attrs({
  50366. 'node': push_app_server.node
  50367. });
  50368. }
  50369. core_api.sendIQ(stanza).catch(e => {
  50370. headless_log.error(`Could not disable push app server for ${push_app_server.jid}`);
  50371. headless_log.error(e);
  50372. });
  50373. }
  50374. async function enablePushAppServer(domain, push_app_server) {
  50375. if (!push_app_server.jid || !push_app_server.node) {
  50376. return;
  50377. }
  50378. const identity = await core_api.disco.getIdentity('pubsub', 'push', push_app_server.jid);
  50379. if (!identity) {
  50380. return headless_log.warn(`Not enabling push the service "${push_app_server.jid}", it doesn't have the right disco identtiy.`);
  50381. }
  50382. const result = await Promise.all([core_api.disco.supports(push_utils_Strophe.NS.PUSH, push_app_server.jid), core_api.disco.supports(push_utils_Strophe.NS.PUSH, domain)]);
  50383. if (!result[0] && !result[1]) {
  50384. headless_log.warn(`Not enabling push app server "${push_app_server.jid}", no disco support from your server.`);
  50385. return;
  50386. }
  50387. const stanza = push_utils_$iq({
  50388. 'type': 'set'
  50389. });
  50390. if (domain !== shared_converse.bare_jid) {
  50391. stanza.attrs({
  50392. 'to': domain
  50393. });
  50394. }
  50395. stanza.c('enable', {
  50396. 'xmlns': push_utils_Strophe.NS.PUSH,
  50397. 'jid': push_app_server.jid,
  50398. 'node': push_app_server.node
  50399. });
  50400. if (push_app_server.secret) {
  50401. stanza.c('x', {
  50402. 'xmlns': push_utils_Strophe.NS.XFORM,
  50403. 'type': 'submit'
  50404. }).c('field', {
  50405. 'var': 'FORM_TYPE'
  50406. }).c('value').t(`${push_utils_Strophe.NS.PUBSUB}#publish-options`).up().up().c('field', {
  50407. 'var': 'secret'
  50408. }).c('value').t(push_app_server.secret);
  50409. }
  50410. return core_api.sendIQ(stanza);
  50411. }
  50412. async function enablePush(domain) {
  50413. domain = domain || shared_converse.bare_jid;
  50414. const push_enabled = shared_converse.session.get('push_enabled') || [];
  50415. if (push_enabled.includes(domain)) {
  50416. return;
  50417. }
  50418. const enabled_services = core_api.settings.get('push_app_servers').filter(s => !s.disable);
  50419. const disabled_services = core_api.settings.get('push_app_servers').filter(s => s.disable);
  50420. const enabled = enabled_services.map(s => enablePushAppServer(domain, s));
  50421. const disabled = disabled_services.map(s => disablePushAppServer(domain, s));
  50422. try {
  50423. await Promise.all(enabled.concat(disabled));
  50424. } catch (e) {
  50425. headless_log.error('Could not enable or disable push App Server');
  50426. if (e) headless_log.error(e);
  50427. } finally {
  50428. push_enabled.push(domain);
  50429. }
  50430. shared_converse.session.save('push_enabled', push_enabled);
  50431. }
  50432. function onChatBoxAdded(model) {
  50433. if (model.get('type') == shared_converse.CHATROOMS_TYPE) {
  50434. enablePush(push_utils_Strophe.getDomainFromJid(model.get('jid')));
  50435. }
  50436. }
  50437. ;// CONCATENATED MODULE: ./src/plugins/push/index.js
  50438. /**
  50439. * @description
  50440. * Converse.js plugin which add support for registering
  50441. * an "App Server" as defined in XEP-0357
  50442. * @copyright 2021, the Converse.js contributors
  50443. * @license Mozilla Public License (MPLv2)
  50444. */
  50445. const {
  50446. Strophe: push_Strophe
  50447. } = core_converse.env;
  50448. push_Strophe.addNamespace('PUSH', 'urn:xmpp:push:0');
  50449. core_converse.plugins.add('converse-push', {
  50450. initialize() {
  50451. /* The initialize function gets called as soon as the plugin is
  50452. * loaded by converse.js's plugin machinery.
  50453. */
  50454. core_api.settings.extend({
  50455. 'push_app_servers': [],
  50456. 'enable_muc_push': false
  50457. });
  50458. core_api.listen.on('statusInitialized', () => enablePush());
  50459. if (core_api.settings.get('enable_muc_push')) {
  50460. core_api.listen.on('chatBoxesInitialized', () => shared_converse.chatboxes.on('add', onChatBoxAdded));
  50461. }
  50462. }
  50463. });
  50464. ;// CONCATENATED MODULE: ./src/plugins/register/templates/registration_form.js
  50465. /* harmony default export */ const registration_form = (o => {
  50466. const i18n_choose_provider = __('Choose a different provider');
  50467. const i18n_has_account = __('Already have a chat account?');
  50468. const i18n_legend = __('Account Registration:');
  50469. const i18n_login = __('Log in here');
  50470. const i18n_register = __('Register');
  50471. const registration_domain = core_api.settings.get('registration_domain');
  50472. return $`
  50473. <form id="converse-register" class="converse-form">
  50474. <legend class="col-form-label">${i18n_legend} ${o.domain}</legend>
  50475. <p class="title">${o.title}</p>
  50476. <p class="form-help instructions">${o.instructions}</p>
  50477. <div class="form-errors hidden"></div>
  50478. ${o.form_fields}
  50479. <fieldset class="buttons form-group">
  50480. ${o.fields ? $`
  50481. <input type="submit" class="btn btn-primary" value="${i18n_register}" />
  50482. ` : ''}
  50483. ${registration_domain ? '' : $`
  50484. <input
  50485. type="button"
  50486. class="btn btn-secondary button-cancel"
  50487. value="${i18n_choose_provider}"
  50488. />
  50489. `}
  50490. <div class="switch-form">
  50491. <p>${i18n_has_account}</p>
  50492. <p><a class="login-here toggle-register-login" href="#converse/login">${i18n_login}</a></p>
  50493. </div>
  50494. </fieldset>
  50495. </form>
  50496. `;
  50497. });
  50498. ;// CONCATENATED MODULE: ./src/plugins/register/templates/register_panel.js
  50499. const tpl_form_request = () => {
  50500. const default_domain = core_api.settings.get('registration_domain');
  50501. const i18n_fetch_form = __("Hold tight, we're fetching the registration form…");
  50502. const i18n_cancel = __('Cancel');
  50503. return $`
  50504. <form id="converse-register" class="converse-form no-scrolling">
  50505. ${spinner({
  50506. 'classes': 'hor_centered'
  50507. })}
  50508. <p class="info">${i18n_fetch_form}</p>
  50509. ${default_domain ? '' : $`
  50510. <button class="btn btn-secondary button-cancel hor_centered">${i18n_cancel}</button>
  50511. `}
  50512. </form>
  50513. `;
  50514. };
  50515. const tpl_domain_input = () => {
  50516. const domain_placeholder = core_api.settings.get('domain_placeholder');
  50517. const i18n_providers = __('Tip: A list of public XMPP providers is available');
  50518. const i18n_providers_link = __('here');
  50519. const href_providers = core_api.settings.get('providers_link');
  50520. return $`
  50521. <input class="form-control" required="required" type="text" name="domain" placeholder="${domain_placeholder}" />
  50522. <p class="form-text text-muted">
  50523. ${i18n_providers}
  50524. <a href="${href_providers}" class="url" target="_blank" rel="noopener">${i18n_providers_link}</a>.
  50525. </p>
  50526. `;
  50527. };
  50528. const tpl_fetch_form_buttons = () => {
  50529. const i18n_register = __('Fetch registration form');
  50530. const i18n_existing_account = __('Already have a chat account?');
  50531. const i18n_login = __('Log in here');
  50532. return $`
  50533. <fieldset class="form-group buttons">
  50534. <input class="btn btn-primary" type="submit" value="${i18n_register}" />
  50535. </fieldset>
  50536. <div class="switch-form">
  50537. <p>${i18n_existing_account}</p>
  50538. <p><a class="login-here toggle-register-login" href="#converse/login">${i18n_login}</a></p>
  50539. </div>
  50540. `;
  50541. };
  50542. const tpl_choose_provider = () => {
  50543. const default_domain = core_api.settings.get('registration_domain');
  50544. const i18n_create_account = __('Create your account');
  50545. const i18n_choose_provider = __('Please enter the XMPP provider to register with:');
  50546. return $`
  50547. <form id="converse-register" class="converse-form">
  50548. <legend class="col-form-label">${i18n_create_account}</legend>
  50549. <div class="form-group">
  50550. <label>${i18n_choose_provider}</label>
  50551. <div class="form-errors hidden"></div>
  50552. ${default_domain ? default_domain : tpl_domain_input()}
  50553. </div>
  50554. ${default_domain ? '' : tpl_fetch_form_buttons()}
  50555. </form>
  50556. `;
  50557. };
  50558. const CHOOSE_PROVIDER = 0;
  50559. const FETCHING_FORM = 1;
  50560. const REGISTRATION_FORM = 2;
  50561. /* harmony default export */ const register_panel = (o => {
  50562. return $`
  50563. <converse-brand-logo></converse-brand-logo>
  50564. ${o.model.get('registration_status') === CHOOSE_PROVIDER ? tpl_choose_provider() : ''}
  50565. ${o.model.get('registration_status') === FETCHING_FORM ? tpl_form_request(o) : ''}
  50566. ${o.model.get('registration_status') === REGISTRATION_FORM ? registration_form(o) : ''}
  50567. `;
  50568. });
  50569. ;// CONCATENATED MODULE: ./src/plugins/register/panel.js
  50570. function register_panel_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  50571. // Strophe methods for building stanzas
  50572. const {
  50573. Strophe: panel_Strophe,
  50574. sizzle: panel_sizzle,
  50575. $iq: panel_$iq
  50576. } = core_converse.env;
  50577. const panel_u = core_converse.env.utils;
  50578. const panel_CHOOSE_PROVIDER = 0;
  50579. const panel_FETCHING_FORM = 1;
  50580. const panel_REGISTRATION_FORM = 2;
  50581. /**
  50582. * @class
  50583. * @namespace _converse.RegisterPanel
  50584. * @memberOf _converse
  50585. */
  50586. class RegisterPanel extends ElementView {
  50587. constructor() {
  50588. super(...arguments);
  50589. register_panel_defineProperty(this, "id", "converse-register-panel");
  50590. register_panel_defineProperty(this, "className", 'controlbox-pane fade-in');
  50591. register_panel_defineProperty(this, "events", {
  50592. 'submit form#converse-register': 'onFormSubmission',
  50593. 'click .button-cancel': 'renderProviderChoiceForm'
  50594. });
  50595. }
  50596. initialize() {
  50597. this.reset();
  50598. const controlbox = shared_converse.chatboxes.get('controlbox');
  50599. this.model = controlbox;
  50600. this.listenTo(shared_converse, 'connectionInitialized', this.registerHooks);
  50601. this.listenTo(this.model, 'change:registration_status', this.render);
  50602. const domain = core_api.settings.get('registration_domain');
  50603. if (domain) {
  50604. this.fetchRegistrationForm(domain);
  50605. } else {
  50606. this.model.set('registration_status', panel_CHOOSE_PROVIDER);
  50607. }
  50608. }
  50609. render() {
  50610. x(register_panel({
  50611. 'domain': this.domain,
  50612. 'fields': this.fields,
  50613. 'form_fields': this.form_fields,
  50614. 'instructions': this.instructions,
  50615. 'model': this.model,
  50616. 'title': this.title
  50617. }), this);
  50618. }
  50619. /**
  50620. * Hook into Strophe's _connect_cb, so that we can send an IQ
  50621. * requesting the registration fields.
  50622. */
  50623. registerHooks() {
  50624. const conn = shared_converse.connection;
  50625. const connect_cb = conn._connect_cb.bind(conn);
  50626. conn._connect_cb = (req, callback, raw) => {
  50627. if (!this._registering) {
  50628. connect_cb(req, callback, raw);
  50629. } else {
  50630. if (this.getRegistrationFields(req, callback)) {
  50631. this._registering = false;
  50632. }
  50633. }
  50634. };
  50635. }
  50636. connectedCallback() {
  50637. super.connectedCallback();
  50638. this.render();
  50639. }
  50640. /**
  50641. * Send an IQ stanza to the XMPP server asking for the registration fields.
  50642. * @private
  50643. * @method _converse.RegisterPanel#getRegistrationFields
  50644. * @param { Strophe.Request } req - The current request
  50645. * @param { Function } callback - The callback function
  50646. */
  50647. getRegistrationFields(req, _callback) {
  50648. const conn = shared_converse.connection;
  50649. conn.connected = true;
  50650. const body = conn._proto._reqToData(req);
  50651. if (!body) {
  50652. return;
  50653. }
  50654. if (conn._proto._connect_cb(body) === panel_Strophe.Status.CONNFAIL) {
  50655. this.showValidationError(__("Sorry, we're unable to connect to your chosen provider."));
  50656. return false;
  50657. }
  50658. const register = body.getElementsByTagName("register");
  50659. const mechanisms = body.getElementsByTagName("mechanism");
  50660. if (register.length === 0 && mechanisms.length === 0) {
  50661. conn._proto._no_auth_received(_callback);
  50662. return false;
  50663. }
  50664. if (register.length === 0) {
  50665. conn._changeConnectStatus(panel_Strophe.Status.REGIFAIL);
  50666. this.showValidationError(__("Sorry, the given provider does not support in " + "band account registration. Please try with a " + "different provider."));
  50667. return true;
  50668. } // Send an IQ stanza to get all required data fields
  50669. conn._addSysHandler(this.onRegistrationFields.bind(this), null, "iq", null, null);
  50670. const stanza = panel_$iq({
  50671. type: "get"
  50672. }).c("query", {
  50673. xmlns: panel_Strophe.NS.REGISTER
  50674. }).tree();
  50675. stanza.setAttribute("id", conn.getUniqueId("sendIQ"));
  50676. conn.send(stanza);
  50677. conn.connected = false;
  50678. return true;
  50679. }
  50680. /**
  50681. * Handler for {@link _converse.RegisterPanel#getRegistrationFields}
  50682. * @private
  50683. * @method _converse.RegisterPanel#onRegistrationFields
  50684. * @param { XMLElement } stanza - The query stanza.
  50685. */
  50686. onRegistrationFields(stanza) {
  50687. if (stanza.getAttribute("type") === "error") {
  50688. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.REGIFAIL, __('Something went wrong while establishing a connection with "%1$s". ' + 'Are you sure it exists?', this.domain));
  50689. return false;
  50690. }
  50691. if (stanza.getElementsByTagName("query").length !== 1) {
  50692. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.REGIFAIL, "unknown");
  50693. return false;
  50694. }
  50695. this.setFields(stanza);
  50696. if (this.model.get('registration_status') === panel_FETCHING_FORM) {
  50697. this.renderRegistrationForm(stanza);
  50698. }
  50699. return false;
  50700. }
  50701. reset(settings) {
  50702. const defaults = {
  50703. fields: {},
  50704. urls: [],
  50705. title: "",
  50706. instructions: "",
  50707. registered: false,
  50708. _registering: false,
  50709. domain: null,
  50710. form_type: null
  50711. };
  50712. Object.assign(this, defaults);
  50713. if (settings) {
  50714. Object.assign(this, lodash_es_pick(settings, Object.keys(defaults)));
  50715. }
  50716. }
  50717. /**
  50718. * Event handler when the #converse-register form is submitted.
  50719. * Depending on the available input fields, we delegate to other methods.
  50720. * @private
  50721. * @param { Event } ev
  50722. */
  50723. onFormSubmission(ev) {
  50724. if (ev && ev.preventDefault) {
  50725. ev.preventDefault();
  50726. }
  50727. if (ev.target.querySelector('input[name=domain]') === null) {
  50728. this.submitRegistrationForm(ev.target);
  50729. } else {
  50730. this.onProviderChosen(ev.target);
  50731. }
  50732. }
  50733. /**
  50734. * Callback method that gets called when the user has chosen an XMPP provider
  50735. * @private
  50736. * @method _converse.RegisterPanel#onProviderChosen
  50737. * @param { HTMLElement } form - The form that was submitted
  50738. */
  50739. onProviderChosen(form) {
  50740. const domain_input = form.querySelector('input[name=domain]'),
  50741. domain = domain_input === null || domain_input === void 0 ? void 0 : domain_input.value;
  50742. if (!domain) {
  50743. // TODO: add validation message
  50744. domain_input.classList.add('error');
  50745. return;
  50746. }
  50747. form.querySelector('input[type=submit]').classList.add('hidden');
  50748. this.fetchRegistrationForm(domain.trim());
  50749. }
  50750. /**
  50751. * Fetch a registration form from the requested domain
  50752. * @private
  50753. * @method _converse.RegisterPanel#fetchRegistrationForm
  50754. * @param { String } domain_name - XMPP server domain
  50755. */
  50756. async fetchRegistrationForm(domain_name) {
  50757. var _converse$connection;
  50758. this.model.set('registration_status', panel_FETCHING_FORM);
  50759. this.reset({
  50760. 'domain': panel_Strophe.getDomainFromJid(domain_name),
  50761. '_registering': true
  50762. });
  50763. await shared_converse.initConnection(this.domain); // When testing, the test tears down before the async function
  50764. // above finishes. So we use optional chaining here
  50765. (_converse$connection = shared_converse.connection) === null || _converse$connection === void 0 ? void 0 : _converse$connection.connect(this.domain, "", status => this.onConnectStatusChanged(status));
  50766. return false;
  50767. }
  50768. giveFeedback(message, klass) {
  50769. let feedback = this.querySelector('.reg-feedback');
  50770. if (feedback !== null) {
  50771. feedback.parentNode.removeChild(feedback);
  50772. }
  50773. const form = this.querySelector('form');
  50774. form.insertAdjacentHTML('afterbegin', '<span class="reg-feedback"></span>');
  50775. feedback = form.querySelector('.reg-feedback');
  50776. feedback.textContent = message;
  50777. if (klass) {
  50778. feedback.classList.add(klass);
  50779. }
  50780. }
  50781. showSpinner() {
  50782. const form = this.querySelector('form');
  50783. x(spinner(), form);
  50784. return this;
  50785. }
  50786. /**
  50787. * Callback function called by Strophe whenever the connection status changes.
  50788. * Passed to Strophe specifically during a registration attempt.
  50789. * @private
  50790. * @method _converse.RegisterPanel#onConnectStatusChanged
  50791. * @param { integer } status_code - The Strophe.Status status code
  50792. */
  50793. onConnectStatusChanged(status_code) {
  50794. headless_log.debug('converse-register: onConnectStatusChanged');
  50795. if ([panel_Strophe.Status.DISCONNECTED, panel_Strophe.Status.CONNFAIL, panel_Strophe.Status.REGIFAIL, panel_Strophe.Status.NOTACCEPTABLE, panel_Strophe.Status.CONFLICT].includes(status_code)) {
  50796. headless_log.error(`Problem during registration: Strophe.Status is ${shared_converse.CONNECTION_STATUS[status_code]}`);
  50797. this.abortRegistration();
  50798. } else if (status_code === panel_Strophe.Status.REGISTERED) {
  50799. headless_log.debug("Registered successfully.");
  50800. shared_converse.connection.reset();
  50801. this.showSpinner();
  50802. if (["converse/login", "converse/register"].includes(shared_converse.router.history.getFragment())) {
  50803. shared_converse.router.navigate('', {
  50804. 'replace': true
  50805. });
  50806. }
  50807. if (this.fields.password && this.fields.username) {
  50808. // automatically log the user in
  50809. shared_converse.connection.connect(this.fields.username.toLowerCase() + '@' + this.domain.toLowerCase(), this.fields.password, shared_converse.onConnectStatusChanged);
  50810. this.giveFeedback(__('Now logging you in'), 'info');
  50811. } else {
  50812. shared_converse.giveFeedback(__('Registered successfully'));
  50813. }
  50814. this.reset();
  50815. }
  50816. }
  50817. getLegacyFormFields() {
  50818. const input_fields = Object.keys(this.fields).map(key => {
  50819. if (key === "username") {
  50820. return form_username({
  50821. 'domain': ` @${this.domain}`,
  50822. 'name': key,
  50823. 'type': "text",
  50824. 'label': key,
  50825. 'value': '',
  50826. 'required': true
  50827. });
  50828. } else {
  50829. return form_input({
  50830. 'label': key,
  50831. 'name': key,
  50832. 'placeholder': key,
  50833. 'required': true,
  50834. 'type': key === 'password' || key === 'email' ? key : "text",
  50835. 'value': ''
  50836. });
  50837. }
  50838. });
  50839. const urls = this.urls.map(u => form_url({
  50840. 'label': '',
  50841. 'value': u
  50842. }));
  50843. return [...input_fields, ...urls];
  50844. }
  50845. getFormFields(stanza) {
  50846. if (this.form_type === 'xform') {
  50847. return Array.from(stanza.querySelectorAll('field')).map(field => utils_form.xForm2TemplateResult(field, stanza, {
  50848. 'domain': this.domain
  50849. }));
  50850. } else {
  50851. return this.getLegacyFormFields();
  50852. }
  50853. }
  50854. /**
  50855. * Renders the registration form based on the XForm fields
  50856. * received from the XMPP server.
  50857. * @private
  50858. * @method _converse.RegisterPanel#renderRegistrationForm
  50859. * @param { XMLElement } stanza - The IQ stanza received from the XMPP server.
  50860. */
  50861. renderRegistrationForm(stanza) {
  50862. this.form_fields = this.getFormFields(stanza);
  50863. this.model.set('registration_status', panel_REGISTRATION_FORM);
  50864. }
  50865. showValidationError(message) {
  50866. const form = this.querySelector('form');
  50867. let flash = form.querySelector('.form-errors');
  50868. if (flash === null) {
  50869. flash = '<div class="form-errors hidden"></div>';
  50870. const instructions = form.querySelector('p.instructions');
  50871. if (instructions === null) {
  50872. form.insertAdjacentHTML('afterbegin', flash);
  50873. } else {
  50874. instructions.insertAdjacentHTML('afterend', flash);
  50875. }
  50876. flash = form.querySelector('.form-errors');
  50877. } else {
  50878. flash.innerHTML = '';
  50879. }
  50880. flash.insertAdjacentHTML('beforeend', '<p class="form-help error">' + message + '</p>');
  50881. flash.classList.remove('hidden');
  50882. }
  50883. /**
  50884. * Report back to the user any error messages received from the
  50885. * XMPP server after attempted registration.
  50886. * @private
  50887. * @method _converse.RegisterPanel#reportErrors
  50888. * @param { XMLElement } stanza - The IQ stanza received from the XMPP server
  50889. */
  50890. reportErrors(stanza) {
  50891. const errors = stanza.querySelectorAll('error');
  50892. errors.forEach(e => this.showValidationError(e.textContent));
  50893. if (!errors.length) {
  50894. const message = __('The provider rejected your registration attempt. ' + 'Please check the values you entered for correctness.');
  50895. this.showValidationError(message);
  50896. }
  50897. }
  50898. renderProviderChoiceForm(ev) {
  50899. if (ev && ev.preventDefault) {
  50900. ev.preventDefault();
  50901. }
  50902. shared_converse.connection._proto._abortAllRequests();
  50903. shared_converse.connection.reset();
  50904. this.render();
  50905. }
  50906. abortRegistration() {
  50907. shared_converse.connection._proto._abortAllRequests();
  50908. shared_converse.connection.reset();
  50909. if ([panel_FETCHING_FORM, panel_REGISTRATION_FORM].includes(this.model.get('registration_status'))) {
  50910. if (core_api.settings.get('registration_domain')) {
  50911. this.fetchRegistrationForm(core_api.settings.get('registration_domain'));
  50912. }
  50913. } else {
  50914. this.render();
  50915. }
  50916. }
  50917. /**
  50918. * Handler, when the user submits the registration form.
  50919. * Provides form error feedback or starts the registration process.
  50920. * @private
  50921. * @method _converse.RegisterPanel#submitRegistrationForm
  50922. * @param { HTMLElement } form - The HTML form that was submitted
  50923. */
  50924. submitRegistrationForm(form) {
  50925. const has_empty_inputs = Array.from(this.querySelectorAll('input.required')).reduce((result, input) => {
  50926. if (input.value === '') {
  50927. input.classList.add('error');
  50928. return result + 1;
  50929. }
  50930. return result;
  50931. }, 0);
  50932. if (has_empty_inputs) {
  50933. return;
  50934. }
  50935. const inputs = panel_sizzle(':input:not([type=button]):not([type=submit])', form);
  50936. const iq = panel_$iq({
  50937. 'type': 'set',
  50938. 'id': panel_u.getUniqueId()
  50939. }).c("query", {
  50940. xmlns: panel_Strophe.NS.REGISTER
  50941. });
  50942. if (this.form_type === 'xform') {
  50943. iq.c("x", {
  50944. xmlns: panel_Strophe.NS.XFORM,
  50945. type: 'submit'
  50946. });
  50947. const xml_nodes = inputs.map(i => utils_form.webForm2xForm(i)).filter(n => n);
  50948. xml_nodes.forEach(n => iq.cnode(n).up());
  50949. } else {
  50950. inputs.forEach(input => iq.c(input.getAttribute('name'), {}, input.value));
  50951. }
  50952. shared_converse.connection._addSysHandler(this._onRegisterIQ.bind(this), null, "iq", null, null);
  50953. shared_converse.connection.send(iq);
  50954. this.setFields(iq.tree());
  50955. }
  50956. /* Stores the values that will be sent to the XMPP server during attempted registration.
  50957. * @private
  50958. * @method _converse.RegisterPanel#setFields
  50959. * @param { XMLElement } stanza - the IQ stanza that will be sent to the XMPP server.
  50960. */
  50961. setFields(stanza) {
  50962. const query = stanza.querySelector('query');
  50963. const xform = panel_sizzle(`x[xmlns="${panel_Strophe.NS.XFORM}"]`, query);
  50964. if (xform.length > 0) {
  50965. this._setFieldsFromXForm(xform.pop());
  50966. } else {
  50967. this._setFieldsFromLegacy(query);
  50968. }
  50969. }
  50970. _setFieldsFromLegacy(query) {
  50971. [].forEach.call(query.children, field => {
  50972. if (field.tagName.toLowerCase() === 'instructions') {
  50973. this.instructions = panel_Strophe.getText(field);
  50974. return;
  50975. } else if (field.tagName.toLowerCase() === 'x') {
  50976. if (field.getAttribute('xmlns') === 'jabber:x:oob') {
  50977. this.urls.concat(panel_sizzle('url', field).map(u => u.textContent));
  50978. }
  50979. return;
  50980. }
  50981. this.fields[field.tagName.toLowerCase()] = panel_Strophe.getText(field);
  50982. });
  50983. this.form_type = 'legacy';
  50984. }
  50985. _setFieldsFromXForm(xform) {
  50986. var _xform$querySelector, _xform$querySelector2;
  50987. this.title = (_xform$querySelector = xform.querySelector('title')) === null || _xform$querySelector === void 0 ? void 0 : _xform$querySelector.textContent;
  50988. this.instructions = (_xform$querySelector2 = xform.querySelector('instructions')) === null || _xform$querySelector2 === void 0 ? void 0 : _xform$querySelector2.textContent;
  50989. xform.querySelectorAll('field').forEach(field => {
  50990. const _var = field.getAttribute('var');
  50991. if (_var) {
  50992. var _field$querySelector;
  50993. this.fields[_var.toLowerCase()] = ((_field$querySelector = field.querySelector('value')) === null || _field$querySelector === void 0 ? void 0 : _field$querySelector.textContent) ?? '';
  50994. } else {
  50995. // TODO: other option seems to be type="fixed"
  50996. headless_log.warn("Found field we couldn't parse");
  50997. }
  50998. });
  50999. this.form_type = 'xform';
  51000. }
  51001. /**
  51002. * Callback method that gets called when a return IQ stanza
  51003. * is received from the XMPP server, after attempting to
  51004. * register a new user.
  51005. * @private
  51006. * @method _converse.RegisterPanel#reportErrors
  51007. * @param { XMLElement } stanza - The IQ stanza.
  51008. */
  51009. _onRegisterIQ(stanza) {
  51010. if (stanza.getAttribute("type") === "error") {
  51011. headless_log.error("Registration failed.");
  51012. this.reportErrors(stanza);
  51013. let error = stanza.getElementsByTagName("error");
  51014. if (error.length !== 1) {
  51015. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.REGIFAIL, "unknown");
  51016. return false;
  51017. }
  51018. error = error[0].firstElementChild.tagName.toLowerCase();
  51019. if (error === 'conflict') {
  51020. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.CONFLICT, error);
  51021. } else if (error === 'not-acceptable') {
  51022. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.NOTACCEPTABLE, error);
  51023. } else {
  51024. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.REGIFAIL, error);
  51025. }
  51026. } else {
  51027. shared_converse.connection._changeConnectStatus(panel_Strophe.Status.REGISTERED, null);
  51028. }
  51029. return false;
  51030. }
  51031. }
  51032. core_api.elements.define('converse-register-panel', RegisterPanel);
  51033. ;// CONCATENATED MODULE: ./src/plugins/register/index.js
  51034. /**
  51035. * @module converse-register
  51036. * @description
  51037. * This is a Converse.js plugin which add support for in-band registration
  51038. * as specified in XEP-0077.
  51039. * @copyright 2022, the Converse.js contributors
  51040. * @license Mozilla Public License (MPLv2)
  51041. */
  51042. // Strophe methods for building stanzas
  51043. const {
  51044. Strophe: register_Strophe
  51045. } = core_converse.env; // Add Strophe Namespaces
  51046. register_Strophe.addNamespace('REGISTER', 'jabber:iq:register'); // Add Strophe Statuses
  51047. const register_i = Object.keys(register_Strophe.Status).reduce((max, k) => Math.max(max, register_Strophe.Status[k]), 0);
  51048. register_Strophe.Status.REGIFAIL = register_i + 1;
  51049. register_Strophe.Status.REGISTERED = register_i + 2;
  51050. register_Strophe.Status.CONFLICT = register_i + 3;
  51051. register_Strophe.Status.NOTACCEPTABLE = register_i + 5;
  51052. core_converse.plugins.add('converse-register', {
  51053. dependencies: ['converse-controlbox'],
  51054. enabled() {
  51055. return true;
  51056. },
  51057. initialize() {
  51058. shared_converse.CONNECTION_STATUS[register_Strophe.Status.REGIFAIL] = 'REGIFAIL';
  51059. shared_converse.CONNECTION_STATUS[register_Strophe.Status.REGISTERED] = 'REGISTERED';
  51060. shared_converse.CONNECTION_STATUS[register_Strophe.Status.CONFLICT] = 'CONFLICT';
  51061. shared_converse.CONNECTION_STATUS[register_Strophe.Status.NOTACCEPTABLE] = 'NOTACCEPTABLE';
  51062. core_api.settings.extend({
  51063. 'allow_registration': true,
  51064. 'domain_placeholder': __(' e.g. conversejs.org'),
  51065. // Placeholder text shown in the domain input on the registration form
  51066. 'providers_link': 'https://compliance.conversations.im/',
  51067. // Link to XMPP providers shown on registration page
  51068. 'registration_domain': ''
  51069. });
  51070. async function setActiveForm(value) {
  51071. await core_api.waitUntil('controlBoxInitialized');
  51072. const controlbox = shared_converse.chatboxes.get('controlbox');
  51073. controlbox.set({
  51074. 'active-form': value
  51075. });
  51076. }
  51077. shared_converse.router.route('converse/login', () => setActiveForm('login'));
  51078. shared_converse.router.route('converse/register', () => setActiveForm('register'));
  51079. core_api.listen.on('controlBoxInitialized', view => {
  51080. view.model.on('change:active-form', view.showLoginOrRegisterForm, view);
  51081. });
  51082. }
  51083. });
  51084. ;// CONCATENATED MODULE: ./src/plugins/roomslist/model.js
  51085. const {
  51086. Strophe: roomslist_model_Strophe
  51087. } = core_converse.env;
  51088. const RoomsListModel = Model.extend({
  51089. defaults: function () {
  51090. return {
  51091. 'muc_domain': core_api.settings.get('muc_domain'),
  51092. 'nick': shared_converse.getDefaultMUCNickname(),
  51093. 'toggle-state': shared_converse.OPENED
  51094. };
  51095. },
  51096. initialize() {
  51097. core_api.settings.listen.on('change:muc_domain', muc_domain => this.setDomain(muc_domain));
  51098. },
  51099. setDomain(jid) {
  51100. if (!core_api.settings.get('locked_muc_domain')) {
  51101. this.save('muc_domain', roomslist_model_Strophe.getDomainFromJid(jid));
  51102. }
  51103. }
  51104. });
  51105. /* harmony default export */ const roomslist_model = (RoomsListModel);
  51106. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/add-muc.js
  51107. const nickname_input = o => {
  51108. const i18n_nickname = __('Nickname');
  51109. const i18n_required_field = __('This field is required');
  51110. return $`
  51111. <div class="form-group" >
  51112. <label for="nickname">${i18n_nickname}:</label>
  51113. <input type="text" title="${i18n_required_field}" required="required" name="nickname" value="${o.nick || ''}" class="form-control"/>
  51114. </div>
  51115. `;
  51116. };
  51117. /* harmony default export */ const add_muc = (o => {
  51118. const i18n_join = __('Join');
  51119. const i18n_enter = __('Enter a new Groupchat');
  51120. return $`
  51121. <div class="modal-dialog" role="document">
  51122. <div class="modal-content">
  51123. <div class="modal-header">
  51124. <h5 class="modal-title" id="add-chatroom-modal-label">${i18n_enter}</h5>
  51125. ${modal_header_close_button}
  51126. </div>
  51127. <div class="modal-body">
  51128. <span class="modal-alert"></span>
  51129. <form class="converse-form add-chatroom">
  51130. <div class="form-group">
  51131. <label for="chatroom">${o.label_room_address}:</label>
  51132. ${o.muc_roomid_policy_error_msg ? $`<label class="roomid-policy-error">${o.muc_roomid_policy_error_msg}</label>` : ''}
  51133. <input type="text" required="required" name="chatroom" class="form-control roomjid-input" placeholder="${o.chatroom_placeholder}"/>
  51134. </div>
  51135. ${o.muc_roomid_policy_hint ? $`<div class="form-group">${unsafe_html_o(purify_default().sanitize(o.muc_roomid_policy_hint, {
  51136. 'ALLOWED_TAGS': ['b', 'br', 'em']
  51137. }))}</div>` : ''}
  51138. ${!core_api.settings.get('locked_muc_nickname') ? nickname_input(o) : ''}
  51139. <input type="submit" class="btn btn-primary" name="join" value="${i18n_join || ''}" ?disabled=${o.muc_roomid_policy_error_msg}>
  51140. </form>
  51141. </div>
  51142. </div>
  51143. </div>
  51144. `;
  51145. });
  51146. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/add-muc.js
  51147. const add_muc_u = core_converse.env.utils;
  51148. const {
  51149. Strophe: add_muc_Strophe
  51150. } = core_converse.env;
  51151. /* harmony default export */ const modals_add_muc = (base.extend({
  51152. persistent: true,
  51153. id: 'add-chatroom-modal',
  51154. events: {
  51155. 'submit form.add-chatroom': 'openChatRoom',
  51156. 'keyup .roomjid-input': 'checkRoomidPolicy',
  51157. 'change .roomjid-input': 'checkRoomidPolicy'
  51158. },
  51159. initialize() {
  51160. base.prototype.initialize.apply(this, arguments);
  51161. this.listenTo(this.model, 'change:muc_domain', this.render);
  51162. this.muc_roomid_policy_error_msg = null;
  51163. },
  51164. toHTML() {
  51165. let placeholder = '';
  51166. if (!core_api.settings.get('locked_muc_domain')) {
  51167. const muc_domain = this.model.get('muc_domain') || core_api.settings.get('muc_domain');
  51168. placeholder = muc_domain ? `name@${muc_domain}` : __('name@conference.example.org');
  51169. }
  51170. return add_muc(Object.assign(this.model.toJSON(), {
  51171. '_converse': shared_converse,
  51172. 'label_room_address': core_api.settings.get('muc_domain') ? __('Groupchat name') : __('Groupchat address'),
  51173. 'chatroom_placeholder': placeholder,
  51174. 'muc_roomid_policy_error_msg': this.muc_roomid_policy_error_msg,
  51175. 'muc_roomid_policy_hint': core_api.settings.get('muc_roomid_policy_hint')
  51176. }));
  51177. },
  51178. afterRender() {
  51179. this.el.addEventListener('shown.bs.modal', () => {
  51180. this.el.querySelector('input[name="chatroom"]').focus();
  51181. }, false);
  51182. },
  51183. parseRoomDataFromEvent(form) {
  51184. const data = new FormData(form);
  51185. const jid = data.get('chatroom');
  51186. let nick;
  51187. if (core_api.settings.get('locked_muc_nickname')) {
  51188. nick = shared_converse.getDefaultMUCNickname();
  51189. if (!nick) {
  51190. throw new Error("Using locked_muc_nickname but no nickname found!");
  51191. }
  51192. } else {
  51193. nick = data.get('nickname').trim();
  51194. }
  51195. return {
  51196. 'jid': jid,
  51197. 'nick': nick
  51198. };
  51199. },
  51200. openChatRoom(ev) {
  51201. ev.preventDefault();
  51202. const data = this.parseRoomDataFromEvent(ev.target);
  51203. if (data.nick === "") {
  51204. // Make sure defaults apply if no nick is provided.
  51205. data.nick = undefined;
  51206. }
  51207. let jid;
  51208. if (core_api.settings.get('locked_muc_domain') || core_api.settings.get('muc_domain') && !add_muc_u.isValidJID(data.jid)) {
  51209. jid = `${add_muc_Strophe.escapeNode(data.jid)}@${core_api.settings.get('muc_domain')}`;
  51210. } else {
  51211. jid = data.jid;
  51212. this.model.setDomain(jid);
  51213. }
  51214. core_api.rooms.open(jid, Object.assign(data, {
  51215. jid
  51216. }), true);
  51217. this.modal.hide();
  51218. ev.target.reset();
  51219. },
  51220. checkRoomidPolicy() {
  51221. if (core_api.settings.get('muc_roomid_policy') && core_api.settings.get('muc_domain')) {
  51222. let jid = this.el.querySelector('.roomjid-input').value;
  51223. if (core_api.settings.get('locked_muc_domain') || !add_muc_u.isValidJID(jid)) {
  51224. jid = `${add_muc_Strophe.escapeNode(jid)}@${core_api.settings.get('muc_domain')}`;
  51225. }
  51226. const roomid = add_muc_Strophe.getNodeFromJid(jid);
  51227. const roomdomain = add_muc_Strophe.getDomainFromJid(jid);
  51228. if (core_api.settings.get('muc_domain') !== roomdomain || core_api.settings.get('muc_roomid_policy').test(roomid)) {
  51229. this.muc_roomid_policy_error_msg = null;
  51230. } else {
  51231. this.muc_roomid_policy_error_msg = __('Groupchat id is invalid.');
  51232. }
  51233. this.render();
  51234. }
  51235. }
  51236. }));
  51237. ;// CONCATENATED MODULE: ./node_modules/lodash-es/head.js
  51238. /**
  51239. * Gets the first element of `array`.
  51240. *
  51241. * @static
  51242. * @memberOf _
  51243. * @since 0.1.0
  51244. * @alias first
  51245. * @category Array
  51246. * @param {Array} array The array to query.
  51247. * @returns {*} Returns the first element of `array`.
  51248. * @example
  51249. *
  51250. * _.head([1, 2, 3]);
  51251. * // => 1
  51252. *
  51253. * _.head([]);
  51254. * // => undefined
  51255. */
  51256. function head(array) {
  51257. return (array && array.length) ? array[0] : undefined;
  51258. }
  51259. /* harmony default export */ const lodash_es_head = (head);
  51260. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-list.js
  51261. const muc_list_form = o => {
  51262. const i18n_query = __('Show groupchats');
  51263. const i18n_server_address = __('Server address');
  51264. return $`
  51265. <form class="converse-form list-chatrooms"
  51266. @submit=${o.submitForm}>
  51267. <div class="form-group">
  51268. <label for="chatroom">${i18n_server_address}:</label>
  51269. <input type="text"
  51270. @change=${o.setDomainFromEvent}
  51271. value="${o.muc_domain || ''}"
  51272. required="required"
  51273. name="server"
  51274. class="form-control"
  51275. placeholder="${o.server_placeholder}"/>
  51276. </div>
  51277. <input type="submit" class="btn btn-primary" name="list" value="${i18n_query}"/>
  51278. </form>
  51279. `;
  51280. };
  51281. const tpl_item = (o, item) => {
  51282. const i18n_info_title = __('Show more information on this groupchat');
  51283. const i18n_open_title = __('Click to open this groupchat');
  51284. return $`
  51285. <li class="room-item list-group-item">
  51286. <div class="available-chatroom d-flex flex-row">
  51287. <a class="open-room available-room w-100"
  51288. @click=${o.openRoom}
  51289. data-room-jid="${item.jid}"
  51290. data-room-name="${item.name}"
  51291. title="${i18n_open_title}"
  51292. href="#">${item.name || item.jid}</a>
  51293. <a class="right room-info icon-room-info"
  51294. @click=${o.toggleRoomInfo}
  51295. data-room-jid="${item.jid}"
  51296. title="${i18n_info_title}"
  51297. href="#"></a>
  51298. </div>
  51299. </li>
  51300. `;
  51301. };
  51302. /* harmony default export */ const muc_list = (o => {
  51303. const i18n_list_chatrooms = __('Query for Groupchats');
  51304. return $`
  51305. <div class="modal-dialog" role="document">
  51306. <div class="modal-content">
  51307. <div class="modal-header">
  51308. <h5 class="modal-title" id="muc-list-modal-label">${i18n_list_chatrooms}</h5>
  51309. ${modal_header_close_button}
  51310. </div>
  51311. <div class="modal-body d-flex flex-column">
  51312. <span class="modal-alert"></span>
  51313. ${o.show_form ? muc_list_form(o) : ''}
  51314. <ul class="available-chatrooms list-group">
  51315. ${o.loading_items ? $`<li class="list-group-item"> ${spinner()} </li>` : ''}
  51316. ${o.feedback_text ? $`<li class="list-group-item active">${o.feedback_text}</li>` : ''}
  51317. ${repeat_c(o.items, item => item.jid, item => tpl_item(o, item))}
  51318. </ul>
  51319. </div>
  51320. <div class="modal-footer">${modal_close_button}</div>
  51321. </div>
  51322. </div>
  51323. `;
  51324. });
  51325. ;// CONCATENATED MODULE: ./src/plugins/muc-views/templates/muc-description.js
  51326. /* harmony default export */ const muc_description = (o => {
  51327. const i18n_desc = __('Description:');
  51328. const i18n_jid = __('Groupchat XMPP Address:');
  51329. const i18n_occ = __('Participants:');
  51330. const i18n_features = __('Features:');
  51331. const i18n_requires_auth = __('Requires authentication');
  51332. const i18n_hidden = __('Hidden');
  51333. const i18n_requires_invite = __('Requires an invitation');
  51334. const i18n_moderated = __('Moderated');
  51335. const i18n_non_anon = __('Non-anonymous');
  51336. const i18n_open_room = __('Open');
  51337. const i18n_permanent_room = __('Permanent');
  51338. const i18n_public = __('Public');
  51339. const i18n_semi_anon = __('Semi-anonymous');
  51340. const i18n_temp_room = __('Temporary');
  51341. const i18n_unmoderated = __('Unmoderated');
  51342. return $`
  51343. <div class="room-info">
  51344. <p class="room-info"><strong>${i18n_jid}</strong> ${o.jid}</p>
  51345. <p class="room-info"><strong>${i18n_desc}</strong> ${o.desc}</p>
  51346. <p class="room-info"><strong>${i18n_occ}</strong> ${o.occ}</p>
  51347. <p class="room-info"><strong>${i18n_features}</strong>
  51348. <ul>
  51349. ${o.passwordprotected ? $`<li class="room-info locked">${i18n_requires_auth}</li>` : ''}
  51350. ${o.hidden ? $`<li class="room-info">${i18n_hidden}</li>` : ''}
  51351. ${o.membersonly ? $`<li class="room-info">${i18n_requires_invite}</li>` : ''}
  51352. ${o.moderated ? $`<li class="room-info">${i18n_moderated}</li>` : ''}
  51353. ${o.nonanonymous ? $`<li class="room-info">${i18n_non_anon}</li>` : ''}
  51354. ${o.open ? $`<li class="room-info">${i18n_open_room}</li>` : ''}
  51355. ${o.persistent ? $`<li class="room-info">${i18n_permanent_room}</li>` : ''}
  51356. ${o.publicroom ? $`<li class="room-info">${i18n_public}</li>` : ''}
  51357. ${o.semianonymous ? $`<li class="room-info">${i18n_semi_anon}</li>` : ''}
  51358. ${o.temporary ? $`<li class="room-info">${i18n_temp_room}</li>` : ''}
  51359. ${o.unmoderated ? $`<li class="room-info">${i18n_unmoderated}</li>` : ''}
  51360. </ul>
  51361. </p>
  51362. </div>
  51363. `;
  51364. });
  51365. ;// CONCATENATED MODULE: ./src/plugins/muc-views/modals/muc-list.js
  51366. const {
  51367. Strophe: muc_list_Strophe,
  51368. $iq: muc_list_$iq,
  51369. sizzle: muc_list_sizzle
  51370. } = core_converse.env;
  51371. const muc_list_u = core_converse.env.utils;
  51372. /* Insert groupchat info (based on returned #disco IQ stanza)
  51373. * @function insertRoomInfo
  51374. * @param { HTMLElement } el - The HTML DOM element that contains the info.
  51375. * @param { XMLElement } stanza - The IQ stanza containing the groupchat info.
  51376. */
  51377. function insertRoomInfo(el, stanza) {
  51378. var _head, _head2;
  51379. // All MUC features found here: https://xmpp.org/registrar/disco-features.html
  51380. el.querySelector('span.spinner').remove();
  51381. el.querySelector('a.room-info').classList.add('selected');
  51382. el.insertAdjacentHTML('beforeEnd', muc_list_u.getElementFromTemplateResult(muc_description({
  51383. 'jid': stanza.getAttribute('from'),
  51384. 'desc': (_head = lodash_es_head(muc_list_sizzle('field[var="muc#roominfo_description"] value', stanza))) === null || _head === void 0 ? void 0 : _head.textContent,
  51385. 'occ': (_head2 = lodash_es_head(muc_list_sizzle('field[var="muc#roominfo_occupants"] value', stanza))) === null || _head2 === void 0 ? void 0 : _head2.textContent,
  51386. 'hidden': muc_list_sizzle('feature[var="muc_hidden"]', stanza).length,
  51387. 'membersonly': muc_list_sizzle('feature[var="muc_membersonly"]', stanza).length,
  51388. 'moderated': muc_list_sizzle('feature[var="muc_moderated"]', stanza).length,
  51389. 'nonanonymous': muc_list_sizzle('feature[var="muc_nonanonymous"]', stanza).length,
  51390. 'open': muc_list_sizzle('feature[var="muc_open"]', stanza).length,
  51391. 'passwordprotected': muc_list_sizzle('feature[var="muc_passwordprotected"]', stanza).length,
  51392. 'persistent': muc_list_sizzle('feature[var="muc_persistent"]', stanza).length,
  51393. 'publicroom': muc_list_sizzle('feature[var="muc_publicroom"]', stanza).length,
  51394. 'semianonymous': muc_list_sizzle('feature[var="muc_semianonymous"]', stanza).length,
  51395. 'temporary': muc_list_sizzle('feature[var="muc_temporary"]', stanza).length,
  51396. 'unmoderated': muc_list_sizzle('feature[var="muc_unmoderated"]', stanza).length
  51397. })));
  51398. }
  51399. /**
  51400. * Show/hide extra information about a groupchat in a listing.
  51401. * @function toggleRoomInfo
  51402. * @param { Event }
  51403. */
  51404. function toggleRoomInfo(ev) {
  51405. const parent_el = muc_list_u.ancestor(ev.target, '.room-item');
  51406. const div_el = parent_el.querySelector('div.room-info');
  51407. if (div_el) {
  51408. muc_list_u.slideIn(div_el).then(muc_list_u.removeElement);
  51409. parent_el.querySelector('a.room-info').classList.remove('selected');
  51410. } else {
  51411. parent_el.insertAdjacentElement('beforeend', muc_list_u.getElementFromTemplateResult(spinner()));
  51412. core_api.disco.info(ev.target.getAttribute('data-room-jid'), null).then(stanza => insertRoomInfo(parent_el, stanza)).catch(e => headless_log.error(e));
  51413. }
  51414. }
  51415. /* harmony default export */ const modals_muc_list = (base.extend({
  51416. id: "muc-list-modal",
  51417. persistent: true,
  51418. initialize() {
  51419. this.items = [];
  51420. this.loading_items = false;
  51421. base.prototype.initialize.apply(this, arguments);
  51422. this.listenTo(this.model, 'change:muc_domain', this.onDomainChange);
  51423. this.listenTo(this.model, 'change:feedback_text', () => this.render());
  51424. this.el.addEventListener('shown.bs.modal', () => core_api.settings.get('locked_muc_domain') ? this.updateRoomsList() : this.el.querySelector('input[name="server"]').focus());
  51425. this.model.save('feedback_text', '');
  51426. },
  51427. toHTML() {
  51428. return muc_list(Object.assign(this.model.toJSON(), {
  51429. 'show_form': !core_api.settings.get('locked_muc_domain'),
  51430. 'server_placeholder': this.model.get('muc_domain') || __('conference.example.org'),
  51431. 'items': this.items,
  51432. 'loading_items': this.loading_items,
  51433. 'openRoom': ev => this.openRoom(ev),
  51434. 'setDomainFromEvent': ev => this.setDomainFromEvent(ev),
  51435. 'submitForm': ev => this.showRooms(ev),
  51436. 'toggleRoomInfo': ev => this.toggleRoomInfo(ev)
  51437. }));
  51438. },
  51439. openRoom(ev) {
  51440. ev.preventDefault();
  51441. const jid = ev.target.getAttribute('data-room-jid');
  51442. const name = ev.target.getAttribute('data-room-name');
  51443. this.modal.hide();
  51444. core_api.rooms.open(jid, {
  51445. 'name': name
  51446. }, true);
  51447. },
  51448. toggleRoomInfo(ev) {
  51449. ev.preventDefault();
  51450. toggleRoomInfo(ev);
  51451. },
  51452. onDomainChange() {
  51453. core_api.settings.get('auto_list_rooms') && this.updateRoomsList();
  51454. },
  51455. /**
  51456. * Handle the IQ stanza returned from the server, containing
  51457. * all its public groupchats.
  51458. * @private
  51459. * @method _converse.ChatRoomView#onRoomsFound
  51460. * @param { HTMLElement } iq
  51461. */
  51462. onRoomsFound(iq) {
  51463. this.loading_items = false;
  51464. const rooms = iq ? muc_list_sizzle('query item', iq) : [];
  51465. if (rooms.length) {
  51466. this.model.set({
  51467. 'feedback_text': __('Groupchats found')
  51468. }, {
  51469. 'silent': true
  51470. });
  51471. this.items = rooms.map(getAttributes);
  51472. } else {
  51473. this.items = [];
  51474. this.model.set({
  51475. 'feedback_text': __('No groupchats found')
  51476. }, {
  51477. 'silent': true
  51478. });
  51479. }
  51480. this.render();
  51481. return true;
  51482. },
  51483. /**
  51484. * Send an IQ stanza to the server asking for all groupchats
  51485. * @private
  51486. * @method _converse.ChatRoomView#updateRoomsList
  51487. */
  51488. updateRoomsList() {
  51489. const iq = muc_list_$iq({
  51490. 'to': this.model.get('muc_domain'),
  51491. 'from': shared_converse.connection.jid,
  51492. 'type': "get"
  51493. }).c("query", {
  51494. xmlns: muc_list_Strophe.NS.DISCO_ITEMS
  51495. });
  51496. core_api.sendIQ(iq).then(iq => this.onRoomsFound(iq)).catch(() => this.onRoomsFound());
  51497. },
  51498. showRooms(ev) {
  51499. ev.preventDefault();
  51500. this.loading_items = true;
  51501. this.render();
  51502. const data = new FormData(ev.target);
  51503. this.model.setDomain(data.get('server'));
  51504. this.updateRoomsList();
  51505. },
  51506. setDomainFromEvent(ev) {
  51507. this.model.setDomain(ev.target.value);
  51508. },
  51509. setNick(ev) {
  51510. this.model.save({
  51511. nick: ev.target.value
  51512. });
  51513. }
  51514. }));
  51515. ;// CONCATENATED MODULE: ./src/plugins/roomslist/templates/roomslist.js
  51516. const bookmark = o => {
  51517. const i18n_add_bookmark = __('Bookmark this groupchat');
  51518. const i18n_remove_bookmark = __('Unbookmark this groupchat');
  51519. if (o.bookmarked) {
  51520. return $`
  51521. <a class="list-item-action fa fa-bookmark remove-bookmark button-on"
  51522. data-room-jid="${o.room.get('jid')}"
  51523. data-bookmark-name="${o.room.getDisplayName()}"
  51524. @click=${o.removeBookmark}
  51525. title="${o.bookmarked ? i18n_remove_bookmark : i18n_add_bookmark}"></a>`;
  51526. } else {
  51527. return $`
  51528. <a class="list-item-action fa fa-bookmark add-bookmark"
  51529. data-room-jid="${o.room.get('jid')}"
  51530. data-bookmark-name="${o.room.getDisplayName()}"
  51531. @click=${o.addBookmark}
  51532. title="${o.bookmarked ? i18n_remove_bookmark : i18n_add_bookmark}"></a>`;
  51533. }
  51534. };
  51535. const unread_indicator = o => $`<span class="list-item-badge badge badge--muc msgs-indicator">${o.room.get('num_unread')}</span>`;
  51536. const activity_indicator = () => $`<span class="list-item-badge badge badge--muc msgs-indicator"></span>`;
  51537. const room_item = o => {
  51538. const i18n_leave_room = __('Leave this groupchat');
  51539. const has_unread_msgs = o.room.get('num_unread_general') || o.room.get('has_activity');
  51540. return $`
  51541. <div class="list-item controlbox-padded available-chatroom d-flex flex-row ${o.currently_open(o.room) ? 'open' : ''} ${has_unread_msgs ? 'unread-msgs' : ''}"
  51542. data-room-jid="${o.room.get('jid')}">
  51543. ${o.room.get('num_unread') ? unread_indicator(o) : o.room.get('has_activity') ? activity_indicator(o) : ''}
  51544. <a class="list-item-link open-room available-room w-100"
  51545. data-room-jid="${o.room.get('jid')}"
  51546. title="${__('Click to open this groupchat')}"
  51547. @click=${o.openRoom}>${o.room.getDisplayName()}</a>
  51548. ${core_api.settings.get('allow_bookmarks') ? bookmark(o) : ''}
  51549. <a class="list-item-action room-info fa fa-info-circle"
  51550. data-room-jid="${o.room.get('jid')}"
  51551. title="${__('Show more information on this groupchat')}"
  51552. @click=${o.showRoomDetailsModal}></a>
  51553. <a class="list-item-action fa fa-sign-out-alt close-room"
  51554. data-room-jid="${o.room.get('jid')}"
  51555. data-room-name="${o.room.getDisplayName()}"
  51556. title="${i18n_leave_room}"
  51557. @click=${o.closeRoom}></a>
  51558. </div>`;
  51559. };
  51560. /* harmony default export */ const roomslist = (o => {
  51561. const i18n_desc_rooms = __('Click to toggle the list of open groupchats');
  51562. const i18n_heading_chatrooms = __('Groupchats');
  51563. const i18n_title_list_rooms = __('Query for groupchats');
  51564. const i18n_title_new_room = __('Add a new groupchat');
  51565. return $`
  51566. <div class="d-flex controlbox-padded">
  51567. <span class="w-100 controlbox-heading controlbox-heading--groupchats">${i18n_heading_chatrooms}</span>
  51568. <a class="controlbox-heading__btn show-list-muc-modal"
  51569. @click=${ev => core_api.modal.show(modals_muc_list, {
  51570. 'model': o.model
  51571. }, ev)}
  51572. title="${i18n_title_list_rooms}" data-toggle="modal" data-target="#muc-list-modal">
  51573. <converse-icon class="fa fa-list-ul right" path-prefix="/dist" size="1em"></converse-icon>
  51574. </a>
  51575. <a class="controlbox-heading__btn show-add-muc-modal"
  51576. @click=${ev => core_api.modal.show(modals_add_muc, {
  51577. 'model': o.model
  51578. }, ev)}
  51579. title="${i18n_title_new_room}" data-toggle="modal" data-target="#add-chatrooms-modal">
  51580. <converse-icon class="fa fa-plus right" path-prefix="/dist" size="1em"></converse-icon>
  51581. </a>
  51582. </div>
  51583. <div class="list-container list-container--openrooms ${o.rooms.length ? '' : 'hidden'}">
  51584. <a class="list-toggle open-rooms-toggle controlbox-padded" title="${i18n_desc_rooms}" @click=${o.toggleRoomsList}>
  51585. <span class="fa ${o.toggle_state === shared_converse.OPENED ? 'fa-caret-down' : 'fa-caret-right'}"></span> ${__('Open Groupchats')}</a>
  51586. <div class="items-list rooms-list open-rooms-list ${o.collapsed && 'collapsed'}">
  51587. ${o.rooms.map(room => room_item(Object.assign({
  51588. room
  51589. }, o)))}
  51590. </div>
  51591. </div>`;
  51592. });
  51593. ;// CONCATENATED MODULE: ./src/plugins/roomslist/view.js
  51594. const {
  51595. Strophe: view_Strophe,
  51596. u: view_u
  51597. } = core_converse.env;
  51598. class RoomsList extends CustomElement {
  51599. initialize() {
  51600. const id = `converse.roomspanel${shared_converse.bare_jid}`;
  51601. this.model = new roomslist_model({
  51602. id
  51603. });
  51604. initStorage(this.model, id);
  51605. this.model.fetch();
  51606. this.listenTo(shared_converse.chatboxes, 'add', this.renderIfChatRoom);
  51607. this.listenTo(shared_converse.chatboxes, 'remove', this.renderIfChatRoom);
  51608. this.listenTo(shared_converse.chatboxes, 'destroy', this.renderIfChatRoom);
  51609. this.listenTo(shared_converse.chatboxes, 'change', this.renderIfRelevantChange);
  51610. this.requestUpdate();
  51611. }
  51612. renderIfChatRoom(model) {
  51613. view_u.isChatRoom(model) && this.requestUpdate();
  51614. }
  51615. renderIfRelevantChange(model) {
  51616. const attrs = ['bookmarked', 'hidden', 'name', 'num_unread', 'num_unread_general', 'has_activity'];
  51617. const changed = model.changed || {};
  51618. if (view_u.isChatRoom(model) && Object.keys(changed).filter(m => attrs.includes(m)).length) {
  51619. this.requestUpdate();
  51620. }
  51621. }
  51622. render() {
  51623. return roomslist({
  51624. 'addBookmark': ev => this.addBookmark(ev),
  51625. 'allow_bookmarks': core_api.settings.get('allow_bookmarks') && shared_converse.bookmarks,
  51626. 'closeRoom': ev => this.closeRoom(ev),
  51627. 'collapsed': this.model.get('toggle-state') !== shared_converse.OPENED,
  51628. 'currently_open': room => isUniView() && !room.get('hidden'),
  51629. 'model': this.model,
  51630. 'openRoom': ev => this.openRoom(ev),
  51631. 'removeBookmark': ev => this.removeBookmark(ev),
  51632. 'rooms': shared_converse.chatboxes.filter(m => m.get('type') === shared_converse.CHATROOMS_TYPE),
  51633. 'showRoomDetailsModal': ev => this.showRoomDetailsModal(ev),
  51634. 'toggleRoomsList': ev => this.toggleRoomsList(ev),
  51635. 'toggle_state': this.model.get('toggle-state')
  51636. });
  51637. }
  51638. showRoomDetailsModal(ev) {
  51639. // eslint-disable-line class-methods-use-this
  51640. const jid = ev.target.getAttribute('data-room-jid');
  51641. const room = shared_converse.chatboxes.get(jid);
  51642. ev.preventDefault();
  51643. core_api.modal.show(modals_muc_details, {
  51644. 'model': room
  51645. }, ev);
  51646. }
  51647. async openRoom(ev) {
  51648. // eslint-disable-line class-methods-use-this
  51649. ev.preventDefault();
  51650. const name = ev.target.textContent;
  51651. const jid = ev.target.getAttribute('data-room-jid');
  51652. const data = {
  51653. 'name': name || view_Strophe.unescapeNode(view_Strophe.getNodeFromJid(jid)) || jid
  51654. };
  51655. await core_api.rooms.open(jid, data, true);
  51656. }
  51657. async closeRoom(ev) {
  51658. // eslint-disable-line class-methods-use-this
  51659. ev.preventDefault();
  51660. const name = ev.target.getAttribute('data-room-name');
  51661. if (confirm(__("Are you sure you want to leave the groupchat %1$s?", name))) {
  51662. const jid = ev.target.getAttribute('data-room-jid');
  51663. const room = await core_api.rooms.get(jid);
  51664. room.close();
  51665. }
  51666. }
  51667. removeBookmark(ev) {
  51668. // eslint-disable-line class-methods-use-this
  51669. shared_converse.removeBookmarkViaEvent(ev);
  51670. }
  51671. addBookmark(ev) {
  51672. // eslint-disable-line class-methods-use-this
  51673. shared_converse.addBookmarkViaEvent(ev);
  51674. }
  51675. toggleRoomsList(ev) {
  51676. var _ev$preventDefault;
  51677. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  51678. const icon_el = ev.target.matches('.fa') ? ev.target : ev.target.querySelector('.fa');
  51679. if (icon_el.classList.contains("fa-caret-down")) {
  51680. view_u.slideIn(this.querySelector('.open-rooms-list')).then(() => {
  51681. this.model.save({
  51682. 'toggle-state': shared_converse.CLOSED
  51683. });
  51684. icon_el.classList.remove("fa-caret-down");
  51685. icon_el.classList.add("fa-caret-right");
  51686. });
  51687. } else {
  51688. view_u.slideOut(this.querySelector('.open-rooms-list')).then(() => {
  51689. this.model.save({
  51690. 'toggle-state': shared_converse.OPENED
  51691. });
  51692. icon_el.classList.remove("fa-caret-right");
  51693. icon_el.classList.add("fa-caret-down");
  51694. });
  51695. }
  51696. }
  51697. }
  51698. core_api.elements.define('converse-rooms-list', RoomsList);
  51699. ;// CONCATENATED MODULE: ./src/plugins/roomslist/index.js
  51700. /**
  51701. * @description
  51702. * Converse.js plugin which shows a list of currently open
  51703. * rooms in the "Rooms Panel" of the ControlBox.
  51704. * @copyright 2022, the Converse.js contributors
  51705. * @license Mozilla Public License (MPLv2)
  51706. */
  51707. core_converse.plugins.add('converse-roomslist', {
  51708. dependencies: ["converse-singleton", "converse-controlbox", "converse-muc", "converse-bookmarks"],
  51709. initialize() {}
  51710. });
  51711. ;// CONCATENATED MODULE: ./src/shared/templates/icons.js
  51712. /* harmony default export */ const icons = (() => $`
  51713. <?xml version="1.0" encoding="UTF-8"?>
  51714. <!--
  51715. Font Awesome Free 5.13.0 by @fontawesome - https://fontawesome.com
  51716. License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
  51717. -->
  51718. <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  51719. <symbol id="icon-address-book" viewBox="0 0 448 512">
  51720. <path d="M436 160c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-20V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h320c26.5 0 48-21.5 48-48v-48h20c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-20v-64h20c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-20v-64h20zm-228-32c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm112 236.8c0 10.6-10 19.2-22.4 19.2H118.4C106 384 96 375.4 96 364.8v-19.2c0-31.8 30.1-57.6 67.2-57.6h5c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h5c37.1 0 67.2 25.8 67.2 57.6v19.2z"></path>
  51721. </symbol>
  51722. <symbol id="icon-angle-double-down" viewBox="0 0 320 512">
  51723. <path d="M143 256.3L7 120.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0L313 86.3c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.4 9.5-24.6 9.5-34 .1zm34 192l136-136c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L160 352.1l-96.4-96.4c-9.4-9.4-24.6-9.4-33.9 0L7 278.3c-9.4 9.4-9.4 24.6 0 33.9l136 136c9.4 9.5 24.6 9.5 34 .1z"></path>
  51724. </symbol>
  51725. <symbol id="icon-angle-double-left" viewBox="0 0 448 512">
  51726. <path d="M223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34zm-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34z"></path>
  51727. </symbol>
  51728. <symbol id="icon-angle-double-right" viewBox="0 0 448 512">
  51729. <path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"></path>
  51730. </symbol>
  51731. <symbol id="icon-angle-double-up" viewBox="0 0 320 512">
  51732. <path d="M177 255.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 351.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 425.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1zm-34-192L7 199.7c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l96.4-96.4 96.4 96.4c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9l-136-136c-9.2-9.4-24.4-9.4-33.8 0z"></path>
  51733. </symbol>
  51734. <symbol id="icon-angle-down" viewBox="0 0 320 512">
  51735. <path d="M143 352.3L7 216.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.2 9.4-24.4 9.4-33.8 0z"></path>
  51736. </symbol>
  51737. <symbol id="icon-angle-left" viewBox="0 0 256 512">
  51738. <path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path>
  51739. </symbol>
  51740. <symbol id="icon-angle-right" viewBox="0 0 256 512">
  51741. <path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"></path>
  51742. </symbol>
  51743. <symbol id="icon-angle-up" viewBox="0 0 320 512">
  51744. <path d="M177 159.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 255.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 329.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1z"></path>
  51745. </symbol>
  51746. <symbol id="icon-arrow-alt-circle-down" viewBox="0 0 512 512">
  51747. <path d="M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zM212 140v116h-70.9c-10.7 0-16.1 13-8.5 20.5l114.9 114.3c4.7 4.7 12.2 4.7 16.9 0l114.9-114.3c7.6-7.6 2.2-20.5-8.5-20.5H300V140c0-6.6-5.4-12-12-12h-64c-6.6 0-12 5.4-12 12z"></path>
  51748. </symbol>
  51749. <symbol id="icon-arrow-alt-circle-left" viewBox="0 0 512 512">
  51750. <path d="M256 504C119 504 8 393 8 256S119 8 256 8s248 111 248 248-111 248-248 248zm116-292H256v-70.9c0-10.7-13-16.1-20.5-8.5L121.2 247.5c-4.7 4.7-4.7 12.2 0 16.9l114.3 114.9c7.6 7.6 20.5 2.2 20.5-8.5V300h116c6.6 0 12-5.4 12-12v-64c0-6.6-5.4-12-12-12z"></path>
  51751. </symbol>
  51752. <symbol id="icon-arrow-alt-circle-right" viewBox="0 0 512 512">
  51753. <path d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zM140 300h116v70.9c0 10.7 13 16.1 20.5 8.5l114.3-114.9c4.7-4.7 4.7-12.2 0-16.9l-114.3-115c-7.6-7.6-20.5-2.2-20.5 8.5V212H140c-6.6 0-12 5.4-12 12v64c0 6.6 5.4 12 12 12z"></path>
  51754. </symbol>
  51755. <symbol id="icon-arrow-alt-circle-up" viewBox="0 0 512 512">
  51756. <path d="M8 256C8 119 119 8 256 8s248 111 248 248-111 248-248 248S8 393 8 256zm292 116V256h70.9c10.7 0 16.1-13 8.5-20.5L264.5 121.2c-4.7-4.7-12.2-4.7-16.9 0l-115 114.3c-7.6 7.6-2.2 20.5 8.5 20.5H212v116c0 6.6 5.4 12 12 12h64c6.6 0 12-5.4 12-12z"></path>
  51757. </symbol>
  51758. <symbol id="icon-arrow-circle-down" viewBox="0 0 512 512">
  51759. <path d="M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-143.6-28.9L288 302.6V120c0-13.3-10.7-24-24-24h-16c-13.3 0-24 10.7-24 24v182.6l-72.4-75.5c-9.3-9.7-24.8-9.9-34.3-.4l-10.9 11c-9.4 9.4-9.4 24.6 0 33.9L239 404.3c9.4 9.4 24.6 9.4 33.9 0l132.7-132.7c9.4-9.4 9.4-24.6 0-33.9l-10.9-11c-9.5-9.5-25-9.3-34.3.4z"></path>
  51760. </symbol>
  51761. <symbol id="icon-arrow-circle-left" viewBox="0 0 512 512">
  51762. <path d="M256 504C119 504 8 393 8 256S119 8 256 8s248 111 248 248-111 248-248 248zm28.9-143.6L209.4 288H392c13.3 0 24-10.7 24-24v-16c0-13.3-10.7-24-24-24H209.4l75.5-72.4c9.7-9.3 9.9-24.8.4-34.3l-11-10.9c-9.4-9.4-24.6-9.4-33.9 0L107.7 239c-9.4 9.4-9.4 24.6 0 33.9l132.7 132.7c9.4 9.4 24.6 9.4 33.9 0l11-10.9c9.5-9.5 9.3-25-.4-34.3z"></path>
  51763. </symbol>
  51764. <symbol id="icon-arrow-circle-right" viewBox="0 0 512 512">
  51765. <path d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm-28.9 143.6l75.5 72.4H120c-13.3 0-24 10.7-24 24v16c0 13.3 10.7 24 24 24h182.6l-75.5 72.4c-9.7 9.3-9.9 24.8-.4 34.3l11 10.9c9.4 9.4 24.6 9.4 33.9 0L404.3 273c9.4-9.4 9.4-24.6 0-33.9L271.6 106.3c-9.4-9.4-24.6-9.4-33.9 0l-11 10.9c-9.5 9.6-9.3 25.1.4 34.4z"></path>
  51766. </symbol>
  51767. <symbol id="icon-arrow-circle-up" viewBox="0 0 512 512">
  51768. <path d="M8 256C8 119 119 8 256 8s248 111 248 248-111 248-248 248S8 393 8 256zm143.6 28.9l72.4-75.5V392c0 13.3 10.7 24 24 24h16c13.3 0 24-10.7 24-24V209.4l72.4 75.5c9.3 9.7 24.8 9.9 34.3.4l10.9-11c9.4-9.4 9.4-24.6 0-33.9L273 107.7c-9.4-9.4-24.6-9.4-33.9 0L106.3 240.4c-9.4 9.4-9.4 24.6 0 33.9l10.9 11c9.6 9.5 25.1 9.3 34.4-.4z"></path>
  51769. </symbol>
  51770. <symbol id="icon-arrow-down" viewBox="0 0 448 512">
  51771. <path d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path>
  51772. </symbol>
  51773. <symbol id="icon-arrow-left" viewBox="0 0 448 512">
  51774. <path d="M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"></path>
  51775. </symbol>
  51776. <symbol id="icon-arrow-right" viewBox="0 0 448 512">
  51777. <path d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path>
  51778. </symbol>
  51779. <symbol id="icon-arrow-up" viewBox="0 0 448 512">
  51780. <path d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path>
  51781. </symbol>
  51782. <symbol id="icon-arrows-alt" viewBox="0 0 512 512">
  51783. <path d="M352.201 425.775l-79.196 79.196c-9.373 9.373-24.568 9.373-33.941 0l-79.196-79.196c-15.119-15.119-4.411-40.971 16.971-40.97h51.162L228 284H127.196v51.162c0 21.382-25.851 32.09-40.971 16.971L7.029 272.937c-9.373-9.373-9.373-24.569 0-33.941L86.225 159.8c15.119-15.119 40.971-4.411 40.971 16.971V228H228V127.196h-51.23c-21.382 0-32.09-25.851-16.971-40.971l79.196-79.196c9.373-9.373 24.568-9.373 33.941 0l79.196 79.196c15.119 15.119 4.411 40.971-16.971 40.971h-51.162V228h100.804v-51.162c0-21.382 25.851-32.09 40.97-16.971l79.196 79.196c9.373 9.373 9.373 24.569 0 33.941L425.773 352.2c-15.119 15.119-40.971 4.411-40.97-16.971V284H284v100.804h51.23c21.382 0 32.09 25.851 16.971 40.971z"></path>
  51784. </symbol>
  51785. <symbol id="icon-arrows-alt-h" viewBox="0 0 512 512">
  51786. <path d="M377.941 169.941V216H134.059v-46.059c0-21.382-25.851-32.09-40.971-16.971L7.029 239.029c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971V296h243.882v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.568 0-33.941l-86.059-86.059c-15.119-15.12-40.971-4.412-40.971 16.97z"></path>
  51787. </symbol>
  51788. <symbol id="icon-arrows-alt-v" viewBox="0 0 256 512">
  51789. <path d="M214.059 377.941H168V134.059h46.059c21.382 0 32.09-25.851 16.971-40.971L144.971 7.029c-9.373-9.373-24.568-9.373-33.941 0L24.971 93.088c-15.119 15.119-4.411 40.971 16.971 40.971H88v243.882H41.941c-21.382 0-32.09 25.851-16.971 40.971l86.059 86.059c9.373 9.373 24.568 9.373 33.941 0l86.059-86.059c15.12-15.119 4.412-40.971-16.97-40.971z"></path>
  51790. </symbol>
  51791. <symbol id="icon-bars" viewBox="0 0 448 512">
  51792. <path d="M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"></path>
  51793. </symbol>
  51794. <symbol id="icon-bookmark" viewBox="0 0 384 512">
  51795. <path d="M0 512V48C0 21.49 21.49 0 48 0h288c26.51 0 48 21.49 48 48v464L192 400 0 512z"></path>
  51796. </symbol>
  51797. <symbol id="icon-caret-down" viewBox="0 0 320 512">
  51798. <path d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"></path>
  51799. </symbol>
  51800. <symbol id="icon-caret-right" viewBox="0 0 192 512">
  51801. <path d="M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"></path>
  51802. </symbol>
  51803. <symbol id="icon-check" viewBox="0 0 512 512">
  51804. <path d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path>
  51805. </symbol>
  51806. <symbol id="icon-circle" viewBox="0 0 512 512">
  51807. <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path>
  51808. </symbol>
  51809. <symbol id="icon-cog" viewBox="0 0 512 512">
  51810. <path d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"></path>
  51811. </symbol>
  51812. <symbol id="icon-database" viewBox="0 0 448 512">
  51813. <path d="M448 73.143v45.714C448 159.143 347.667 192 224 192S0 159.143 0 118.857V73.143C0 32.857 100.333 0 224 0s224 32.857 224 73.143zM448 176v102.857C448 319.143 347.667 352 224 352S0 319.143 0 278.857V176c48.125 33.143 136.208 48.572 224 48.572S399.874 209.143 448 176zm0 160v102.857C448 479.143 347.667 512 224 512S0 479.143 0 438.857V336c48.125 33.143 136.208 48.572 224 48.572S399.874 369.143 448 336z"></path>
  51814. </symbol>
  51815. <symbol id="icon-edit" viewBox="0 0 576 512">
  51816. <path d="M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"></path>
  51817. </symbol>
  51818. <symbol id="icon-eye" viewBox="0 0 576 512">
  51819. <path d="M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"></path>
  51820. </symbol>
  51821. <symbol id="icon-eye-slash" viewBox="0 0 640 512">
  51822. <path d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z"></path>
  51823. </symbol>
  51824. <symbol id="icon-gavel" viewBox="0 0 512 512">
  51825. <path d="M504.971 199.362l-22.627-22.627c-9.373-9.373-24.569-9.373-33.941 0l-5.657 5.657L329.608 69.255l5.657-5.657c9.373-9.373 9.373-24.569 0-33.941L312.638 7.029c-9.373-9.373-24.569-9.373-33.941 0L154.246 131.48c-9.373 9.373-9.373 24.569 0 33.941l22.627 22.627c9.373 9.373 24.569 9.373 33.941 0l5.657-5.657 39.598 39.598-81.04 81.04-5.657-5.657c-12.497-12.497-32.758-12.497-45.255 0L9.373 412.118c-12.497 12.497-12.497 32.758 0 45.255l45.255 45.255c12.497 12.497 32.758 12.497 45.255 0l114.745-114.745c12.497-12.497 12.497-32.758 0-45.255l-5.657-5.657 81.04-81.04 39.598 39.598-5.657 5.657c-9.373 9.373-9.373 24.569 0 33.941l22.627 22.627c9.373 9.373 24.569 9.373 33.941 0l124.451-124.451c9.372-9.372 9.372-24.568 0-33.941z"></path>
  51826. </symbol>
  51827. <symbol id="icon-globe" viewBox="0 0 496 512">
  51828. <path d="M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"></path>
  51829. </symbol>
  51830. <symbol id="icon-id-card" viewBox="0 0 576 512">
  51831. <path d="M528 32H48C21.5 32 0 53.5 0 80v16h576V80c0-26.5-21.5-48-48-48zM0 432c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V128H0v304zm352-232c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zM176 192c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zM67.1 396.2C75.5 370.5 99.6 352 128 352h8.2c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h8.2c28.4 0 52.5 18.5 60.9 44.2 3.2 9.9-5.2 19.8-15.6 19.8H82.7c-10.4 0-18.8-10-15.6-19.8z"></path>
  51832. </symbol>
  51833. <symbol id="icon-id-card-alt" viewBox="0 0 576 512">
  51834. <path d="M528 64H384v96H192V64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM288 224c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm93.3 224H194.7c-10.4 0-18.8-10-15.6-19.8 8.3-25.6 32.4-44.2 60.9-44.2h8.2c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h8.2c28.4 0 52.5 18.5 60.9 44.2 3.2 9.8-5.2 19.8-15.6 19.8zM352 32c0-17.7-14.3-32-32-32h-64c-17.7 0-32 14.3-32 32v96h128V32z"></path>
  51835. </symbol>
  51836. <symbol id="icon-info" viewBox="0 0 192 512">
  51837. <path d="M20 424.229h20V279.771H20c-11.046 0-20-8.954-20-20V212c0-11.046 8.954-20 20-20h112c11.046 0 20 8.954 20 20v212.229h20c11.046 0 20 8.954 20 20V492c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20v-47.771c0-11.046 8.954-20 20-20zM96 0C56.235 0 24 32.235 24 72s32.235 72 72 72 72-32.235 72-72S135.764 0 96 0z"></path>
  51838. </symbol>
  51839. <symbol id="icon-info-circle" viewBox="0 0 512 512">
  51840. <path d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"></path>
  51841. </symbol>
  51842. <symbol id="icon-list-ul" viewBox="0 0 512 512">
  51843. <path d="M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"></path>
  51844. </symbol>
  51845. <symbol id="icon-lock" viewBox="0 0 448 512">
  51846. <path d="M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"></path>
  51847. </symbol>
  51848. <symbol id="icon-lock-open" viewBox="0 0 576 512">
  51849. <path d="M423.5 0C339.5.3 272 69.5 272 153.5V224H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48h-48v-71.1c0-39.6 31.7-72.5 71.3-72.9 40-.4 72.7 32.1 72.7 72v80c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24v-80C576 68 507.5-.3 423.5 0z"></path>
  51850. </symbol>
  51851. <symbol id="icon-minus" viewBox="0 0 448 512">
  51852. <path d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path>
  51853. </symbol>
  51854. <symbol id="icon-minus-circle" viewBox="0 0 512 512">
  51855. <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z"></path>
  51856. </symbol>
  51857. <symbol id="icon-minus-square" viewBox="0 0 448 512">
  51858. <path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z"></path>
  51859. </symbol>
  51860. <symbol id="icon-paper-plane" viewBox="0 0 512 512">
  51861. <path d="M476 3.2L12.5 270.6c-18.1 10.4-15.8 35.6 2.2 43.2L121 358.4l287.3-253.2c5.5-4.9 13.3 2.6 8.6 8.3L176 407v80.5c0 23.6 28.5 32.9 42.5 15.8L282 426l124.6 52.2c14.2 6 30.4-2.9 33-18.2l72-432C515 7.8 493.3-6.8 476 3.2z"></path>
  51862. </symbol>
  51863. <symbol id="icon-paperclip" viewBox="0 0 448 512">
  51864. <path d="M43.246 466.142c-58.43-60.289-57.341-157.511 1.386-217.581L254.392 34c44.316-45.332 116.351-45.336 160.671 0 43.89 44.894 43.943 117.329 0 162.276L232.214 383.128c-29.855 30.537-78.633 30.111-107.982-.998-28.275-29.97-27.368-77.473 1.452-106.953l143.743-146.835c6.182-6.314 16.312-6.422 22.626-.241l22.861 22.379c6.315 6.182 6.422 16.312.241 22.626L171.427 319.927c-4.932 5.045-5.236 13.428-.648 18.292 4.372 4.634 11.245 4.711 15.688.165l182.849-186.851c19.613-20.062 19.613-52.725-.011-72.798-19.189-19.627-49.957-19.637-69.154 0L90.39 293.295c-34.763 35.56-35.299 93.12-1.191 128.313 34.01 35.093 88.985 35.137 123.058.286l172.06-175.999c6.177-6.319 16.307-6.433 22.626-.256l22.877 22.364c6.319 6.177 6.434 16.307.256 22.626l-172.06 175.998c-59.576 60.938-155.943 60.216-214.77-.485z"></path>
  51865. </symbol>
  51866. <symbol id="icon-pencil-alt" viewBox="0 0 512 512">
  51867. <path d="M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"></path>
  51868. </symbol>
  51869. <symbol id="icon-phone" viewBox="0 0 512 512">
  51870. <path d="M493.4 24.6l-104-24c-11.3-2.6-22.9 3.3-27.5 13.9l-48 112c-4.2 9.8-1.4 21.3 6.9 28l60.6 49.6c-36 76.7-98.9 140.5-177.2 177.2l-49.6-60.6c-6.8-8.3-18.2-11.1-28-6.9l-112 48C3.9 366.5-2 378.1.6 389.4l24 104C27.1 504.2 36.7 512 48 512c256.1 0 464-207.5 464-464 0-11.2-7.7-20.9-18.6-23.4z"></path>
  51871. </symbol>
  51872. <symbol id="icon-plus" viewBox="0 0 448 512">
  51873. <path d="M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"></path>
  51874. </symbol>
  51875. <symbol id="icon-plus-circle" viewBox="0 0 512 512">
  51876. <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"></path>
  51877. </symbol>
  51878. <symbol id="icon-plus-square" viewBox="0 0 448 512">
  51879. <path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"></path>
  51880. </symbol>
  51881. <symbol id="icon-save" viewBox="0 0 448 512">
  51882. <path d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"></path>
  51883. </symbol>
  51884. <symbol id="icon-sign-out-alt" viewBox="0 0 512 512">
  51885. <path d="M497 273L329 441c-15 15-41 4.5-41-17v-96H152c-13.3 0-24-10.7-24-24v-96c0-13.3 10.7-24 24-24h136V88c0-21.4 25.9-32 41-17l168 168c9.3 9.4 9.3 24.6 0 34zM192 436v-40c0-6.6-5.4-12-12-12H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h84c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12H96c-53 0-96 43-96 96v192c0 53 43 96 96 96h84c6.6 0 12-5.4 12-12z"></path>
  51886. </symbol>
  51887. <symbol id="icon-smile" viewBox="0 0 496 512">
  51888. <path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"></path>
  51889. </symbol>
  51890. <symbol id="icon-snowflake" viewBox="0 0 448 512">
  51891. <path d="M440.3 345.2l-33.8-19.5 26-7c8.2-2.2 13.1-10.7 10.9-18.9l-4-14.9c-2.2-8.2-10.7-13.1-18.9-10.9l-70.8 19-63.9-37 63.8-36.9 70.8 19c8.2 2.2 16.7-2.7 18.9-10.9l4-14.9c2.2-8.2-2.7-16.7-10.9-18.9l-26-7 33.8-19.5c7.4-4.3 9.9-13.7 5.7-21.1L430.4 119c-4.3-7.4-13.7-9.9-21.1-5.7l-33.8 19.5 7-26c2.2-8.2-2.7-16.7-10.9-18.9l-14.9-4c-8.2-2.2-16.7 2.7-18.9 10.9l-19 70.8-62.8 36.2v-77.5l53.7-53.7c6.2-6.2 6.2-16.4 0-22.6l-11.3-11.3c-6.2-6.2-16.4-6.2-22.6 0L256 56.4V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v40.4l-19.7-19.7c-6.2-6.2-16.4-6.2-22.6 0L138.3 48c-6.3 6.2-6.3 16.4 0 22.6l53.7 53.7v77.5l-62.8-36.2-19-70.8c-2.2-8.2-10.7-13.1-18.9-10.9l-14.9 4c-8.2 2.2-13.1 10.7-10.9 18.9l7 26-33.8-19.5c-7.4-4.3-16.8-1.7-21.1 5.7L2.1 145.7c-4.3 7.4-1.7 16.8 5.7 21.1l33.8 19.5-26 7c-8.3 2.2-13.2 10.7-11 19l4 14.9c2.2 8.2 10.7 13.1 18.9 10.9l70.8-19 63.8 36.9-63.8 36.9-70.8-19c-8.2-2.2-16.7 2.7-18.9 10.9l-4 14.9c-2.2 8.2 2.7 16.7 10.9 18.9l26 7-33.8 19.6c-7.4 4.3-9.9 13.7-5.7 21.1l15.5 26.8c4.3 7.4 13.7 9.9 21.1 5.7l33.8-19.5-7 26c-2.2 8.2 2.7 16.7 10.9 18.9l14.9 4c8.2 2.2 16.7-2.7 18.9-10.9l19-70.8 62.8-36.2v77.5l-53.7 53.7c-6.3 6.2-6.3 16.4 0 22.6l11.3 11.3c6.2 6.2 16.4 6.2 22.6 0l19.7-19.7V496c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-40.4l19.7 19.7c6.2 6.2 16.4 6.2 22.6 0l11.3-11.3c6.2-6.2 6.2-16.4 0-22.6L256 387.7v-77.5l62.8 36.2 19 70.8c2.2 8.2 10.7 13.1 18.9 10.9l14.9-4c8.2-2.2 13.1-10.7 10.9-18.9l-7-26 33.8 19.5c7.4 4.3 16.8 1.7 21.1-5.7l15.5-26.8c4.3-7.3 1.8-16.8-5.6-21z"></path>
  51892. </symbol>
  51893. <symbol id="icon-spinner" viewBox="0 0 512 512">
  51894. <path d="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"></path>
  51895. </symbol>
  51896. <symbol id="icon-sync" viewBox="0 0 512 512">
  51897. <path d="M440.65 12.57l4 82.77A247.16 247.16 0 0 0 255.83 8C134.73 8 33.91 94.92 12.29 209.82A12 12 0 0 0 24.09 224h49.05a12 12 0 0 0 11.67-9.26 175.91 175.91 0 0 1 317-56.94l-101.46-4.86a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12H500a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12h-47.37a12 12 0 0 0-11.98 12.57zM255.83 432a175.61 175.61 0 0 1-146-77.8l101.8 4.87a12 12 0 0 0 12.57-12v-47.4a12 12 0 0 0-12-12H12a12 12 0 0 0-12 12V500a12 12 0 0 0 12 12h47.35a12 12 0 0 0 12-12.6l-4.15-82.57A247.17 247.17 0 0 0 255.83 504c121.11 0 221.93-86.92 243.55-201.82a12 12 0 0 0-11.8-14.18h-49.05a12 12 0 0 0-11.67 9.26A175.86 175.86 0 0 1 255.83 432z"></path>
  51898. </symbol>
  51899. <symbol id="icon-times" viewBox="0 0 352 512">
  51900. <path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path>
  51901. </symbol>
  51902. <symbol id="icon-times-circle" viewBox="0 0 512 512">
  51903. <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"></path>
  51904. </symbol>
  51905. <symbol id="icon-trash" viewBox="0 0 448 512">
  51906. <path d="M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"></path>
  51907. </symbol>
  51908. <symbol id="icon-trash-alt" viewBox="0 0 448 512">
  51909. <path d="M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"></path>
  51910. </symbol>
  51911. <symbol id="icon-unlock" viewBox="0 0 448 512">
  51912. <path d="M400 256H152V152.9c0-39.6 31.7-72.5 71.3-72.9 40-.4 72.7 32.1 72.7 72v16c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24v-16C376 68 307.5-.3 223.5 0 139.5.3 72 69.5 72 153.5V256H48c-26.5 0-48 21.5-48 48v160c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z"></path>
  51913. </symbol>
  51914. <symbol id="icon-user" viewBox="0 0 448 512">
  51915. <path d="M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"></path>
  51916. </symbol>
  51917. <symbol id="icon-user-cog" viewBox="0 0 640 512">
  51918. <path d="M610.5 373.3c2.6-14.1 2.6-28.5 0-42.6l25.8-14.9c3-1.7 4.3-5.2 3.3-8.5-6.7-21.6-18.2-41.2-33.2-57.4-2.3-2.5-6-3.1-9-1.4l-25.8 14.9c-10.9-9.3-23.4-16.5-36.9-21.3v-29.8c0-3.4-2.4-6.4-5.7-7.1-22.3-5-45-4.8-66.2 0-3.3.7-5.7 3.7-5.7 7.1v29.8c-13.5 4.8-26 12-36.9 21.3l-25.8-14.9c-2.9-1.7-6.7-1.1-9 1.4-15 16.2-26.5 35.8-33.2 57.4-1 3.3.4 6.8 3.3 8.5l25.8 14.9c-2.6 14.1-2.6 28.5 0 42.6l-25.8 14.9c-3 1.7-4.3 5.2-3.3 8.5 6.7 21.6 18.2 41.1 33.2 57.4 2.3 2.5 6 3.1 9 1.4l25.8-14.9c10.9 9.3 23.4 16.5 36.9 21.3v29.8c0 3.4 2.4 6.4 5.7 7.1 22.3 5 45 4.8 66.2 0 3.3-.7 5.7-3.7 5.7-7.1v-29.8c13.5-4.8 26-12 36.9-21.3l25.8 14.9c2.9 1.7 6.7 1.1 9-1.4 15-16.2 26.5-35.8 33.2-57.4 1-3.3-.4-6.8-3.3-8.5l-25.8-14.9zM496 400.5c-26.8 0-48.5-21.8-48.5-48.5s21.8-48.5 48.5-48.5 48.5 21.8 48.5 48.5-21.7 48.5-48.5 48.5zM224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm201.2 226.5c-2.3-1.2-4.6-2.6-6.8-3.9l-7.9 4.6c-6 3.4-12.8 5.3-19.6 5.3-10.9 0-21.4-4.6-28.9-12.6-18.3-19.8-32.3-43.9-40.2-69.6-5.5-17.7 1.9-36.4 17.9-45.7l7.9-4.6c-.1-2.6-.1-5.2 0-7.8l-7.9-4.6c-16-9.2-23.4-28-17.9-45.7.9-2.9 2.2-5.8 3.2-8.7-3.8-.3-7.5-1.2-11.4-1.2h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c10.1 0 19.5-3.2 27.2-8.5-1.2-3.8-2-7.7-2-11.8v-9.2z"></path>
  51919. </symbol>
  51920. <symbol id="icon-user-plus" viewBox="0 0 640 512">
  51921. <path d="M624 208h-64v-64c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v64h-64c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h64v64c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-64h64c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm-400 48c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"></path>
  51922. </symbol>
  51923. <symbol id="icon-user-secret" viewBox="0 0 448 512">
  51924. <path d="M383.9 308.3l23.9-62.6c4-10.5-3.7-21.7-15-21.7h-58.5c11-18.9 17.8-40.6 17.8-64v-.3c39.2-7.8 64-19.1 64-31.7 0-13.3-27.3-25.1-70.1-33-9.2-32.8-27-65.8-40.6-82.8-9.5-11.9-25.9-15.6-39.5-8.8l-27.6 13.8c-9 4.5-19.6 4.5-28.6 0L182.1 3.4c-13.6-6.8-30-3.1-39.5 8.8-13.5 17-31.4 50-40.6 82.8-42.7 7.9-70 19.7-70 33 0 12.6 24.8 23.9 64 31.7v.3c0 23.4 6.8 45.1 17.8 64H56.3c-11.5 0-19.2 11.7-14.7 22.3l25.8 60.2C27.3 329.8 0 372.7 0 422.4v44.8C0 491.9 20.1 512 44.8 512h358.4c24.7 0 44.8-20.1 44.8-44.8v-44.8c0-48.4-25.8-90.4-64.1-114.1zM176 480l-41.6-192 49.6 32 24 40-32 120zm96 0l-32-120 24-40 49.6-32L272 480zm41.7-298.5c-3.9 11.9-7 24.6-16.5 33.4-10.1 9.3-48 22.4-64-25-2.8-8.4-15.4-8.4-18.3 0-17 50.2-56 32.4-64 25-9.5-8.8-12.7-21.5-16.5-33.4-.8-2.5-6.3-5.7-6.3-5.8v-10.8c28.3 3.6 61 5.8 96 5.8s67.7-2.1 96-5.8v10.8c-.1.1-5.6 3.2-6.4 5.8z"></path>
  51925. </symbol>
  51926. <symbol id="icon-users" viewBox="0 0 640 512">
  51927. <path d="M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z"></path>
  51928. </symbol>
  51929. <symbol id="icon-wrench" viewBox="0 0 512 512">
  51930. <path d="M507.73 109.1c-2.24-9.03-13.54-12.09-20.12-5.51l-74.36 74.36-67.88-11.31-11.31-67.88 74.36-74.36c6.62-6.62 3.43-17.9-5.66-20.16-47.38-11.74-99.55.91-136.58 37.93-39.64 39.64-50.55 97.1-34.05 147.2L18.74 402.76c-24.99 24.99-24.99 65.51 0 90.5 24.99 24.99 65.51 24.99 90.5 0l213.21-213.21c50.12 16.71 107.47 5.68 147.37-34.22 37.07-37.07 49.7-89.32 37.91-136.73zM64 472c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"></path>
  51931. </symbol>
  51932. <symbol id="icon-refresh" viewBox="0 0 512 512">
  51933. <path d="M464 16c-17.67 0-32 14.31-32 32v74.09C392.1 66.52 327.4 32 256 32C161.5 32 78.59 92.34 49.58 182.2c-5.438 16.81 3.797 34.88 20.61 40.28c16.89 5.5 34.88-3.812 40.3-20.59C130.9 138.5 189.4 96 256 96c50.5 0 96.26 24.55 124.4 64H336c-17.67 0-32 14.31-32 32s14.33 32 32 32h128c17.67 0 32-14.31 32-32V48C496 30.31 481.7 16 464 16zM441.8 289.6c-16.92-5.438-34.88 3.812-40.3 20.59C381.1 373.5 322.6 416 256 416c-50.5 0-96.25-24.55-124.4-64H176c17.67 0 32-14.31 32-32s-14.33-32-32-32h-128c-17.67 0-32 14.31-32 32v144c0 17.69 14.33 32 32 32s32-14.31 32-32v-74.09C119.9 445.5 184.6 480 255.1 480c94.45 0 177.4-60.34 206.4-150.2C467.9 313 458.6 294.1 441.8 289.6z"></path>
  51934. </symbol>
  51935. </svg>
  51936. `);
  51937. ;// CONCATENATED MODULE: ./src/shared/components/font-awesome.js
  51938. class FontAwesome extends CustomElement {
  51939. render() {
  51940. // eslint-disable-line class-methods-use-this
  51941. return icons();
  51942. }
  51943. }
  51944. window.customElements.define('converse-fontawesome', FontAwesome);
  51945. ;// CONCATENATED MODULE: ./src/plugins/rootview/templates/root.js
  51946. /* harmony default export */ const templates_root = (() => {
  51947. const extra_classes = core_api.settings.get('singleton') ? ['converse-singleton'] : [];
  51948. extra_classes.push(`converse-${core_api.settings.get('view_mode')}`);
  51949. return $`
  51950. <converse-chats class="converse-chatboxes row no-gutters ${extra_classes.join(' ')}"></converse-chats>
  51951. <div id="converse-modals" class="modals"></div>
  51952. <converse-fontawesome></converse-fontawesome>
  51953. `;
  51954. });
  51955. ;// CONCATENATED MODULE: ./src/plugins/rootview/utils.js
  51956. function getTheme() {
  51957. if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
  51958. return core_api.settings.get('dark_theme');
  51959. } else {
  51960. return core_api.settings.get('theme');
  51961. }
  51962. }
  51963. function ensureElement() {
  51964. if (!core_api.settings.get('auto_insert')) {
  51965. return;
  51966. }
  51967. const root = core_api.settings.get('root');
  51968. if (!root.querySelector('converse-root')) {
  51969. const el = document.createElement('converse-root');
  51970. const body = root.querySelector('body');
  51971. if (body) {
  51972. body.appendChild(el);
  51973. } else {
  51974. root.appendChild(el); // Perhaps inside a web component?
  51975. }
  51976. }
  51977. }
  51978. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/rootview/styles/root.scss
  51979. var styles_root = __webpack_require__(1513);
  51980. ;// CONCATENATED MODULE: ./src/plugins/rootview/styles/root.scss
  51981. var root_options = {};
  51982. root_options.styleTagTransform = (styleTagTransform_default());
  51983. root_options.setAttributes = (setAttributesWithoutAttributes_default());
  51984. root_options.insert = insertBySelector_default().bind(null, "head");
  51985. root_options.domAPI = (styleDomAPI_default());
  51986. root_options.insertStyleElement = (insertStyleElement_default());
  51987. var root_update = injectStylesIntoStyleTag_default()(styles_root/* default */.Z, root_options);
  51988. /* harmony default export */ const rootview_styles_root = (styles_root/* default */.Z && styles_root/* default.locals */.Z.locals ? styles_root/* default.locals */.Z.locals : undefined);
  51989. ;// CONCATENATED MODULE: ./src/plugins/rootview/root.js
  51990. /**
  51991. * `converse-root` is an optional custom element which can be used to
  51992. * declaratively insert the Converse UI into the DOM.
  51993. *
  51994. * It can be inserted into the DOM before or after Converse has loaded or been
  51995. * initialized.
  51996. */
  51997. class ConverseRoot extends CustomElement {
  51998. render() {
  51999. // eslint-disable-line class-methods-use-this
  52000. return templates_root();
  52001. }
  52002. initialize() {
  52003. this.setAttribute('id', 'conversejs');
  52004. this.setClasses();
  52005. const settings = getAppSettings();
  52006. this.listenTo(settings, 'change:view_mode', () => this.setClasses());
  52007. this.listenTo(settings, 'change:singleton', () => this.setClasses());
  52008. window.matchMedia('(prefers-color-scheme: dark)').addListener(() => this.setClasses());
  52009. window.matchMedia('(prefers-color-scheme: light)').addListener(() => this.setClasses());
  52010. }
  52011. setClasses() {
  52012. this.className = "";
  52013. this.classList.add('conversejs');
  52014. this.classList.add(`converse-${core_api.settings.get('view_mode')}`);
  52015. this.classList.add(`theme-${getTheme()}`);
  52016. this.requestUpdate();
  52017. }
  52018. }
  52019. ;// CONCATENATED MODULE: ./src/plugins/rootview/index.js
  52020. core_converse.plugins.add('converse-rootview', {
  52021. initialize() {
  52022. // Configuration values for this plugin
  52023. // ====================================
  52024. // Refer to docs/source/configuration.rst for explanations of these
  52025. // configuration settings.
  52026. core_api.settings.extend({
  52027. 'auto_insert': true,
  52028. 'theme': 'classic',
  52029. 'dark_theme': 'dracula'
  52030. });
  52031. core_api.listen.on('chatBoxesInitialized', ensureElement); // Only define the element now, otherwise it it's already in the DOM
  52032. // before `converse.initialized` has been called it will render too
  52033. // early.
  52034. core_api.elements.define('converse-root', ConverseRoot);
  52035. }
  52036. });
  52037. ;// CONCATENATED MODULE: ./src/modals/templates/add-contact.js
  52038. /* harmony default export */ const add_contact = (o => {
  52039. const i18n_contact_placeholder = __('name@example.org');
  52040. const i18n_add = __('Add');
  52041. const i18n_error_message = __('Please enter a valid XMPP address');
  52042. const i18n_new_contact = __('Add a Contact');
  52043. const i18n_xmpp_address = __('XMPP Address');
  52044. const i18n_nickname = __('Nickname');
  52045. return $`
  52046. <div class="modal-dialog" role="document">
  52047. <div class="modal-content">
  52048. <div class="modal-header">
  52049. <h5 class="modal-title" id="addContactModalLabel">${i18n_new_contact}</h5>
  52050. ${modal_header_close_button}
  52051. </div>
  52052. <form class="converse-form add-xmpp-contact">
  52053. <div class="modal-body">
  52054. <span class="modal-alert"></span>
  52055. <div class="form-group add-xmpp-contact__jid">
  52056. <label class="clearfix" for="jid">${i18n_xmpp_address}:</label>
  52057. <div class="suggestion-box suggestion-box__jid">
  52058. <ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
  52059. <input type="text" name="jid" ?required=${!core_api.settings.get('xhr_user_search_url')}
  52060. value="${o.jid || ''}"
  52061. class="form-control suggestion-box__input"
  52062. placeholder="${i18n_contact_placeholder}"/>
  52063. <span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
  52064. </div>
  52065. </div>
  52066. <div class="form-group add-xmpp-contact__name">
  52067. <label class="clearfix" for="name">${i18n_nickname}:</label>
  52068. <div class="suggestion-box suggestion-box__name">
  52069. <ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
  52070. <input type="text" name="name" value="${o.nickname || ''}"
  52071. class="form-control suggestion-box__input"
  52072. placeholder="${i18n_nickname}"/>
  52073. <span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
  52074. </div>
  52075. </div>
  52076. <div class="form-group">
  52077. <div class="invalid-feedback">${i18n_error_message}</div>
  52078. </div>
  52079. <button type="submit" class="btn btn-primary">${i18n_add}</button>
  52080. </div>
  52081. </form>
  52082. </div>
  52083. </div>
  52084. `;
  52085. });
  52086. ;// CONCATENATED MODULE: ./src/modals/add-contact.js
  52087. const {
  52088. Strophe: add_contact_Strophe
  52089. } = core_converse.env;
  52090. const add_contact_u = core_converse.env.utils;
  52091. const AddContactModal = base.extend({
  52092. id: "add-contact-modal",
  52093. events: {
  52094. 'submit form': 'addContactFromForm'
  52095. },
  52096. initialize() {
  52097. base.prototype.initialize.apply(this, arguments);
  52098. this.listenTo(this.model, 'change', this.render);
  52099. },
  52100. toHTML() {
  52101. const label_nickname = core_api.settings.get('xhr_user_search_url') ? __('Contact name') : __('Optional nickname');
  52102. return add_contact(Object.assign(this.model.toJSON(), {
  52103. _converse: shared_converse,
  52104. label_nickname
  52105. }));
  52106. },
  52107. afterRender() {
  52108. if (typeof core_api.settings.get('xhr_user_search_url') === 'string') {
  52109. this.initXHRAutoComplete();
  52110. } else {
  52111. this.initJIDAutoComplete();
  52112. }
  52113. const jid_input = this.el.querySelector('input[name="jid"]');
  52114. this.el.addEventListener('shown.bs.modal', () => jid_input.focus(), false);
  52115. },
  52116. initJIDAutoComplete() {
  52117. if (!core_api.settings.get('autocomplete_add_contact')) {
  52118. return;
  52119. }
  52120. const el = this.el.querySelector('.suggestion-box__jid').parentElement;
  52121. this.jid_auto_complete = new shared_converse.AutoComplete(el, {
  52122. 'data': (text, input) => `${input.slice(0, input.indexOf("@"))}@${text}`,
  52123. 'filter': shared_converse.FILTER_STARTSWITH,
  52124. 'list': [...new Set(shared_converse.roster.map(item => add_contact_Strophe.getDomainFromJid(item.get('jid'))))]
  52125. });
  52126. },
  52127. initXHRAutoComplete() {
  52128. if (!core_api.settings.get('autocomplete_add_contact')) {
  52129. return this.initXHRFetch();
  52130. }
  52131. const el = this.el.querySelector('.suggestion-box__name').parentElement;
  52132. this.name_auto_complete = new shared_converse.AutoComplete(el, {
  52133. 'auto_evaluate': false,
  52134. 'filter': shared_converse.FILTER_STARTSWITH,
  52135. 'list': []
  52136. });
  52137. const xhr = new window.XMLHttpRequest(); // `open` must be called after `onload` for mock/testing purposes.
  52138. xhr.onload = () => {
  52139. if (xhr.responseText) {
  52140. const r = xhr.responseText;
  52141. this.name_auto_complete.list = JSON.parse(r).map(i => ({
  52142. 'label': i.fullname || i.jid,
  52143. 'value': i.jid
  52144. }));
  52145. this.name_auto_complete.auto_completing = true;
  52146. this.name_auto_complete.evaluate();
  52147. }
  52148. };
  52149. const input_el = this.el.querySelector('input[name="name"]');
  52150. input_el.addEventListener('input', lodash_es_debounce(() => {
  52151. xhr.open("GET", `${core_api.settings.get('xhr_user_search_url')}q=${encodeURIComponent(input_el.value)}`, true);
  52152. xhr.send();
  52153. }, 300));
  52154. this.name_auto_complete.on('suggestion-box-selectcomplete', ev => {
  52155. this.el.querySelector('input[name="name"]').value = ev.text.label;
  52156. this.el.querySelector('input[name="jid"]').value = ev.text.value;
  52157. });
  52158. },
  52159. initXHRFetch() {
  52160. this.xhr = new window.XMLHttpRequest();
  52161. this.xhr.onload = () => {
  52162. if (this.xhr.responseText) {
  52163. const r = this.xhr.responseText;
  52164. const list = JSON.parse(r).map(i => ({
  52165. 'label': i.fullname || i.jid,
  52166. 'value': i.jid
  52167. }));
  52168. if (list.length !== 1) {
  52169. const el = this.el.querySelector('.invalid-feedback');
  52170. el.textContent = __('Sorry, could not find a contact with that name');
  52171. add_contact_u.addClass('d-block', el);
  52172. return;
  52173. }
  52174. const jid = list[0].value;
  52175. if (this.validateSubmission(jid)) {
  52176. const form = this.el.querySelector('form');
  52177. const name = list[0].label;
  52178. this.afterSubmission(form, jid, name);
  52179. }
  52180. }
  52181. };
  52182. },
  52183. validateSubmission(jid) {
  52184. const el = this.el.querySelector('.invalid-feedback');
  52185. if (!jid || lodash_es_compact(jid.split('@')).length < 2) {
  52186. add_contact_u.addClass('is-invalid', this.el.querySelector('input[name="jid"]'));
  52187. add_contact_u.addClass('d-block', el);
  52188. return false;
  52189. } else if (shared_converse.roster.get(add_contact_Strophe.getBareJidFromJid(jid))) {
  52190. el.textContent = __('This contact has already been added');
  52191. add_contact_u.addClass('d-block', el);
  52192. return false;
  52193. }
  52194. add_contact_u.removeClass('d-block', el);
  52195. return true;
  52196. },
  52197. afterSubmission(form, jid, name) {
  52198. shared_converse.roster.addAndSubscribe(jid, name);
  52199. this.model.clear();
  52200. this.modal.hide();
  52201. },
  52202. addContactFromForm(ev) {
  52203. ev.preventDefault();
  52204. const data = new FormData(ev.target),
  52205. jid = (data.get('jid') || '').trim();
  52206. if (!jid && typeof core_api.settings.get('xhr_user_search_url') === 'string') {
  52207. const input_el = this.el.querySelector('input[name="name"]');
  52208. this.xhr.open("GET", `${core_api.settings.get('xhr_user_search_url')}q=${encodeURIComponent(input_el.value)}`, true);
  52209. this.xhr.send();
  52210. return;
  52211. }
  52212. if (this.validateSubmission(jid)) {
  52213. this.afterSubmission(ev.target, jid, data.get('name'));
  52214. }
  52215. }
  52216. });
  52217. shared_converse.AddContactModal = AddContactModal;
  52218. /* harmony default export */ const modals_add_contact = ((/* unused pure expression or super */ null && (AddContactModal)));
  52219. ;// CONCATENATED MODULE: ./src/plugins/rosterview/utils.js
  52220. function highlightRosterItem(chatbox) {
  52221. var _converse$roster, _converse$roster$get;
  52222. (_converse$roster = shared_converse.roster) === null || _converse$roster === void 0 ? void 0 : (_converse$roster$get = _converse$roster.get(chatbox.get('jid'))) === null || _converse$roster$get === void 0 ? void 0 : _converse$roster$get.trigger('highlight');
  52223. }
  52224. function toggleGroup(ev, name) {
  52225. var _ev$preventDefault;
  52226. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  52227. const collapsed = shared_converse.roster.state.get('collapsed_groups');
  52228. if (collapsed.includes(name)) {
  52229. shared_converse.roster.state.save('collapsed_groups', collapsed.filter(n => n !== name));
  52230. } else {
  52231. shared_converse.roster.state.save('collapsed_groups', [...collapsed, name]);
  52232. }
  52233. }
  52234. function isContactFiltered(contact, groupname) {
  52235. const filter = shared_converse.roster_filter;
  52236. const type = filter.get('filter_type');
  52237. const q = type === 'state' ? filter.get('chat_state').toLowerCase() : filter.get('filter_text').toLowerCase();
  52238. if (!q) return false;
  52239. if (type === 'state') {
  52240. const sticky_groups = [shared_converse.HEADER_REQUESTING_CONTACTS, shared_converse.HEADER_UNREAD];
  52241. if (sticky_groups.includes(groupname)) {
  52242. // When filtering by chat state, we still want to
  52243. // show sticky groups, even though they don't
  52244. // match the state in question.
  52245. return false;
  52246. } else if (q === 'unread_messages') {
  52247. return contact.get('num_unread') === 0;
  52248. } else if (q === 'online') {
  52249. return ["offline", "unavailable"].includes(contact.presence.get('show'));
  52250. } else {
  52251. return !contact.presence.get('show').includes(q);
  52252. }
  52253. } else if (type === 'contacts') {
  52254. return !contact.getFilterCriteria().includes(q);
  52255. }
  52256. }
  52257. function shouldShowContact(contact, groupname) {
  52258. const chat_status = contact.presence.get('show');
  52259. if (core_api.settings.get('hide_offline_users') && chat_status === 'offline') {
  52260. // If pending or requesting, show
  52261. if (contact.get('ask') === 'subscribe' || contact.get('subscription') === 'from' || contact.get('requesting') === true) {
  52262. return !isContactFiltered(contact, groupname);
  52263. }
  52264. return false;
  52265. }
  52266. return !isContactFiltered(contact, groupname);
  52267. }
  52268. function shouldShowGroup(group) {
  52269. const filter = shared_converse.roster_filter;
  52270. const type = filter.get('filter_type');
  52271. if (type === 'groups') {
  52272. var _filter$get;
  52273. const q = (_filter$get = filter.get('filter_text')) === null || _filter$get === void 0 ? void 0 : _filter$get.toLowerCase();
  52274. if (!q) {
  52275. return true;
  52276. }
  52277. if (!group.toLowerCase().includes(q)) {
  52278. return false;
  52279. }
  52280. }
  52281. return true;
  52282. }
  52283. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/group.js
  52284. const {
  52285. u: group_u
  52286. } = core_converse.env;
  52287. function renderContact(contact) {
  52288. const jid = contact.get('jid');
  52289. const extra_classes = [];
  52290. if (isUniView()) {
  52291. const chatbox = shared_converse.chatboxes.get(jid);
  52292. if (chatbox && !chatbox.get('hidden')) {
  52293. extra_classes.push('open');
  52294. }
  52295. }
  52296. const ask = contact.get('ask');
  52297. const requesting = contact.get('requesting');
  52298. const subscription = contact.get('subscription');
  52299. if (ask === 'subscribe' || subscription === 'from') {
  52300. /* ask === 'subscribe'
  52301. * Means we have asked to subscribe to them.
  52302. *
  52303. * subscription === 'from'
  52304. * They are subscribed to us, but not vice versa.
  52305. * We assume that there is a pending subscription
  52306. * from us to them (otherwise we're in a state not
  52307. * supported by converse.js).
  52308. *
  52309. * So in both cases the user is a "pending" contact.
  52310. */
  52311. extra_classes.push('pending-xmpp-contact');
  52312. } else if (requesting === true) {
  52313. extra_classes.push('requesting-xmpp-contact');
  52314. } else if (subscription === 'both' || subscription === 'to' || group_u.isSameBareJID(jid, shared_converse.connection.jid)) {
  52315. extra_classes.push('current-xmpp-contact');
  52316. extra_classes.push(subscription);
  52317. extra_classes.push(contact.presence.get('show'));
  52318. }
  52319. return $`
  52320. <li class="list-item d-flex controlbox-padded ${extra_classes.join(' ')}" data-status="${contact.presence.get('show')}">
  52321. <converse-roster-contact .model=${contact}></converse-roster-contact>
  52322. </li>`;
  52323. }
  52324. /* harmony default export */ const group = (o => {
  52325. const i18n_title = __('Click to hide these contacts');
  52326. const collapsed = shared_converse.roster.state.get('collapsed_groups');
  52327. return $`
  52328. <div class="roster-group" data-group="${o.name}">
  52329. <a href="#" class="list-toggle group-toggle controlbox-padded" title="${i18n_title}" @click=${ev => toggleGroup(ev, o.name)}>
  52330. <converse-icon color="var(--chat-head-color-dark)" size="1em" class="fa ${collapsed.includes(o.name) ? 'fa-caret-right' : 'fa-caret-down'}"></converse-icon> ${o.name}
  52331. </a>
  52332. <ul class="items-list roster-group-contacts ${collapsed.includes(o.name) ? 'collapsed' : ''}" data-group="${o.name}">
  52333. ${o.contacts.map(renderContact)}
  52334. </ul>
  52335. </div>`;
  52336. });
  52337. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/roster.js
  52338. function populateContactsMap(contacts_map, contact) {
  52339. if (contact.get('ask') === 'subscribe') {
  52340. const name = shared_converse.HEADER_PENDING_CONTACTS;
  52341. contacts_map[name] ? contacts_map[name].push(contact) : contacts_map[name] = [contact];
  52342. } else if (contact.get('requesting')) {
  52343. const name = shared_converse.HEADER_REQUESTING_CONTACTS;
  52344. contacts_map[name] ? contacts_map[name].push(contact) : contacts_map[name] = [contact];
  52345. } else {
  52346. let contact_groups;
  52347. if (core_api.settings.get('roster_groups')) {
  52348. contact_groups = contact.get('groups');
  52349. contact_groups = contact_groups.length === 0 ? [shared_converse.HEADER_UNGROUPED] : contact_groups;
  52350. } else {
  52351. contact_groups = [shared_converse.HEADER_CURRENT_CONTACTS];
  52352. }
  52353. for (const name of contact_groups) {
  52354. contacts_map[name] ? contacts_map[name].push(contact) : contacts_map[name] = [contact];
  52355. }
  52356. }
  52357. if (contact.get('num_unread')) {
  52358. const name = shared_converse.HEADER_UNREAD;
  52359. contacts_map[name] ? contacts_map[name].push(contact) : contacts_map[name] = [contact];
  52360. }
  52361. return contacts_map;
  52362. }
  52363. /* harmony default export */ const roster = (el => {
  52364. const i18n_heading_contacts = __('Contacts');
  52365. const i18n_title_add_contact = __('Add a contact');
  52366. const i18n_title_sync_contacts = __('Re-sync your contacts');
  52367. const roster = shared_converse.roster || [];
  52368. const contacts_map = roster.reduce((acc, contact) => populateContactsMap(acc, contact), {});
  52369. const groupnames = Object.keys(contacts_map).filter(shouldShowGroup);
  52370. groupnames.sort(groupsComparator);
  52371. return $`
  52372. <div class="d-flex controlbox-padded">
  52373. <span class="w-100 controlbox-heading controlbox-heading--contacts">${i18n_heading_contacts}</span>
  52374. <a class="controlbox-heading__btn sync-contacts" @click=${ev => el.syncContacts(ev)} title="${i18n_title_sync_contacts}">
  52375. <converse-icon class="fa fa-sync right ${el.syncing_contacts ? 'fa-spin' : ''}" size="1em"></converse-icon>
  52376. </a>
  52377. ${core_api.settings.get('allow_contact_requests') ? $`
  52378. <a class="controlbox-heading__btn add-contact"
  52379. @click=${ev => el.showAddContactModal(ev)}
  52380. title="${i18n_title_add_contact}"
  52381. data-toggle="modal"
  52382. data-target="#add-contact-modal">
  52383. <converse-icon class="fa fa-user-plus right" size="1.25em"></converse-icon>
  52384. </a>` : ''}
  52385. </div>
  52386. <converse-roster-filter></converse-roster-filter>
  52387. <div class="list-container roster-contacts">
  52388. ${repeat_c(groupnames, n => n, name => {
  52389. const contacts = contacts_map[name].filter(c => shouldShowContact(c, name));
  52390. contacts.sort(contactsComparator);
  52391. if (contacts.length) {
  52392. return group({
  52393. 'contacts': contacts,
  52394. 'name': name
  52395. });
  52396. } else {
  52397. return '';
  52398. }
  52399. })}
  52400. </div>
  52401. `;
  52402. });
  52403. ;// CONCATENATED MODULE: ./src/plugins/rosterview/rosterview.js
  52404. /**
  52405. * @class
  52406. * @namespace _converse.RosterView
  52407. * @memberOf _converse
  52408. */
  52409. class RosterView extends CustomElement {
  52410. async initialize() {
  52411. await core_api.waitUntil('rosterInitialized');
  52412. this.listenTo(shared_converse, 'rosterContactsFetched', this.requestUpdate);
  52413. this.listenTo(shared_converse.presences, 'change:show', this.requestUpdate);
  52414. this.listenTo(shared_converse.roster, 'add', this.requestUpdate);
  52415. this.listenTo(shared_converse.roster, 'destroy', this.requestUpdate);
  52416. this.listenTo(shared_converse.roster, 'remove', this.requestUpdate);
  52417. this.listenTo(shared_converse.roster, 'change', this.requestUpdate);
  52418. this.listenTo(shared_converse.roster.state, 'change', this.requestUpdate);
  52419. /**
  52420. * Triggered once the _converse.RosterView instance has been created and initialized.
  52421. * @event _converse#rosterViewInitialized
  52422. * @example _converse.api.listen.on('rosterViewInitialized', () => { ... });
  52423. */
  52424. core_api.trigger('rosterViewInitialized');
  52425. }
  52426. firstUpdated() {
  52427. this.listenToRosterFilter();
  52428. }
  52429. render() {
  52430. return roster(this);
  52431. }
  52432. listenToRosterFilter() {
  52433. this.filter_view = this.querySelector('converse-roster-filter');
  52434. this.filter_view.addEventListener('update', () => this.requestUpdate());
  52435. }
  52436. showAddContactModal(ev) {
  52437. // eslint-disable-line class-methods-use-this
  52438. core_api.modal.show(shared_converse.AddContactModal, {
  52439. 'model': new Model()
  52440. }, ev);
  52441. }
  52442. async syncContacts(ev) {
  52443. // eslint-disable-line class-methods-use-this
  52444. ev.preventDefault();
  52445. this.syncing_contacts = true;
  52446. this.requestUpdate();
  52447. shared_converse.roster.data.save('version', null);
  52448. await shared_converse.roster.fetchFromServer();
  52449. core_api.user.presence.send();
  52450. this.syncing_contacts = false;
  52451. this.requestUpdate();
  52452. }
  52453. }
  52454. core_api.elements.define('converse-roster', RosterView);
  52455. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/pending_contact.js
  52456. const tpl_pending_contact = o => $`<span class="pending-contact-name" title="JID: ${o.jid}">${o.display_name}</span>`;
  52457. /* harmony default export */ const pending_contact = (o => {
  52458. const i18n_remove = __('Click to remove %1$s as a contact', o.display_name);
  52459. return $`
  52460. ${core_api.settings.get('allow_chat_pending_contacts') ? $`<a class="list-item-link open-chat w-100" href="#" @click=${o.openChat}>${tpl_pending_contact(o)}</a>` : tpl_pending_contact(o)}
  52461. <a class="list-item-action remove-xmpp-contact far fa-trash-alt" @click=${o.removeContact} title="${i18n_remove}" href="#"></a>`;
  52462. });
  52463. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/requesting_contact.js
  52464. const tpl_requesting_contact = o => $`<span class="req-contact-name w-100" title="JID: ${o.jid}">${o.display_name}</span>`;
  52465. /* harmony default export */ const requesting_contact = (o => $`
  52466. ${core_api.settings.get('allow_chat_pending_contacts') ? $`<a class="open-chat w-100" href="#" @click=${o.openChat}>${tpl_requesting_contact(o)}</a>` : tpl_requesting_contact(o)}
  52467. <a class="accept-xmpp-request list-item-action list-item-action--visible fa fa-check"
  52468. @click=${o.acceptRequest}
  52469. aria-label="${o.desc_accept}" title="${o.desc_accept}" href="#"></a>
  52470. <a class="decline-xmpp-request list-item-action list-item-action--visible fa fa-times"
  52471. @click=${o.declineRequest}
  52472. aria-label="${o.desc_decline}" title="${o.desc_decline}" href="#"></a>`);
  52473. ;// CONCATENATED MODULE: ./src/plugins/rosterview/constants.js
  52474. const STATUSES = {
  52475. 'dnd': __('This contact is busy'),
  52476. 'online': __('This contact is online'),
  52477. 'offline': __('This contact is offline'),
  52478. 'unavailable': __('This contact is unavailable'),
  52479. 'xa': __('This contact is away for an extended period'),
  52480. 'away': __('This contact is away')
  52481. };
  52482. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/roster_item.js
  52483. const tpl_remove_link = (el, item) => {
  52484. const display_name = item.getDisplayName();
  52485. const i18n_remove = __('Click to remove %1$s as a contact', display_name);
  52486. return $`
  52487. <a class="list-item-action remove-xmpp-contact" @click=${el.removeContact} title="${i18n_remove}" href="#">
  52488. <converse-icon class="fa fa-trash-alt" size="1.5em"></converse-icon>
  52489. </a>
  52490. `;
  52491. };
  52492. /* harmony default export */ const roster_item = ((el, item) => {
  52493. var _el$model$vcard, _el$model$vcard2;
  52494. const show = item.presence.get('show') || 'offline';
  52495. let classes, color;
  52496. if (show === 'online') {
  52497. [classes, color] = ['fa fa-circle', 'chat-status-online'];
  52498. } else if (show === 'dnd') {
  52499. [classes, color] = ['fa fa-minus-circle', 'chat-status-busy'];
  52500. } else if (show === 'away') {
  52501. [classes, color] = ['fa fa-circle', 'chat-status-away'];
  52502. } else {
  52503. [classes, color] = ['fa fa-circle', 'subdued-color'];
  52504. }
  52505. const desc_status = STATUSES[show];
  52506. const num_unread = item.get('num_unread') || 0;
  52507. const display_name = item.getDisplayName();
  52508. const i18n_chat = __('Click to chat with %1$s (XMPP address: %2$s)', display_name, el.model.get('jid'));
  52509. return $`
  52510. <a class="list-item-link cbox-list-item open-chat ${num_unread ? 'unread-msgs' : ''}" title="${i18n_chat}" href="#" @click=${el.openChat}>
  52511. <span>
  52512. <converse-avatar
  52513. class="avatar"
  52514. .data=${(_el$model$vcard = el.model.vcard) === null || _el$model$vcard === void 0 ? void 0 : _el$model$vcard.attributes}
  52515. nonce=${(_el$model$vcard2 = el.model.vcard) === null || _el$model$vcard2 === void 0 ? void 0 : _el$model$vcard2.get('vcard_updated')}
  52516. height="30" width="30"></converse-avatar>
  52517. <converse-icon
  52518. title="${desc_status}"
  52519. color="var(--${color})"
  52520. size="1em"
  52521. class="${classes} chat-status chat-status--avatar"></converse-icon>
  52522. </span>
  52523. ${num_unread ? $`<span class="msgs-indicator">${num_unread}</span>` : ''}
  52524. <span class="contact-name contact-name--${el.show} ${num_unread ? 'unread-msgs' : ''}">${display_name}</span>
  52525. </a>
  52526. ${core_api.settings.get('allow_contact_removal') ? tpl_remove_link(el, item) : ''}`;
  52527. });
  52528. ;// CONCATENATED MODULE: ./src/plugins/rosterview/contactview.js
  52529. const contactview_u = core_converse.env.utils;
  52530. class contactview_RosterContact extends CustomElement {
  52531. static get properties() {
  52532. return {
  52533. model: {
  52534. type: Object
  52535. }
  52536. };
  52537. }
  52538. initialize() {
  52539. this.listenTo(this.model, "change", () => this.requestUpdate());
  52540. this.listenTo(this.model, "highlight", () => this.requestUpdate());
  52541. this.listenTo(this.model, 'vcard:add', () => this.requestUpdate());
  52542. this.listenTo(this.model, 'vcard:change', () => this.requestUpdate());
  52543. }
  52544. render() {
  52545. const ask = this.model.get('ask');
  52546. const requesting = this.model.get('requesting');
  52547. const subscription = this.model.get('subscription');
  52548. const jid = this.model.get('jid');
  52549. if (ask === 'subscribe' || subscription === 'from') {
  52550. /* ask === 'subscribe'
  52551. * Means we have asked to subscribe to them.
  52552. *
  52553. * subscription === 'from'
  52554. * They are subscribed to use, but not vice versa.
  52555. * We assume that there is a pending subscription
  52556. * from us to them (otherwise we're in a state not
  52557. * supported by converse.js).
  52558. *
  52559. * So in both cases the user is a "pending" contact.
  52560. */
  52561. const display_name = this.model.getDisplayName();
  52562. return pending_contact(Object.assign(this.model.toJSON(), {
  52563. display_name,
  52564. 'openChat': ev => this.openChat(ev),
  52565. 'removeContact': ev => this.removeContact(ev)
  52566. }));
  52567. } else if (requesting === true) {
  52568. const display_name = this.model.getDisplayName();
  52569. return requesting_contact(Object.assign(this.model.toJSON(), {
  52570. display_name,
  52571. 'openChat': ev => this.openChat(ev),
  52572. 'acceptRequest': ev => this.acceptRequest(ev),
  52573. 'declineRequest': ev => this.declineRequest(ev),
  52574. 'desc_accept': __("Click to accept the contact request from %1$s", display_name),
  52575. 'desc_decline': __("Click to decline the contact request from %1$s", display_name),
  52576. 'allow_chat_pending_contacts': core_api.settings.get('allow_chat_pending_contacts')
  52577. }));
  52578. } else if (subscription === 'both' || subscription === 'to' || contactview_u.isSameBareJID(jid, shared_converse.connection.jid)) {
  52579. return this.renderRosterItem(this.model);
  52580. }
  52581. }
  52582. renderRosterItem(item) {
  52583. return roster_item(this, item);
  52584. }
  52585. openChat(ev) {
  52586. var _ev$preventDefault;
  52587. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault = ev.preventDefault) === null || _ev$preventDefault === void 0 ? void 0 : _ev$preventDefault.call(ev);
  52588. this.model.openChat();
  52589. }
  52590. removeContact(ev) {
  52591. var _ev$preventDefault2;
  52592. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault2 = ev.preventDefault) === null || _ev$preventDefault2 === void 0 ? void 0 : _ev$preventDefault2.call(ev);
  52593. if (!core_api.settings.get('allow_contact_removal')) {
  52594. return;
  52595. }
  52596. if (!confirm(__("Are you sure you want to remove this contact?"))) {
  52597. return;
  52598. }
  52599. try {
  52600. this.model.removeFromRoster();
  52601. if (this.model.collection) {
  52602. // The model might have already been removed as
  52603. // result of a roster push.
  52604. this.model.destroy();
  52605. }
  52606. } catch (e) {
  52607. headless_log.error(e);
  52608. core_api.alert('error', __('Error'), [__('Sorry, there was an error while trying to remove %1$s as a contact.', this.model.getDisplayName())]);
  52609. }
  52610. }
  52611. async acceptRequest(ev) {
  52612. var _ev$preventDefault3;
  52613. ev === null || ev === void 0 ? void 0 : (_ev$preventDefault3 = ev.preventDefault) === null || _ev$preventDefault3 === void 0 ? void 0 : _ev$preventDefault3.call(ev);
  52614. await shared_converse.roster.sendContactAddIQ(this.model.get('jid'), this.model.getFullname(), []);
  52615. this.model.authorize().subscribe();
  52616. }
  52617. declineRequest(ev) {
  52618. if (ev && ev.preventDefault) {
  52619. ev.preventDefault();
  52620. }
  52621. const result = confirm(__("Are you sure you want to decline this contact request?"));
  52622. if (result === true) {
  52623. this.model.unauthorize().destroy();
  52624. }
  52625. return this;
  52626. }
  52627. }
  52628. core_api.elements.define('converse-roster-contact', contactview_RosterContact);
  52629. ;// CONCATENATED MODULE: ./src/plugins/rosterview/templates/roster_filter.js
  52630. /* harmony default export */ const roster_filter = (o => {
  52631. const i18n_placeholder = __('Filter');
  52632. const title_contact_filter = __('Filter by contact name');
  52633. const title_group_filter = __('Filter by group name');
  52634. const title_status_filter = __('Filter by status');
  52635. const label_any = __('Any');
  52636. const label_unread_messages = __('Unread');
  52637. const label_online = __('Online');
  52638. const label_chatty = __('Chatty');
  52639. const label_busy = __('Busy');
  52640. const label_away = __('Away');
  52641. const label_xa = __('Extended Away');
  52642. const label_offline = __('Offline');
  52643. return $`
  52644. <form class="controlbox-padded roster-filter-form input-button-group ${!o.visible ? 'hidden' : 'fade-in'}"
  52645. @submit=${o.submitFilter}>
  52646. <div class="form-inline flex-nowrap">
  52647. <div class="filter-by d-flex flex-nowrap">
  52648. <converse-icon size="1em" @click=${o.changeTypeFilter} class="fa fa-user clickable ${o.filter_type === 'contacts' ? 'selected' : ''}" data-type="contacts" title="${title_contact_filter}"></converse-icon>
  52649. <converse-icon size="1em" @click=${o.changeTypeFilter} class="fa fa-users clickable ${o.filter_type === 'groups' ? 'selected' : ''}" data-type="groups" title="${title_group_filter}"></converse-icon>
  52650. <converse-icon size="1em" @click=${o.changeTypeFilter} class="fa fa-circle clickable ${o.filter_type === 'state' ? 'selected' : ''}" data-type="state" title="${title_status_filter}"></converse-icon>
  52651. </div>
  52652. <div class="btn-group">
  52653. <input .value="${o.filter_text || ''}"
  52654. @keydown=${o.liveFilter}
  52655. class="roster-filter form-control ${o.filter_type === 'state' ? 'hidden' : ''}"
  52656. placeholder="${i18n_placeholder}"/>
  52657. <converse-icon size="1em" class="fa fa-times clear-input ${!o.filter_text || o.filter_type === 'state' ? 'hidden' : ''}"
  52658. @click=${o.clearFilter}>
  52659. </converse-icon>
  52660. </div>
  52661. <select class="form-control state-type ${o.filter_type !== 'state' ? 'hidden' : ''}"
  52662. @change=${o.changeChatStateFilter}>
  52663. <option value="">${label_any}</option>
  52664. <option ?selected=${o.chat_state === 'unread_messages'} value="unread_messages">${label_unread_messages}</option>
  52665. <option ?selected=${o.chat_state === 'online'} value="online">${label_online}</option>
  52666. <option ?selected=${o.chat_state === 'chat'} value="chat">${label_chatty}</option>
  52667. <option ?selected=${o.chat_state === 'dnd'} value="dnd">${label_busy}</option>
  52668. <option ?selected=${o.chat_state === 'away'} value="away">${label_away}</option>
  52669. <option ?selected=${o.chat_state === 'xa'} value="xa">${label_xa}</option>
  52670. <option ?selected=${o.chat_state === 'offline'} value="offline">${label_offline}</option>
  52671. </select>
  52672. </div>
  52673. </form>`;
  52674. });
  52675. ;// CONCATENATED MODULE: ./src/plugins/rosterview/filterview.js
  52676. class RosterFilterView extends CustomElement {
  52677. async initialize() {
  52678. await core_api.waitUntil('rosterInitialized');
  52679. this.model = shared_converse.roster_filter;
  52680. this.liveFilter = lodash_es_debounce(() => {
  52681. this.model.save({
  52682. 'filter_text': this.querySelector('.roster-filter').value
  52683. });
  52684. }, 250);
  52685. this.listenTo(shared_converse, 'rosterContactsFetched', () => this.requestUpdate());
  52686. this.listenTo(shared_converse.presences, 'change:show', () => this.requestUpdate());
  52687. this.listenTo(shared_converse.roster, "add", () => this.requestUpdate());
  52688. this.listenTo(shared_converse.roster, "destroy", () => this.requestUpdate());
  52689. this.listenTo(shared_converse.roster, "remove", () => this.requestUpdate());
  52690. this.listenTo(this.model, 'change', this.dispatchUpdateEvent);
  52691. this.listenTo(this.model, 'change', () => this.requestUpdate());
  52692. this.requestUpdate();
  52693. }
  52694. render() {
  52695. return this.model ? roster_filter(Object.assign(this.model.toJSON(), {
  52696. visible: this.shouldBeVisible(),
  52697. changeChatStateFilter: ev => this.changeChatStateFilter(ev),
  52698. changeTypeFilter: ev => this.changeTypeFilter(ev),
  52699. clearFilter: ev => this.clearFilter(ev),
  52700. liveFilter: ev => this.liveFilter(ev),
  52701. submitFilter: ev => this.submitFilter(ev)
  52702. })) : '';
  52703. }
  52704. dispatchUpdateEvent() {
  52705. this.dispatchEvent(new CustomEvent('update', {
  52706. 'detail': this.model.changed
  52707. }));
  52708. }
  52709. changeChatStateFilter(ev) {
  52710. ev && ev.preventDefault();
  52711. this.model.save({
  52712. 'chat_state': this.querySelector('.state-type').value
  52713. });
  52714. }
  52715. changeTypeFilter(ev) {
  52716. var _ancestor;
  52717. ev && ev.preventDefault();
  52718. const type = ((_ancestor = ancestor(ev.target, 'converse-icon')) === null || _ancestor === void 0 ? void 0 : _ancestor.dataset.type) || 'contacts';
  52719. if (type === 'state') {
  52720. this.model.save({
  52721. 'filter_type': type,
  52722. 'chat_state': this.querySelector('.state-type').value
  52723. });
  52724. } else {
  52725. this.model.save({
  52726. 'filter_type': type,
  52727. 'filter_text': this.querySelector('.roster-filter').value
  52728. });
  52729. }
  52730. }
  52731. submitFilter(ev) {
  52732. ev && ev.preventDefault();
  52733. this.liveFilter();
  52734. }
  52735. /**
  52736. * Returns true if the filter is enabled (i.e. if the user
  52737. * has added values to the filter).
  52738. * @private
  52739. * @method _converse.RosterFilterView#isActive
  52740. */
  52741. isActive() {
  52742. return this.model.get('filter_type') === 'state' || this.model.get('filter_text');
  52743. }
  52744. shouldBeVisible() {
  52745. var _converse$roster;
  52746. return ((_converse$roster = shared_converse.roster) === null || _converse$roster === void 0 ? void 0 : _converse$roster.length) >= 5 || this.isActive();
  52747. }
  52748. clearFilter(ev) {
  52749. ev && ev.preventDefault();
  52750. this.model.save({
  52751. 'filter_text': ''
  52752. });
  52753. }
  52754. }
  52755. core_api.elements.define('converse-roster-filter', RosterFilterView);
  52756. // EXTERNAL MODULE: ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[2].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[2].use[3]!./node_modules/mini-css-extract-plugin/dist/loader.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/postcss-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/plugins/rosterview/styles/roster.scss
  52757. var styles_roster = __webpack_require__(1984);
  52758. ;// CONCATENATED MODULE: ./src/plugins/rosterview/styles/roster.scss
  52759. var roster_options = {};
  52760. roster_options.styleTagTransform = (styleTagTransform_default());
  52761. roster_options.setAttributes = (setAttributesWithoutAttributes_default());
  52762. roster_options.insert = insertBySelector_default().bind(null, "head");
  52763. roster_options.domAPI = (styleDomAPI_default());
  52764. roster_options.insertStyleElement = (insertStyleElement_default());
  52765. var roster_update = injectStylesIntoStyleTag_default()(styles_roster/* default */.Z, roster_options);
  52766. /* harmony default export */ const rosterview_styles_roster = (styles_roster/* default */.Z && styles_roster/* default.locals */.Z.locals ? styles_roster/* default.locals */.Z.locals : undefined);
  52767. ;// CONCATENATED MODULE: ./src/plugins/rosterview/index.js
  52768. /**
  52769. * @copyright 2022, the Converse.js contributors
  52770. * @license Mozilla Public License (MPLv2)
  52771. */
  52772. core_converse.plugins.add('converse-rosterview', {
  52773. dependencies: ["converse-roster", "converse-modal", "converse-chatboxviews"],
  52774. initialize() {
  52775. core_api.settings.extend({
  52776. 'autocomplete_add_contact': true,
  52777. 'allow_chat_pending_contacts': true,
  52778. 'allow_contact_removal': true,
  52779. 'hide_offline_users': false,
  52780. 'roster_groups': true,
  52781. 'xhr_user_search_url': null
  52782. });
  52783. core_api.promises.add('rosterViewInitialized');
  52784. shared_converse.RosterFilter = RosterFilter;
  52785. shared_converse.RosterFilterView = RosterFilterView;
  52786. shared_converse.RosterContactView = contactview_RosterContact;
  52787. /* -------- Event Handlers ----------- */
  52788. core_api.listen.on('chatBoxesInitialized', () => {
  52789. shared_converse.chatboxes.on('destroy', chatbox => highlightRosterItem(chatbox));
  52790. shared_converse.chatboxes.on('change:hidden', chatbox => highlightRosterItem(chatbox));
  52791. });
  52792. core_api.listen.on('afterTearDown', () => {
  52793. var _converse$rotergroups;
  52794. return (_converse$rotergroups = shared_converse.rotergroups) === null || _converse$rotergroups === void 0 ? void 0 : _converse$rotergroups.off().reset();
  52795. });
  52796. }
  52797. });
  52798. ;// CONCATENATED MODULE: ./src/converse.js
  52799. /**
  52800. * @description Converse.js (A browser based XMPP chat client)
  52801. * @copyright 2021, The Converse developers
  52802. * @license Mozilla Public License (MPLv2)
  52803. */
  52804. /* START: Removable plugins
  52805. * ------------------------
  52806. * Any of the following plugin imports may be removed if the plugin is not needed
  52807. */
  52808. // Views for XEP-0048 Bookmarks
  52809. // Renders standalone chat boxes for single user chat
  52810. // The control box
  52811. // Allows chat boxes to be resized by dragging them
  52812. // Allows chat boxes to be minimized
  52813. // Views related to MUC
  52814. // XEP-0357 Push Notifications
  52815. // XEP-0077 In-band registration
  52816. // Show currently open chat rooms
  52817. /* END: Removable components */
  52818. shared_converse.CustomElement = CustomElement;
  52819. const initialize = core_converse.initialize;
  52820. core_converse.initialize = function (settings, callback) {
  52821. if (Array.isArray(settings.whitelisted_plugins)) {
  52822. settings.whitelisted_plugins = settings.whitelisted_plugins.concat(VIEW_PLUGINS);
  52823. } else {
  52824. settings.whitelisted_plugins = VIEW_PLUGINS;
  52825. }
  52826. return initialize(settings, callback);
  52827. };
  52828. /* harmony default export */ const src_converse = (core_converse);
  52829. /***/ }),
  52830. /***/ 6151:
  52831. /***/ (function(module, exports, __webpack_require__) {
  52832. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Native Javascript for Bootstrap 4 v2.0.27 | © dnp_theme | MIT-License
  52833. (function (root, factory) {
  52834. if (true) {
  52835. // AMD support:
  52836. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  52837. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  52838. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  52839. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  52840. } else { var bsn; }
  52841. }(this, function () {
  52842. /* Native Javascript for Bootstrap 4 | Internal Utility Functions
  52843. ----------------------------------------------------------------*/
  52844. "use strict";
  52845. // globals
  52846. var globalObject = typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g : this||window,
  52847. DOC = document, HTML = DOC.documentElement, body = 'body', // allow the library to be used in <head>
  52848. // Native Javascript for Bootstrap Global Object
  52849. BSN = globalObject.BSN = {},
  52850. supports = BSN.supports = [],
  52851. // function toggle attributes
  52852. dataToggle = 'data-toggle',
  52853. dataDismiss = 'data-dismiss',
  52854. dataSpy = 'data-spy',
  52855. dataRide = 'data-ride',
  52856. // components
  52857. stringAlert = 'Alert',
  52858. stringButton = 'Button',
  52859. stringCarousel = 'Carousel',
  52860. stringCollapse = 'Collapse',
  52861. stringDropdown = 'Dropdown',
  52862. stringModal = 'Modal',
  52863. stringPopover = 'Popover',
  52864. stringScrollSpy = 'ScrollSpy',
  52865. stringTab = 'Tab',
  52866. stringTooltip = 'Tooltip',
  52867. stringToast = 'Toast',
  52868. // options DATA API
  52869. dataAutohide = 'data-autohide',
  52870. databackdrop = 'data-backdrop',
  52871. dataKeyboard = 'data-keyboard',
  52872. dataTarget = 'data-target',
  52873. dataInterval = 'data-interval',
  52874. dataHeight = 'data-height',
  52875. dataPause = 'data-pause',
  52876. dataTitle = 'data-title',
  52877. dataOriginalTitle = 'data-original-title',
  52878. dataDismissible = 'data-dismissible',
  52879. dataTrigger = 'data-trigger',
  52880. dataAnimation = 'data-animation',
  52881. dataContainer = 'data-container',
  52882. dataPlacement = 'data-placement',
  52883. dataDelay = 'data-delay',
  52884. // option keys
  52885. backdrop = 'backdrop', keyboard = 'keyboard', delay = 'delay',
  52886. content = 'content', target = 'target', currentTarget = 'currentTarget',
  52887. interval = 'interval', pause = 'pause', animation = 'animation',
  52888. placement = 'placement', container = 'container',
  52889. // box model
  52890. offsetTop = 'offsetTop', offsetBottom = 'offsetBottom',
  52891. offsetLeft = 'offsetLeft',
  52892. scrollTop = 'scrollTop', scrollLeft = 'scrollLeft',
  52893. clientWidth = 'clientWidth', clientHeight = 'clientHeight',
  52894. offsetWidth = 'offsetWidth', offsetHeight = 'offsetHeight',
  52895. innerWidth = 'innerWidth', innerHeight = 'innerHeight',
  52896. scrollHeight = 'scrollHeight', scrollWidth = 'scrollWidth',
  52897. height = 'height',
  52898. // aria
  52899. ariaExpanded = 'aria-expanded',
  52900. ariaHidden = 'aria-hidden',
  52901. ariaSelected = 'aria-selected',
  52902. // event names
  52903. clickEvent = 'click',
  52904. focusEvent = 'focus',
  52905. hoverEvent = 'hover',
  52906. keydownEvent = 'keydown',
  52907. keyupEvent = 'keyup',
  52908. resizeEvent = 'resize', // passive
  52909. scrollEvent = 'scroll', // passive
  52910. mouseHover = ('onmouseleave' in DOC) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ],
  52911. // touch since 2.0.26
  52912. touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove' }, // passive
  52913. // originalEvents
  52914. showEvent = 'show',
  52915. shownEvent = 'shown',
  52916. hideEvent = 'hide',
  52917. hiddenEvent = 'hidden',
  52918. closeEvent = 'close',
  52919. closedEvent = 'closed',
  52920. slidEvent = 'slid',
  52921. slideEvent = 'slide',
  52922. changeEvent = 'change',
  52923. // other
  52924. getAttribute = 'getAttribute',
  52925. setAttribute = 'setAttribute',
  52926. hasAttribute = 'hasAttribute',
  52927. createElement = 'createElement',
  52928. appendChild = 'appendChild',
  52929. innerHTML = 'innerHTML',
  52930. getElementsByTagName = 'getElementsByTagName',
  52931. preventDefault = 'preventDefault',
  52932. getBoundingClientRect = 'getBoundingClientRect',
  52933. querySelectorAll = 'querySelectorAll',
  52934. getElementsByCLASSNAME = 'getElementsByClassName',
  52935. getComputedStyle = 'getComputedStyle',
  52936. indexOf = 'indexOf',
  52937. parentNode = 'parentNode',
  52938. length = 'length',
  52939. toLowerCase = 'toLowerCase',
  52940. Transition = 'Transition',
  52941. Duration = 'Duration',
  52942. Webkit = 'Webkit',
  52943. style = 'style',
  52944. push = 'push',
  52945. tabindex = 'tabindex',
  52946. contains = 'contains',
  52947. active = 'active',
  52948. showClass = 'show',
  52949. collapsing = 'collapsing',
  52950. disabled = 'disabled',
  52951. loading = 'loading',
  52952. left = 'left',
  52953. right = 'right',
  52954. top = 'top',
  52955. bottom = 'bottom',
  52956. // tooltip / popover
  52957. tipPositions = /\b(top|bottom|left|right)+/,
  52958. // modal
  52959. modalOverlay = 0,
  52960. fixedTop = 'fixed-top',
  52961. fixedBottom = 'fixed-bottom',
  52962. // transitionEnd since 2.0.4
  52963. supportTransitions = Webkit+Transition in HTML[style] || Transition[toLowerCase]() in HTML[style],
  52964. transitionEndEvent = Webkit+Transition in HTML[style] ? Webkit[toLowerCase]()+Transition+'End' : Transition[toLowerCase]()+'end',
  52965. transitionDuration = Webkit+Duration in HTML[style] ? Webkit[toLowerCase]()+Transition+Duration : Transition[toLowerCase]()+Duration,
  52966. // set new focus element since 2.0.3
  52967. setFocus = function(element){
  52968. element.focus ? element.focus() : element.setActive();
  52969. },
  52970. // class manipulation, since 2.0.0 requires polyfill.js
  52971. addClass = function(element,classNAME) {
  52972. element.classList.add(classNAME);
  52973. },
  52974. removeClass = function(element,classNAME) {
  52975. element.classList.remove(classNAME);
  52976. },
  52977. hasClass = function(element,classNAME){ // since 2.0.0
  52978. return element.classList[contains](classNAME);
  52979. },
  52980. // selection methods
  52981. getElementsByClassName = function(element,classNAME) { // returns Array
  52982. return [].slice.call(element[getElementsByCLASSNAME]( classNAME ));
  52983. },
  52984. queryElement = function (selector, parent) {
  52985. var lookUp = parent ? parent : DOC;
  52986. return typeof selector === 'object' ? selector : lookUp.querySelector(selector);
  52987. },
  52988. getClosest = function (element, selector) { //element is the element and selector is for the closest parent element to find
  52989. // source http://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/
  52990. var firstChar = selector.charAt(0), selectorSubstring = selector.substr(1);
  52991. if ( firstChar === '.' ) {// If selector is a class
  52992. for ( ; element && element !== DOC; element = element[parentNode] ) { // Get closest match
  52993. if ( queryElement(selector,element[parentNode]) !== null && hasClass(element,selectorSubstring) ) { return element; }
  52994. }
  52995. } else if ( firstChar === '#' ) { // If selector is an ID
  52996. for ( ; element && element !== DOC; element = element[parentNode] ) { // Get closest match
  52997. if ( element.id === selectorSubstring ) { return element; }
  52998. }
  52999. }
  53000. return false;
  53001. },
  53002. // event attach jQuery style / trigger since 1.2.0
  53003. on = function (element, event, handler, options) {
  53004. options = options || false;
  53005. element.addEventListener(event, handler, options);
  53006. },
  53007. off = function(element, event, handler, options) {
  53008. options = options || false;
  53009. element.removeEventListener(event, handler, options);
  53010. },
  53011. one = function (element, event, handler, options) { // one since 2.0.4
  53012. on(element, event, function handlerWrapper(e){
  53013. handler(e);
  53014. off(element, event, handlerWrapper, options);
  53015. }, options);
  53016. },
  53017. // determine support for passive events
  53018. supportPassive = (function(){
  53019. // Test via a getter in the options object to see if the passive property is accessed
  53020. var result = false;
  53021. try {
  53022. var opts = Object.defineProperty({}, 'passive', {
  53023. get: function() {
  53024. result = true;
  53025. }
  53026. });
  53027. one(globalObject, 'testPassive', null, opts);
  53028. } catch (e) {}
  53029. return result;
  53030. }()),
  53031. // event options
  53032. // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
  53033. passiveHandler = supportPassive ? { passive: true } : false,
  53034. // transitions
  53035. getTransitionDurationFromElement = function(element) {
  53036. var duration = supportTransitions ? globalObject[getComputedStyle](element)[transitionDuration] : 0;
  53037. duration = parseFloat(duration);
  53038. duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0;
  53039. return duration; // we take a short offset to make sure we fire on the next frame after animation
  53040. },
  53041. emulateTransitionEnd = function(element,handler){ // emulateTransitionEnd since 2.0.4
  53042. var called = 0, duration = getTransitionDurationFromElement(element);
  53043. duration ? one(element, transitionEndEvent, function(e){ !called && handler(e), called = 1; })
  53044. : setTimeout(function() { !called && handler(), called = 1; }, 17);
  53045. },
  53046. bootstrapCustomEvent = function (eventName, componentName, related) {
  53047. var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName);
  53048. OriginalCustomEvent.relatedTarget = related;
  53049. this.dispatchEvent(OriginalCustomEvent);
  53050. },
  53051. // tooltip / popover stuff
  53052. getScroll = function() { // also Affix and ScrollSpy uses it
  53053. return {
  53054. y : globalObject.pageYOffset || HTML[scrollTop],
  53055. x : globalObject.pageXOffset || HTML[scrollLeft]
  53056. }
  53057. },
  53058. styleTip = function(link,element,position,parent) { // both popovers and tooltips (target,tooltip,placement,elementToAppendTo)
  53059. var elementDimensions = { w : element[offsetWidth], h: element[offsetHeight] },
  53060. windowWidth = (HTML[clientWidth] || DOC[body][clientWidth]),
  53061. windowHeight = (HTML[clientHeight] || DOC[body][clientHeight]),
  53062. rect = link[getBoundingClientRect](),
  53063. scroll = parent === DOC[body] ? getScroll() : { x: parent[offsetLeft] + parent[scrollLeft], y: parent[offsetTop] + parent[scrollTop] },
  53064. linkDimensions = { w: rect[right] - rect[left], h: rect[bottom] - rect[top] },
  53065. isPopover = hasClass(element,'popover'),
  53066. topPosition, leftPosition,
  53067. arrow = queryElement('.arrow',element),
  53068. arrowTop, arrowLeft, arrowWidth, arrowHeight,
  53069. halfTopExceed = rect[top] + linkDimensions.h/2 - elementDimensions.h/2 < 0,
  53070. halfLeftExceed = rect[left] + linkDimensions.w/2 - elementDimensions.w/2 < 0,
  53071. halfRightExceed = rect[left] + elementDimensions.w/2 + linkDimensions.w/2 >= windowWidth,
  53072. halfBottomExceed = rect[top] + elementDimensions.h/2 + linkDimensions.h/2 >= windowHeight,
  53073. topExceed = rect[top] - elementDimensions.h < 0,
  53074. leftExceed = rect[left] - elementDimensions.w < 0,
  53075. bottomExceed = rect[top] + elementDimensions.h + linkDimensions.h >= windowHeight,
  53076. rightExceed = rect[left] + elementDimensions.w + linkDimensions.w >= windowWidth;
  53077. // recompute position
  53078. position = (position === left || position === right) && leftExceed && rightExceed ? top : position; // first, when both left and right limits are exceeded, we fall back to top|bottom
  53079. position = position === top && topExceed ? bottom : position;
  53080. position = position === bottom && bottomExceed ? top : position;
  53081. position = position === left && leftExceed ? right : position;
  53082. position = position === right && rightExceed ? left : position;
  53083. // update tooltip/popover class
  53084. element.className[indexOf](position) === -1 && (element.className = element.className.replace(tipPositions,position));
  53085. // we check the computed width & height and update here
  53086. arrowWidth = arrow[offsetWidth]; arrowHeight = arrow[offsetHeight];
  53087. // apply styling to tooltip or popover
  53088. if ( position === left || position === right ) { // secondary|side positions
  53089. if ( position === left ) { // LEFT
  53090. leftPosition = rect[left] + scroll.x - elementDimensions.w - ( isPopover ? arrowWidth : 0 );
  53091. } else { // RIGHT
  53092. leftPosition = rect[left] + scroll.x + linkDimensions.w;
  53093. }
  53094. // adjust top and arrow
  53095. if (halfTopExceed) {
  53096. topPosition = rect[top] + scroll.y;
  53097. arrowTop = linkDimensions.h/2 - arrowWidth;
  53098. } else if (halfBottomExceed) {
  53099. topPosition = rect[top] + scroll.y - elementDimensions.h + linkDimensions.h;
  53100. arrowTop = elementDimensions.h - linkDimensions.h/2 - arrowWidth;
  53101. } else {
  53102. topPosition = rect[top] + scroll.y - elementDimensions.h/2 + linkDimensions.h/2;
  53103. arrowTop = elementDimensions.h/2 - (isPopover ? arrowHeight*0.9 : arrowHeight/2);
  53104. }
  53105. } else if ( position === top || position === bottom ) { // primary|vertical positions
  53106. if ( position === top) { // TOP
  53107. topPosition = rect[top] + scroll.y - elementDimensions.h - ( isPopover ? arrowHeight : 0 );
  53108. } else { // BOTTOM
  53109. topPosition = rect[top] + scroll.y + linkDimensions.h;
  53110. }
  53111. // adjust left | right and also the arrow
  53112. if (halfLeftExceed) {
  53113. leftPosition = 0;
  53114. arrowLeft = rect[left] + linkDimensions.w/2 - arrowWidth;
  53115. } else if (halfRightExceed) {
  53116. leftPosition = windowWidth - elementDimensions.w*1.01;
  53117. arrowLeft = elementDimensions.w - ( windowWidth - rect[left] ) + linkDimensions.w/2 - arrowWidth/2;
  53118. } else {
  53119. leftPosition = rect[left] + scroll.x - elementDimensions.w/2 + linkDimensions.w/2;
  53120. arrowLeft = elementDimensions.w/2 - ( isPopover ? arrowWidth : arrowWidth/2 );
  53121. }
  53122. }
  53123. // apply style to tooltip/popover and its arrow
  53124. element[style][top] = topPosition + 'px';
  53125. element[style][left] = leftPosition + 'px';
  53126. arrowTop && (arrow[style][top] = arrowTop + 'px');
  53127. arrowLeft && (arrow[style][left] = arrowLeft + 'px');
  53128. };
  53129. BSN.version = '2.0.27';
  53130. /* Native Javascript for Bootstrap 4 | Alert
  53131. -------------------------------------------*/
  53132. // ALERT DEFINITION
  53133. // ================
  53134. var Alert = function( element ) {
  53135. // initialization element
  53136. element = queryElement(element);
  53137. // bind, target alert, duration and stuff
  53138. var self = this, component = 'alert',
  53139. alert = getClosest(element,'.'+component),
  53140. triggerHandler = function(){ hasClass(alert,'fade') ? emulateTransitionEnd(alert,transitionEndHandler) : transitionEndHandler(); },
  53141. // handlers
  53142. clickHandler = function(e){
  53143. alert = getClosest(e[target],'.'+component);
  53144. element = queryElement('['+dataDismiss+'="'+component+'"]',alert);
  53145. element && alert && (element === e[target] || element[contains](e[target])) && self.close();
  53146. },
  53147. transitionEndHandler = function(){
  53148. bootstrapCustomEvent.call(alert, closedEvent, component);
  53149. off(element, clickEvent, clickHandler); // detach it's listener
  53150. alert[parentNode].removeChild(alert);
  53151. };
  53152. // public method
  53153. this.close = function() {
  53154. if ( alert && element && hasClass(alert,showClass) ) {
  53155. bootstrapCustomEvent.call(alert, closeEvent, component);
  53156. removeClass(alert,showClass);
  53157. alert && triggerHandler();
  53158. }
  53159. };
  53160. // init
  53161. if ( !(stringAlert in element ) ) { // prevent adding event handlers twice
  53162. on(element, clickEvent, clickHandler);
  53163. }
  53164. element[stringAlert] = self;
  53165. };
  53166. // ALERT DATA API
  53167. // ==============
  53168. supports[push]([stringAlert, Alert, '['+dataDismiss+'="alert"]']);
  53169. /* Native Javascript for Bootstrap 4 | Button
  53170. ---------------------------------------------*/
  53171. // BUTTON DEFINITION
  53172. // ===================
  53173. var Button = function( element ) {
  53174. // initialization element
  53175. element = queryElement(element);
  53176. // constant
  53177. var toggled = false, // toggled makes sure to prevent triggering twice the change.bs.button events
  53178. // strings
  53179. component = 'button',
  53180. checked = 'checked',
  53181. LABEL = 'LABEL',
  53182. INPUT = 'INPUT',
  53183. // private methods
  53184. keyHandler = function(e){
  53185. var key = e.which || e.keyCode;
  53186. key === 32 && e[target] === DOC.activeElement && toggle(e);
  53187. },
  53188. preventScroll = function(e){
  53189. var key = e.which || e.keyCode;
  53190. key === 32 && e[preventDefault]();
  53191. },
  53192. toggle = function(e) {
  53193. var label = e[target].tagName === LABEL ? e[target] : e[target][parentNode].tagName === LABEL ? e[target][parentNode] : null; // the .btn label
  53194. if ( !label ) return; //react if a label or its immediate child is clicked
  53195. var labels = getElementsByClassName(label[parentNode],'btn'), // all the button group buttons
  53196. input = label[getElementsByTagName](INPUT)[0];
  53197. if ( !input ) return; // return if no input found
  53198. // manage the dom manipulation
  53199. if ( input.type === 'checkbox' ) { //checkboxes
  53200. if ( !input[checked] ) {
  53201. addClass(label,active);
  53202. input[getAttribute](checked);
  53203. input[setAttribute](checked,checked);
  53204. input[checked] = true;
  53205. } else {
  53206. removeClass(label,active);
  53207. input[getAttribute](checked);
  53208. input.removeAttribute(checked);
  53209. input[checked] = false;
  53210. }
  53211. if (!toggled) { // prevent triggering the event twice
  53212. toggled = true;
  53213. bootstrapCustomEvent.call(input, changeEvent, component); //trigger the change for the input
  53214. bootstrapCustomEvent.call(element, changeEvent, component); //trigger the change for the btn-group
  53215. }
  53216. }
  53217. if ( input.type === 'radio' && !toggled ) { // radio buttons
  53218. // don't trigger if already active (the OR condition is a hack to check if the buttons were selected with key press and NOT mouse click)
  53219. if ( !input[checked] || (e.screenX === 0 && e.screenY == 0) ) {
  53220. addClass(label,active);
  53221. addClass(label,focusEvent);
  53222. input[setAttribute](checked,checked);
  53223. input[checked] = true;
  53224. bootstrapCustomEvent.call(input, changeEvent, component); //trigger the change for the input
  53225. bootstrapCustomEvent.call(element, changeEvent, component); //trigger the change for the btn-group
  53226. toggled = true;
  53227. for (var i = 0, ll = labels[length]; i<ll; i++) {
  53228. var otherLabel = labels[i], otherInput = otherLabel[getElementsByTagName](INPUT)[0];
  53229. if ( otherLabel !== label && hasClass(otherLabel,active) ) {
  53230. removeClass(otherLabel,active);
  53231. otherInput.removeAttribute(checked);
  53232. otherInput[checked] = false;
  53233. bootstrapCustomEvent.call(otherInput, changeEvent, component); // trigger the change
  53234. }
  53235. }
  53236. }
  53237. }
  53238. setTimeout( function() { toggled = false; }, 50 );
  53239. },
  53240. focusHandler = function(e) {
  53241. addClass(e[target][parentNode],focusEvent);
  53242. },
  53243. blurHandler = function(e) {
  53244. removeClass(e[target][parentNode],focusEvent);
  53245. };
  53246. // init
  53247. if ( !( stringButton in element ) ) { // prevent adding event handlers twice
  53248. on( element, clickEvent, toggle );
  53249. on( element, keyupEvent, keyHandler ), on( element, keydownEvent, preventScroll );
  53250. var allBtns = getElementsByClassName(element, 'btn');
  53251. for (var i=0; i<allBtns.length; i++) {
  53252. var input = allBtns[i][getElementsByTagName](INPUT)[0];
  53253. on( input, focusEvent, focusHandler), on( input, 'blur', blurHandler);
  53254. }
  53255. }
  53256. // activate items on load
  53257. var labelsToACtivate = getElementsByClassName(element, 'btn'), lbll = labelsToACtivate[length];
  53258. for (var i=0; i<lbll; i++) {
  53259. !hasClass(labelsToACtivate[i],active) && queryElement('input:checked',labelsToACtivate[i])
  53260. && addClass(labelsToACtivate[i],active);
  53261. }
  53262. element[stringButton] = this;
  53263. };
  53264. // BUTTON DATA API
  53265. // =================
  53266. supports[push]( [ stringButton, Button, '['+dataToggle+'="buttons"]' ] );
  53267. /* Native Javascript for Bootstrap 4 | Collapse
  53268. -----------------------------------------------*/
  53269. // COLLAPSE DEFINITION
  53270. // ===================
  53271. var Collapse = function( element, options ) {
  53272. // initialization element
  53273. element = queryElement(element);
  53274. // set options
  53275. options = options || {};
  53276. // event targets and constants
  53277. var accordion = null, collapse = null, self = this,
  53278. accordionData = element[getAttribute]('data-parent'),
  53279. activeCollapse, activeElement,
  53280. // component strings
  53281. component = 'collapse',
  53282. collapsed = 'collapsed',
  53283. isAnimating = 'isAnimating',
  53284. // private methods
  53285. openAction = function(collapseElement,toggle) {
  53286. bootstrapCustomEvent.call(collapseElement, showEvent, component);
  53287. collapseElement[isAnimating] = true;
  53288. addClass(collapseElement,collapsing);
  53289. removeClass(collapseElement,component);
  53290. collapseElement[style][height] = collapseElement[scrollHeight] + 'px';
  53291. emulateTransitionEnd(collapseElement, function() {
  53292. collapseElement[isAnimating] = false;
  53293. collapseElement[setAttribute](ariaExpanded,'true');
  53294. toggle[setAttribute](ariaExpanded,'true');
  53295. removeClass(collapseElement,collapsing);
  53296. addClass(collapseElement, component);
  53297. addClass(collapseElement,showClass);
  53298. collapseElement[style][height] = '';
  53299. bootstrapCustomEvent.call(collapseElement, shownEvent, component);
  53300. });
  53301. },
  53302. closeAction = function(collapseElement,toggle) {
  53303. bootstrapCustomEvent.call(collapseElement, hideEvent, component);
  53304. collapseElement[isAnimating] = true;
  53305. collapseElement[style][height] = collapseElement[scrollHeight] + 'px'; // set height first
  53306. removeClass(collapseElement,component);
  53307. removeClass(collapseElement,showClass);
  53308. addClass(collapseElement,collapsing);
  53309. collapseElement[offsetWidth]; // force reflow to enable transition
  53310. collapseElement[style][height] = '0px';
  53311. emulateTransitionEnd(collapseElement, function() {
  53312. collapseElement[isAnimating] = false;
  53313. collapseElement[setAttribute](ariaExpanded,'false');
  53314. toggle[setAttribute](ariaExpanded,'false');
  53315. removeClass(collapseElement,collapsing);
  53316. addClass(collapseElement,component);
  53317. collapseElement[style][height] = '';
  53318. bootstrapCustomEvent.call(collapseElement, hiddenEvent, component);
  53319. });
  53320. },
  53321. getTarget = function() {
  53322. var href = element.href && element[getAttribute]('href'),
  53323. parent = element[getAttribute](dataTarget),
  53324. id = href || ( parent && parent.charAt(0) === '#' ) && parent;
  53325. return id && queryElement(id);
  53326. };
  53327. // public methods
  53328. this.toggle = function(e) {
  53329. e[preventDefault]();
  53330. if (!hasClass(collapse,showClass)) { self.show(); }
  53331. else { self.hide(); }
  53332. };
  53333. this.hide = function() {
  53334. if ( collapse[isAnimating] ) return;
  53335. closeAction(collapse,element);
  53336. addClass(element,collapsed);
  53337. };
  53338. this.show = function() {
  53339. if ( accordion ) {
  53340. activeCollapse = queryElement('.'+component+'.'+showClass,accordion);
  53341. activeElement = activeCollapse && (queryElement('['+dataTarget+'="#'+activeCollapse.id+'"]',accordion)
  53342. || queryElement('[href="#'+activeCollapse.id+'"]',accordion) );
  53343. }
  53344. if ( !collapse[isAnimating] || activeCollapse && !activeCollapse[isAnimating] ) {
  53345. if ( activeElement && activeCollapse !== collapse ) {
  53346. closeAction(activeCollapse,activeElement);
  53347. addClass(activeElement,collapsed);
  53348. }
  53349. openAction(collapse,element);
  53350. removeClass(element,collapsed);
  53351. }
  53352. };
  53353. // init
  53354. if ( !(stringCollapse in element ) ) { // prevent adding event handlers twice
  53355. on(element, clickEvent, self.toggle);
  53356. }
  53357. collapse = getTarget();
  53358. collapse[isAnimating] = false; // when true it will prevent click handlers
  53359. accordion = queryElement(options.parent) || accordionData && getClosest(element, accordionData);
  53360. element[stringCollapse] = self;
  53361. };
  53362. // COLLAPSE DATA API
  53363. // =================
  53364. supports[push]( [ stringCollapse, Collapse, '['+dataToggle+'="collapse"]' ] );
  53365. /* Native Javascript for Bootstrap 4 | Dropdown
  53366. ----------------------------------------------*/
  53367. // DROPDOWN DEFINITION
  53368. // ===================
  53369. var Dropdown = function( element, option ) {
  53370. // initialization element
  53371. element = queryElement(element);
  53372. // set option
  53373. this.persist = option === true || element[getAttribute]('data-persist') === 'true' || false;
  53374. // constants, event targets, strings
  53375. var self = this, children = 'children',
  53376. parent = element[parentNode],
  53377. component = 'dropdown', open = 'open',
  53378. relatedTarget = null,
  53379. menu = queryElement('.dropdown-menu', parent),
  53380. menuItems = (function(){
  53381. var set = menu[children], newSet = [];
  53382. for ( var i=0; i<set[length]; i++ ){
  53383. set[i][children][length] && (set[i][children][0].tagName === 'A' && newSet[push](set[i][children][0]));
  53384. set[i].tagName === 'A' && newSet[push](set[i]);
  53385. }
  53386. return newSet;
  53387. })(),
  53388. // preventDefault on empty anchor links
  53389. preventEmptyAnchor = function(anchor){
  53390. (anchor.href && anchor.href.slice(-1) === '#' || anchor[parentNode] && anchor[parentNode].href
  53391. && anchor[parentNode].href.slice(-1) === '#') && this[preventDefault]();
  53392. },
  53393. // toggle dismissible events
  53394. toggleDismiss = function(){
  53395. var type = element[open] ? on : off;
  53396. type(DOC, clickEvent, dismissHandler);
  53397. type(DOC, keydownEvent, preventScroll);
  53398. type(DOC, keyupEvent, keyHandler);
  53399. type(DOC, focusEvent, dismissHandler, true);
  53400. },
  53401. // handlers
  53402. dismissHandler = function(e) {
  53403. var eventTarget = e[target], hasData = eventTarget && (eventTarget[getAttribute](dataToggle)
  53404. || eventTarget[parentNode] && getAttribute in eventTarget[parentNode]
  53405. && eventTarget[parentNode][getAttribute](dataToggle));
  53406. if ( e.type === focusEvent && (eventTarget === element || eventTarget === menu || menu[contains](eventTarget) ) ) {
  53407. return;
  53408. }
  53409. if ( (eventTarget === menu || menu[contains](eventTarget)) && (self.persist || hasData) ) { return; }
  53410. else {
  53411. relatedTarget = eventTarget === element || element[contains](eventTarget) ? element : null;
  53412. hide();
  53413. }
  53414. preventEmptyAnchor.call(e,eventTarget);
  53415. },
  53416. clickHandler = function(e) {
  53417. relatedTarget = element;
  53418. show();
  53419. preventEmptyAnchor.call(e,e[target]);
  53420. },
  53421. preventScroll = function(e){
  53422. var key = e.which || e.keyCode;
  53423. if( key === 38 || key === 40 ) { e[preventDefault](); }
  53424. },
  53425. keyHandler = function(e){
  53426. var key = e.which || e.keyCode,
  53427. activeItem = DOC.activeElement,
  53428. idx = menuItems[indexOf](activeItem),
  53429. isSameElement = activeItem === element,
  53430. isInsideMenu = menu[contains](activeItem),
  53431. isMenuItem = activeItem[parentNode] === menu || activeItem[parentNode][parentNode] === menu;
  53432. if ( isMenuItem ) { // navigate up | down
  53433. idx = isSameElement ? 0
  53434. : key === 38 ? (idx>1?idx-1:0)
  53435. : key === 40 ? (idx<menuItems[length]-1?idx+1:idx) : idx;
  53436. menuItems[idx] && setFocus(menuItems[idx]);
  53437. }
  53438. if ( (menuItems[length] && isMenuItem // menu has items
  53439. || !menuItems[length] && (isInsideMenu || isSameElement) // menu might be a form
  53440. || !isInsideMenu ) // or the focused element is not in the menu at all
  53441. && element[open] && key === 27 // menu must be open
  53442. ) {
  53443. self.toggle();
  53444. relatedTarget = null;
  53445. }
  53446. },
  53447. // private methods
  53448. show = function() {
  53449. bootstrapCustomEvent.call(parent, showEvent, component, relatedTarget);
  53450. addClass(menu,showClass);
  53451. addClass(parent,showClass);
  53452. element[setAttribute](ariaExpanded,true);
  53453. bootstrapCustomEvent.call(parent, shownEvent, component, relatedTarget);
  53454. element[open] = true;
  53455. off(element, clickEvent, clickHandler);
  53456. setTimeout(function(){
  53457. setFocus( menu[getElementsByTagName]('INPUT')[0] || element ); // focus the first input item | element
  53458. toggleDismiss();
  53459. },1);
  53460. },
  53461. hide = function() {
  53462. bootstrapCustomEvent.call(parent, hideEvent, component, relatedTarget);
  53463. removeClass(menu,showClass);
  53464. removeClass(parent,showClass);
  53465. element[setAttribute](ariaExpanded,false);
  53466. bootstrapCustomEvent.call(parent, hiddenEvent, component, relatedTarget);
  53467. element[open] = false;
  53468. toggleDismiss();
  53469. setFocus(element);
  53470. setTimeout(function(){ on(element, clickEvent, clickHandler); },1);
  53471. };
  53472. // set initial state to closed
  53473. element[open] = false;
  53474. // public methods
  53475. this.toggle = function() {
  53476. if (hasClass(parent,showClass) && element[open]) { hide(); }
  53477. else { show(); }
  53478. };
  53479. // init
  53480. if ( !(stringDropdown in element) ) { // prevent adding event handlers twice
  53481. !tabindex in menu && menu[setAttribute](tabindex, '0'); // Fix onblur on Chrome | Safari
  53482. on(element, clickEvent, clickHandler);
  53483. }
  53484. element[stringDropdown] = self;
  53485. };
  53486. // DROPDOWN DATA API
  53487. // =================
  53488. supports[push]( [stringDropdown, Dropdown, '['+dataToggle+'="dropdown"]'] );
  53489. /* Native Javascript for Bootstrap 4 | Modal
  53490. -------------------------------------------*/
  53491. // MODAL DEFINITION
  53492. // ===============
  53493. var Modal = function(element, options) { // element can be the modal/triggering button
  53494. // the modal (both JavaScript / DATA API init) / triggering button element (DATA API)
  53495. element = queryElement(element);
  53496. // strings
  53497. var component = 'modal',
  53498. staticString = 'static',
  53499. modalTrigger = 'modalTrigger',
  53500. paddingRight = 'paddingRight',
  53501. modalBackdropString = 'modal-backdrop',
  53502. isAnimating = 'isAnimating',
  53503. // determine modal, triggering element
  53504. btnCheck = element[getAttribute](dataTarget)||element[getAttribute]('href'),
  53505. checkModal = queryElement( btnCheck ),
  53506. modal = hasClass(element,component) ? element : checkModal;
  53507. if ( hasClass(element, component) ) { element = null; } // modal is now independent of it's triggering element
  53508. if ( !modal ) { return; } // invalidate
  53509. // set options
  53510. options = options || {};
  53511. this[keyboard] = options[keyboard] === false || modal[getAttribute](dataKeyboard) === 'false' ? false : true;
  53512. this[backdrop] = options[backdrop] === staticString || modal[getAttribute](databackdrop) === staticString ? staticString : true;
  53513. this[backdrop] = options[backdrop] === false || modal[getAttribute](databackdrop) === 'false' ? false : this[backdrop];
  53514. this[animation] = hasClass(modal, 'fade') ? true : false;
  53515. this[content] = options[content]; // JavaScript only
  53516. // set an initial state of the modal
  53517. modal[isAnimating] = false;
  53518. // bind, constants, event targets and other vars
  53519. var self = this, relatedTarget = null,
  53520. bodyIsOverflowing, scrollBarWidth, overlay, overlayDelay, modalTimer,
  53521. // also find fixed-top / fixed-bottom items
  53522. fixedItems = getElementsByClassName(HTML,fixedTop).concat(getElementsByClassName(HTML,fixedBottom)),
  53523. // private methods
  53524. getWindowWidth = function() {
  53525. var htmlRect = HTML[getBoundingClientRect]();
  53526. return globalObject[innerWidth] || (htmlRect[right] - Math.abs(htmlRect[left]));
  53527. },
  53528. setScrollbar = function () {
  53529. var bodyStyle = globalObject[getComputedStyle](DOC[body]),
  53530. bodyPad = parseInt((bodyStyle[paddingRight]), 10), itemPad;
  53531. if (bodyIsOverflowing) {
  53532. DOC[body][style][paddingRight] = (bodyPad + scrollBarWidth) + 'px';
  53533. modal[style][paddingRight] = scrollBarWidth+'px';
  53534. if (fixedItems[length]){
  53535. for (var i = 0; i < fixedItems[length]; i++) {
  53536. itemPad = globalObject[getComputedStyle](fixedItems[i])[paddingRight];
  53537. fixedItems[i][style][paddingRight] = ( parseInt(itemPad) + scrollBarWidth) + 'px';
  53538. }
  53539. }
  53540. }
  53541. },
  53542. resetScrollbar = function () {
  53543. DOC[body][style][paddingRight] = '';
  53544. modal[style][paddingRight] = '';
  53545. if (fixedItems[length]){
  53546. for (var i = 0; i < fixedItems[length]; i++) {
  53547. fixedItems[i][style][paddingRight] = '';
  53548. }
  53549. }
  53550. },
  53551. measureScrollbar = function () { // thx walsh
  53552. var scrollDiv = DOC[createElement]('div'), widthValue;
  53553. scrollDiv.className = component+'-scrollbar-measure'; // this is here to stay
  53554. DOC[body][appendChild](scrollDiv);
  53555. widthValue = scrollDiv[offsetWidth] - scrollDiv[clientWidth];
  53556. DOC[body].removeChild(scrollDiv);
  53557. return widthValue;
  53558. },
  53559. checkScrollbar = function () {
  53560. bodyIsOverflowing = DOC[body][clientWidth] < getWindowWidth();
  53561. scrollBarWidth = measureScrollbar();
  53562. },
  53563. createOverlay = function() {
  53564. var newOverlay = DOC[createElement]('div');
  53565. overlay = queryElement('.'+modalBackdropString);
  53566. if ( overlay === null ) {
  53567. newOverlay[setAttribute]('class', modalBackdropString + (self[animation] ? ' fade' : ''));
  53568. overlay = newOverlay;
  53569. DOC[body][appendChild](overlay);
  53570. }
  53571. modalOverlay = 1;
  53572. },
  53573. removeOverlay = function() {
  53574. overlay = queryElement('.'+modalBackdropString);
  53575. if ( overlay && overlay !== null && typeof overlay === 'object' ) {
  53576. modalOverlay = 0;
  53577. DOC[body].removeChild(overlay); overlay = null;
  53578. }
  53579. },
  53580. // triggers
  53581. triggerShow = function() {
  53582. setFocus(modal);
  53583. modal[isAnimating] = false;
  53584. bootstrapCustomEvent.call(modal, shownEvent, component, relatedTarget);
  53585. on(globalObject, resizeEvent, self.update, passiveHandler);
  53586. on(modal, clickEvent, dismissHandler);
  53587. on(DOC, keydownEvent, keyHandler);
  53588. },
  53589. triggerHide = function() {
  53590. modal[style].display = '';
  53591. element && (setFocus(element));
  53592. bootstrapCustomEvent.call(modal, hiddenEvent, component);
  53593. (function(){
  53594. if (!getElementsByClassName(DOC,component+' '+showClass)[0]) {
  53595. resetScrollbar();
  53596. removeClass(DOC[body],component+'-open');
  53597. overlay && hasClass(overlay,'fade') ? (removeClass(overlay,showClass), emulateTransitionEnd(overlay,removeOverlay))
  53598. : removeOverlay();
  53599. off(globalObject, resizeEvent, self.update, passiveHandler);
  53600. off(modal, clickEvent, dismissHandler);
  53601. off(DOC, keydownEvent, keyHandler);
  53602. }
  53603. }());
  53604. modal[isAnimating] = false;
  53605. },
  53606. // handlers
  53607. clickHandler = function(e) {
  53608. if ( modal[isAnimating] ) return;
  53609. var clickTarget = e[target];
  53610. clickTarget = clickTarget[hasAttribute](dataTarget) || clickTarget[hasAttribute]('href') ? clickTarget : clickTarget[parentNode];
  53611. if ( clickTarget === element && !hasClass(modal,showClass) ) {
  53612. modal[modalTrigger] = element;
  53613. relatedTarget = element;
  53614. self.show();
  53615. e[preventDefault]();
  53616. }
  53617. },
  53618. keyHandler = function(e) {
  53619. if ( modal[isAnimating] ) return;
  53620. if (self[keyboard] && e.which == 27 && hasClass(modal,showClass) ) {
  53621. self.hide();
  53622. }
  53623. },
  53624. dismissHandler = function(e) {
  53625. if ( modal[isAnimating] ) return;
  53626. var clickTarget = e[target];
  53627. if ( hasClass(modal,showClass) && ( clickTarget[parentNode][getAttribute](dataDismiss) === component
  53628. || clickTarget[getAttribute](dataDismiss) === component
  53629. || clickTarget === modal && self[backdrop] !== staticString ) ) {
  53630. self.hide(); relatedTarget = null;
  53631. e[preventDefault]();
  53632. }
  53633. };
  53634. // public methods
  53635. this.toggle = function() {
  53636. if ( hasClass(modal,showClass) ) {this.hide();} else {this.show();}
  53637. };
  53638. this.show = function() {
  53639. if ( hasClass(modal,showClass) || modal[isAnimating] ) {return}
  53640. clearTimeout(modalTimer);
  53641. modalTimer = setTimeout(function(){
  53642. modal[isAnimating] = true;
  53643. bootstrapCustomEvent.call(modal, showEvent, component, relatedTarget);
  53644. // we elegantly hide any opened modal
  53645. var currentOpen = getElementsByClassName(DOC,component+' '+showClass)[0];
  53646. if (currentOpen && currentOpen !== modal) {
  53647. modalTrigger in currentOpen && currentOpen[modalTrigger][stringModal].hide();
  53648. stringModal in currentOpen && currentOpen[stringModal].hide();
  53649. }
  53650. if ( self[backdrop] ) {
  53651. !modalOverlay && !overlay && createOverlay();
  53652. }
  53653. if ( overlay && !hasClass(overlay,showClass) ) {
  53654. overlay[offsetWidth]; // force reflow to enable trasition
  53655. overlayDelay = getTransitionDurationFromElement(overlay);
  53656. addClass(overlay, showClass);
  53657. }
  53658. setTimeout( function() {
  53659. modal[style].display = 'block';
  53660. checkScrollbar();
  53661. setScrollbar();
  53662. addClass(DOC[body],component+'-open');
  53663. addClass(modal,showClass);
  53664. modal[setAttribute](ariaHidden, false);
  53665. hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerShow) : triggerShow();
  53666. }, supportTransitions && overlay && overlayDelay ? overlayDelay : 1);
  53667. },1);
  53668. };
  53669. this.hide = function() {
  53670. if ( modal[isAnimating] || !hasClass(modal,showClass) ) {return}
  53671. clearTimeout(modalTimer);
  53672. modalTimer = setTimeout(function(){
  53673. modal[isAnimating] = true;
  53674. bootstrapCustomEvent.call(modal, hideEvent, component);
  53675. overlay = queryElement('.'+modalBackdropString);
  53676. overlayDelay = overlay && getTransitionDurationFromElement(overlay);
  53677. removeClass(modal,showClass);
  53678. modal[setAttribute](ariaHidden, true);
  53679. setTimeout(function(){
  53680. hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerHide) : triggerHide();
  53681. }, supportTransitions && overlay && overlayDelay ? overlayDelay : 2);
  53682. },2)
  53683. };
  53684. this.setContent = function( content ) {
  53685. queryElement('.'+component+'-content',modal)[innerHTML] = content;
  53686. };
  53687. this.update = function() {
  53688. if (hasClass(modal,showClass)) {
  53689. checkScrollbar();
  53690. setScrollbar();
  53691. }
  53692. };
  53693. // init
  53694. // prevent adding event handlers over and over
  53695. // modal is independent of a triggering element
  53696. if ( !!element && !(stringModal in element) ) {
  53697. on(element, clickEvent, clickHandler);
  53698. }
  53699. if ( !!self[content] ) { self.setContent( self[content] ); }
  53700. if (element) { element[stringModal] = self; modal[modalTrigger] = element; }
  53701. else { modal[stringModal] = self; }
  53702. };
  53703. // DATA API
  53704. supports[push]( [ stringModal, Modal, '['+dataToggle+'="modal"]' ] );
  53705. /* Native Javascript for Bootstrap 4 | Popover
  53706. ----------------------------------------------*/
  53707. // POPOVER DEFINITION
  53708. // ==================
  53709. var Popover = function( element, options ) {
  53710. // initialization element
  53711. element = queryElement(element);
  53712. // set options
  53713. options = options || {};
  53714. // DATA API
  53715. var triggerData = element[getAttribute](dataTrigger), // click / hover / focus
  53716. animationData = element[getAttribute](dataAnimation), // true / false
  53717. placementData = element[getAttribute](dataPlacement),
  53718. dismissibleData = element[getAttribute](dataDismissible),
  53719. delayData = element[getAttribute](dataDelay),
  53720. containerData = element[getAttribute](dataContainer),
  53721. // internal strings
  53722. component = 'popover',
  53723. template = 'template',
  53724. trigger = 'trigger',
  53725. classString = 'class',
  53726. div = 'div',
  53727. fade = 'fade',
  53728. dataContent = 'data-content',
  53729. dismissible = 'dismissible',
  53730. closeBtn = '<button type="button" class="close">×</button>',
  53731. // check container
  53732. containerElement = queryElement(options[container]),
  53733. containerDataElement = queryElement(containerData),
  53734. // maybe the element is inside a modal
  53735. modal = getClosest(element,'.modal'),
  53736. // maybe the element is inside a fixed navbar
  53737. navbarFixedTop = getClosest(element,'.'+fixedTop),
  53738. navbarFixedBottom = getClosest(element,'.'+fixedBottom);
  53739. // set instance options
  53740. this[template] = options[template] ? options[template] : null; // JavaScript only
  53741. this[trigger] = options[trigger] ? options[trigger] : triggerData || hoverEvent;
  53742. this[animation] = options[animation] && options[animation] !== fade ? options[animation] : animationData || fade;
  53743. this[placement] = options[placement] ? options[placement] : placementData || top;
  53744. this[delay] = parseInt(options[delay] || delayData) || 200;
  53745. this[dismissible] = options[dismissible] || dismissibleData === 'true' ? true : false;
  53746. this[container] = containerElement ? containerElement
  53747. : containerDataElement ? containerDataElement
  53748. : navbarFixedTop ? navbarFixedTop
  53749. : navbarFixedBottom ? navbarFixedBottom
  53750. : modal ? modal : DOC[body];
  53751. // bind, content
  53752. var self = this,
  53753. titleString = options.title || element[getAttribute](dataTitle) || null,
  53754. contentString = options.content || element[getAttribute](dataContent) || null;
  53755. if ( !contentString && !this[template] ) return; // invalidate
  53756. // constants, vars
  53757. var popover = null, timer = 0, placementSetting = this[placement],
  53758. // handlers
  53759. dismissibleHandler = function(e) {
  53760. if (popover !== null && e[target] === queryElement('.close',popover)) {
  53761. self.hide();
  53762. }
  53763. },
  53764. // private methods
  53765. removePopover = function() {
  53766. self[container].removeChild(popover);
  53767. timer = null; popover = null;
  53768. },
  53769. createPopover = function() {
  53770. titleString = options.title || element[getAttribute](dataTitle);
  53771. contentString = options.content || element[getAttribute](dataContent);
  53772. // fixing https://github.com/thednp/bootstrap.native/issues/233
  53773. contentString = !!contentString ? contentString.trim() : null;
  53774. popover = DOC[createElement](div);
  53775. // popover arrow
  53776. var popoverArrow = DOC[createElement](div);
  53777. popoverArrow[setAttribute](classString,'arrow');
  53778. popover[appendChild](popoverArrow);
  53779. if ( contentString !== null && self[template] === null ) { //create the popover from data attributes
  53780. popover[setAttribute]('role','tooltip');
  53781. if (titleString !== null) {
  53782. var popoverTitle = DOC[createElement]('h3');
  53783. popoverTitle[setAttribute](classString,component+'-header');
  53784. popoverTitle[innerHTML] = self[dismissible] ? titleString + closeBtn : titleString;
  53785. popover[appendChild](popoverTitle);
  53786. }
  53787. //set popover content
  53788. var popoverContent = DOC[createElement](div);
  53789. popoverContent[setAttribute](classString,component+'-body');
  53790. popoverContent[innerHTML] = self[dismissible] && titleString === null ? contentString + closeBtn : contentString;
  53791. popover[appendChild](popoverContent);
  53792. } else { // or create the popover from template
  53793. var popoverTemplate = DOC[createElement](div);
  53794. self[template] = self[template].trim();
  53795. popoverTemplate[innerHTML] = self[template];
  53796. popover[innerHTML] = popoverTemplate.firstChild[innerHTML];
  53797. }
  53798. //append to the container
  53799. self[container][appendChild](popover);
  53800. popover[style].display = 'block';
  53801. popover[setAttribute](classString, component+ ' bs-' + component+'-'+placementSetting + ' ' + self[animation]);
  53802. },
  53803. showPopover = function () {
  53804. !hasClass(popover,showClass) && ( addClass(popover,showClass) );
  53805. },
  53806. updatePopover = function() {
  53807. styleTip(element, popover, placementSetting, self[container]);
  53808. },
  53809. // event toggle
  53810. dismissHandlerToggle = function(type){
  53811. if (clickEvent == self[trigger] || 'focus' == self[trigger]) {
  53812. !self[dismissible] && type( element, 'blur', self.hide );
  53813. }
  53814. self[dismissible] && type( DOC, clickEvent, dismissibleHandler );
  53815. type( globalObject, resizeEvent, self.hide, passiveHandler );
  53816. },
  53817. // triggers
  53818. showTrigger = function() {
  53819. dismissHandlerToggle(on);
  53820. bootstrapCustomEvent.call(element, shownEvent, component);
  53821. },
  53822. hideTrigger = function() {
  53823. dismissHandlerToggle(off);
  53824. removePopover();
  53825. bootstrapCustomEvent.call(element, hiddenEvent, component);
  53826. };
  53827. // public methods / handlers
  53828. this.toggle = function() {
  53829. if (popover === null) { self.show(); }
  53830. else { self.hide(); }
  53831. };
  53832. this.show = function() {
  53833. clearTimeout(timer);
  53834. timer = setTimeout( function() {
  53835. if (popover === null) {
  53836. placementSetting = self[placement]; // we reset placement in all cases
  53837. createPopover();
  53838. updatePopover();
  53839. showPopover();
  53840. bootstrapCustomEvent.call(element, showEvent, component);
  53841. !!self[animation] ? emulateTransitionEnd(popover, showTrigger) : showTrigger();
  53842. }
  53843. }, 20 );
  53844. };
  53845. this.hide = function() {
  53846. clearTimeout(timer);
  53847. timer = setTimeout( function() {
  53848. if (popover && popover !== null && hasClass(popover,showClass)) {
  53849. bootstrapCustomEvent.call(element, hideEvent, component);
  53850. removeClass(popover,showClass);
  53851. !!self[animation] ? emulateTransitionEnd(popover, hideTrigger) : hideTrigger();
  53852. }
  53853. }, self[delay] );
  53854. };
  53855. // init
  53856. if ( !(stringPopover in element) ) { // prevent adding event handlers twice
  53857. if (self[trigger] === hoverEvent) {
  53858. on( element, mouseHover[0], self.show );
  53859. if (!self[dismissible]) { on( element, mouseHover[1], self.hide ); }
  53860. } else if (clickEvent == self[trigger] || 'focus' == self[trigger]) {
  53861. on( element, self[trigger], self.toggle );
  53862. }
  53863. }
  53864. element[stringPopover] = self;
  53865. };
  53866. // POPOVER DATA API
  53867. // ================
  53868. supports[push]( [ stringPopover, Popover, '['+dataToggle+'="popover"]' ] );
  53869. /* Native Javascript for Bootstrap 4 | Tab
  53870. -----------------------------------------*/
  53871. // TAB DEFINITION
  53872. // ==============
  53873. var Tab = function( element, options ) {
  53874. // initialization element
  53875. element = queryElement(element);
  53876. // DATA API
  53877. var heightData = element[getAttribute](dataHeight),
  53878. // strings
  53879. component = 'tab', height = 'height', float = 'float', isAnimating = 'isAnimating';
  53880. // set options
  53881. options = options || {};
  53882. this[height] = supportTransitions ? (options[height] || heightData === 'true') : false;
  53883. // bind, event targets
  53884. var self = this, next,
  53885. tabs = getClosest(element,'.nav'),
  53886. tabsContentContainer = false,
  53887. dropdown = tabs && queryElement('.dropdown-toggle',tabs),
  53888. activeTab, activeContent, nextContent, containerHeight, equalContents, nextHeight,
  53889. // trigger
  53890. triggerEnd = function(){
  53891. tabsContentContainer[style][height] = '';
  53892. removeClass(tabsContentContainer,collapsing);
  53893. tabs[isAnimating] = false;
  53894. },
  53895. triggerShow = function() {
  53896. if (tabsContentContainer) { // height animation
  53897. if ( equalContents ) {
  53898. triggerEnd();
  53899. } else {
  53900. setTimeout(function(){ // enables height animation
  53901. tabsContentContainer[style][height] = nextHeight + 'px'; // height animation
  53902. tabsContentContainer[offsetWidth];
  53903. emulateTransitionEnd(tabsContentContainer, triggerEnd);
  53904. },50);
  53905. }
  53906. } else {
  53907. tabs[isAnimating] = false;
  53908. }
  53909. bootstrapCustomEvent.call(next, shownEvent, component, activeTab);
  53910. },
  53911. triggerHide = function() {
  53912. if (tabsContentContainer) {
  53913. activeContent[style][float] = left;
  53914. nextContent[style][float] = left;
  53915. containerHeight = activeContent[scrollHeight];
  53916. }
  53917. addClass(nextContent,active);
  53918. bootstrapCustomEvent.call(next, showEvent, component, activeTab);
  53919. removeClass(activeContent,active);
  53920. bootstrapCustomEvent.call(activeTab, hiddenEvent, component, next);
  53921. if (tabsContentContainer) {
  53922. nextHeight = nextContent[scrollHeight];
  53923. equalContents = nextHeight === containerHeight;
  53924. addClass(tabsContentContainer,collapsing);
  53925. tabsContentContainer[style][height] = containerHeight + 'px'; // height animation
  53926. tabsContentContainer[offsetHeight];
  53927. activeContent[style][float] = '';
  53928. nextContent[style][float] = '';
  53929. }
  53930. if ( hasClass(nextContent, 'fade') ) {
  53931. setTimeout(function(){
  53932. addClass(nextContent,showClass);
  53933. emulateTransitionEnd(nextContent,triggerShow);
  53934. },20);
  53935. } else { triggerShow(); }
  53936. };
  53937. if (!tabs) return; // invalidate
  53938. // set default animation state
  53939. tabs[isAnimating] = false;
  53940. // private methods
  53941. var getActiveTab = function() {
  53942. var activeTabs = getElementsByClassName(tabs,active), activeTab;
  53943. if ( activeTabs[length] === 1 && !hasClass(activeTabs[0][parentNode],'dropdown') ) {
  53944. activeTab = activeTabs[0];
  53945. } else if ( activeTabs[length] > 1 ) {
  53946. activeTab = activeTabs[activeTabs[length]-1];
  53947. }
  53948. return activeTab;
  53949. },
  53950. getActiveContent = function() {
  53951. return queryElement(getActiveTab()[getAttribute]('href'));
  53952. },
  53953. // handler
  53954. clickHandler = function(e) {
  53955. e[preventDefault]();
  53956. next = e[currentTarget];
  53957. !tabs[isAnimating] && !hasClass(next,active) && self.show();
  53958. };
  53959. // public method
  53960. this.show = function() { // the tab we clicked is now the next tab
  53961. next = next || element;
  53962. nextContent = queryElement(next[getAttribute]('href')); //this is the actual object, the next tab content to activate
  53963. activeTab = getActiveTab();
  53964. activeContent = getActiveContent();
  53965. tabs[isAnimating] = true;
  53966. removeClass(activeTab,active);
  53967. activeTab[setAttribute](ariaSelected,'false');
  53968. addClass(next,active);
  53969. next[setAttribute](ariaSelected,'true');
  53970. if ( dropdown ) {
  53971. if ( !hasClass(element[parentNode],'dropdown-menu') ) {
  53972. if (hasClass(dropdown,active)) removeClass(dropdown,active);
  53973. } else {
  53974. if (!hasClass(dropdown,active)) addClass(dropdown,active);
  53975. }
  53976. }
  53977. bootstrapCustomEvent.call(activeTab, hideEvent, component, next);
  53978. if (hasClass(activeContent, 'fade')) {
  53979. removeClass(activeContent,showClass);
  53980. emulateTransitionEnd(activeContent, triggerHide);
  53981. } else { triggerHide(); }
  53982. };
  53983. // init
  53984. if ( !(stringTab in element) ) { // prevent adding event handlers twice
  53985. on(element, clickEvent, clickHandler);
  53986. }
  53987. if (self[height]) { tabsContentContainer = getActiveContent()[parentNode]; }
  53988. element[stringTab] = self;
  53989. };
  53990. // TAB DATA API
  53991. // ============
  53992. supports[push]( [ stringTab, Tab, '['+dataToggle+'="tab"]' ] );
  53993. /* Native Javascript for Bootstrap | Initialize Data API
  53994. --------------------------------------------------------*/
  53995. var initializeDataAPI = function( constructor, collection ){
  53996. for (var i=0, l=collection[length]; i<l; i++) {
  53997. new constructor(collection[i]);
  53998. }
  53999. },
  54000. initCallback = BSN.initCallback = function(lookUp){
  54001. lookUp = lookUp || DOC;
  54002. for (var i=0, l=supports[length]; i<l; i++) {
  54003. initializeDataAPI( supports[i][1], lookUp[querySelectorAll] (supports[i][2]) );
  54004. }
  54005. };
  54006. // bulk initialize all components
  54007. DOC[body] ? initCallback() : on( DOC, 'DOMContentLoaded', function(){ initCallback(); } );
  54008. return {
  54009. Alert: Alert,
  54010. Button: Button,
  54011. Collapse: Collapse,
  54012. Dropdown: Dropdown,
  54013. Modal: Modal,
  54014. Popover: Popover,
  54015. Tab: Tab
  54016. };
  54017. }));
  54018. /***/ }),
  54019. /***/ 577:
  54020. /***/ ((module) => {
  54021. !function(t,e){ true?module.exports=e():0}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.loadImageElement=function(t,e){return new Promise(function(r,n){t.addEventListener("load",function(){r(t)},!1),t.addEventListener("error",function(t){n(t)},!1),t.src=e})},e.resize=function(t,e,r,n){if(!r&&!n)return{currentWidth:t,currentHeight:e};var i=t/e,o=void 0,a=void 0;return i>r/n?a=(o=Math.min(t,r))/i:o=(a=Math.min(e,n))*i,{width:o,height:a}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.base64ToFile=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"image/jpeg",r=window.atob(t),n=[],i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new window.Blob([new Uint8Array(n)],{type:e})},e.imageToCanvas=function(t,e,r,n){var i=document.createElement("canvas"),o=i.getContext("2d");if(i.width=e,i.height=r,!n||n>8)return o.drawImage(t,0,0,i.width,i.height),i;switch(n>4&&(i.width=r,i.height=e),n){case 2:o.translate(e,0),o.scale(-1,1);break;case 3:o.translate(e,r),o.rotate(Math.PI);break;case 4:o.translate(0,r),o.scale(1,-1);break;case 5:o.rotate(.5*Math.PI),o.scale(1,-1);break;case 6:o.rotate(.5*Math.PI),o.translate(0,-r);break;case 7:o.rotate(.5*Math.PI),o.translate(e,-r),o.scale(-1,1);break;case 8:o.rotate(-.5*Math.PI),o.translate(-e,0)}return n>4?o.drawImage(t,0,0,i.height,i.width):o.drawImage(t,0,0,i.width,i.height),i},e.canvasToBlob=function(t,e){return new Promise(function(r,n){t.toBlob(function(t){r(t)},"image/jpeg",e)})},e.size=function(t){return{kB:.001*t,MB:1e-6*t}},e.blobToBase64=function(t){return new Promise(function(e,r){var n=new window.FileReader;n.addEventListener("load",function(t){e(t.target.result)},!1),n.addEventListener("error",function(t){r(t)},!1),n.readAsDataURL(t)})}},function(t,e,r){t.exports=r(6)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.extractOrientation=function(t){return new Promise(function(e,r){var n=new window.FileReader;n.onload=function(t){var r=new DataView(t.target.result);65496!==r.getUint16(0,!1)&&e(-2);for(var n=r.byteLength,i=2;i<n;){var o=r.getUint16(i,!1);if(i+=2,65505===o){1165519206!==r.getUint32(i+=2,!1)&&e(-1);var a=18761===r.getUint16(i+=6,!1);i+=r.getUint32(i+4,a);var u=r.getUint16(i,a);i+=2;for(var s=0;s<u;s++)274===r.getUint16(i+12*s,a)&&e(r.getUint16(i+12*s+8,a))}else{if(65280!=(65280&o))break;i+=r.getUint16(i,!1)}}e(-1)},n.readAsArrayBuffer(t.slice(0,65536))})}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,i=r(2),o=(n=i)&&n.__esModule?n:{default:n},a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),u=r(3),s=r(0),c=r(1);function f(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,r){return function n(i,o){try{var a=e[i](o),u=a.value}catch(t){return void r(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}("next")})}}var l=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.data=e,this.name=e.name,this.type=e.type,this.size=e.size}return a(t,[{key:"setData",value:function(t){this.data=t,this.size=t.size,this.type=t.type}},{key:"_calculateOrientation",value:function(){var t=f(o.default.mark(function t(){var e;return o.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,u.extractOrientation)(this.data);case 2:e=t.sent,this.orientation=e;case 4:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"load",value:function(){var t=f(o.default.mark(function t(){var e,r;return o.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._calculateOrientation();case 2:return e=URL.createObjectURL(this.data),r=new window.Image,t.next=6,(0,s.loadImageElement)(r,e);case 6:URL.revokeObjectURL(e),this._img=r,this.width=r.naturalWidth,this.height=r.naturalHeight;case 10:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"getCanvas",value:function(t,e,r){return void 0!==r?(0,c.imageToCanvas)(this._img,t,e,r):(0,c.imageToCanvas)(this._img,t,e,this.orientation)}}]),t}();e.default=l,t.exports=e.default},function(t,e){!function(e){"use strict";var r,n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag",c="object"==typeof t,f=e.regeneratorRuntime;if(f)c&&(t.exports=f);else{(f=e.regeneratorRuntime=c?t.exports:{}).wrap=w;var l="suspendedStart",h="suspendedYield",p="executing",d="completed",A={},v={};v[a]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(z([])));g&&g!==n&&i.call(g,a)&&(v=g);var m=B.prototype=x.prototype=Object.create(v);b.prototype=m.constructor=B,B.constructor=b,B[s]=b.displayName="GeneratorFunction",f.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},f.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,B):(t.__proto__=B,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(m),t},f.awrap=function(t){return{__await:t}},Q(_.prototype),_.prototype[u]=function(){return this},f.AsyncIterator=_,f.async=function(t,e,r,n){var i=new _(w(t,e,r,n));return f.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},Q(m),m[s]="Generator",m[a]=function(){return this},m.toString=function(){return"[object Generator]"},f.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},f.values=z,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return u.type="throw",u.arg=t,e.next=n,i&&(e.method="next",e.arg=r),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,A):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),A},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),A}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:z(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),A}}}function w(t,e,r,n){var i=e&&e.prototype instanceof x?e:x,o=Object.create(i.prototype),a=new O(n||[]);return o._invoke=function(t,e,r){var n=l;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===d){if("throw"===i)throw o;return j()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=k(a,r);if(u){if(u===A)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var s=E(t,e,r);if("normal"===s.type){if(n=r.done?d:h,s.arg===A)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function E(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function x(){}function b(){}function B(){}function Q(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function _(t){var e;this._invoke=function(r,n){function o(){return new Promise(function(e,o){!function e(r,n,o,a){var u=E(t[r],t,n);if("throw"!==u.type){var s=u.arg,c=s.value;return c&&"object"==typeof c&&i.call(c,"__await")?Promise.resolve(c.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(c).then(function(t){s.value=t,o(s)},a)}a(u.arg)}(r,n,e,o)})}return e=e?e.then(o,o):o()}}function k(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,k(t,e),"throw"===e.method))return A;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return A}var i=E(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,A;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,A):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,A)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function z(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(i.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:r,done:!0}}}(function(){return this}()||Function("return this")())},function(t,e,r){var n=function(){return this}()||Function("return this")(),i=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,o=i&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=r(5),i)n.regeneratorRuntime=o;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=s(r(2)),i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(1)),a=r(0),u=s(r(4));function s(t){return t&&t.__esModule?t:{default:t}}function c(t){return function(){var e=t.apply(this,arguments);return new Promise(function(t,r){return function n(i,o){try{var a=e[i](o),u=a.value}catch(t){return void r(t)}if(!a.done)return Promise.resolve(u).then(function(t){n("next",t)},function(t){n("throw",t)});t(u)}("next")})}}var f=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setOptions(e)}return i(t,[{key:"setOptions",value:function(t){var e={targetSize:1/0,quality:.75,minQuality:.5,qualityStepSize:.1,maxWidth:1920,maxHeight:1920,resize:!0,throwIfSizeNotReached:!1,autoRotate:!0},r=new Proxy(t,{get:function(t,r){return r in t?t[r]:e[r]}});this.options=r}},{key:"_compressFile",value:function(){var t=c(n.default.mark(function t(e){var r,i;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=new u.default(e),(i={}).start=window.performance.now(),i.quality=this.options.quality,i.startType=r.type,t.next=7,r.load();case 7:return t.next=9,this._compressImage(r,i);case 9:return t.abrupt("return",t.sent);case 10:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"_compressImage",value:function(){var t=c(n.default.mark(function t(e,r){var i,u,s,c,f;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r.startWidth=e.width,r.startHeight=e.height,i=void 0,u=void 0,this.options.resize?(s=(0,a.resize)(e.width,e.height,this.options.maxWidth,this.options.maxHeight),i=s.width,u=s.height):(i=e.width,u=e.height),r.endWidth=i,r.endHeight=u,c=this.doAutoRotation?void 0:1,f=e.getCanvas(i,u,c),r.iterations=0,r.startSizeMB=o.size(e.size).MB,t.next=12,this._loopCompression(f,e,r);case 12:return r.endSizeMB=o.size(e.size).MB,r.sizeReducedInPercent=(r.startSizeMB-r.endSizeMB)/r.startSizeMB*100,r.end=window.performance.now(),r.elapsedTimeInSeconds=(r.end-r.start)/1e3,r.endType=e.type,t.abrupt("return",{photo:e,info:r});case 18:case"end":return t.stop()}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"_loopCompression",value:function(){var t=c(n.default.mark(function t(e,r,i){var a;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i.iterations++,t.t0=r,t.next=4,o.canvasToBlob(e,i.quality);case 4:if(t.t1=t.sent,t.t0.setData.call(t.t0,t.t1),1==i.iterations&&(r.width=i.endWidth,r.height=i.endHeight),!(o.size(r.size).MB>this.options.targetSize)){t.next=24;break}if(!(i.quality.toFixed(10)-.1<this.options.minQuality)){t.next=18;break}if(a="Couldn't compress image to target size while maintaining quality.\n Target size: "+this.options.targetSize+"\n Actual size: "+o.size(r.size).MB,this.options.throwIfSizeNotReached){t.next=14;break}console.error(a),t.next=15;break;case 14:throw new Error(a);case 15:return t.abrupt("return");case 18:return i.quality-=this.options.qualityStepSize,t.next=21,this._loopCompression(e,r,i);case 21:return t.abrupt("return",t.sent);case 22:t.next=25;break;case 24:return t.abrupt("return");case 25:case"end":return t.stop()}},t,this)}));return function(e,r,n){return t.apply(this,arguments)}}()},{key:"setAutoRotate",value:function(){var e=c(n.default.mark(function e(){var r;return n.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.automaticRotationFeatureTest();case 2:r=e.sent,this.doAutoRotation=this.options.autoRotate&&!r;case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"compress",value:function(){var t=c(n.default.mark(function t(e){var r=this;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.setAutoRotate();case 2:return t.abrupt("return",Promise.all(e.map(function(t){return r._compressFile(t)})));case 3:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()}],[{key:"blobToBase64",value:function(){var t=c(n.default.mark(function t(){var e=arguments;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,o.blobToBase64.apply(o,e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"loadImageElement",value:function(){var t=c(n.default.mark(function t(){var e=arguments;return n.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.loadImageElement.apply(void 0,e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"automaticRotationFeatureTest",value:function(){return new Promise(function(t){var e=new Image;e.onload=function(){var r=1===e.width&&2===e.height;t(r)},e.src="data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q=="})}}]),t}();e.default=f,t.exports=e.default}])});
  54022. /***/ }),
  54023. /***/ 5251:
  54024. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54025. "use strict";
  54026. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54027. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54028. /* harmony export */ });
  54029. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54030. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54031. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54032. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54033. // Imports
  54034. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54035. // Module
  54036. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54037. // Exports
  54038. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54039. /***/ }),
  54040. /***/ 6931:
  54041. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54042. "use strict";
  54043. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54044. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54045. /* harmony export */ });
  54046. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54047. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54048. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54049. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54050. // Imports
  54051. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54052. // Module
  54053. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54054. // Exports
  54055. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54056. /***/ }),
  54057. /***/ 352:
  54058. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54059. "use strict";
  54060. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54061. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54062. /* harmony export */ });
  54063. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54064. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54065. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54066. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54067. // Imports
  54068. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54069. // Module
  54070. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54071. // Exports
  54072. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54073. /***/ }),
  54074. /***/ 7802:
  54075. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54076. "use strict";
  54077. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54078. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54079. /* harmony export */ });
  54080. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54081. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54082. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54083. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54084. // Imports
  54085. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54086. // Module
  54087. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54088. // Exports
  54089. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54090. /***/ }),
  54091. /***/ 5599:
  54092. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54093. "use strict";
  54094. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54095. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54096. /* harmony export */ });
  54097. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54098. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54099. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54100. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54101. // Imports
  54102. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54103. // Module
  54104. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54105. // Exports
  54106. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54107. /***/ }),
  54108. /***/ 1875:
  54109. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54110. "use strict";
  54111. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54112. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54113. /* harmony export */ });
  54114. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54115. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54116. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54117. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54118. // Imports
  54119. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54120. // Module
  54121. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54122. // Exports
  54123. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54124. /***/ }),
  54125. /***/ 2791:
  54126. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54127. "use strict";
  54128. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54129. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54130. /* harmony export */ });
  54131. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54132. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54133. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54134. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54135. // Imports
  54136. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54137. // Module
  54138. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54139. // Exports
  54140. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54141. /***/ }),
  54142. /***/ 5956:
  54143. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54144. "use strict";
  54145. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54146. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54147. /* harmony export */ });
  54148. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54149. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54150. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54151. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54152. // Imports
  54153. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54154. // Module
  54155. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54156. // Exports
  54157. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54158. /***/ }),
  54159. /***/ 9679:
  54160. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54161. "use strict";
  54162. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54163. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54164. /* harmony export */ });
  54165. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54166. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54167. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54168. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54169. // Imports
  54170. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54171. // Module
  54172. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54173. // Exports
  54174. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54175. /***/ }),
  54176. /***/ 4915:
  54177. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54178. "use strict";
  54179. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54180. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54181. /* harmony export */ });
  54182. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54183. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54184. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54185. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54186. // Imports
  54187. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54188. // Module
  54189. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54190. // Exports
  54191. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54192. /***/ }),
  54193. /***/ 1638:
  54194. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54195. "use strict";
  54196. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54197. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54198. /* harmony export */ });
  54199. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54200. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54201. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54202. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54203. // Imports
  54204. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54205. // Module
  54206. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54207. // Exports
  54208. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54209. /***/ }),
  54210. /***/ 3076:
  54211. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54212. "use strict";
  54213. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54214. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54215. /* harmony export */ });
  54216. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54217. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54218. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54219. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54220. // Imports
  54221. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54222. // Module
  54223. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54224. // Exports
  54225. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54226. /***/ }),
  54227. /***/ 6916:
  54228. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54229. "use strict";
  54230. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54231. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54232. /* harmony export */ });
  54233. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54234. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54235. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54236. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54237. // Imports
  54238. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54239. // Module
  54240. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54241. // Exports
  54242. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54243. /***/ }),
  54244. /***/ 7140:
  54245. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54246. "use strict";
  54247. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54248. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54249. /* harmony export */ });
  54250. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54251. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54252. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54253. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54254. // Imports
  54255. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54256. // Module
  54257. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54258. // Exports
  54259. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54260. /***/ }),
  54261. /***/ 3288:
  54262. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54263. "use strict";
  54264. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54265. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54266. /* harmony export */ });
  54267. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54268. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54269. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54270. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54271. // Imports
  54272. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54273. // Module
  54274. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54275. // Exports
  54276. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54277. /***/ }),
  54278. /***/ 902:
  54279. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54280. "use strict";
  54281. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54282. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54283. /* harmony export */ });
  54284. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54285. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54286. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54287. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54288. // Imports
  54289. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54290. // Module
  54291. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54292. // Exports
  54293. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54294. /***/ }),
  54295. /***/ 6233:
  54296. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54297. "use strict";
  54298. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54299. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54300. /* harmony export */ });
  54301. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54302. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54303. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54304. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54305. // Imports
  54306. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54307. // Module
  54308. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54309. // Exports
  54310. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54311. /***/ }),
  54312. /***/ 1513:
  54313. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54314. "use strict";
  54315. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54316. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54317. /* harmony export */ });
  54318. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54319. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54320. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54321. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54322. // Imports
  54323. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54324. // Module
  54325. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54326. // Exports
  54327. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54328. /***/ }),
  54329. /***/ 1984:
  54330. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54331. "use strict";
  54332. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54333. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54334. /* harmony export */ });
  54335. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54336. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54337. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54338. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54339. // Imports
  54340. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54341. // Module
  54342. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54343. // Exports
  54344. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54345. /***/ }),
  54346. /***/ 1833:
  54347. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54348. "use strict";
  54349. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54350. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54351. /* harmony export */ });
  54352. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54353. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54354. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54355. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54356. // Imports
  54357. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54358. // Module
  54359. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54360. // Exports
  54361. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54362. /***/ }),
  54363. /***/ 4921:
  54364. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54365. "use strict";
  54366. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54367. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54368. /* harmony export */ });
  54369. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54370. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54371. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54372. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54373. // Imports
  54374. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54375. // Module
  54376. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54377. // Exports
  54378. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54379. /***/ }),
  54380. /***/ 5222:
  54381. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54382. "use strict";
  54383. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54384. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54385. /* harmony export */ });
  54386. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54387. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54388. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54389. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54390. // Imports
  54391. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54392. // Module
  54393. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54394. // Exports
  54395. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54396. /***/ }),
  54397. /***/ 8054:
  54398. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54399. "use strict";
  54400. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54401. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54402. /* harmony export */ });
  54403. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54404. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54405. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54406. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54407. // Imports
  54408. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54409. // Module
  54410. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54411. // Exports
  54412. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54413. /***/ }),
  54414. /***/ 8125:
  54415. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54416. "use strict";
  54417. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54418. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54419. /* harmony export */ });
  54420. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54421. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54422. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54423. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54424. // Imports
  54425. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54426. // Module
  54427. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54428. // Exports
  54429. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54430. /***/ }),
  54431. /***/ 4166:
  54432. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54433. "use strict";
  54434. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54435. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54436. /* harmony export */ });
  54437. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54438. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54439. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54440. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54441. // Imports
  54442. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54443. // Module
  54444. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54445. // Exports
  54446. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54447. /***/ }),
  54448. /***/ 6278:
  54449. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54450. "use strict";
  54451. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54452. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54453. /* harmony export */ });
  54454. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54455. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54456. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54457. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54458. // Imports
  54459. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54460. // Module
  54461. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54462. // Exports
  54463. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54464. /***/ }),
  54465. /***/ 9523:
  54466. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54467. "use strict";
  54468. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54469. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54470. /* harmony export */ });
  54471. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54472. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54473. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54474. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54475. // Imports
  54476. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54477. // Module
  54478. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54479. // Exports
  54480. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54481. /***/ }),
  54482. /***/ 6176:
  54483. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54484. "use strict";
  54485. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54486. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54487. /* harmony export */ });
  54488. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54489. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54490. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54491. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54492. // Imports
  54493. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54494. // Module
  54495. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54496. // Exports
  54497. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54498. /***/ }),
  54499. /***/ 5046:
  54500. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54501. "use strict";
  54502. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54503. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54504. /* harmony export */ });
  54505. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54506. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54507. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54508. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54509. // Imports
  54510. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54511. // Module
  54512. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54513. // Exports
  54514. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54515. /***/ }),
  54516. /***/ 7631:
  54517. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54518. "use strict";
  54519. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54520. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54521. /* harmony export */ });
  54522. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54523. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54524. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54525. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54526. // Imports
  54527. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54528. // Module
  54529. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54530. // Exports
  54531. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54532. /***/ }),
  54533. /***/ 4903:
  54534. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54535. "use strict";
  54536. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54537. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54538. /* harmony export */ });
  54539. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54540. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54541. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54542. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54543. // Imports
  54544. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54545. // Module
  54546. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54547. // Exports
  54548. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54549. /***/ }),
  54550. /***/ 6450:
  54551. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54552. "use strict";
  54553. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54554. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54555. /* harmony export */ });
  54556. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54557. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54558. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54559. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54560. // Imports
  54561. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54562. // Module
  54563. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54564. // Exports
  54565. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54566. /***/ }),
  54567. /***/ 307:
  54568. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54569. "use strict";
  54570. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54571. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54572. /* harmony export */ });
  54573. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54574. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54575. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54576. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54577. // Imports
  54578. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54579. // Module
  54580. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54581. // Exports
  54582. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54583. /***/ }),
  54584. /***/ 9537:
  54585. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54586. "use strict";
  54587. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54588. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54589. /* harmony export */ });
  54590. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54591. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54592. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54593. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54594. // Imports
  54595. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54596. // Module
  54597. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54598. // Exports
  54599. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54600. /***/ }),
  54601. /***/ 9959:
  54602. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  54603. "use strict";
  54604. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  54605. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  54606. /* harmony export */ });
  54607. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7537);
  54608. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  54609. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3645);
  54610. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  54611. // Imports
  54612. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  54613. // Module
  54614. ___CSS_LOADER_EXPORT___.push([module.id, "", "",{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}]);
  54615. // Exports
  54616. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
  54617. /***/ }),
  54618. /***/ 3645:
  54619. /***/ ((module) => {
  54620. "use strict";
  54621. /*
  54622. MIT License http://www.opensource.org/licenses/mit-license.php
  54623. Author Tobias Koppers @sokra
  54624. */
  54625. module.exports = function (cssWithMappingToString) {
  54626. var list = []; // return the list of modules as css string
  54627. list.toString = function toString() {
  54628. return this.map(function (item) {
  54629. var content = "";
  54630. var needLayer = typeof item[5] !== "undefined";
  54631. if (item[4]) {
  54632. content += "@supports (".concat(item[4], ") {");
  54633. }
  54634. if (item[2]) {
  54635. content += "@media ".concat(item[2], " {");
  54636. }
  54637. if (needLayer) {
  54638. content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
  54639. }
  54640. content += cssWithMappingToString(item);
  54641. if (needLayer) {
  54642. content += "}";
  54643. }
  54644. if (item[2]) {
  54645. content += "}";
  54646. }
  54647. if (item[4]) {
  54648. content += "}";
  54649. }
  54650. return content;
  54651. }).join("");
  54652. }; // import a list of modules into the list
  54653. list.i = function i(modules, media, dedupe, supports, layer) {
  54654. if (typeof modules === "string") {
  54655. modules = [[null, modules, undefined]];
  54656. }
  54657. var alreadyImportedModules = {};
  54658. if (dedupe) {
  54659. for (var k = 0; k < this.length; k++) {
  54660. var id = this[k][0];
  54661. if (id != null) {
  54662. alreadyImportedModules[id] = true;
  54663. }
  54664. }
  54665. }
  54666. for (var _k = 0; _k < modules.length; _k++) {
  54667. var item = [].concat(modules[_k]);
  54668. if (dedupe && alreadyImportedModules[item[0]]) {
  54669. continue;
  54670. }
  54671. if (typeof layer !== "undefined") {
  54672. if (typeof item[5] === "undefined") {
  54673. item[5] = layer;
  54674. } else {
  54675. item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
  54676. item[5] = layer;
  54677. }
  54678. }
  54679. if (media) {
  54680. if (!item[2]) {
  54681. item[2] = media;
  54682. } else {
  54683. item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
  54684. item[2] = media;
  54685. }
  54686. }
  54687. if (supports) {
  54688. if (!item[4]) {
  54689. item[4] = "".concat(supports);
  54690. } else {
  54691. item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
  54692. item[4] = supports;
  54693. }
  54694. }
  54695. list.push(item);
  54696. }
  54697. };
  54698. return list;
  54699. };
  54700. /***/ }),
  54701. /***/ 7537:
  54702. /***/ ((module) => {
  54703. "use strict";
  54704. module.exports = function (item) {
  54705. var content = item[1];
  54706. var cssMapping = item[3];
  54707. if (!cssMapping) {
  54708. return content;
  54709. }
  54710. if (typeof btoa === "function") {
  54711. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
  54712. var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
  54713. var sourceMapping = "/*# ".concat(data, " */");
  54714. var sourceURLs = cssMapping.sources.map(function (source) {
  54715. return "/*# sourceURL=".concat(cssMapping.sourceRoot || "").concat(source, " */");
  54716. });
  54717. return [content].concat(sourceURLs).concat([sourceMapping]).join("\n");
  54718. }
  54719. return [content].join("\n");
  54720. };
  54721. /***/ }),
  54722. /***/ 7484:
  54723. /***/ (function(module) {
  54724. !function(t,e){ true?module.exports=e():0}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v="en",D={};D[v]=M;var p=function(t){return t instanceof _},S=function t(e,n,r){var i;if(!e)return v;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(v=i),i||!r&&v},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var v=this.$locale().weekStart||0,D=(y<v?y+7:y)-v;return $(r?m-D:m+(6-D),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||$;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||l[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,v=O.m(this,M);return v=(l={},l[c]=v/12,l[f]=v,l[h]=v/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?v:O.a(v)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[v],w.Ls=D,w.p={},w}));
  54725. /***/ }),
  54726. /***/ 9434:
  54727. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  54728. var map = {
  54729. "./af.js": [
  54730. 5903,
  54731. 9210
  54732. ],
  54733. "./am.js": [
  54734. 9911,
  54735. 5073
  54736. ],
  54737. "./ar-dz.js": [
  54738. 7200,
  54739. 9406
  54740. ],
  54741. "./ar-iq.js": [
  54742. 7719,
  54743. 2990
  54744. ],
  54745. "./ar-kw.js": [
  54746. 2376,
  54747. 9897
  54748. ],
  54749. "./ar-ly.js": [
  54750. 8540,
  54751. 3521
  54752. ],
  54753. "./ar-ma.js": [
  54754. 6817,
  54755. 5313
  54756. ],
  54757. "./ar-sa.js": [
  54758. 1573,
  54759. 485
  54760. ],
  54761. "./ar-tn.js": [
  54762. 9339,
  54763. 8040
  54764. ],
  54765. "./ar.js": [
  54766. 3939,
  54767. 6755
  54768. ],
  54769. "./az.js": [
  54770. 8092,
  54771. 4963
  54772. ],
  54773. "./be.js": [
  54774. 504,
  54775. 9478
  54776. ],
  54777. "./bg.js": [
  54778. 9091,
  54779. 578
  54780. ],
  54781. "./bi.js": [
  54782. 9149,
  54783. 2984
  54784. ],
  54785. "./bm.js": [
  54786. 5287,
  54787. 2263
  54788. ],
  54789. "./bn-bd.js": [
  54790. 4067,
  54791. 1351
  54792. ],
  54793. "./bn.js": [
  54794. 5254,
  54795. 280
  54796. ],
  54797. "./bo.js": [
  54798. 2502,
  54799. 9950
  54800. ],
  54801. "./br.js": [
  54802. 8864,
  54803. 760
  54804. ],
  54805. "./bs.js": [
  54806. 4502,
  54807. 9833
  54808. ],
  54809. "./ca.js": [
  54810. 3646,
  54811. 102
  54812. ],
  54813. "./cs.js": [
  54814. 8507,
  54815. 7400
  54816. ],
  54817. "./cv.js": [
  54818. 6636,
  54819. 4481
  54820. ],
  54821. "./cy.js": [
  54822. 8792,
  54823. 6740
  54824. ],
  54825. "./da.js": [
  54826. 7427,
  54827. 2548
  54828. ],
  54829. "./de-at.js": [
  54830. 3237,
  54831. 7175
  54832. ],
  54833. "./de-ch.js": [
  54834. 6148,
  54835. 1679
  54836. ],
  54837. "./de.js": [
  54838. 790,
  54839. 52
  54840. ],
  54841. "./dv.js": [
  54842. 1794,
  54843. 5569
  54844. ],
  54845. "./el.js": [
  54846. 5423,
  54847. 1606
  54848. ],
  54849. "./en-au.js": [
  54850. 5109,
  54851. 5485
  54852. ],
  54853. "./en-ca.js": [
  54854. 5105,
  54855. 4035
  54856. ],
  54857. "./en-gb.js": [
  54858. 9517,
  54859. 6031
  54860. ],
  54861. "./en-ie.js": [
  54862. 758,
  54863. 8129
  54864. ],
  54865. "./en-il.js": [
  54866. 5805,
  54867. 3463
  54868. ],
  54869. "./en-in.js": [
  54870. 8529,
  54871. 6898
  54872. ],
  54873. "./en-nz.js": [
  54874. 302,
  54875. 8547
  54876. ],
  54877. "./en-sg.js": [
  54878. 5941,
  54879. 1735
  54880. ],
  54881. "./en-tt.js": [
  54882. 6183,
  54883. 6105
  54884. ],
  54885. "./en.js": [
  54886. 5054,
  54887. 535
  54888. ],
  54889. "./eo.js": [
  54890. 4990,
  54891. 5121
  54892. ],
  54893. "./es-do.js": [
  54894. 3864,
  54895. 8758
  54896. ],
  54897. "./es-mx.js": [
  54898. 7118,
  54899. 7416
  54900. ],
  54901. "./es-pr.js": [
  54902. 3521,
  54903. 911
  54904. ],
  54905. "./es-us.js": [
  54906. 6165,
  54907. 3208
  54908. ],
  54909. "./es.js": [
  54910. 7763,
  54911. 3411
  54912. ],
  54913. "./et.js": [
  54914. 9670,
  54915. 4153
  54916. ],
  54917. "./eu.js": [
  54918. 6629,
  54919. 1396
  54920. ],
  54921. "./fa.js": [
  54922. 6953,
  54923. 5544
  54924. ],
  54925. "./fi.js": [
  54926. 7822,
  54927. 2130
  54928. ],
  54929. "./fo.js": [
  54930. 9197,
  54931. 8745
  54932. ],
  54933. "./fr-ca.js": [
  54934. 7989,
  54935. 7363
  54936. ],
  54937. "./fr-ch.js": [
  54938. 4254,
  54939. 7952
  54940. ],
  54941. "./fr.js": [
  54942. 6023,
  54943. 1910
  54944. ],
  54945. "./fy.js": [
  54946. 3220,
  54947. 6376
  54948. ],
  54949. "./ga.js": [
  54950. 7467,
  54951. 688
  54952. ],
  54953. "./gd.js": [
  54954. 4855,
  54955. 5050
  54956. ],
  54957. "./gl.js": [
  54958. 229,
  54959. 5818
  54960. ],
  54961. "./gom-latn.js": [
  54962. 6312,
  54963. 825
  54964. ],
  54965. "./gu.js": [
  54966. 7632,
  54967. 3623
  54968. ],
  54969. "./he.js": [
  54970. 5418,
  54971. 9372
  54972. ],
  54973. "./hi.js": [
  54974. 7573,
  54975. 8010
  54976. ],
  54977. "./hr.js": [
  54978. 6257,
  54979. 7419
  54980. ],
  54981. "./ht.js": [
  54982. 8889,
  54983. 5822
  54984. ],
  54985. "./hu.js": [
  54986. 8562,
  54987. 8214
  54988. ],
  54989. "./hy-am.js": [
  54990. 8242,
  54991. 5407
  54992. ],
  54993. "./id.js": [
  54994. 3783,
  54995. 9513
  54996. ],
  54997. "./is.js": [
  54998. 8980,
  54999. 1194
  55000. ],
  55001. "./it-ch.js": [
  55002. 3706,
  55003. 6010
  55004. ],
  55005. "./it.js": [
  55006. 5551,
  55007. 1880
  55008. ],
  55009. "./ja.js": [
  55010. 6831,
  55011. 1107
  55012. ],
  55013. "./jv.js": [
  55014. 2641,
  55015. 4305
  55016. ],
  55017. "./ka.js": [
  55018. 6622,
  55019. 5186
  55020. ],
  55021. "./kk.js": [
  55022. 2921,
  55023. 5206
  55024. ],
  55025. "./km.js": [
  55026. 5567,
  55027. 2475
  55028. ],
  55029. "./kn.js": [
  55030. 1113,
  55031. 7523
  55032. ],
  55033. "./ko.js": [
  55034. 9132,
  55035. 3446
  55036. ],
  55037. "./ku.js": [
  55038. 4888,
  55039. 7024
  55040. ],
  55041. "./ky.js": [
  55042. 466,
  55043. 5055
  55044. ],
  55045. "./lb.js": [
  55046. 1796,
  55047. 5215
  55048. ],
  55049. "./lo.js": [
  55050. 8894,
  55051. 1204
  55052. ],
  55053. "./lt.js": [
  55054. 8768,
  55055. 7899
  55056. ],
  55057. "./lv.js": [
  55058. 953,
  55059. 631
  55060. ],
  55061. "./me.js": [
  55062. 8066,
  55063. 145
  55064. ],
  55065. "./mi.js": [
  55066. 8602,
  55067. 7454
  55068. ],
  55069. "./mk.js": [
  55070. 1560,
  55071. 4951
  55072. ],
  55073. "./ml.js": [
  55074. 4017,
  55075. 7679
  55076. ],
  55077. "./mn.js": [
  55078. 4717,
  55079. 8618
  55080. ],
  55081. "./mr.js": [
  55082. 5473,
  55083. 5600
  55084. ],
  55085. "./ms-my.js": [
  55086. 7387,
  55087. 882
  55088. ],
  55089. "./ms.js": [
  55090. 5742,
  55091. 9095
  55092. ],
  55093. "./mt.js": [
  55094. 8477,
  55095. 9665
  55096. ],
  55097. "./my.js": [
  55098. 2966,
  55099. 5166
  55100. ],
  55101. "./nb.js": [
  55102. 9682,
  55103. 646
  55104. ],
  55105. "./ne.js": [
  55106. 4149,
  55107. 9030
  55108. ],
  55109. "./nl-be.js": [
  55110. 7496,
  55111. 3155
  55112. ],
  55113. "./nl.js": [
  55114. 9182,
  55115. 1520
  55116. ],
  55117. "./nn.js": [
  55118. 2722,
  55119. 7050
  55120. ],
  55121. "./oc-lnc.js": [
  55122. 6159,
  55123. 7203
  55124. ],
  55125. "./pa-in.js": [
  55126. 5914,
  55127. 5850
  55128. ],
  55129. "./pl.js": [
  55130. 1987,
  55131. 1211
  55132. ],
  55133. "./pt-br.js": [
  55134. 7548,
  55135. 5274
  55136. ],
  55137. "./pt.js": [
  55138. 5001,
  55139. 265
  55140. ],
  55141. "./rn.js": [
  55142. 123,
  55143. 4678
  55144. ],
  55145. "./ro.js": [
  55146. 8146,
  55147. 8022
  55148. ],
  55149. "./ru.js": [
  55150. 600,
  55151. 559
  55152. ],
  55153. "./rw.js": [
  55154. 6509,
  55155. 3221
  55156. ],
  55157. "./sd.js": [
  55158. 5437,
  55159. 1298
  55160. ],
  55161. "./se.js": [
  55162. 772,
  55163. 1942
  55164. ],
  55165. "./si.js": [
  55166. 7109,
  55167. 9333
  55168. ],
  55169. "./sk.js": [
  55170. 5627,
  55171. 6783
  55172. ],
  55173. "./sl.js": [
  55174. 2544,
  55175. 9625
  55176. ],
  55177. "./sq.js": [
  55178. 8341,
  55179. 8603
  55180. ],
  55181. "./sr-cyrl.js": [
  55182. 7101,
  55183. 3435
  55184. ],
  55185. "./sr.js": [
  55186. 617,
  55187. 7390
  55188. ],
  55189. "./ss.js": [
  55190. 4127,
  55191. 9238
  55192. ],
  55193. "./sv-fi.js": [
  55194. 6421,
  55195. 9997
  55196. ],
  55197. "./sv.js": [
  55198. 1876,
  55199. 9652
  55200. ],
  55201. "./sw.js": [
  55202. 2030,
  55203. 9733
  55204. ],
  55205. "./ta.js": [
  55206. 5596,
  55207. 7645
  55208. ],
  55209. "./te.js": [
  55210. 5159,
  55211. 7714
  55212. ],
  55213. "./tet.js": [
  55214. 9157,
  55215. 555
  55216. ],
  55217. "./tg.js": [
  55218. 9928,
  55219. 2446
  55220. ],
  55221. "./th.js": [
  55222. 2019,
  55223. 1729
  55224. ],
  55225. "./tk.js": [
  55226. 5817,
  55227. 5256
  55228. ],
  55229. "./tl-ph.js": [
  55230. 6513,
  55231. 9443
  55232. ],
  55233. "./tlh.js": [
  55234. 7296,
  55235. 2814
  55236. ],
  55237. "./tr.js": [
  55238. 3035,
  55239. 8665
  55240. ],
  55241. "./tzl.js": [
  55242. 7797,
  55243. 2843
  55244. ],
  55245. "./tzm-latn.js": [
  55246. 261,
  55247. 3933
  55248. ],
  55249. "./tzm.js": [
  55250. 4722,
  55251. 4342
  55252. ],
  55253. "./ug-cn.js": [
  55254. 313,
  55255. 6890
  55256. ],
  55257. "./uk.js": [
  55258. 4144,
  55259. 1619
  55260. ],
  55261. "./ur.js": [
  55262. 2957,
  55263. 9568
  55264. ],
  55265. "./uz-latn.js": [
  55266. 8727,
  55267. 1110
  55268. ],
  55269. "./uz.js": [
  55270. 7486,
  55271. 3153
  55272. ],
  55273. "./vi.js": [
  55274. 7553,
  55275. 8073
  55276. ],
  55277. "./x-pseudo.js": [
  55278. 5321,
  55279. 4423
  55280. ],
  55281. "./yo.js": [
  55282. 4724,
  55283. 8692
  55284. ],
  55285. "./zh-cn.js": [
  55286. 3852,
  55287. 9630
  55288. ],
  55289. "./zh-hk.js": [
  55290. 2390,
  55291. 3755
  55292. ],
  55293. "./zh-tw.js": [
  55294. 3901,
  55295. 6776
  55296. ],
  55297. "./zh.js": [
  55298. 2009,
  55299. 8458
  55300. ]
  55301. };
  55302. function webpackAsyncContext(req) {
  55303. if(!__webpack_require__.o(map, req)) {
  55304. return Promise.resolve().then(() => {
  55305. var e = new Error("Cannot find module '" + req + "'");
  55306. e.code = 'MODULE_NOT_FOUND';
  55307. throw e;
  55308. });
  55309. }
  55310. var ids = map[req], id = ids[0];
  55311. return __webpack_require__.e(ids[1]).then(() => {
  55312. return __webpack_require__.t(id, 7 | 16);
  55313. });
  55314. }
  55315. webpackAsyncContext.keys = () => (Object.keys(map));
  55316. webpackAsyncContext.id = 9434;
  55317. module.exports = webpackAsyncContext;
  55318. /***/ }),
  55319. /***/ 8734:
  55320. /***/ (function(module) {
  55321. !function(e,t){ true?module.exports=t():0}(this,(function(){"use strict";return function(e,t,r){var n=t.prototype,s=n.format;r.en.ordinal=function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"},n.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return s.bind(this)(e);var n=this.$utils(),a=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return r.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return r.ordinal(t.week(),"W");case"w":case"ww":return n.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return n.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return n.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return"["+t.offsetName()+"]";case"zzz":return"["+t.offsetName("long")+"]";default:return e}}));return s.bind(this)(a)}}}));
  55322. /***/ }),
  55323. /***/ 7856:
  55324. /***/ (function(module) {
  55325. /*! @license DOMPurify 2.3.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.6/LICENSE */
  55326. (function (global, factory) {
  55327. true ? module.exports = factory() :
  55328. 0;
  55329. }(this, function () { 'use strict';
  55330. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  55331. var hasOwnProperty = Object.hasOwnProperty,
  55332. setPrototypeOf = Object.setPrototypeOf,
  55333. isFrozen = Object.isFrozen,
  55334. getPrototypeOf = Object.getPrototypeOf,
  55335. getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  55336. var freeze = Object.freeze,
  55337. seal = Object.seal,
  55338. create = Object.create; // eslint-disable-line import/no-mutable-exports
  55339. var _ref = typeof Reflect !== 'undefined' && Reflect,
  55340. apply = _ref.apply,
  55341. construct = _ref.construct;
  55342. if (!apply) {
  55343. apply = function apply(fun, thisValue, args) {
  55344. return fun.apply(thisValue, args);
  55345. };
  55346. }
  55347. if (!freeze) {
  55348. freeze = function freeze(x) {
  55349. return x;
  55350. };
  55351. }
  55352. if (!seal) {
  55353. seal = function seal(x) {
  55354. return x;
  55355. };
  55356. }
  55357. if (!construct) {
  55358. construct = function construct(Func, args) {
  55359. return new (Function.prototype.bind.apply(Func, [null].concat(_toConsumableArray(args))))();
  55360. };
  55361. }
  55362. var arrayForEach = unapply(Array.prototype.forEach);
  55363. var arrayPop = unapply(Array.prototype.pop);
  55364. var arrayPush = unapply(Array.prototype.push);
  55365. var stringToLowerCase = unapply(String.prototype.toLowerCase);
  55366. var stringMatch = unapply(String.prototype.match);
  55367. var stringReplace = unapply(String.prototype.replace);
  55368. var stringIndexOf = unapply(String.prototype.indexOf);
  55369. var stringTrim = unapply(String.prototype.trim);
  55370. var regExpTest = unapply(RegExp.prototype.test);
  55371. var typeErrorCreate = unconstruct(TypeError);
  55372. function unapply(func) {
  55373. return function (thisArg) {
  55374. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  55375. args[_key - 1] = arguments[_key];
  55376. }
  55377. return apply(func, thisArg, args);
  55378. };
  55379. }
  55380. function unconstruct(func) {
  55381. return function () {
  55382. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  55383. args[_key2] = arguments[_key2];
  55384. }
  55385. return construct(func, args);
  55386. };
  55387. }
  55388. /* Add properties to a lookup table */
  55389. function addToSet(set, array) {
  55390. if (setPrototypeOf) {
  55391. // Make 'in' and truthy checks like Boolean(set.constructor)
  55392. // independent of any properties defined on Object.prototype.
  55393. // Prevent prototype setters from intercepting set as a this value.
  55394. setPrototypeOf(set, null);
  55395. }
  55396. var l = array.length;
  55397. while (l--) {
  55398. var element = array[l];
  55399. if (typeof element === 'string') {
  55400. var lcElement = stringToLowerCase(element);
  55401. if (lcElement !== element) {
  55402. // Config presets (e.g. tags.js, attrs.js) are immutable.
  55403. if (!isFrozen(array)) {
  55404. array[l] = lcElement;
  55405. }
  55406. element = lcElement;
  55407. }
  55408. }
  55409. set[element] = true;
  55410. }
  55411. return set;
  55412. }
  55413. /* Shallow clone an object */
  55414. function clone(object) {
  55415. var newObject = create(null);
  55416. var property = void 0;
  55417. for (property in object) {
  55418. if (apply(hasOwnProperty, object, [property])) {
  55419. newObject[property] = object[property];
  55420. }
  55421. }
  55422. return newObject;
  55423. }
  55424. /* IE10 doesn't support __lookupGetter__ so lets'
  55425. * simulate it. It also automatically checks
  55426. * if the prop is function or getter and behaves
  55427. * accordingly. */
  55428. function lookupGetter(object, prop) {
  55429. while (object !== null) {
  55430. var desc = getOwnPropertyDescriptor(object, prop);
  55431. if (desc) {
  55432. if (desc.get) {
  55433. return unapply(desc.get);
  55434. }
  55435. if (typeof desc.value === 'function') {
  55436. return unapply(desc.value);
  55437. }
  55438. }
  55439. object = getPrototypeOf(object);
  55440. }
  55441. function fallbackValue(element) {
  55442. console.warn('fallback value for', element);
  55443. return null;
  55444. }
  55445. return fallbackValue;
  55446. }
  55447. var html = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
  55448. // SVG
  55449. var svg = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
  55450. var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
  55451. // List of SVG elements that are disallowed by default.
  55452. // We still need to know them so that we can do namespace
  55453. // checks properly in case one wants to add them to
  55454. // allow-list.
  55455. var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
  55456. var mathMl = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']);
  55457. // Similarly to SVG, we want to know all MathML elements,
  55458. // even those that we disallow by default.
  55459. var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
  55460. var text = freeze(['#text']);
  55461. var html$1 = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
  55462. var svg$1 = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
  55463. var mathMl$1 = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
  55464. var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
  55465. // eslint-disable-next-line unicorn/better-regex
  55466. var MUSTACHE_EXPR = seal(/\{\{[\s\S]*|[\s\S]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
  55467. var ERB_EXPR = seal(/<%[\s\S]*|[\s\S]*%>/gm);
  55468. var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
  55469. var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
  55470. var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
  55471. );
  55472. var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
  55473. var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
  55474. );
  55475. var DOCTYPE_NAME = seal(/^html$/i);
  55476. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  55477. function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  55478. var getGlobal = function getGlobal() {
  55479. return typeof window === 'undefined' ? null : window;
  55480. };
  55481. /**
  55482. * Creates a no-op policy for internal use only.
  55483. * Don't export this function outside this module!
  55484. * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
  55485. * @param {Document} document The document object (to determine policy name suffix)
  55486. * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
  55487. * are not supported).
  55488. */
  55489. var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
  55490. if ((typeof trustedTypes === 'undefined' ? 'undefined' : _typeof(trustedTypes)) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
  55491. return null;
  55492. }
  55493. // Allow the callers to control the unique policy name
  55494. // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
  55495. // Policy creation with duplicate names throws in Trusted Types.
  55496. var suffix = null;
  55497. var ATTR_NAME = 'data-tt-policy-suffix';
  55498. if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
  55499. suffix = document.currentScript.getAttribute(ATTR_NAME);
  55500. }
  55501. var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
  55502. try {
  55503. return trustedTypes.createPolicy(policyName, {
  55504. createHTML: function createHTML(html$$1) {
  55505. return html$$1;
  55506. }
  55507. });
  55508. } catch (_) {
  55509. // Policy creation failed (most likely another DOMPurify script has
  55510. // already run). Skip creating the policy, as this will only cause errors
  55511. // if TT are enforced.
  55512. console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
  55513. return null;
  55514. }
  55515. };
  55516. function createDOMPurify() {
  55517. var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
  55518. var DOMPurify = function DOMPurify(root) {
  55519. return createDOMPurify(root);
  55520. };
  55521. /**
  55522. * Version label, exposed for easier checks
  55523. * if DOMPurify is up to date or not
  55524. */
  55525. DOMPurify.version = '2.3.6';
  55526. /**
  55527. * Array of elements that DOMPurify removed during sanitation.
  55528. * Empty if nothing was removed.
  55529. */
  55530. DOMPurify.removed = [];
  55531. if (!window || !window.document || window.document.nodeType !== 9) {
  55532. // Not running in a browser, provide a factory function
  55533. // so that you can pass your own Window
  55534. DOMPurify.isSupported = false;
  55535. return DOMPurify;
  55536. }
  55537. var originalDocument = window.document;
  55538. var document = window.document;
  55539. var DocumentFragment = window.DocumentFragment,
  55540. HTMLTemplateElement = window.HTMLTemplateElement,
  55541. Node = window.Node,
  55542. Element = window.Element,
  55543. NodeFilter = window.NodeFilter,
  55544. _window$NamedNodeMap = window.NamedNodeMap,
  55545. NamedNodeMap = _window$NamedNodeMap === undefined ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
  55546. HTMLFormElement = window.HTMLFormElement,
  55547. DOMParser = window.DOMParser,
  55548. trustedTypes = window.trustedTypes;
  55549. var ElementPrototype = Element.prototype;
  55550. var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
  55551. var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
  55552. var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
  55553. var getParentNode = lookupGetter(ElementPrototype, 'parentNode');
  55554. // As per issue #47, the web-components registry is inherited by a
  55555. // new document created via createHTMLDocument. As per the spec
  55556. // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
  55557. // a new empty registry is used when creating a template contents owner
  55558. // document, so we use that as our parent document to ensure nothing
  55559. // is inherited.
  55560. if (typeof HTMLTemplateElement === 'function') {
  55561. var template = document.createElement('template');
  55562. if (template.content && template.content.ownerDocument) {
  55563. document = template.content.ownerDocument;
  55564. }
  55565. }
  55566. var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
  55567. var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
  55568. var _document = document,
  55569. implementation = _document.implementation,
  55570. createNodeIterator = _document.createNodeIterator,
  55571. createDocumentFragment = _document.createDocumentFragment,
  55572. getElementsByTagName = _document.getElementsByTagName;
  55573. var importNode = originalDocument.importNode;
  55574. var documentMode = {};
  55575. try {
  55576. documentMode = clone(document).documentMode ? document.documentMode : {};
  55577. } catch (_) {}
  55578. var hooks = {};
  55579. /**
  55580. * Expose whether this browser supports running the full DOMPurify.
  55581. */
  55582. DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
  55583. var MUSTACHE_EXPR$$1 = MUSTACHE_EXPR,
  55584. ERB_EXPR$$1 = ERB_EXPR,
  55585. DATA_ATTR$$1 = DATA_ATTR,
  55586. ARIA_ATTR$$1 = ARIA_ATTR,
  55587. IS_SCRIPT_OR_DATA$$1 = IS_SCRIPT_OR_DATA,
  55588. ATTR_WHITESPACE$$1 = ATTR_WHITESPACE;
  55589. var IS_ALLOWED_URI$$1 = IS_ALLOWED_URI;
  55590. /**
  55591. * We consider the elements and attributes below to be safe. Ideally
  55592. * don't add any new ones but feel free to remove unwanted ones.
  55593. */
  55594. /* allowed element names */
  55595. var ALLOWED_TAGS = null;
  55596. var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(html), _toConsumableArray$1(svg), _toConsumableArray$1(svgFilters), _toConsumableArray$1(mathMl), _toConsumableArray$1(text)));
  55597. /* Allowed attribute names */
  55598. var ALLOWED_ATTR = null;
  55599. var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray$1(html$1), _toConsumableArray$1(svg$1), _toConsumableArray$1(mathMl$1), _toConsumableArray$1(xml)));
  55600. /*
  55601. * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
  55602. * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
  55603. * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
  55604. * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
  55605. */
  55606. var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
  55607. tagNameCheck: {
  55608. writable: true,
  55609. configurable: false,
  55610. enumerable: true,
  55611. value: null
  55612. },
  55613. attributeNameCheck: {
  55614. writable: true,
  55615. configurable: false,
  55616. enumerable: true,
  55617. value: null
  55618. },
  55619. allowCustomizedBuiltInElements: {
  55620. writable: true,
  55621. configurable: false,
  55622. enumerable: true,
  55623. value: false
  55624. }
  55625. }));
  55626. /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
  55627. var FORBID_TAGS = null;
  55628. /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
  55629. var FORBID_ATTR = null;
  55630. /* Decide if ARIA attributes are okay */
  55631. var ALLOW_ARIA_ATTR = true;
  55632. /* Decide if custom data attributes are okay */
  55633. var ALLOW_DATA_ATTR = true;
  55634. /* Decide if unknown protocols are okay */
  55635. var ALLOW_UNKNOWN_PROTOCOLS = false;
  55636. /* Output should be safe for common template engines.
  55637. * This means, DOMPurify removes data attributes, mustaches and ERB
  55638. */
  55639. var SAFE_FOR_TEMPLATES = false;
  55640. /* Decide if document with <html>... should be returned */
  55641. var WHOLE_DOCUMENT = false;
  55642. /* Track whether config is already set on this instance of DOMPurify. */
  55643. var SET_CONFIG = false;
  55644. /* Decide if all elements (e.g. style, script) must be children of
  55645. * document.body. By default, browsers might move them to document.head */
  55646. var FORCE_BODY = false;
  55647. /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
  55648. * string (or a TrustedHTML object if Trusted Types are supported).
  55649. * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
  55650. */
  55651. var RETURN_DOM = false;
  55652. /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
  55653. * string (or a TrustedHTML object if Trusted Types are supported) */
  55654. var RETURN_DOM_FRAGMENT = false;
  55655. /* Try to return a Trusted Type object instead of a string, return a string in
  55656. * case Trusted Types are not supported */
  55657. var RETURN_TRUSTED_TYPE = false;
  55658. /* Output should be free from DOM clobbering attacks? */
  55659. var SANITIZE_DOM = true;
  55660. /* Keep element content when removing element? */
  55661. var KEEP_CONTENT = true;
  55662. /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
  55663. * of importing it into a new Document and returning a sanitized copy */
  55664. var IN_PLACE = false;
  55665. /* Allow usage of profiles like html, svg and mathMl */
  55666. var USE_PROFILES = {};
  55667. /* Tags to ignore content of when KEEP_CONTENT is true */
  55668. var FORBID_CONTENTS = null;
  55669. var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
  55670. /* Tags that are safe for data: URIs */
  55671. var DATA_URI_TAGS = null;
  55672. var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
  55673. /* Attributes safe for values like "javascript:" */
  55674. var URI_SAFE_ATTRIBUTES = null;
  55675. var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
  55676. var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  55677. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  55678. var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
  55679. /* Document namespace */
  55680. var NAMESPACE = HTML_NAMESPACE;
  55681. var IS_EMPTY_INPUT = false;
  55682. /* Parsing of strict XHTML documents */
  55683. var PARSER_MEDIA_TYPE = void 0;
  55684. var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
  55685. var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
  55686. var transformCaseFunc = void 0;
  55687. /* Keep a reference to config to pass to hooks */
  55688. var CONFIG = null;
  55689. /* Ideally, do not touch anything below this line */
  55690. /* ______________________________________________ */
  55691. var formElement = document.createElement('form');
  55692. var isRegexOrFunction = function isRegexOrFunction(testValue) {
  55693. return testValue instanceof RegExp || testValue instanceof Function;
  55694. };
  55695. /**
  55696. * _parseConfig
  55697. *
  55698. * @param {Object} cfg optional config literal
  55699. */
  55700. // eslint-disable-next-line complexity
  55701. var _parseConfig = function _parseConfig(cfg) {
  55702. if (CONFIG && CONFIG === cfg) {
  55703. return;
  55704. }
  55705. /* Shield configuration object from tampering */
  55706. if (!cfg || (typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) !== 'object') {
  55707. cfg = {};
  55708. }
  55709. /* Shield configuration object from prototype pollution */
  55710. cfg = clone(cfg);
  55711. /* Set configuration parameters */
  55712. ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS) : DEFAULT_ALLOWED_TAGS;
  55713. ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR) : DEFAULT_ALLOWED_ATTR;
  55714. URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR) : DEFAULT_URI_SAFE_ATTRIBUTES;
  55715. DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS) : DEFAULT_DATA_URI_TAGS;
  55716. FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS) : DEFAULT_FORBID_CONTENTS;
  55717. FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS) : {};
  55718. FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR) : {};
  55719. USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
  55720. ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
  55721. ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
  55722. ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
  55723. SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
  55724. WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
  55725. RETURN_DOM = cfg.RETURN_DOM || false; // Default false
  55726. RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
  55727. RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
  55728. FORCE_BODY = cfg.FORCE_BODY || false; // Default false
  55729. SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
  55730. KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
  55731. IN_PLACE = cfg.IN_PLACE || false; // Default false
  55732. IS_ALLOWED_URI$$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$$1;
  55733. NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
  55734. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
  55735. CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
  55736. }
  55737. if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
  55738. CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
  55739. }
  55740. if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
  55741. CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
  55742. }
  55743. PARSER_MEDIA_TYPE =
  55744. // eslint-disable-next-line unicorn/prefer-includes
  55745. SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
  55746. // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
  55747. transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
  55748. return x;
  55749. } : stringToLowerCase;
  55750. if (SAFE_FOR_TEMPLATES) {
  55751. ALLOW_DATA_ATTR = false;
  55752. }
  55753. if (RETURN_DOM_FRAGMENT) {
  55754. RETURN_DOM = true;
  55755. }
  55756. /* Parse profile info */
  55757. if (USE_PROFILES) {
  55758. ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray$1(text)));
  55759. ALLOWED_ATTR = [];
  55760. if (USE_PROFILES.html === true) {
  55761. addToSet(ALLOWED_TAGS, html);
  55762. addToSet(ALLOWED_ATTR, html$1);
  55763. }
  55764. if (USE_PROFILES.svg === true) {
  55765. addToSet(ALLOWED_TAGS, svg);
  55766. addToSet(ALLOWED_ATTR, svg$1);
  55767. addToSet(ALLOWED_ATTR, xml);
  55768. }
  55769. if (USE_PROFILES.svgFilters === true) {
  55770. addToSet(ALLOWED_TAGS, svgFilters);
  55771. addToSet(ALLOWED_ATTR, svg$1);
  55772. addToSet(ALLOWED_ATTR, xml);
  55773. }
  55774. if (USE_PROFILES.mathMl === true) {
  55775. addToSet(ALLOWED_TAGS, mathMl);
  55776. addToSet(ALLOWED_ATTR, mathMl$1);
  55777. addToSet(ALLOWED_ATTR, xml);
  55778. }
  55779. }
  55780. /* Merge configuration parameters */
  55781. if (cfg.ADD_TAGS) {
  55782. if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
  55783. ALLOWED_TAGS = clone(ALLOWED_TAGS);
  55784. }
  55785. addToSet(ALLOWED_TAGS, cfg.ADD_TAGS);
  55786. }
  55787. if (cfg.ADD_ATTR) {
  55788. if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
  55789. ALLOWED_ATTR = clone(ALLOWED_ATTR);
  55790. }
  55791. addToSet(ALLOWED_ATTR, cfg.ADD_ATTR);
  55792. }
  55793. if (cfg.ADD_URI_SAFE_ATTR) {
  55794. addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR);
  55795. }
  55796. if (cfg.FORBID_CONTENTS) {
  55797. if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
  55798. FORBID_CONTENTS = clone(FORBID_CONTENTS);
  55799. }
  55800. addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS);
  55801. }
  55802. /* Add #text in case KEEP_CONTENT is set to true */
  55803. if (KEEP_CONTENT) {
  55804. ALLOWED_TAGS['#text'] = true;
  55805. }
  55806. /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
  55807. if (WHOLE_DOCUMENT) {
  55808. addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
  55809. }
  55810. /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
  55811. if (ALLOWED_TAGS.table) {
  55812. addToSet(ALLOWED_TAGS, ['tbody']);
  55813. delete FORBID_TAGS.tbody;
  55814. }
  55815. // Prevent further manipulation of configuration.
  55816. // Not available in IE8, Safari 5, etc.
  55817. if (freeze) {
  55818. freeze(cfg);
  55819. }
  55820. CONFIG = cfg;
  55821. };
  55822. var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
  55823. var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']);
  55824. /* Keep track of all possible SVG and MathML tags
  55825. * so that we can perform the namespace checks
  55826. * correctly. */
  55827. var ALL_SVG_TAGS = addToSet({}, svg);
  55828. addToSet(ALL_SVG_TAGS, svgFilters);
  55829. addToSet(ALL_SVG_TAGS, svgDisallowed);
  55830. var ALL_MATHML_TAGS = addToSet({}, mathMl);
  55831. addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
  55832. /**
  55833. *
  55834. *
  55835. * @param {Element} element a DOM element whose namespace is being checked
  55836. * @returns {boolean} Return false if the element has a
  55837. * namespace that a spec-compliant parser would never
  55838. * return. Return true otherwise.
  55839. */
  55840. var _checkValidNamespace = function _checkValidNamespace(element) {
  55841. var parent = getParentNode(element);
  55842. // In JSDOM, if we're inside shadow DOM, then parentNode
  55843. // can be null. We just simulate parent in this case.
  55844. if (!parent || !parent.tagName) {
  55845. parent = {
  55846. namespaceURI: HTML_NAMESPACE,
  55847. tagName: 'template'
  55848. };
  55849. }
  55850. var tagName = stringToLowerCase(element.tagName);
  55851. var parentTagName = stringToLowerCase(parent.tagName);
  55852. if (element.namespaceURI === SVG_NAMESPACE) {
  55853. // The only way to switch from HTML namespace to SVG
  55854. // is via <svg>. If it happens via any other tag, then
  55855. // it should be killed.
  55856. if (parent.namespaceURI === HTML_NAMESPACE) {
  55857. return tagName === 'svg';
  55858. }
  55859. // The only way to switch from MathML to SVG is via
  55860. // svg if parent is either <annotation-xml> or MathML
  55861. // text integration points.
  55862. if (parent.namespaceURI === MATHML_NAMESPACE) {
  55863. return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
  55864. }
  55865. // We only allow elements that are defined in SVG
  55866. // spec. All others are disallowed in SVG namespace.
  55867. return Boolean(ALL_SVG_TAGS[tagName]);
  55868. }
  55869. if (element.namespaceURI === MATHML_NAMESPACE) {
  55870. // The only way to switch from HTML namespace to MathML
  55871. // is via <math>. If it happens via any other tag, then
  55872. // it should be killed.
  55873. if (parent.namespaceURI === HTML_NAMESPACE) {
  55874. return tagName === 'math';
  55875. }
  55876. // The only way to switch from SVG to MathML is via
  55877. // <math> and HTML integration points
  55878. if (parent.namespaceURI === SVG_NAMESPACE) {
  55879. return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
  55880. }
  55881. // We only allow elements that are defined in MathML
  55882. // spec. All others are disallowed in MathML namespace.
  55883. return Boolean(ALL_MATHML_TAGS[tagName]);
  55884. }
  55885. if (element.namespaceURI === HTML_NAMESPACE) {
  55886. // The only way to switch from SVG to HTML is via
  55887. // HTML integration points, and from MathML to HTML
  55888. // is via MathML text integration points
  55889. if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
  55890. return false;
  55891. }
  55892. if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
  55893. return false;
  55894. }
  55895. // Certain elements are allowed in both SVG and HTML
  55896. // namespace. We need to specify them explicitly
  55897. // so that they don't get erronously deleted from
  55898. // HTML namespace.
  55899. var commonSvgAndHTMLElements = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
  55900. // We disallow tags that are specific for MathML
  55901. // or SVG and should never appear in HTML namespace
  55902. return !ALL_MATHML_TAGS[tagName] && (commonSvgAndHTMLElements[tagName] || !ALL_SVG_TAGS[tagName]);
  55903. }
  55904. // The code should never reach this place (this means
  55905. // that the element somehow got namespace that is not
  55906. // HTML, SVG or MathML). Return false just in case.
  55907. return false;
  55908. };
  55909. /**
  55910. * _forceRemove
  55911. *
  55912. * @param {Node} node a DOM node
  55913. */
  55914. var _forceRemove = function _forceRemove(node) {
  55915. arrayPush(DOMPurify.removed, { element: node });
  55916. try {
  55917. // eslint-disable-next-line unicorn/prefer-dom-node-remove
  55918. node.parentNode.removeChild(node);
  55919. } catch (_) {
  55920. try {
  55921. node.outerHTML = emptyHTML;
  55922. } catch (_) {
  55923. node.remove();
  55924. }
  55925. }
  55926. };
  55927. /**
  55928. * _removeAttribute
  55929. *
  55930. * @param {String} name an Attribute name
  55931. * @param {Node} node a DOM node
  55932. */
  55933. var _removeAttribute = function _removeAttribute(name, node) {
  55934. try {
  55935. arrayPush(DOMPurify.removed, {
  55936. attribute: node.getAttributeNode(name),
  55937. from: node
  55938. });
  55939. } catch (_) {
  55940. arrayPush(DOMPurify.removed, {
  55941. attribute: null,
  55942. from: node
  55943. });
  55944. }
  55945. node.removeAttribute(name);
  55946. // We void attribute values for unremovable "is"" attributes
  55947. if (name === 'is' && !ALLOWED_ATTR[name]) {
  55948. if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
  55949. try {
  55950. _forceRemove(node);
  55951. } catch (_) {}
  55952. } else {
  55953. try {
  55954. node.setAttribute(name, '');
  55955. } catch (_) {}
  55956. }
  55957. }
  55958. };
  55959. /**
  55960. * _initDocument
  55961. *
  55962. * @param {String} dirty a string of dirty markup
  55963. * @return {Document} a DOM, filled with the dirty markup
  55964. */
  55965. var _initDocument = function _initDocument(dirty) {
  55966. /* Create a HTML document */
  55967. var doc = void 0;
  55968. var leadingWhitespace = void 0;
  55969. if (FORCE_BODY) {
  55970. dirty = '<remove></remove>' + dirty;
  55971. } else {
  55972. /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
  55973. var matches = stringMatch(dirty, /^[\r\n\t ]+/);
  55974. leadingWhitespace = matches && matches[0];
  55975. }
  55976. if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
  55977. // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
  55978. dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
  55979. }
  55980. var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
  55981. /*
  55982. * Use the DOMParser API by default, fallback later if needs be
  55983. * DOMParser not work for svg when has multiple root element.
  55984. */
  55985. if (NAMESPACE === HTML_NAMESPACE) {
  55986. try {
  55987. doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
  55988. } catch (_) {}
  55989. }
  55990. /* Use createHTMLDocument in case DOMParser is not available */
  55991. if (!doc || !doc.documentElement) {
  55992. doc = implementation.createDocument(NAMESPACE, 'template', null);
  55993. try {
  55994. doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
  55995. } catch (_) {
  55996. // Syntax error if dirtyPayload is invalid xml
  55997. }
  55998. }
  55999. var body = doc.body || doc.documentElement;
  56000. if (dirty && leadingWhitespace) {
  56001. body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
  56002. }
  56003. /* Work on whole document or just its body */
  56004. if (NAMESPACE === HTML_NAMESPACE) {
  56005. return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
  56006. }
  56007. return WHOLE_DOCUMENT ? doc.documentElement : body;
  56008. };
  56009. /**
  56010. * _createIterator
  56011. *
  56012. * @param {Document} root document/fragment to create iterator for
  56013. * @return {Iterator} iterator instance
  56014. */
  56015. var _createIterator = function _createIterator(root) {
  56016. return createNodeIterator.call(root.ownerDocument || root, root,
  56017. // eslint-disable-next-line no-bitwise
  56018. NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
  56019. };
  56020. /**
  56021. * _isClobbered
  56022. *
  56023. * @param {Node} elm element to check for clobbering attacks
  56024. * @return {Boolean} true if clobbered, false if safe
  56025. */
  56026. var _isClobbered = function _isClobbered(elm) {
  56027. return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function');
  56028. };
  56029. /**
  56030. * _isNode
  56031. *
  56032. * @param {Node} obj object to check whether it's a DOM node
  56033. * @return {Boolean} true is object is a DOM node
  56034. */
  56035. var _isNode = function _isNode(object) {
  56036. return (typeof Node === 'undefined' ? 'undefined' : _typeof(Node)) === 'object' ? object instanceof Node : object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
  56037. };
  56038. /**
  56039. * _executeHook
  56040. * Execute user configurable hooks
  56041. *
  56042. * @param {String} entryPoint Name of the hook's entry point
  56043. * @param {Node} currentNode node to work on with the hook
  56044. * @param {Object} data additional hook parameters
  56045. */
  56046. var _executeHook = function _executeHook(entryPoint, currentNode, data) {
  56047. if (!hooks[entryPoint]) {
  56048. return;
  56049. }
  56050. arrayForEach(hooks[entryPoint], function (hook) {
  56051. hook.call(DOMPurify, currentNode, data, CONFIG);
  56052. });
  56053. };
  56054. /**
  56055. * _sanitizeElements
  56056. *
  56057. * @protect nodeName
  56058. * @protect textContent
  56059. * @protect removeChild
  56060. *
  56061. * @param {Node} currentNode to check for permission to exist
  56062. * @return {Boolean} true if node was killed, false if left alive
  56063. */
  56064. var _sanitizeElements = function _sanitizeElements(currentNode) {
  56065. var content = void 0;
  56066. /* Execute a hook if present */
  56067. _executeHook('beforeSanitizeElements', currentNode, null);
  56068. /* Check if element is clobbered or can clobber */
  56069. if (_isClobbered(currentNode)) {
  56070. _forceRemove(currentNode);
  56071. return true;
  56072. }
  56073. /* Check if tagname contains Unicode */
  56074. if (stringMatch(currentNode.nodeName, /[\u0080-\uFFFF]/)) {
  56075. _forceRemove(currentNode);
  56076. return true;
  56077. }
  56078. /* Now let's check the element's type and name */
  56079. var tagName = transformCaseFunc(currentNode.nodeName);
  56080. /* Execute a hook if present */
  56081. _executeHook('uponSanitizeElement', currentNode, {
  56082. tagName: tagName,
  56083. allowedTags: ALLOWED_TAGS
  56084. });
  56085. /* Detect mXSS attempts abusing namespace confusion */
  56086. if (!_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
  56087. _forceRemove(currentNode);
  56088. return true;
  56089. }
  56090. /* Mitigate a problem with templates inside select */
  56091. if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
  56092. _forceRemove(currentNode);
  56093. return true;
  56094. }
  56095. /* Remove element if anything forbids its presence */
  56096. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  56097. /* Check if we have a custom element to handle */
  56098. if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
  56099. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
  56100. if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
  56101. }
  56102. /* Keep content except for bad-listed elements */
  56103. if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
  56104. var parentNode = getParentNode(currentNode) || currentNode.parentNode;
  56105. var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
  56106. if (childNodes && parentNode) {
  56107. var childCount = childNodes.length;
  56108. for (var i = childCount - 1; i >= 0; --i) {
  56109. parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
  56110. }
  56111. }
  56112. }
  56113. _forceRemove(currentNode);
  56114. return true;
  56115. }
  56116. /* Check whether element has a valid namespace */
  56117. if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
  56118. _forceRemove(currentNode);
  56119. return true;
  56120. }
  56121. if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
  56122. _forceRemove(currentNode);
  56123. return true;
  56124. }
  56125. /* Sanitize element content to be template-safe */
  56126. if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
  56127. /* Get the element's text content */
  56128. content = currentNode.textContent;
  56129. content = stringReplace(content, MUSTACHE_EXPR$$1, ' ');
  56130. content = stringReplace(content, ERB_EXPR$$1, ' ');
  56131. if (currentNode.textContent !== content) {
  56132. arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
  56133. currentNode.textContent = content;
  56134. }
  56135. }
  56136. /* Execute a hook if present */
  56137. _executeHook('afterSanitizeElements', currentNode, null);
  56138. return false;
  56139. };
  56140. /**
  56141. * _isValidAttribute
  56142. *
  56143. * @param {string} lcTag Lowercase tag name of containing element.
  56144. * @param {string} lcName Lowercase attribute name.
  56145. * @param {string} value Attribute value.
  56146. * @return {Boolean} Returns true if `value` is valid, otherwise false.
  56147. */
  56148. // eslint-disable-next-line complexity
  56149. var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
  56150. /* Make sure attribute cannot clobber */
  56151. if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
  56152. return false;
  56153. }
  56154. /* Allow valid data-* attributes: At least one character after "-"
  56155. (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
  56156. XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
  56157. We don't need to check the value; it's always URI safe. */
  56158. if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
  56159. if (
  56160. // First condition does a very basic check if a) it's basically a valid custom element tagname AND
  56161. // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  56162. // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
  56163. _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
  56164. // Alternative, second condition checks if it's an `is`-attribute, AND
  56165. // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
  56166. lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
  56167. return false;
  56168. }
  56169. /* Check value is safe. First, is attr inert? If so, is safe */
  56170. } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$$1, stringReplace(value, ATTR_WHITESPACE$$1, ''))) ; else if (!value) ; else {
  56171. return false;
  56172. }
  56173. return true;
  56174. };
  56175. /**
  56176. * _basicCustomElementCheck
  56177. * checks if at least one dash is included in tagName, and it's not the first char
  56178. * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
  56179. * @param {string} tagName name of the tag of the node to sanitize
  56180. */
  56181. var _basicCustomElementTest = function _basicCustomElementTest(tagName) {
  56182. return tagName.indexOf('-') > 0;
  56183. };
  56184. /**
  56185. * _sanitizeAttributes
  56186. *
  56187. * @protect attributes
  56188. * @protect nodeName
  56189. * @protect removeAttribute
  56190. * @protect setAttribute
  56191. *
  56192. * @param {Node} currentNode to sanitize
  56193. */
  56194. var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
  56195. var attr = void 0;
  56196. var value = void 0;
  56197. var lcName = void 0;
  56198. var l = void 0;
  56199. /* Execute a hook if present */
  56200. _executeHook('beforeSanitizeAttributes', currentNode, null);
  56201. var attributes = currentNode.attributes;
  56202. /* Check if we have attributes; if not we might have a text node */
  56203. if (!attributes) {
  56204. return;
  56205. }
  56206. var hookEvent = {
  56207. attrName: '',
  56208. attrValue: '',
  56209. keepAttr: true,
  56210. allowedAttributes: ALLOWED_ATTR
  56211. };
  56212. l = attributes.length;
  56213. /* Go backwards over all attributes; safely remove bad ones */
  56214. while (l--) {
  56215. attr = attributes[l];
  56216. var _attr = attr,
  56217. name = _attr.name,
  56218. namespaceURI = _attr.namespaceURI;
  56219. value = stringTrim(attr.value);
  56220. lcName = transformCaseFunc(name);
  56221. /* Execute a hook if present */
  56222. hookEvent.attrName = lcName;
  56223. hookEvent.attrValue = value;
  56224. hookEvent.keepAttr = true;
  56225. hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
  56226. _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
  56227. value = hookEvent.attrValue;
  56228. /* Did the hooks approve of the attribute? */
  56229. if (hookEvent.forceKeepAttr) {
  56230. continue;
  56231. }
  56232. /* Remove attribute */
  56233. _removeAttribute(name, currentNode);
  56234. /* Did the hooks approve of the attribute? */
  56235. if (!hookEvent.keepAttr) {
  56236. continue;
  56237. }
  56238. /* Work around a security issue in jQuery 3.0 */
  56239. if (regExpTest(/\/>/i, value)) {
  56240. _removeAttribute(name, currentNode);
  56241. continue;
  56242. }
  56243. /* Sanitize attribute content to be template-safe */
  56244. if (SAFE_FOR_TEMPLATES) {
  56245. value = stringReplace(value, MUSTACHE_EXPR$$1, ' ');
  56246. value = stringReplace(value, ERB_EXPR$$1, ' ');
  56247. }
  56248. /* Is `value` valid for this attribute? */
  56249. var lcTag = transformCaseFunc(currentNode.nodeName);
  56250. if (!_isValidAttribute(lcTag, lcName, value)) {
  56251. continue;
  56252. }
  56253. /* Handle invalid data-* attribute set by try-catching it */
  56254. try {
  56255. if (namespaceURI) {
  56256. currentNode.setAttributeNS(namespaceURI, name, value);
  56257. } else {
  56258. /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
  56259. currentNode.setAttribute(name, value);
  56260. }
  56261. arrayPop(DOMPurify.removed);
  56262. } catch (_) {}
  56263. }
  56264. /* Execute a hook if present */
  56265. _executeHook('afterSanitizeAttributes', currentNode, null);
  56266. };
  56267. /**
  56268. * _sanitizeShadowDOM
  56269. *
  56270. * @param {DocumentFragment} fragment to iterate over recursively
  56271. */
  56272. var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
  56273. var shadowNode = void 0;
  56274. var shadowIterator = _createIterator(fragment);
  56275. /* Execute a hook if present */
  56276. _executeHook('beforeSanitizeShadowDOM', fragment, null);
  56277. while (shadowNode = shadowIterator.nextNode()) {
  56278. /* Execute a hook if present */
  56279. _executeHook('uponSanitizeShadowNode', shadowNode, null);
  56280. /* Sanitize tags and elements */
  56281. if (_sanitizeElements(shadowNode)) {
  56282. continue;
  56283. }
  56284. /* Deep shadow DOM detected */
  56285. if (shadowNode.content instanceof DocumentFragment) {
  56286. _sanitizeShadowDOM(shadowNode.content);
  56287. }
  56288. /* Check attributes, sanitize if necessary */
  56289. _sanitizeAttributes(shadowNode);
  56290. }
  56291. /* Execute a hook if present */
  56292. _executeHook('afterSanitizeShadowDOM', fragment, null);
  56293. };
  56294. /**
  56295. * Sanitize
  56296. * Public method providing core sanitation functionality
  56297. *
  56298. * @param {String|Node} dirty string or DOM node
  56299. * @param {Object} configuration object
  56300. */
  56301. // eslint-disable-next-line complexity
  56302. DOMPurify.sanitize = function (dirty, cfg) {
  56303. var body = void 0;
  56304. var importedNode = void 0;
  56305. var currentNode = void 0;
  56306. var oldNode = void 0;
  56307. var returnNode = void 0;
  56308. /* Make sure we have a string to sanitize.
  56309. DO NOT return early, as this will return the wrong type if
  56310. the user has requested a DOM object rather than a string */
  56311. IS_EMPTY_INPUT = !dirty;
  56312. if (IS_EMPTY_INPUT) {
  56313. dirty = '<!-->';
  56314. }
  56315. /* Stringify, in case dirty is an object */
  56316. if (typeof dirty !== 'string' && !_isNode(dirty)) {
  56317. // eslint-disable-next-line no-negated-condition
  56318. if (typeof dirty.toString !== 'function') {
  56319. throw typeErrorCreate('toString is not a function');
  56320. } else {
  56321. dirty = dirty.toString();
  56322. if (typeof dirty !== 'string') {
  56323. throw typeErrorCreate('dirty is not a string, aborting');
  56324. }
  56325. }
  56326. }
  56327. /* Check we can run. Otherwise fall back or ignore */
  56328. if (!DOMPurify.isSupported) {
  56329. if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
  56330. if (typeof dirty === 'string') {
  56331. return window.toStaticHTML(dirty);
  56332. }
  56333. if (_isNode(dirty)) {
  56334. return window.toStaticHTML(dirty.outerHTML);
  56335. }
  56336. }
  56337. return dirty;
  56338. }
  56339. /* Assign config vars */
  56340. if (!SET_CONFIG) {
  56341. _parseConfig(cfg);
  56342. }
  56343. /* Clean up removed elements */
  56344. DOMPurify.removed = [];
  56345. /* Check if dirty is correctly typed for IN_PLACE */
  56346. if (typeof dirty === 'string') {
  56347. IN_PLACE = false;
  56348. }
  56349. if (IN_PLACE) {
  56350. /* Do some early pre-sanitization to avoid unsafe root nodes */
  56351. if (dirty.nodeName) {
  56352. var tagName = transformCaseFunc(dirty.nodeName);
  56353. if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
  56354. throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
  56355. }
  56356. }
  56357. } else if (dirty instanceof Node) {
  56358. /* If dirty is a DOM element, append to an empty document to avoid
  56359. elements being stripped by the parser */
  56360. body = _initDocument('<!---->');
  56361. importedNode = body.ownerDocument.importNode(dirty, true);
  56362. if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
  56363. /* Node is already a body, use as is */
  56364. body = importedNode;
  56365. } else if (importedNode.nodeName === 'HTML') {
  56366. body = importedNode;
  56367. } else {
  56368. // eslint-disable-next-line unicorn/prefer-dom-node-append
  56369. body.appendChild(importedNode);
  56370. }
  56371. } else {
  56372. /* Exit directly if we have nothing to do */
  56373. if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
  56374. // eslint-disable-next-line unicorn/prefer-includes
  56375. dirty.indexOf('<') === -1) {
  56376. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
  56377. }
  56378. /* Initialize the document to work on */
  56379. body = _initDocument(dirty);
  56380. /* Check we have a DOM node from the data */
  56381. if (!body) {
  56382. return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
  56383. }
  56384. }
  56385. /* Remove first element node (ours) if FORCE_BODY is set */
  56386. if (body && FORCE_BODY) {
  56387. _forceRemove(body.firstChild);
  56388. }
  56389. /* Get node iterator */
  56390. var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
  56391. /* Now start iterating over the created document */
  56392. while (currentNode = nodeIterator.nextNode()) {
  56393. /* Fix IE's strange behavior with manipulated textNodes #89 */
  56394. if (currentNode.nodeType === 3 && currentNode === oldNode) {
  56395. continue;
  56396. }
  56397. /* Sanitize tags and elements */
  56398. if (_sanitizeElements(currentNode)) {
  56399. continue;
  56400. }
  56401. /* Shadow DOM detected, sanitize it */
  56402. if (currentNode.content instanceof DocumentFragment) {
  56403. _sanitizeShadowDOM(currentNode.content);
  56404. }
  56405. /* Check attributes, sanitize if necessary */
  56406. _sanitizeAttributes(currentNode);
  56407. oldNode = currentNode;
  56408. }
  56409. oldNode = null;
  56410. /* If we sanitized `dirty` in-place, return it. */
  56411. if (IN_PLACE) {
  56412. return dirty;
  56413. }
  56414. /* Return sanitized string or DOM */
  56415. if (RETURN_DOM) {
  56416. if (RETURN_DOM_FRAGMENT) {
  56417. returnNode = createDocumentFragment.call(body.ownerDocument);
  56418. while (body.firstChild) {
  56419. // eslint-disable-next-line unicorn/prefer-dom-node-append
  56420. returnNode.appendChild(body.firstChild);
  56421. }
  56422. } else {
  56423. returnNode = body;
  56424. }
  56425. if (ALLOWED_ATTR.shadowroot) {
  56426. /*
  56427. AdoptNode() is not used because internal state is not reset
  56428. (e.g. the past names map of a HTMLFormElement), this is safe
  56429. in theory but we would rather not risk another attack vector.
  56430. The state that is cloned by importNode() is explicitly defined
  56431. by the specs.
  56432. */
  56433. returnNode = importNode.call(originalDocument, returnNode, true);
  56434. }
  56435. return returnNode;
  56436. }
  56437. var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
  56438. /* Serialize doctype if allowed */
  56439. if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
  56440. serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
  56441. }
  56442. /* Sanitize final string template-safe */
  56443. if (SAFE_FOR_TEMPLATES) {
  56444. serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$$1, ' ');
  56445. serializedHTML = stringReplace(serializedHTML, ERB_EXPR$$1, ' ');
  56446. }
  56447. return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
  56448. };
  56449. /**
  56450. * Public method to set the configuration once
  56451. * setConfig
  56452. *
  56453. * @param {Object} cfg configuration object
  56454. */
  56455. DOMPurify.setConfig = function (cfg) {
  56456. _parseConfig(cfg);
  56457. SET_CONFIG = true;
  56458. };
  56459. /**
  56460. * Public method to remove the configuration
  56461. * clearConfig
  56462. *
  56463. */
  56464. DOMPurify.clearConfig = function () {
  56465. CONFIG = null;
  56466. SET_CONFIG = false;
  56467. };
  56468. /**
  56469. * Public method to check if an attribute value is valid.
  56470. * Uses last set config, if any. Otherwise, uses config defaults.
  56471. * isValidAttribute
  56472. *
  56473. * @param {string} tag Tag name of containing element.
  56474. * @param {string} attr Attribute name.
  56475. * @param {string} value Attribute value.
  56476. * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
  56477. */
  56478. DOMPurify.isValidAttribute = function (tag, attr, value) {
  56479. /* Initialize shared config vars if necessary. */
  56480. if (!CONFIG) {
  56481. _parseConfig({});
  56482. }
  56483. var lcTag = transformCaseFunc(tag);
  56484. var lcName = transformCaseFunc(attr);
  56485. return _isValidAttribute(lcTag, lcName, value);
  56486. };
  56487. /**
  56488. * AddHook
  56489. * Public method to add DOMPurify hooks
  56490. *
  56491. * @param {String} entryPoint entry point for the hook to add
  56492. * @param {Function} hookFunction function to execute
  56493. */
  56494. DOMPurify.addHook = function (entryPoint, hookFunction) {
  56495. if (typeof hookFunction !== 'function') {
  56496. return;
  56497. }
  56498. hooks[entryPoint] = hooks[entryPoint] || [];
  56499. arrayPush(hooks[entryPoint], hookFunction);
  56500. };
  56501. /**
  56502. * RemoveHook
  56503. * Public method to remove a DOMPurify hook at a given entryPoint
  56504. * (pops it from the stack of hooks if more are present)
  56505. *
  56506. * @param {String} entryPoint entry point for the hook to remove
  56507. */
  56508. DOMPurify.removeHook = function (entryPoint) {
  56509. if (hooks[entryPoint]) {
  56510. arrayPop(hooks[entryPoint]);
  56511. }
  56512. };
  56513. /**
  56514. * RemoveHooks
  56515. * Public method to remove all DOMPurify hooks at a given entryPoint
  56516. *
  56517. * @param {String} entryPoint entry point for the hooks to remove
  56518. */
  56519. DOMPurify.removeHooks = function (entryPoint) {
  56520. if (hooks[entryPoint]) {
  56521. hooks[entryPoint] = [];
  56522. }
  56523. };
  56524. /**
  56525. * RemoveAllHooks
  56526. * Public method to remove all DOMPurify hooks
  56527. *
  56528. */
  56529. DOMPurify.removeAllHooks = function () {
  56530. hooks = {};
  56531. };
  56532. return DOMPurify;
  56533. }
  56534. var purify = createDOMPurify();
  56535. return purify;
  56536. }));
  56537. //# sourceMappingURL=purify.js.map
  56538. /***/ }),
  56539. /***/ 4023:
  56540. /***/ ((module, exports) => {
  56541. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
  56542. * @license MIT or GPL-2.0
  56543. * @fileOverview Favico animations
  56544. * @author Miroslav Magda, http://blog.ejci.net
  56545. * @source: https://github.com/ejci/favico.js
  56546. * @version 0.3.10
  56547. */
  56548. /**
  56549. * Create new favico instance
  56550. * @param {Object} Options
  56551. * @return {Object} Favico object
  56552. * @example
  56553. * var favico = new Favico({
  56554. * bgColor : '#d00',
  56555. * textColor : '#fff',
  56556. * fontFamily : 'sans-serif',
  56557. * fontStyle : 'bold',
  56558. * type : 'circle',
  56559. * position : 'down',
  56560. * animation : 'slide',
  56561. * elementId: false,
  56562. * element: null,
  56563. * dataUrl: function(url){},
  56564. * win: window
  56565. * });
  56566. */
  56567. (function () {
  56568. var Favico = (function (opt) {
  56569. 'use strict';
  56570. opt = (opt) ? opt : {};
  56571. var _def = {
  56572. bgColor: '#d00',
  56573. textColor: '#fff',
  56574. fontFamily: 'sans-serif', //Arial,Verdana,Times New Roman,serif,sans-serif,...
  56575. fontStyle: 'bold', //normal,italic,oblique,bold,bolder,lighter,100,200,300,400,500,600,700,800,900
  56576. type: 'circle',
  56577. position: 'down', // down, up, left, leftup (upleft)
  56578. animation: 'slide',
  56579. elementId: false,
  56580. element: null,
  56581. dataUrl: false,
  56582. win: window
  56583. };
  56584. var _opt, _orig, _h, _w, _canvas, _context, _img, _ready, _lastBadge, _running, _readyCb, _stop, _browser, _animTimeout, _drawTimeout, _doc;
  56585. _browser = {};
  56586. _browser.ff = typeof InstallTrigger != 'undefined';
  56587. _browser.chrome = !!window.chrome;
  56588. _browser.opera = !!window.opera || navigator.userAgent.indexOf('Opera') >= 0;
  56589. _browser.ie = /*@cc_on!@*/false;
  56590. _browser.safari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
  56591. _browser.supported = (_browser.chrome || _browser.ff || _browser.opera);
  56592. var _queue = [];
  56593. _readyCb = function () {
  56594. };
  56595. _ready = _stop = false;
  56596. /**
  56597. * Initialize favico
  56598. */
  56599. var init = function () {
  56600. //merge initial options
  56601. _opt = merge(_def, opt);
  56602. _opt.bgColor = hexToRgb(_opt.bgColor);
  56603. _opt.textColor = hexToRgb(_opt.textColor);
  56604. _opt.position = _opt.position.toLowerCase();
  56605. _opt.animation = (animation.types['' + _opt.animation]) ? _opt.animation : _def.animation;
  56606. _doc = _opt.win.document;
  56607. var isUp = _opt.position.indexOf('up') > -1;
  56608. var isLeft = _opt.position.indexOf('left') > -1;
  56609. //transform the animations
  56610. if (isUp || isLeft) {
  56611. for (var a in animation.types) {
  56612. for (var i = 0; i < animation.types[a].length; i++) {
  56613. var step = animation.types[a][i];
  56614. if (isUp) {
  56615. if (step.y < 0.6) {
  56616. step.y = step.y - 0.4;
  56617. } else {
  56618. step.y = step.y - 2 * step.y + (1 - step.w);
  56619. }
  56620. }
  56621. if (isLeft) {
  56622. if (step.x < 0.6) {
  56623. step.x = step.x - 0.4;
  56624. } else {
  56625. step.x = step.x - 2 * step.x + (1 - step.h);
  56626. }
  56627. }
  56628. animation.types[a][i] = step;
  56629. }
  56630. }
  56631. }
  56632. _opt.type = (type['' + _opt.type]) ? _opt.type : _def.type;
  56633. _orig = link. getIcons();
  56634. //create temp canvas
  56635. _canvas = document.createElement('canvas');
  56636. //create temp image
  56637. _img = document.createElement('img');
  56638. var lastIcon = _orig[_orig.length - 1];
  56639. if (lastIcon.hasAttribute('href')) {
  56640. _img.setAttribute('crossOrigin', 'anonymous');
  56641. //get width/height
  56642. _img.onload = function () {
  56643. _h = (_img.height > 0) ? _img.height : 32;
  56644. _w = (_img.width > 0) ? _img.width : 32;
  56645. _canvas.height = _h;
  56646. _canvas.width = _w;
  56647. _context = _canvas.getContext('2d');
  56648. icon.ready();
  56649. };
  56650. _img.setAttribute('src', lastIcon.getAttribute('href'));
  56651. } else {
  56652. _h = 32;
  56653. _w = 32;
  56654. _img.height = _h;
  56655. _img.width = _w;
  56656. _canvas.height = _h;
  56657. _canvas.width = _w;
  56658. _context = _canvas.getContext('2d');
  56659. icon.ready();
  56660. }
  56661. };
  56662. /**
  56663. * Icon namespace
  56664. */
  56665. var icon = {};
  56666. /**
  56667. * Icon is ready (reset icon) and start animation (if ther is any)
  56668. */
  56669. icon.ready = function () {
  56670. _ready = true;
  56671. icon.reset();
  56672. _readyCb();
  56673. };
  56674. /**
  56675. * Reset icon to default state
  56676. */
  56677. icon.reset = function () {
  56678. //reset
  56679. if (!_ready) {
  56680. return;
  56681. }
  56682. _queue = [];
  56683. _lastBadge = false;
  56684. _running = false;
  56685. _context.clearRect(0, 0, _w, _h);
  56686. _context.drawImage(_img, 0, 0, _w, _h);
  56687. //_stop=true;
  56688. link.setIcon(_canvas);
  56689. //webcam('stop');
  56690. //video('stop');
  56691. window.clearTimeout(_animTimeout);
  56692. window.clearTimeout(_drawTimeout);
  56693. };
  56694. /**
  56695. * Start animation
  56696. */
  56697. icon.start = function () {
  56698. if (!_ready || _running) {
  56699. return;
  56700. }
  56701. var finished = function () {
  56702. _lastBadge = _queue[0];
  56703. _running = false;
  56704. if (_queue.length > 0) {
  56705. _queue.shift();
  56706. icon.start();
  56707. } else {
  56708. }
  56709. };
  56710. if (_queue.length > 0) {
  56711. _running = true;
  56712. var run = function () {
  56713. // apply options for this animation
  56714. ['type', 'animation', 'bgColor', 'textColor', 'fontFamily', 'fontStyle'].forEach(function (a) {
  56715. if (a in _queue[0].options) {
  56716. _opt[a] = _queue[0].options[a];
  56717. }
  56718. });
  56719. animation.run(_queue[0].options, function () {
  56720. finished();
  56721. }, false);
  56722. };
  56723. if (_lastBadge) {
  56724. animation.run(_lastBadge.options, function () {
  56725. run();
  56726. }, true);
  56727. } else {
  56728. run();
  56729. }
  56730. }
  56731. };
  56732. /**
  56733. * Badge types
  56734. */
  56735. var type = {};
  56736. var options = function (opt) {
  56737. opt.n = ((typeof opt.n) === 'number') ? Math.abs(opt.n | 0) : opt.n;
  56738. opt.x = _w * opt.x;
  56739. opt.y = _h * opt.y;
  56740. opt.w = _w * opt.w;
  56741. opt.h = _h * opt.h;
  56742. opt.len = ("" + opt.n).length;
  56743. return opt;
  56744. };
  56745. /**
  56746. * Generate circle
  56747. * @param {Object} opt Badge options
  56748. */
  56749. type.circle = function (opt) {
  56750. opt = options(opt);
  56751. var more = false;
  56752. if (opt.len === 2) {
  56753. opt.x = opt.x - opt.w * 0.4;
  56754. opt.w = opt.w * 1.4;
  56755. more = true;
  56756. } else if (opt.len >= 3) {
  56757. opt.x = opt.x - opt.w * 0.65;
  56758. opt.w = opt.w * 1.65;
  56759. more = true;
  56760. }
  56761. _context.clearRect(0, 0, _w, _h);
  56762. _context.drawImage(_img, 0, 0, _w, _h);
  56763. _context.beginPath();
  56764. _context.font = _opt.fontStyle + " " + Math.floor(opt.h * (opt.n > 99 ? 0.85 : 1)) + "px " + _opt.fontFamily;
  56765. _context.textAlign = 'center';
  56766. if (more) {
  56767. _context.moveTo(opt.x + opt.w / 2, opt.y);
  56768. _context.lineTo(opt.x + opt.w - opt.h / 2, opt.y);
  56769. _context.quadraticCurveTo(opt.x + opt.w, opt.y, opt.x + opt.w, opt.y + opt.h / 2);
  56770. _context.lineTo(opt.x + opt.w, opt.y + opt.h - opt.h / 2);
  56771. _context.quadraticCurveTo(opt.x + opt.w, opt.y + opt.h, opt.x + opt.w - opt.h / 2, opt.y + opt.h);
  56772. _context.lineTo(opt.x + opt.h / 2, opt.y + opt.h);
  56773. _context.quadraticCurveTo(opt.x, opt.y + opt.h, opt.x, opt.y + opt.h - opt.h / 2);
  56774. _context.lineTo(opt.x, opt.y + opt.h / 2);
  56775. _context.quadraticCurveTo(opt.x, opt.y, opt.x + opt.h / 2, opt.y);
  56776. } else {
  56777. _context.arc(opt.x + opt.w / 2, opt.y + opt.h / 2, opt.h / 2, 0, 2 * Math.PI);
  56778. }
  56779. _context.fillStyle = 'rgba(' + _opt.bgColor.r + ',' + _opt.bgColor.g + ',' + _opt.bgColor.b + ',' + opt.o + ')';
  56780. _context.fill();
  56781. _context.closePath();
  56782. _context.beginPath();
  56783. _context.stroke();
  56784. _context.fillStyle = 'rgba(' + _opt.textColor.r + ',' + _opt.textColor.g + ',' + _opt.textColor.b + ',' + opt.o + ')';
  56785. //_context.fillText((more) ? '9+' : opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
  56786. if ((typeof opt.n) === 'number' && opt.n > 999) {
  56787. _context.fillText(((opt.n > 9999) ? 9 : Math.floor(opt.n / 1000)) + 'k+', Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
  56788. } else {
  56789. _context.fillText(opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
  56790. }
  56791. _context.closePath();
  56792. };
  56793. /**
  56794. * Generate rectangle
  56795. * @param {Object} opt Badge options
  56796. */
  56797. type.rectangle = function (opt) {
  56798. opt = options(opt);
  56799. var more = false;
  56800. if (opt.len === 2) {
  56801. opt.x = opt.x - opt.w * 0.4;
  56802. opt.w = opt.w * 1.4;
  56803. more = true;
  56804. } else if (opt.len >= 3) {
  56805. opt.x = opt.x - opt.w * 0.65;
  56806. opt.w = opt.w * 1.65;
  56807. more = true;
  56808. }
  56809. _context.clearRect(0, 0, _w, _h);
  56810. _context.drawImage(_img, 0, 0, _w, _h);
  56811. _context.beginPath();
  56812. _context.font = _opt.fontStyle + " " + Math.floor(opt.h * (opt.n > 99 ? 0.9 : 1)) + "px " + _opt.fontFamily;
  56813. _context.textAlign = 'center';
  56814. _context.fillStyle = 'rgba(' + _opt.bgColor.r + ',' + _opt.bgColor.g + ',' + _opt.bgColor.b + ',' + opt.o + ')';
  56815. _context.fillRect(opt.x, opt.y, opt.w, opt.h);
  56816. _context.fillStyle = 'rgba(' + _opt.textColor.r + ',' + _opt.textColor.g + ',' + _opt.textColor.b + ',' + opt.o + ')';
  56817. //_context.fillText((more) ? '9+' : opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
  56818. if ((typeof opt.n) === 'number' && opt.n > 999) {
  56819. _context.fillText(((opt.n > 9999) ? 9 : Math.floor(opt.n / 1000)) + 'k+', Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
  56820. } else {
  56821. _context.fillText(opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
  56822. }
  56823. _context.closePath();
  56824. };
  56825. /**
  56826. * Set badge
  56827. */
  56828. var badge = function (number, opts) {
  56829. opts = ((typeof opts) === 'string' ? {
  56830. animation: opts
  56831. } : opts) || {};
  56832. _readyCb = function () {
  56833. try {
  56834. if (typeof (number) === 'number' ? (number > 0) : (number !== '')) {
  56835. var q = {
  56836. type: 'badge',
  56837. options: {
  56838. n: number
  56839. }
  56840. };
  56841. if ('animation' in opts && animation.types['' + opts.animation]) {
  56842. q.options.animation = '' + opts.animation;
  56843. }
  56844. if ('type' in opts && type['' + opts.type]) {
  56845. q.options.type = '' + opts.type;
  56846. }
  56847. ['bgColor', 'textColor'].forEach(function (o) {
  56848. if (o in opts) {
  56849. q.options[o] = hexToRgb(opts[o]);
  56850. }
  56851. });
  56852. ['fontStyle', 'fontFamily'].forEach(function (o) {
  56853. if (o in opts) {
  56854. q.options[o] = opts[o];
  56855. }
  56856. });
  56857. _queue.push(q);
  56858. if (_queue.length > 100) {
  56859. throw new Error('Too many badges requests in queue.');
  56860. }
  56861. icon.start();
  56862. } else {
  56863. icon.reset();
  56864. }
  56865. } catch (e) {
  56866. throw new Error('Error setting badge. Message: ' + e.message);
  56867. }
  56868. };
  56869. if (_ready) {
  56870. _readyCb();
  56871. }
  56872. };
  56873. var setOpt = function (key, value) {
  56874. var opts = key;
  56875. if (!(value == null && Object.prototype.toString.call(key) == '[object Object]')) {
  56876. opts = {};
  56877. opts[key] = value;
  56878. }
  56879. var keys = Object.keys(opts);
  56880. for (var i = 0; i < keys.length; i++) {
  56881. if (keys[i] == 'bgColor' || keys[i] == 'textColor') {
  56882. _opt[keys[i]] = hexToRgb(opts[keys[i]]);
  56883. } else {
  56884. _opt[keys[i]] = opts[keys[i]];
  56885. }
  56886. }
  56887. _queue.push(_lastBadge);
  56888. icon.start();
  56889. };
  56890. var link = {};
  56891. /**
  56892. * Get icons from HEAD tag or create a new <link> element
  56893. */
  56894. link.getIcons = function () {
  56895. var elms = [];
  56896. //get link element
  56897. var getLinks = function () {
  56898. var icons = [];
  56899. var links = _doc.getElementsByTagName('head')[0].getElementsByTagName('link');
  56900. for (var i = 0; i < links.length; i++) {
  56901. if ((/(^|\s)icon(\s|$)/i).test(links[i].getAttribute('rel'))) {
  56902. icons.push(links[i]);
  56903. }
  56904. }
  56905. return icons;
  56906. };
  56907. if (_opt.element) {
  56908. elms = [_opt.element];
  56909. } else if (_opt.elementId) {
  56910. //if img element identified by elementId
  56911. elms = [_doc.getElementById(_opt.elementId)];
  56912. elms[0].setAttribute('href', elms[0].getAttribute('src'));
  56913. } else {
  56914. //if link element
  56915. elms = getLinks();
  56916. if (elms.length === 0) {
  56917. elms = [_doc.createElement('link')];
  56918. elms[0].setAttribute('rel', 'icon');
  56919. _doc.getElementsByTagName('head')[0].appendChild(elms[0]);
  56920. }
  56921. }
  56922. elms.forEach(function(item) {
  56923. item.setAttribute('type', 'image/png');
  56924. });
  56925. return elms;
  56926. };
  56927. link.setIcon = function (canvas) {
  56928. var url = canvas.toDataURL('image/png');
  56929. link.setIconSrc(url);
  56930. };
  56931. link.setIconSrc = function (url) {
  56932. if (_opt.dataUrl) {
  56933. //if using custom exporter
  56934. _opt.dataUrl(url);
  56935. }
  56936. if (_opt.element) {
  56937. _opt.element.setAttribute('href', url);
  56938. _opt.element.setAttribute('src', url);
  56939. } else if (_opt.elementId) {
  56940. //if is attached to element (image)
  56941. var elm = _doc.getElementById(_opt.elementId);
  56942. elm.setAttribute('href', url);
  56943. elm.setAttribute('src', url);
  56944. } else {
  56945. //if is attached to fav icon
  56946. if (_browser.ff || _browser.opera) {
  56947. //for FF we need to "recreate" element, atach to dom and remove old <link>
  56948. //var originalType = _orig.getAttribute('rel');
  56949. var old = _orig[_orig.length - 1];
  56950. var newIcon = _doc.createElement('link');
  56951. _orig = [newIcon];
  56952. //_orig.setAttribute('rel', originalType);
  56953. if (_browser.opera) {
  56954. newIcon.setAttribute('rel', 'icon');
  56955. }
  56956. newIcon.setAttribute('rel', 'icon');
  56957. newIcon.setAttribute('type', 'image/png');
  56958. _doc.getElementsByTagName('head')[0].appendChild(newIcon);
  56959. newIcon.setAttribute('href', url);
  56960. if (old.parentNode) {
  56961. old.parentNode.removeChild(old);
  56962. }
  56963. } else {
  56964. _orig.forEach(function(icon) {
  56965. icon.setAttribute('href', url);
  56966. });
  56967. }
  56968. }
  56969. };
  56970. //http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-5624139
  56971. //HEX to RGB convertor
  56972. function hexToRgb(hex) {
  56973. var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  56974. hex = hex.replace(shorthandRegex, function (m, r, g, b) {
  56975. return r + r + g + g + b + b;
  56976. });
  56977. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  56978. return result ? {
  56979. r: parseInt(result[1], 16),
  56980. g: parseInt(result[2], 16),
  56981. b: parseInt(result[3], 16)
  56982. } : false;
  56983. }
  56984. /**
  56985. * Merge options
  56986. */
  56987. function merge(def, opt) {
  56988. var mergedOpt = {};
  56989. var attrname;
  56990. for (attrname in def) {
  56991. mergedOpt[attrname] = def[attrname];
  56992. }
  56993. for (attrname in opt) {
  56994. mergedOpt[attrname] = opt[attrname];
  56995. }
  56996. return mergedOpt;
  56997. }
  56998. /**
  56999. * Cross-browser page visibility shim
  57000. * http://stackoverflow.com/questions/12536562/detect-whether-a-window-is-visible
  57001. */
  57002. function isPageHidden() {
  57003. return _doc.hidden || _doc.msHidden || _doc.webkitHidden || _doc.mozHidden;
  57004. }
  57005. /**
  57006. * @namespace animation
  57007. */
  57008. var animation = {};
  57009. /**
  57010. * Animation "frame" duration
  57011. */
  57012. animation.duration = 40;
  57013. /**
  57014. * Animation types (none,fade,pop,slide)
  57015. */
  57016. animation.types = {};
  57017. animation.types.fade = [{
  57018. x: 0.4,
  57019. y: 0.4,
  57020. w: 0.6,
  57021. h: 0.6,
  57022. o: 0.0
  57023. }, {
  57024. x: 0.4,
  57025. y: 0.4,
  57026. w: 0.6,
  57027. h: 0.6,
  57028. o: 0.1
  57029. }, {
  57030. x: 0.4,
  57031. y: 0.4,
  57032. w: 0.6,
  57033. h: 0.6,
  57034. o: 0.2
  57035. }, {
  57036. x: 0.4,
  57037. y: 0.4,
  57038. w: 0.6,
  57039. h: 0.6,
  57040. o: 0.3
  57041. }, {
  57042. x: 0.4,
  57043. y: 0.4,
  57044. w: 0.6,
  57045. h: 0.6,
  57046. o: 0.4
  57047. }, {
  57048. x: 0.4,
  57049. y: 0.4,
  57050. w: 0.6,
  57051. h: 0.6,
  57052. o: 0.5
  57053. }, {
  57054. x: 0.4,
  57055. y: 0.4,
  57056. w: 0.6,
  57057. h: 0.6,
  57058. o: 0.6
  57059. }, {
  57060. x: 0.4,
  57061. y: 0.4,
  57062. w: 0.6,
  57063. h: 0.6,
  57064. o: 0.7
  57065. }, {
  57066. x: 0.4,
  57067. y: 0.4,
  57068. w: 0.6,
  57069. h: 0.6,
  57070. o: 0.8
  57071. }, {
  57072. x: 0.4,
  57073. y: 0.4,
  57074. w: 0.6,
  57075. h: 0.6,
  57076. o: 0.9
  57077. }, {
  57078. x: 0.4,
  57079. y: 0.4,
  57080. w: 0.6,
  57081. h: 0.6,
  57082. o: 1.0
  57083. }];
  57084. animation.types.none = [{
  57085. x: 0.4,
  57086. y: 0.4,
  57087. w: 0.6,
  57088. h: 0.6,
  57089. o: 1
  57090. }];
  57091. animation.types.pop = [{
  57092. x: 1,
  57093. y: 1,
  57094. w: 0,
  57095. h: 0,
  57096. o: 1
  57097. }, {
  57098. x: 0.9,
  57099. y: 0.9,
  57100. w: 0.1,
  57101. h: 0.1,
  57102. o: 1
  57103. }, {
  57104. x: 0.8,
  57105. y: 0.8,
  57106. w: 0.2,
  57107. h: 0.2,
  57108. o: 1
  57109. }, {
  57110. x: 0.7,
  57111. y: 0.7,
  57112. w: 0.3,
  57113. h: 0.3,
  57114. o: 1
  57115. }, {
  57116. x: 0.6,
  57117. y: 0.6,
  57118. w: 0.4,
  57119. h: 0.4,
  57120. o: 1
  57121. }, {
  57122. x: 0.5,
  57123. y: 0.5,
  57124. w: 0.5,
  57125. h: 0.5,
  57126. o: 1
  57127. }, {
  57128. x: 0.4,
  57129. y: 0.4,
  57130. w: 0.6,
  57131. h: 0.6,
  57132. o: 1
  57133. }];
  57134. animation.types.popFade = [{
  57135. x: 0.75,
  57136. y: 0.75,
  57137. w: 0,
  57138. h: 0,
  57139. o: 0
  57140. }, {
  57141. x: 0.65,
  57142. y: 0.65,
  57143. w: 0.1,
  57144. h: 0.1,
  57145. o: 0.2
  57146. }, {
  57147. x: 0.6,
  57148. y: 0.6,
  57149. w: 0.2,
  57150. h: 0.2,
  57151. o: 0.4
  57152. }, {
  57153. x: 0.55,
  57154. y: 0.55,
  57155. w: 0.3,
  57156. h: 0.3,
  57157. o: 0.6
  57158. }, {
  57159. x: 0.50,
  57160. y: 0.50,
  57161. w: 0.4,
  57162. h: 0.4,
  57163. o: 0.8
  57164. }, {
  57165. x: 0.45,
  57166. y: 0.45,
  57167. w: 0.5,
  57168. h: 0.5,
  57169. o: 0.9
  57170. }, {
  57171. x: 0.4,
  57172. y: 0.4,
  57173. w: 0.6,
  57174. h: 0.6,
  57175. o: 1
  57176. }];
  57177. animation.types.slide = [{
  57178. x: 0.4,
  57179. y: 1,
  57180. w: 0.6,
  57181. h: 0.6,
  57182. o: 1
  57183. }, {
  57184. x: 0.4,
  57185. y: 0.9,
  57186. w: 0.6,
  57187. h: 0.6,
  57188. o: 1
  57189. }, {
  57190. x: 0.4,
  57191. y: 0.9,
  57192. w: 0.6,
  57193. h: 0.6,
  57194. o: 1
  57195. }, {
  57196. x: 0.4,
  57197. y: 0.8,
  57198. w: 0.6,
  57199. h: 0.6,
  57200. o: 1
  57201. }, {
  57202. x: 0.4,
  57203. y: 0.7,
  57204. w: 0.6,
  57205. h: 0.6,
  57206. o: 1
  57207. }, {
  57208. x: 0.4,
  57209. y: 0.6,
  57210. w: 0.6,
  57211. h: 0.6,
  57212. o: 1
  57213. }, {
  57214. x: 0.4,
  57215. y: 0.5,
  57216. w: 0.6,
  57217. h: 0.6,
  57218. o: 1
  57219. }, {
  57220. x: 0.4,
  57221. y: 0.4,
  57222. w: 0.6,
  57223. h: 0.6,
  57224. o: 1
  57225. }];
  57226. /**
  57227. * Run animation
  57228. * @param {Object} opt Animation options
  57229. * @param {Object} cb Callabak after all steps are done
  57230. * @param {Object} revert Reverse order? true|false
  57231. * @param {Object} step Optional step number (frame bumber)
  57232. */
  57233. animation.run = function (opt, cb, revert, step) {
  57234. var animationType = animation.types[isPageHidden() ? 'none' : _opt.animation];
  57235. if (revert === true) {
  57236. step = (typeof step !== 'undefined') ? step : animationType.length - 1;
  57237. } else {
  57238. step = (typeof step !== 'undefined') ? step : 0;
  57239. }
  57240. cb = (cb) ? cb : function () {
  57241. };
  57242. if ((step < animationType.length) && (step >= 0)) {
  57243. type[_opt.type](merge(opt, animationType[step]));
  57244. _animTimeout = setTimeout(function () {
  57245. if (revert) {
  57246. step = step - 1;
  57247. } else {
  57248. step = step + 1;
  57249. }
  57250. animation.run(opt, cb, revert, step);
  57251. }, animation.duration);
  57252. link.setIcon(_canvas);
  57253. } else {
  57254. cb();
  57255. return;
  57256. }
  57257. };
  57258. //auto init
  57259. init();
  57260. return {
  57261. badge: badge,
  57262. setOpt: setOpt,
  57263. reset: icon.reset,
  57264. browser: {
  57265. supported: _browser.supported
  57266. }
  57267. };
  57268. });
  57269. // AMD / RequireJS
  57270. if (true) {
  57271. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  57272. return Favico;
  57273. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  57274. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  57275. }
  57276. // CommonJS
  57277. else {}
  57278. })();
  57279. /***/ }),
  57280. /***/ 6755:
  57281. /***/ (function(module) {
  57282. /*!
  57283. 2020 Jason Mulligan <jason.mulligan@avoidwork.com>
  57284. @version 7.0.0
  57285. */
  57286. !function(e,i){ true?module.exports=i():0}(this,(function(){"use strict";var e=/^(b|B)$/,i={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},t={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},o={floor:Math.floor,ceil:Math.ceil};function n(n){var r,a,b,l,s,c,d,f,p,u,B,h,g,y,M,m,v,x,N,j,T,E=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},w=[],P=0;if(isNaN(n))throw new TypeError("Invalid number");if(b=!0===E.bits,M=!0===E.unix,h=!0===E.pad,a=E.base||2,g=void 0!==E.round?E.round:M?1:2,d=void 0!==E.locale?E.locale:"",f=E.localeOptions||{},m=void 0!==E.separator?E.separator:"",v=void 0!==E.spacer?E.spacer:M?"":" ",N=E.symbols||{},x=2===a&&E.standard||"jedec",B=E.output||"string",s=!0===E.fullform,c=E.fullforms instanceof Array?E.fullforms:[],r=void 0!==E.exponent?E.exponent:-1,j=o[E.roundingMethod]||Math.round,p=(u=Number(n))<0,l=a>2?1e3:1024,T=!1===isNaN(E.precision)?parseInt(E.precision,10):0,p&&(u=-u),(-1===r||isNaN(r))&&(r=Math.floor(Math.log(u)/Math.log(l)))<0&&(r=0),r>8&&(T>0&&(T+=8-r),r=8),"exponent"===B)return r;if(0===u)w[0]=0,y=w[1]=M?"":i[x][b?"bits":"bytes"][r];else{P=u/(2===a?Math.pow(2,10*r):Math.pow(1e3,r)),b&&(P*=8)>=l&&r<8&&(P/=l,r++);var k=Math.pow(10,r>0?g:0);w[0]=j(P*k)/k,w[0]===l&&r<8&&void 0===E.exponent&&(w[0]=1,r++),y=w[1]=10===a&&1===r?b?"kb":"kB":i[x][b?"bits":"bytes"][r],M&&(w[1]="jedec"===x?w[1].charAt(0):r>0?w[1].replace(/B$/,""):w[1],e.test(w[1])&&(w[0]=Math.floor(w[0]),w[1]=""))}if(p&&(w[0]=-w[0]),T>0&&(w[0]=w[0].toPrecision(T)),w[1]=N[w[1]]||w[1],!0===d?w[0]=w[0].toLocaleString():d.length>0?w[0]=w[0].toLocaleString(d,f):m.length>0&&(w[0]=w[0].toString().replace(".",m)),h&&!1===Number.isInteger(w[0])&&g>0){var G=m||".",K=w[0].toString().split(G),S=K[1]||"",Y=S.length,Z=g-Y;w[0]="".concat(K[0]).concat(G).concat(S.padEnd(Y+Z,"0"))}return s&&(w[1]=c[r]?c[r]:t[x][r]+(b?"bit":"byte")+(1===w[0]?"":"s")),"array"===B?w:"object"===B?{value:w[0],symbol:w[1],exponent:r,unit:y}:w.join(v)}return n.partial=function(e){return function(i){return n(i,e)}},n}));
  57287. //# sourceMappingURL=filesize.min.js.map
  57288. /***/ }),
  57289. /***/ 5705:
  57290. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  57291. "use strict";
  57292. var Mutation = __webpack_require__.g.MutationObserver || __webpack_require__.g.WebKitMutationObserver;
  57293. var scheduleDrain;
  57294. {
  57295. if (Mutation) {
  57296. var called = 0;
  57297. var observer = new Mutation(nextTick);
  57298. var element = __webpack_require__.g.document.createTextNode('');
  57299. observer.observe(element, {
  57300. characterData: true
  57301. });
  57302. scheduleDrain = function () {
  57303. element.data = (called = ++called % 2);
  57304. };
  57305. } else if (!__webpack_require__.g.setImmediate && typeof __webpack_require__.g.MessageChannel !== 'undefined') {
  57306. var channel = new __webpack_require__.g.MessageChannel();
  57307. channel.port1.onmessage = nextTick;
  57308. scheduleDrain = function () {
  57309. channel.port2.postMessage(0);
  57310. };
  57311. } else if ('document' in __webpack_require__.g && 'onreadystatechange' in __webpack_require__.g.document.createElement('script')) {
  57312. scheduleDrain = function () {
  57313. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  57314. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  57315. var scriptEl = __webpack_require__.g.document.createElement('script');
  57316. scriptEl.onreadystatechange = function () {
  57317. nextTick();
  57318. scriptEl.onreadystatechange = null;
  57319. scriptEl.parentNode.removeChild(scriptEl);
  57320. scriptEl = null;
  57321. };
  57322. __webpack_require__.g.document.documentElement.appendChild(scriptEl);
  57323. };
  57324. } else {
  57325. scheduleDrain = function () {
  57326. setTimeout(nextTick, 0);
  57327. };
  57328. }
  57329. }
  57330. var draining;
  57331. var queue = [];
  57332. //named nextTick for less confusing stack traces
  57333. function nextTick() {
  57334. draining = true;
  57335. var i, oldQueue;
  57336. var len = queue.length;
  57337. while (len) {
  57338. oldQueue = queue;
  57339. queue = [];
  57340. i = -1;
  57341. while (++i < len) {
  57342. oldQueue[i]();
  57343. }
  57344. len = queue.length;
  57345. }
  57346. draining = false;
  57347. }
  57348. module.exports = immediate;
  57349. function immediate(task) {
  57350. if (queue.push(task) === 1 && !draining) {
  57351. scheduleDrain();
  57352. }
  57353. }
  57354. /***/ }),
  57355. /***/ 2353:
  57356. /***/ (function(module, exports) {
  57357. /**
  57358. * @preserve jed.js https://github.com/SlexAxton/Jed
  57359. */
  57360. /*
  57361. -----------
  57362. A gettext compatible i18n library for modern JavaScript Applications
  57363. by Alex Sexton - AlexSexton [at] gmail - @SlexAxton
  57364. MIT License
  57365. A jQuery Foundation project - requires CLA to contribute -
  57366. https://contribute.jquery.org/CLA/
  57367. Jed offers the entire applicable GNU gettext spec'd set of
  57368. functions, but also offers some nicer wrappers around them.
  57369. The api for gettext was written for a language with no function
  57370. overloading, so Jed allows a little more of that.
  57371. Many thanks to Joshua I. Miller - unrtst@cpan.org - who wrote
  57372. gettext.js back in 2008. I was able to vet a lot of my ideas
  57373. against his. I also made sure Jed passed against his tests
  57374. in order to offer easy upgrades -- jsgettext.berlios.de
  57375. */
  57376. (function (root, undef) {
  57377. // Set up some underscore-style functions, if you already have
  57378. // underscore, feel free to delete this section, and use it
  57379. // directly, however, the amount of functions used doesn't
  57380. // warrant having underscore as a full dependency.
  57381. // Underscore 1.3.0 was used to port and is licensed
  57382. // under the MIT License by Jeremy Ashkenas.
  57383. var ArrayProto = Array.prototype,
  57384. ObjProto = Object.prototype,
  57385. slice = ArrayProto.slice,
  57386. hasOwnProp = ObjProto.hasOwnProperty,
  57387. nativeForEach = ArrayProto.forEach,
  57388. breaker = {};
  57389. // We're not using the OOP style _ so we don't need the
  57390. // extra level of indirection. This still means that you
  57391. // sub out for real `_` though.
  57392. var _ = {
  57393. forEach : function( obj, iterator, context ) {
  57394. var i, l, key;
  57395. if ( obj === null ) {
  57396. return;
  57397. }
  57398. if ( nativeForEach && obj.forEach === nativeForEach ) {
  57399. obj.forEach( iterator, context );
  57400. }
  57401. else if ( obj.length === +obj.length ) {
  57402. for ( i = 0, l = obj.length; i < l; i++ ) {
  57403. if ( i in obj && iterator.call( context, obj[i], i, obj ) === breaker ) {
  57404. return;
  57405. }
  57406. }
  57407. }
  57408. else {
  57409. for ( key in obj) {
  57410. if ( hasOwnProp.call( obj, key ) ) {
  57411. if ( iterator.call (context, obj[key], key, obj ) === breaker ) {
  57412. return;
  57413. }
  57414. }
  57415. }
  57416. }
  57417. },
  57418. extend : function( obj ) {
  57419. this.forEach( slice.call( arguments, 1 ), function ( source ) {
  57420. for ( var prop in source ) {
  57421. obj[prop] = source[prop];
  57422. }
  57423. });
  57424. return obj;
  57425. }
  57426. };
  57427. // END Miniature underscore impl
  57428. // Jed is a constructor function
  57429. var Jed = function ( options ) {
  57430. // Some minimal defaults
  57431. this.defaults = {
  57432. "locale_data" : {
  57433. "messages" : {
  57434. "" : {
  57435. "domain" : "messages",
  57436. "lang" : "en",
  57437. "plural_forms" : "nplurals=2; plural=(n != 1);"
  57438. }
  57439. // There are no default keys, though
  57440. }
  57441. },
  57442. // The default domain if one is missing
  57443. "domain" : "messages",
  57444. // enable debug mode to log untranslated strings to the console
  57445. "debug" : false
  57446. };
  57447. // Mix in the sent options with the default options
  57448. this.options = _.extend( {}, this.defaults, options );
  57449. this.textdomain( this.options.domain );
  57450. if ( options.domain && ! this.options.locale_data[ this.options.domain ] ) {
  57451. throw new Error('Text domain set to non-existent domain: `' + options.domain + '`');
  57452. }
  57453. };
  57454. // The gettext spec sets this character as the default
  57455. // delimiter for context lookups.
  57456. // e.g.: context\u0004key
  57457. // If your translation company uses something different,
  57458. // just change this at any time and it will use that instead.
  57459. Jed.context_delimiter = String.fromCharCode( 4 );
  57460. function getPluralFormFunc ( plural_form_string ) {
  57461. return Jed.PF.compile( plural_form_string || "nplurals=2; plural=(n != 1);");
  57462. }
  57463. function Chain( key, i18n ){
  57464. this._key = key;
  57465. this._i18n = i18n;
  57466. }
  57467. // Create a chainable api for adding args prettily
  57468. _.extend( Chain.prototype, {
  57469. onDomain : function ( domain ) {
  57470. this._domain = domain;
  57471. return this;
  57472. },
  57473. withContext : function ( context ) {
  57474. this._context = context;
  57475. return this;
  57476. },
  57477. ifPlural : function ( num, pkey ) {
  57478. this._val = num;
  57479. this._pkey = pkey;
  57480. return this;
  57481. },
  57482. fetch : function ( sArr ) {
  57483. if ( {}.toString.call( sArr ) != '[object Array]' ) {
  57484. sArr = [].slice.call(arguments, 0);
  57485. }
  57486. return ( sArr && sArr.length ? Jed.sprintf : function(x){ return x; } )(
  57487. this._i18n.dcnpgettext(this._domain, this._context, this._key, this._pkey, this._val),
  57488. sArr
  57489. );
  57490. }
  57491. });
  57492. // Add functions to the Jed prototype.
  57493. // These will be the functions on the object that's returned
  57494. // from creating a `new Jed()`
  57495. // These seem redundant, but they gzip pretty well.
  57496. _.extend( Jed.prototype, {
  57497. // The sexier api start point
  57498. translate : function ( key ) {
  57499. return new Chain( key, this );
  57500. },
  57501. textdomain : function ( domain ) {
  57502. if ( ! domain ) {
  57503. return this._textdomain;
  57504. }
  57505. this._textdomain = domain;
  57506. },
  57507. gettext : function ( key ) {
  57508. return this.dcnpgettext.call( this, undef, undef, key );
  57509. },
  57510. dgettext : function ( domain, key ) {
  57511. return this.dcnpgettext.call( this, domain, undef, key );
  57512. },
  57513. dcgettext : function ( domain , key /*, category */ ) {
  57514. // Ignores the category anyways
  57515. return this.dcnpgettext.call( this, domain, undef, key );
  57516. },
  57517. ngettext : function ( skey, pkey, val ) {
  57518. return this.dcnpgettext.call( this, undef, undef, skey, pkey, val );
  57519. },
  57520. dngettext : function ( domain, skey, pkey, val ) {
  57521. return this.dcnpgettext.call( this, domain, undef, skey, pkey, val );
  57522. },
  57523. dcngettext : function ( domain, skey, pkey, val/*, category */) {
  57524. return this.dcnpgettext.call( this, domain, undef, skey, pkey, val );
  57525. },
  57526. pgettext : function ( context, key ) {
  57527. return this.dcnpgettext.call( this, undef, context, key );
  57528. },
  57529. dpgettext : function ( domain, context, key ) {
  57530. return this.dcnpgettext.call( this, domain, context, key );
  57531. },
  57532. dcpgettext : function ( domain, context, key/*, category */) {
  57533. return this.dcnpgettext.call( this, domain, context, key );
  57534. },
  57535. npgettext : function ( context, skey, pkey, val ) {
  57536. return this.dcnpgettext.call( this, undef, context, skey, pkey, val );
  57537. },
  57538. dnpgettext : function ( domain, context, skey, pkey, val ) {
  57539. return this.dcnpgettext.call( this, domain, context, skey, pkey, val );
  57540. },
  57541. // The most fully qualified gettext function. It has every option.
  57542. // Since it has every option, we can use it from every other method.
  57543. // This is the bread and butter.
  57544. // Technically there should be one more argument in this function for 'Category',
  57545. // but since we never use it, we might as well not waste the bytes to define it.
  57546. dcnpgettext : function ( domain, context, singular_key, plural_key, val ) {
  57547. // Set some defaults
  57548. plural_key = plural_key || singular_key;
  57549. // Use the global domain default if one
  57550. // isn't explicitly passed in
  57551. domain = domain || this._textdomain;
  57552. var fallback;
  57553. // Handle special cases
  57554. // No options found
  57555. if ( ! this.options ) {
  57556. // There's likely something wrong, but we'll return the correct key for english
  57557. // We do this by instantiating a brand new Jed instance with the default set
  57558. // for everything that could be broken.
  57559. fallback = new Jed();
  57560. return fallback.dcnpgettext.call( fallback, undefined, undefined, singular_key, plural_key, val );
  57561. }
  57562. // No translation data provided
  57563. if ( ! this.options.locale_data ) {
  57564. throw new Error('No locale data provided.');
  57565. }
  57566. if ( ! this.options.locale_data[ domain ] ) {
  57567. throw new Error('Domain `' + domain + '` was not found.');
  57568. }
  57569. if ( ! this.options.locale_data[ domain ][ "" ] ) {
  57570. throw new Error('No locale meta information provided.');
  57571. }
  57572. // Make sure we have a truthy key. Otherwise we might start looking
  57573. // into the empty string key, which is the options for the locale
  57574. // data.
  57575. if ( ! singular_key ) {
  57576. throw new Error('No translation key found.');
  57577. }
  57578. var key = context ? context + Jed.context_delimiter + singular_key : singular_key,
  57579. locale_data = this.options.locale_data,
  57580. dict = locale_data[ domain ],
  57581. defaultConf = (locale_data.messages || this.defaults.locale_data.messages)[""],
  57582. pluralForms = dict[""].plural_forms || dict[""]["Plural-Forms"] || dict[""]["plural-forms"] || defaultConf.plural_forms || defaultConf["Plural-Forms"] || defaultConf["plural-forms"],
  57583. val_list,
  57584. res;
  57585. var val_idx;
  57586. if (val === undefined) {
  57587. // No value passed in; assume singular key lookup.
  57588. val_idx = 0;
  57589. } else {
  57590. // Value has been passed in; use plural-forms calculations.
  57591. // Handle invalid numbers, but try casting strings for good measure
  57592. if ( typeof val != 'number' ) {
  57593. val = parseInt( val, 10 );
  57594. if ( isNaN( val ) ) {
  57595. throw new Error('The number that was passed in is not a number.');
  57596. }
  57597. }
  57598. val_idx = getPluralFormFunc(pluralForms)(val);
  57599. }
  57600. // Throw an error if a domain isn't found
  57601. if ( ! dict ) {
  57602. throw new Error('No domain named `' + domain + '` could be found.');
  57603. }
  57604. val_list = dict[ key ];
  57605. // If there is no match, then revert back to
  57606. // english style singular/plural with the keys passed in.
  57607. if ( ! val_list || val_idx > val_list.length ) {
  57608. if (this.options.missing_key_callback) {
  57609. this.options.missing_key_callback(key, domain);
  57610. }
  57611. res = [ singular_key, plural_key ];
  57612. // collect untranslated strings
  57613. if (this.options.debug===true) {
  57614. console.log(res[ getPluralFormFunc(pluralForms)( val ) ]);
  57615. }
  57616. return res[ getPluralFormFunc()( val ) ];
  57617. }
  57618. res = val_list[ val_idx ];
  57619. // This includes empty strings on purpose
  57620. if ( ! res ) {
  57621. res = [ singular_key, plural_key ];
  57622. return res[ getPluralFormFunc()( val ) ];
  57623. }
  57624. return res;
  57625. }
  57626. });
  57627. // We add in sprintf capabilities for post translation value interolation
  57628. // This is not internally used, so you can remove it if you have this
  57629. // available somewhere else, or want to use a different system.
  57630. // We _slightly_ modify the normal sprintf behavior to more gracefully handle
  57631. // undefined values.
  57632. /**
  57633. sprintf() for JavaScript 0.7-beta1
  57634. http://www.diveintojavascript.com/projects/javascript-sprintf
  57635. Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
  57636. All rights reserved.
  57637. Redistribution and use in source and binary forms, with or without
  57638. modification, are permitted provided that the following conditions are met:
  57639. * Redistributions of source code must retain the above copyright
  57640. notice, this list of conditions and the following disclaimer.
  57641. * Redistributions in binary form must reproduce the above copyright
  57642. notice, this list of conditions and the following disclaimer in the
  57643. documentation and/or other materials provided with the distribution.
  57644. * Neither the name of sprintf() for JavaScript nor the
  57645. names of its contributors may be used to endorse or promote products
  57646. derived from this software without specific prior written permission.
  57647. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  57648. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  57649. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  57650. DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
  57651. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  57652. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  57653. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  57654. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  57655. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  57656. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  57657. */
  57658. var sprintf = (function() {
  57659. function get_type(variable) {
  57660. return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
  57661. }
  57662. function str_repeat(input, multiplier) {
  57663. for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
  57664. return output.join('');
  57665. }
  57666. var str_format = function() {
  57667. if (!str_format.cache.hasOwnProperty(arguments[0])) {
  57668. str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
  57669. }
  57670. return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
  57671. };
  57672. str_format.format = function(parse_tree, argv) {
  57673. var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
  57674. for (i = 0; i < tree_length; i++) {
  57675. node_type = get_type(parse_tree[i]);
  57676. if (node_type === 'string') {
  57677. output.push(parse_tree[i]);
  57678. }
  57679. else if (node_type === 'array') {
  57680. match = parse_tree[i]; // convenience purposes only
  57681. if (match[2]) { // keyword argument
  57682. arg = argv[cursor];
  57683. for (k = 0; k < match[2].length; k++) {
  57684. if (!arg.hasOwnProperty(match[2][k])) {
  57685. throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
  57686. }
  57687. arg = arg[match[2][k]];
  57688. }
  57689. }
  57690. else if (match[1]) { // positional argument (explicit)
  57691. arg = argv[match[1]];
  57692. }
  57693. else { // positional argument (implicit)
  57694. arg = argv[cursor++];
  57695. }
  57696. if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
  57697. throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
  57698. }
  57699. // Jed EDIT
  57700. if ( typeof arg == 'undefined' || arg === null ) {
  57701. arg = '';
  57702. }
  57703. // Jed EDIT
  57704. switch (match[8]) {
  57705. case 'b': arg = arg.toString(2); break;
  57706. case 'c': arg = String.fromCharCode(arg); break;
  57707. case 'd': arg = parseInt(arg, 10); break;
  57708. case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
  57709. case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
  57710. case 'o': arg = arg.toString(8); break;
  57711. case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
  57712. case 'u': arg = Math.abs(arg); break;
  57713. case 'x': arg = arg.toString(16); break;
  57714. case 'X': arg = arg.toString(16).toUpperCase(); break;
  57715. }
  57716. arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
  57717. pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
  57718. pad_length = match[6] - String(arg).length;
  57719. pad = match[6] ? str_repeat(pad_character, pad_length) : '';
  57720. output.push(match[5] ? arg + pad : pad + arg);
  57721. }
  57722. }
  57723. return output.join('');
  57724. };
  57725. str_format.cache = {};
  57726. str_format.parse = function(fmt) {
  57727. var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
  57728. while (_fmt) {
  57729. if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
  57730. parse_tree.push(match[0]);
  57731. }
  57732. else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
  57733. parse_tree.push('%');
  57734. }
  57735. else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
  57736. if (match[2]) {
  57737. arg_names |= 1;
  57738. var field_list = [], replacement_field = match[2], field_match = [];
  57739. if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  57740. field_list.push(field_match[1]);
  57741. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  57742. if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  57743. field_list.push(field_match[1]);
  57744. }
  57745. else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
  57746. field_list.push(field_match[1]);
  57747. }
  57748. else {
  57749. throw('[sprintf] huh?');
  57750. }
  57751. }
  57752. }
  57753. else {
  57754. throw('[sprintf] huh?');
  57755. }
  57756. match[2] = field_list;
  57757. }
  57758. else {
  57759. arg_names |= 2;
  57760. }
  57761. if (arg_names === 3) {
  57762. throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
  57763. }
  57764. parse_tree.push(match);
  57765. }
  57766. else {
  57767. throw('[sprintf] huh?');
  57768. }
  57769. _fmt = _fmt.substring(match[0].length);
  57770. }
  57771. return parse_tree;
  57772. };
  57773. return str_format;
  57774. })();
  57775. var vsprintf = function(fmt, argv) {
  57776. argv.unshift(fmt);
  57777. return sprintf.apply(null, argv);
  57778. };
  57779. Jed.parse_plural = function ( plural_forms, n ) {
  57780. plural_forms = plural_forms.replace(/n/g, n);
  57781. return Jed.parse_expression(plural_forms);
  57782. };
  57783. Jed.sprintf = function ( fmt, args ) {
  57784. if ( {}.toString.call( args ) == '[object Array]' ) {
  57785. return vsprintf( fmt, [].slice.call(args) );
  57786. }
  57787. return sprintf.apply(this, [].slice.call(arguments) );
  57788. };
  57789. Jed.prototype.sprintf = function () {
  57790. return Jed.sprintf.apply(this, arguments);
  57791. };
  57792. // END sprintf Implementation
  57793. // Start the Plural forms section
  57794. // This is a full plural form expression parser. It is used to avoid
  57795. // running 'eval' or 'new Function' directly against the plural
  57796. // forms.
  57797. //
  57798. // This can be important if you get translations done through a 3rd
  57799. // party vendor. I encourage you to use this instead, however, I
  57800. // also will provide a 'precompiler' that you can use at build time
  57801. // to output valid/safe function representations of the plural form
  57802. // expressions. This means you can build this code out for the most
  57803. // part.
  57804. Jed.PF = {};
  57805. Jed.PF.parse = function ( p ) {
  57806. var plural_str = Jed.PF.extractPluralExpr( p );
  57807. return Jed.PF.parser.parse.call(Jed.PF.parser, plural_str);
  57808. };
  57809. Jed.PF.compile = function ( p ) {
  57810. // Handle trues and falses as 0 and 1
  57811. function imply( val ) {
  57812. return (val === true ? 1 : val ? val : 0);
  57813. }
  57814. var ast = Jed.PF.parse( p );
  57815. return function ( n ) {
  57816. return imply( Jed.PF.interpreter( ast )( n ) );
  57817. };
  57818. };
  57819. Jed.PF.interpreter = function ( ast ) {
  57820. return function ( n ) {
  57821. var res;
  57822. switch ( ast.type ) {
  57823. case 'GROUP':
  57824. return Jed.PF.interpreter( ast.expr )( n );
  57825. case 'TERNARY':
  57826. if ( Jed.PF.interpreter( ast.expr )( n ) ) {
  57827. return Jed.PF.interpreter( ast.truthy )( n );
  57828. }
  57829. return Jed.PF.interpreter( ast.falsey )( n );
  57830. case 'OR':
  57831. return Jed.PF.interpreter( ast.left )( n ) || Jed.PF.interpreter( ast.right )( n );
  57832. case 'AND':
  57833. return Jed.PF.interpreter( ast.left )( n ) && Jed.PF.interpreter( ast.right )( n );
  57834. case 'LT':
  57835. return Jed.PF.interpreter( ast.left )( n ) < Jed.PF.interpreter( ast.right )( n );
  57836. case 'GT':
  57837. return Jed.PF.interpreter( ast.left )( n ) > Jed.PF.interpreter( ast.right )( n );
  57838. case 'LTE':
  57839. return Jed.PF.interpreter( ast.left )( n ) <= Jed.PF.interpreter( ast.right )( n );
  57840. case 'GTE':
  57841. return Jed.PF.interpreter( ast.left )( n ) >= Jed.PF.interpreter( ast.right )( n );
  57842. case 'EQ':
  57843. return Jed.PF.interpreter( ast.left )( n ) == Jed.PF.interpreter( ast.right )( n );
  57844. case 'NEQ':
  57845. return Jed.PF.interpreter( ast.left )( n ) != Jed.PF.interpreter( ast.right )( n );
  57846. case 'MOD':
  57847. return Jed.PF.interpreter( ast.left )( n ) % Jed.PF.interpreter( ast.right )( n );
  57848. case 'VAR':
  57849. return n;
  57850. case 'NUM':
  57851. return ast.val;
  57852. default:
  57853. throw new Error("Invalid Token found.");
  57854. }
  57855. };
  57856. };
  57857. Jed.PF.extractPluralExpr = function ( p ) {
  57858. // trim first
  57859. p = p.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  57860. if (! /;\s*$/.test(p)) {
  57861. p = p.concat(';');
  57862. }
  57863. var nplurals_re = /nplurals\=(\d+);/,
  57864. plural_re = /plural\=(.*);/,
  57865. nplurals_matches = p.match( nplurals_re ),
  57866. res = {},
  57867. plural_matches;
  57868. // Find the nplurals number
  57869. if ( nplurals_matches.length > 1 ) {
  57870. res.nplurals = nplurals_matches[1];
  57871. }
  57872. else {
  57873. throw new Error('nplurals not found in plural_forms string: ' + p );
  57874. }
  57875. // remove that data to get to the formula
  57876. p = p.replace( nplurals_re, "" );
  57877. plural_matches = p.match( plural_re );
  57878. if (!( plural_matches && plural_matches.length > 1 ) ) {
  57879. throw new Error('`plural` expression not found: ' + p);
  57880. }
  57881. return plural_matches[ 1 ];
  57882. };
  57883. /* Jison generated parser */
  57884. Jed.PF.parser = (function(){
  57885. var parser = {trace: function trace() { },
  57886. yy: {},
  57887. symbols_: {"error":2,"expressions":3,"e":4,"EOF":5,"?":6,":":7,"||":8,"&&":9,"<":10,"<=":11,">":12,">=":13,"!=":14,"==":15,"%":16,"(":17,")":18,"n":19,"NUMBER":20,"$accept":0,"$end":1},
  57888. terminals_: {2:"error",5:"EOF",6:"?",7:":",8:"||",9:"&&",10:"<",11:"<=",12:">",13:">=",14:"!=",15:"==",16:"%",17:"(",18:")",19:"n",20:"NUMBER"},
  57889. productions_: [0,[3,2],[4,5],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,1],[4,1]],
  57890. performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
  57891. var $0 = $$.length - 1;
  57892. switch (yystate) {
  57893. case 1: return { type : 'GROUP', expr: $$[$0-1] };
  57894. break;
  57895. case 2:this.$ = { type: 'TERNARY', expr: $$[$0-4], truthy : $$[$0-2], falsey: $$[$0] };
  57896. break;
  57897. case 3:this.$ = { type: "OR", left: $$[$0-2], right: $$[$0] };
  57898. break;
  57899. case 4:this.$ = { type: "AND", left: $$[$0-2], right: $$[$0] };
  57900. break;
  57901. case 5:this.$ = { type: 'LT', left: $$[$0-2], right: $$[$0] };
  57902. break;
  57903. case 6:this.$ = { type: 'LTE', left: $$[$0-2], right: $$[$0] };
  57904. break;
  57905. case 7:this.$ = { type: 'GT', left: $$[$0-2], right: $$[$0] };
  57906. break;
  57907. case 8:this.$ = { type: 'GTE', left: $$[$0-2], right: $$[$0] };
  57908. break;
  57909. case 9:this.$ = { type: 'NEQ', left: $$[$0-2], right: $$[$0] };
  57910. break;
  57911. case 10:this.$ = { type: 'EQ', left: $$[$0-2], right: $$[$0] };
  57912. break;
  57913. case 11:this.$ = { type: 'MOD', left: $$[$0-2], right: $$[$0] };
  57914. break;
  57915. case 12:this.$ = { type: 'GROUP', expr: $$[$0-1] };
  57916. break;
  57917. case 13:this.$ = { type: 'VAR' };
  57918. break;
  57919. case 14:this.$ = { type: 'NUM', val: Number(yytext) };
  57920. break;
  57921. }
  57922. },
  57923. table: [{3:1,4:2,17:[1,3],19:[1,4],20:[1,5]},{1:[3]},{5:[1,6],6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{4:17,17:[1,3],19:[1,4],20:[1,5]},{5:[2,13],6:[2,13],7:[2,13],8:[2,13],9:[2,13],10:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13],15:[2,13],16:[2,13],18:[2,13]},{5:[2,14],6:[2,14],7:[2,14],8:[2,14],9:[2,14],10:[2,14],11:[2,14],12:[2,14],13:[2,14],14:[2,14],15:[2,14],16:[2,14],18:[2,14]},{1:[2,1]},{4:18,17:[1,3],19:[1,4],20:[1,5]},{4:19,17:[1,3],19:[1,4],20:[1,5]},{4:20,17:[1,3],19:[1,4],20:[1,5]},{4:21,17:[1,3],19:[1,4],20:[1,5]},{4:22,17:[1,3],19:[1,4],20:[1,5]},{4:23,17:[1,3],19:[1,4],20:[1,5]},{4:24,17:[1,3],19:[1,4],20:[1,5]},{4:25,17:[1,3],19:[1,4],20:[1,5]},{4:26,17:[1,3],19:[1,4],20:[1,5]},{4:27,17:[1,3],19:[1,4],20:[1,5]},{6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[1,28]},{6:[1,7],7:[1,29],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{5:[2,3],6:[2,3],7:[2,3],8:[2,3],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[2,4],9:[2,4],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[2,5],12:[2,5],13:[2,5],14:[2,5],15:[2,5],16:[1,16],18:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[2,6],12:[2,6],13:[2,6],14:[2,6],15:[2,6],16:[1,16],18:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[2,7],12:[2,7],13:[2,7],14:[2,7],15:[2,7],16:[1,16],18:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[1,16],18:[2,8]},{5:[2,9],6:[2,9],7:[2,9],8:[2,9],9:[2,9],10:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[1,16],18:[2,9]},{5:[2,10],6:[2,10],7:[2,10],8:[2,10],9:[2,10],10:[2,10],11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[2,10],16:[1,16],18:[2,10]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11],15:[2,11],16:[2,11],18:[2,11]},{5:[2,12],6:[2,12],7:[2,12],8:[2,12],9:[2,12],10:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12],15:[2,12],16:[2,12],18:[2,12]},{4:30,17:[1,3],19:[1,4],20:[1,5]},{5:[2,2],6:[1,7],7:[2,2],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,2]}],
  57924. defaultActions: {6:[2,1]},
  57925. parseError: function parseError(str, hash) {
  57926. throw new Error(str);
  57927. },
  57928. parse: function parse(input) {
  57929. var self = this,
  57930. stack = [0],
  57931. vstack = [null], // semantic value stack
  57932. lstack = [], // location stack
  57933. table = this.table,
  57934. yytext = '',
  57935. yylineno = 0,
  57936. yyleng = 0,
  57937. recovering = 0,
  57938. TERROR = 2,
  57939. EOF = 1;
  57940. //this.reductionCount = this.shiftCount = 0;
  57941. this.lexer.setInput(input);
  57942. this.lexer.yy = this.yy;
  57943. this.yy.lexer = this.lexer;
  57944. if (typeof this.lexer.yylloc == 'undefined')
  57945. this.lexer.yylloc = {};
  57946. var yyloc = this.lexer.yylloc;
  57947. lstack.push(yyloc);
  57948. if (typeof this.yy.parseError === 'function')
  57949. this.parseError = this.yy.parseError;
  57950. function popStack (n) {
  57951. stack.length = stack.length - 2*n;
  57952. vstack.length = vstack.length - n;
  57953. lstack.length = lstack.length - n;
  57954. }
  57955. function lex() {
  57956. var token;
  57957. token = self.lexer.lex() || 1; // $end = 1
  57958. // if token isn't its numeric value, convert
  57959. if (typeof token !== 'number') {
  57960. token = self.symbols_[token] || token;
  57961. }
  57962. return token;
  57963. }
  57964. var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
  57965. while (true) {
  57966. // retreive state number from top of stack
  57967. state = stack[stack.length-1];
  57968. // use default actions if available
  57969. if (this.defaultActions[state]) {
  57970. action = this.defaultActions[state];
  57971. } else {
  57972. if (symbol == null)
  57973. symbol = lex();
  57974. // read action for current state and first input
  57975. action = table[state] && table[state][symbol];
  57976. }
  57977. // handle parse error
  57978. _handle_error:
  57979. if (typeof action === 'undefined' || !action.length || !action[0]) {
  57980. if (!recovering) {
  57981. // Report error
  57982. expected = [];
  57983. for (p in table[state]) if (this.terminals_[p] && p > 2) {
  57984. expected.push("'"+this.terminals_[p]+"'");
  57985. }
  57986. var errStr = '';
  57987. if (this.lexer.showPosition) {
  57988. errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
  57989. } else {
  57990. errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
  57991. (symbol == 1 /*EOF*/ ? "end of input" :
  57992. ("'"+(this.terminals_[symbol] || symbol)+"'"));
  57993. }
  57994. this.parseError(errStr,
  57995. {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
  57996. }
  57997. // just recovered from another error
  57998. if (recovering == 3) {
  57999. if (symbol == EOF) {
  58000. throw new Error(errStr || 'Parsing halted.');
  58001. }
  58002. // discard current lookahead and grab another
  58003. yyleng = this.lexer.yyleng;
  58004. yytext = this.lexer.yytext;
  58005. yylineno = this.lexer.yylineno;
  58006. yyloc = this.lexer.yylloc;
  58007. symbol = lex();
  58008. }
  58009. // try to recover from error
  58010. while (1) {
  58011. // check for error recovery rule in this state
  58012. if ((TERROR.toString()) in table[state]) {
  58013. break;
  58014. }
  58015. if (state == 0) {
  58016. throw new Error(errStr || 'Parsing halted.');
  58017. }
  58018. popStack(1);
  58019. state = stack[stack.length-1];
  58020. }
  58021. preErrorSymbol = symbol; // save the lookahead token
  58022. symbol = TERROR; // insert generic error symbol as new lookahead
  58023. state = stack[stack.length-1];
  58024. action = table[state] && table[state][TERROR];
  58025. recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
  58026. }
  58027. // this shouldn't happen, unless resolve defaults are off
  58028. if (action[0] instanceof Array && action.length > 1) {
  58029. throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
  58030. }
  58031. switch (action[0]) {
  58032. case 1: // shift
  58033. //this.shiftCount++;
  58034. stack.push(symbol);
  58035. vstack.push(this.lexer.yytext);
  58036. lstack.push(this.lexer.yylloc);
  58037. stack.push(action[1]); // push state
  58038. symbol = null;
  58039. if (!preErrorSymbol) { // normal execution/no error
  58040. yyleng = this.lexer.yyleng;
  58041. yytext = this.lexer.yytext;
  58042. yylineno = this.lexer.yylineno;
  58043. yyloc = this.lexer.yylloc;
  58044. if (recovering > 0)
  58045. recovering--;
  58046. } else { // error just occurred, resume old lookahead f/ before error
  58047. symbol = preErrorSymbol;
  58048. preErrorSymbol = null;
  58049. }
  58050. break;
  58051. case 2: // reduce
  58052. //this.reductionCount++;
  58053. len = this.productions_[action[1]][1];
  58054. // perform semantic action
  58055. yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
  58056. // default location, uses first token for firsts, last for lasts
  58057. yyval._$ = {
  58058. first_line: lstack[lstack.length-(len||1)].first_line,
  58059. last_line: lstack[lstack.length-1].last_line,
  58060. first_column: lstack[lstack.length-(len||1)].first_column,
  58061. last_column: lstack[lstack.length-1].last_column
  58062. };
  58063. r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
  58064. if (typeof r !== 'undefined') {
  58065. return r;
  58066. }
  58067. // pop off stack
  58068. if (len) {
  58069. stack = stack.slice(0,-1*len*2);
  58070. vstack = vstack.slice(0, -1*len);
  58071. lstack = lstack.slice(0, -1*len);
  58072. }
  58073. stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
  58074. vstack.push(yyval.$);
  58075. lstack.push(yyval._$);
  58076. // goto new state = table[STATE][NONTERMINAL]
  58077. newState = table[stack[stack.length-2]][stack[stack.length-1]];
  58078. stack.push(newState);
  58079. break;
  58080. case 3: // accept
  58081. return true;
  58082. }
  58083. }
  58084. return true;
  58085. }};/* Jison generated lexer */
  58086. var lexer = (function(){
  58087. var lexer = ({EOF:1,
  58088. parseError:function parseError(str, hash) {
  58089. if (this.yy.parseError) {
  58090. this.yy.parseError(str, hash);
  58091. } else {
  58092. throw new Error(str);
  58093. }
  58094. },
  58095. setInput:function (input) {
  58096. this._input = input;
  58097. this._more = this._less = this.done = false;
  58098. this.yylineno = this.yyleng = 0;
  58099. this.yytext = this.matched = this.match = '';
  58100. this.conditionStack = ['INITIAL'];
  58101. this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
  58102. return this;
  58103. },
  58104. input:function () {
  58105. var ch = this._input[0];
  58106. this.yytext+=ch;
  58107. this.yyleng++;
  58108. this.match+=ch;
  58109. this.matched+=ch;
  58110. var lines = ch.match(/\n/);
  58111. if (lines) this.yylineno++;
  58112. this._input = this._input.slice(1);
  58113. return ch;
  58114. },
  58115. unput:function (ch) {
  58116. this._input = ch + this._input;
  58117. return this;
  58118. },
  58119. more:function () {
  58120. this._more = true;
  58121. return this;
  58122. },
  58123. pastInput:function () {
  58124. var past = this.matched.substr(0, this.matched.length - this.match.length);
  58125. return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
  58126. },
  58127. upcomingInput:function () {
  58128. var next = this.match;
  58129. if (next.length < 20) {
  58130. next += this._input.substr(0, 20-next.length);
  58131. }
  58132. return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
  58133. },
  58134. showPosition:function () {
  58135. var pre = this.pastInput();
  58136. var c = new Array(pre.length + 1).join("-");
  58137. return pre + this.upcomingInput() + "\n" + c+"^";
  58138. },
  58139. next:function () {
  58140. if (this.done) {
  58141. return this.EOF;
  58142. }
  58143. if (!this._input) this.done = true;
  58144. var token,
  58145. match,
  58146. col,
  58147. lines;
  58148. if (!this._more) {
  58149. this.yytext = '';
  58150. this.match = '';
  58151. }
  58152. var rules = this._currentRules();
  58153. for (var i=0;i < rules.length; i++) {
  58154. match = this._input.match(this.rules[rules[i]]);
  58155. if (match) {
  58156. lines = match[0].match(/\n.*/g);
  58157. if (lines) this.yylineno += lines.length;
  58158. this.yylloc = {first_line: this.yylloc.last_line,
  58159. last_line: this.yylineno+1,
  58160. first_column: this.yylloc.last_column,
  58161. last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
  58162. this.yytext += match[0];
  58163. this.match += match[0];
  58164. this.matches = match;
  58165. this.yyleng = this.yytext.length;
  58166. this._more = false;
  58167. this._input = this._input.slice(match[0].length);
  58168. this.matched += match[0];
  58169. token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
  58170. if (token) return token;
  58171. else return;
  58172. }
  58173. }
  58174. if (this._input === "") {
  58175. return this.EOF;
  58176. } else {
  58177. this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
  58178. {text: "", token: null, line: this.yylineno});
  58179. }
  58180. },
  58181. lex:function lex() {
  58182. var r = this.next();
  58183. if (typeof r !== 'undefined') {
  58184. return r;
  58185. } else {
  58186. return this.lex();
  58187. }
  58188. },
  58189. begin:function begin(condition) {
  58190. this.conditionStack.push(condition);
  58191. },
  58192. popState:function popState() {
  58193. return this.conditionStack.pop();
  58194. },
  58195. _currentRules:function _currentRules() {
  58196. return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
  58197. },
  58198. topState:function () {
  58199. return this.conditionStack[this.conditionStack.length-2];
  58200. },
  58201. pushState:function begin(condition) {
  58202. this.begin(condition);
  58203. }});
  58204. lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
  58205. var YYSTATE=YY_START;
  58206. switch($avoiding_name_collisions) {
  58207. case 0:/* skip whitespace */
  58208. break;
  58209. case 1:return 20
  58210. break;
  58211. case 2:return 19
  58212. break;
  58213. case 3:return 8
  58214. break;
  58215. case 4:return 9
  58216. break;
  58217. case 5:return 6
  58218. break;
  58219. case 6:return 7
  58220. break;
  58221. case 7:return 11
  58222. break;
  58223. case 8:return 13
  58224. break;
  58225. case 9:return 10
  58226. break;
  58227. case 10:return 12
  58228. break;
  58229. case 11:return 14
  58230. break;
  58231. case 12:return 15
  58232. break;
  58233. case 13:return 16
  58234. break;
  58235. case 14:return 17
  58236. break;
  58237. case 15:return 18
  58238. break;
  58239. case 16:return 5
  58240. break;
  58241. case 17:return 'INVALID'
  58242. break;
  58243. }
  58244. };
  58245. lexer.rules = [/^\s+/,/^[0-9]+(\.[0-9]+)?\b/,/^n\b/,/^\|\|/,/^&&/,/^\?/,/^:/,/^<=/,/^>=/,/^</,/^>/,/^!=/,/^==/,/^%/,/^\(/,/^\)/,/^$/,/^./];
  58246. lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],"inclusive":true}};return lexer;})()
  58247. parser.lexer = lexer;
  58248. return parser;
  58249. })();
  58250. // End parser
  58251. // Handle node, amd, and global systems
  58252. if (true) {
  58253. if ( true && module.exports) {
  58254. exports = module.exports = Jed;
  58255. }
  58256. exports.Jed = Jed;
  58257. }
  58258. else {}
  58259. })(this);
  58260. /***/ }),
  58261. /***/ 3389:
  58262. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  58263. "use strict";
  58264. var immediate = __webpack_require__(5705);
  58265. /* istanbul ignore next */
  58266. function INTERNAL() {}
  58267. var handlers = {};
  58268. var REJECTED = ['REJECTED'];
  58269. var FULFILLED = ['FULFILLED'];
  58270. var PENDING = ['PENDING'];
  58271. module.exports = Promise;
  58272. function Promise(resolver) {
  58273. if (typeof resolver !== 'function') {
  58274. throw new TypeError('resolver must be a function');
  58275. }
  58276. this.state = PENDING;
  58277. this.queue = [];
  58278. this.outcome = void 0;
  58279. if (resolver !== INTERNAL) {
  58280. safelyResolveThenable(this, resolver);
  58281. }
  58282. }
  58283. Promise.prototype["catch"] = function (onRejected) {
  58284. return this.then(null, onRejected);
  58285. };
  58286. Promise.prototype.then = function (onFulfilled, onRejected) {
  58287. if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||
  58288. typeof onRejected !== 'function' && this.state === REJECTED) {
  58289. return this;
  58290. }
  58291. var promise = new this.constructor(INTERNAL);
  58292. if (this.state !== PENDING) {
  58293. var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
  58294. unwrap(promise, resolver, this.outcome);
  58295. } else {
  58296. this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
  58297. }
  58298. return promise;
  58299. };
  58300. function QueueItem(promise, onFulfilled, onRejected) {
  58301. this.promise = promise;
  58302. if (typeof onFulfilled === 'function') {
  58303. this.onFulfilled = onFulfilled;
  58304. this.callFulfilled = this.otherCallFulfilled;
  58305. }
  58306. if (typeof onRejected === 'function') {
  58307. this.onRejected = onRejected;
  58308. this.callRejected = this.otherCallRejected;
  58309. }
  58310. }
  58311. QueueItem.prototype.callFulfilled = function (value) {
  58312. handlers.resolve(this.promise, value);
  58313. };
  58314. QueueItem.prototype.otherCallFulfilled = function (value) {
  58315. unwrap(this.promise, this.onFulfilled, value);
  58316. };
  58317. QueueItem.prototype.callRejected = function (value) {
  58318. handlers.reject(this.promise, value);
  58319. };
  58320. QueueItem.prototype.otherCallRejected = function (value) {
  58321. unwrap(this.promise, this.onRejected, value);
  58322. };
  58323. function unwrap(promise, func, value) {
  58324. immediate(function () {
  58325. var returnValue;
  58326. try {
  58327. returnValue = func(value);
  58328. } catch (e) {
  58329. return handlers.reject(promise, e);
  58330. }
  58331. if (returnValue === promise) {
  58332. handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
  58333. } else {
  58334. handlers.resolve(promise, returnValue);
  58335. }
  58336. });
  58337. }
  58338. handlers.resolve = function (self, value) {
  58339. var result = tryCatch(getThen, value);
  58340. if (result.status === 'error') {
  58341. return handlers.reject(self, result.value);
  58342. }
  58343. var thenable = result.value;
  58344. if (thenable) {
  58345. safelyResolveThenable(self, thenable);
  58346. } else {
  58347. self.state = FULFILLED;
  58348. self.outcome = value;
  58349. var i = -1;
  58350. var len = self.queue.length;
  58351. while (++i < len) {
  58352. self.queue[i].callFulfilled(value);
  58353. }
  58354. }
  58355. return self;
  58356. };
  58357. handlers.reject = function (self, error) {
  58358. self.state = REJECTED;
  58359. self.outcome = error;
  58360. var i = -1;
  58361. var len = self.queue.length;
  58362. while (++i < len) {
  58363. self.queue[i].callRejected(error);
  58364. }
  58365. return self;
  58366. };
  58367. function getThen(obj) {
  58368. // Make sure we only access the accessor once as required by the spec
  58369. var then = obj && obj.then;
  58370. if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {
  58371. return function appyThen() {
  58372. then.apply(obj, arguments);
  58373. };
  58374. }
  58375. }
  58376. function safelyResolveThenable(self, thenable) {
  58377. // Either fulfill, reject or reject with error
  58378. var called = false;
  58379. function onError(value) {
  58380. if (called) {
  58381. return;
  58382. }
  58383. called = true;
  58384. handlers.reject(self, value);
  58385. }
  58386. function onSuccess(value) {
  58387. if (called) {
  58388. return;
  58389. }
  58390. called = true;
  58391. handlers.resolve(self, value);
  58392. }
  58393. function tryToUnwrap() {
  58394. thenable(onSuccess, onError);
  58395. }
  58396. var result = tryCatch(tryToUnwrap);
  58397. if (result.status === 'error') {
  58398. onError(result.value);
  58399. }
  58400. }
  58401. function tryCatch(func, value) {
  58402. var out = {};
  58403. try {
  58404. out.value = func(value);
  58405. out.status = 'success';
  58406. } catch (e) {
  58407. out.status = 'error';
  58408. out.value = e;
  58409. }
  58410. return out;
  58411. }
  58412. Promise.resolve = resolve;
  58413. function resolve(value) {
  58414. if (value instanceof this) {
  58415. return value;
  58416. }
  58417. return handlers.resolve(new this(INTERNAL), value);
  58418. }
  58419. Promise.reject = reject;
  58420. function reject(reason) {
  58421. var promise = new this(INTERNAL);
  58422. return handlers.reject(promise, reason);
  58423. }
  58424. Promise.all = all;
  58425. function all(iterable) {
  58426. var self = this;
  58427. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  58428. return this.reject(new TypeError('must be an array'));
  58429. }
  58430. var len = iterable.length;
  58431. var called = false;
  58432. if (!len) {
  58433. return this.resolve([]);
  58434. }
  58435. var values = new Array(len);
  58436. var resolved = 0;
  58437. var i = -1;
  58438. var promise = new this(INTERNAL);
  58439. while (++i < len) {
  58440. allResolver(iterable[i], i);
  58441. }
  58442. return promise;
  58443. function allResolver(value, i) {
  58444. self.resolve(value).then(resolveFromAll, function (error) {
  58445. if (!called) {
  58446. called = true;
  58447. handlers.reject(promise, error);
  58448. }
  58449. });
  58450. function resolveFromAll(outValue) {
  58451. values[i] = outValue;
  58452. if (++resolved === len && !called) {
  58453. called = true;
  58454. handlers.resolve(promise, values);
  58455. }
  58456. }
  58457. }
  58458. }
  58459. Promise.race = race;
  58460. function race(iterable) {
  58461. var self = this;
  58462. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  58463. return this.reject(new TypeError('must be an array'));
  58464. }
  58465. var len = iterable.length;
  58466. var called = false;
  58467. if (!len) {
  58468. return this.resolve([]);
  58469. }
  58470. var i = -1;
  58471. var promise = new this(INTERNAL);
  58472. while (++i < len) {
  58473. resolver(iterable[i]);
  58474. }
  58475. return promise;
  58476. function resolver(value) {
  58477. self.resolve(value).then(function (response) {
  58478. if (!called) {
  58479. called = true;
  58480. handlers.resolve(promise, response);
  58481. }
  58482. }, function (error) {
  58483. if (!called) {
  58484. called = true;
  58485. handlers.reject(promise, error);
  58486. }
  58487. });
  58488. }
  58489. }
  58490. /***/ }),
  58491. /***/ 9236:
  58492. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  58493. "use strict";
  58494. if (typeof __webpack_require__.g.Promise !== 'function') {
  58495. __webpack_require__.g.Promise = __webpack_require__(3389);
  58496. }
  58497. /***/ }),
  58498. /***/ 3245:
  58499. /***/ (function(__unused_webpack_module, exports) {
  58500. /*!
  58501. MIT License
  58502. Copyright (c) 2018 Arturas Molcanovas <a.molcanovas@gmail.com>
  58503. Permission is hereby granted, free of charge, to any person obtaining a copy
  58504. of this software and associated documentation files (the "Software"), to deal
  58505. in the Software without restriction, including without limitation the rights
  58506. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58507. copies of the Software, and to permit persons to whom the Software is
  58508. furnished to do so, subject to the following conditions:
  58509. The above copyright notice and this permission notice shall be included in all
  58510. copies or substantial portions of the Software.
  58511. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58512. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58513. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58514. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58515. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58516. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  58517. SOFTWARE.
  58518. */
  58519. (function (global, factory) {
  58520. true ? factory(exports) :
  58521. 0;
  58522. }(typeof self !== 'undefined' ? self : this, function (exports) { 'use strict';
  58523. var _driver = 'localforage-driver-memory';
  58524. /*! *****************************************************************************
  58525. Copyright (c) Microsoft Corporation. All rights reserved.
  58526. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  58527. this file except in compliance with the License. You may obtain a copy of the
  58528. License at http://www.apache.org/licenses/LICENSE-2.0
  58529. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58530. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  58531. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  58532. MERCHANTABLITY OR NON-INFRINGEMENT.
  58533. See the Apache Version 2.0 License for specific language governing permissions
  58534. and limitations under the License.
  58535. ***************************************************************************** */
  58536. function __values(o) {
  58537. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  58538. if (m) return m.call(o);
  58539. return {
  58540. next: function () {
  58541. if (o && i >= o.length) o = void 0;
  58542. return { value: o && o[i++], done: !o };
  58543. }
  58544. };
  58545. }
  58546. /*!
  58547. MIT License
  58548. Copyright (c) 2018 Arturas Molcanovas <a.molcanovas@gmail.com>
  58549. Permission is hereby granted, free of charge, to any person obtaining a copy
  58550. of this software and associated documentation files (the "Software"), to deal
  58551. in the Software without restriction, including without limitation the rights
  58552. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58553. copies of the Software, and to permit persons to whom the Software is
  58554. furnished to do so, subject to the following conditions:
  58555. The above copyright notice and this permission notice shall be included in all
  58556. copies or substantial portions of the Software.
  58557. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58558. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58559. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58560. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58561. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58562. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  58563. SOFTWARE.
  58564. */
  58565. /**
  58566. * Abstracts constructing a Blob object, so it also works in older
  58567. * browsers that don't support the native Blob constructor. (i.e.
  58568. * old QtWebKit versions, at least).
  58569. * Abstracts constructing a Blob object, so it also works in older
  58570. * browsers that don't support the native Blob constructor. (i.e.
  58571. * old QtWebKit versions, at least).
  58572. *
  58573. * @param parts
  58574. * @param properties
  58575. */
  58576. function createBlob(parts, properties) {
  58577. /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */
  58578. parts = parts || [];
  58579. properties = properties || {};
  58580. try {
  58581. return new Blob(parts, properties);
  58582. }
  58583. catch (e) {
  58584. if (e.name !== 'TypeError') {
  58585. throw e;
  58586. }
  58587. //tslint:disable-next-line:variable-name
  58588. var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder
  58589. : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder
  58590. : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder
  58591. : WebKitBlobBuilder;
  58592. var builder = new Builder();
  58593. for (var i = 0; i < parts.length; i += 1) {
  58594. builder.append(parts[i]);
  58595. }
  58596. return builder.getBlob(properties.type);
  58597. }
  58598. }
  58599. var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
  58600. var SERIALIZED_MARKER_LENGTH = "__lfsc__:" /* SERIALIZED_MARKER */.length;
  58601. var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + "arbf" /* TYPE_ARRAYBUFFER */.length;
  58602. //tslint:disable:no-magic-numbers no-bitwise prefer-switch no-unbound-method
  58603. var toString = Object.prototype.toString;
  58604. function stringToBuffer(serializedString) {
  58605. // Fill the string into a ArrayBuffer.
  58606. var bufferLength = serializedString.length * 0.75;
  58607. var len = serializedString.length;
  58608. if (serializedString[serializedString.length - 1] === '=') {
  58609. bufferLength--;
  58610. if (serializedString[serializedString.length - 2] === '=') {
  58611. bufferLength--;
  58612. }
  58613. }
  58614. var buffer = new ArrayBuffer(bufferLength);
  58615. var bytes = new Uint8Array(buffer);
  58616. for (var i = 0, p = 0; i < len; i += 4) {
  58617. var encoded1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */.indexOf(serializedString[i]);
  58618. var encoded2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */.indexOf(serializedString[i + 1]);
  58619. var encoded3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */.indexOf(serializedString[i + 2]);
  58620. var encoded4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */.indexOf(serializedString[i + 3]);
  58621. bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
  58622. bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
  58623. bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
  58624. }
  58625. return buffer;
  58626. }
  58627. /**
  58628. * Converts a buffer to a string to store, serialized, in the backend
  58629. * storage library.
  58630. */
  58631. function bufferToString(buffer) {
  58632. // base64-arraybuffer
  58633. var bytes = new Uint8Array(buffer);
  58634. var base64String = '';
  58635. for (var i = 0; i < bytes.length; i += 3) {
  58636. /*jslint bitwise: true */
  58637. base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */[bytes[i] >> 2];
  58638. base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
  58639. base64String +=
  58640. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
  58641. base64String += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" /* BASE_CHARS */[bytes[i + 2] & 63];
  58642. }
  58643. if (bytes.length % 3 === 2) {
  58644. base64String = base64String.substring(0, base64String.length - 1) + '=';
  58645. }
  58646. else if (bytes.length % 3 === 1) {
  58647. base64String = base64String.substring(0, base64String.length - 2) + '==';
  58648. }
  58649. return base64String;
  58650. }
  58651. /**
  58652. * Serialize a value, afterwards executing a callback (which usually
  58653. * instructs the `setItem()` callback/promise to be executed). This is how
  58654. * we store binary data with localStorage.
  58655. * @param value
  58656. * @param callback
  58657. */
  58658. function serialize(value, callback) {
  58659. var valueType = '';
  58660. if (value) {
  58661. valueType = toString.call(value);
  58662. }
  58663. // Cannot use `value instanceof ArrayBuffer` or such here, as these
  58664. // checks fail when running the tests using casper.js...
  58665. if (value && (valueType === '[object ArrayBuffer]' ||
  58666. (value.buffer && toString.call(value.buffer) === '[object ArrayBuffer]'))) {
  58667. // Convert binary arrays to a string and prefix the string with
  58668. // a special marker.
  58669. var buffer = void 0;
  58670. var marker = "__lfsc__:" /* SERIALIZED_MARKER */;
  58671. if (value instanceof ArrayBuffer) {
  58672. buffer = value;
  58673. marker += "arbf" /* TYPE_ARRAYBUFFER */;
  58674. }
  58675. else {
  58676. buffer = value.buffer;
  58677. if (valueType === '[object Int8Array]') {
  58678. marker += "si08" /* TYPE_INT8ARRAY */;
  58679. }
  58680. else if (valueType === '[object Uint8Array]') {
  58681. marker += "ui08" /* TYPE_UINT8ARRAY */;
  58682. }
  58683. else if (valueType === '[object Uint8ClampedArray]') {
  58684. marker += "uic8" /* TYPE_UINT8CLAMPEDARRAY */;
  58685. }
  58686. else if (valueType === '[object Int16Array]') {
  58687. marker += "si16" /* TYPE_INT16ARRAY */;
  58688. }
  58689. else if (valueType === '[object Uint16Array]') {
  58690. marker += "ur16" /* TYPE_UINT16ARRAY */;
  58691. }
  58692. else if (valueType === '[object Int32Array]') {
  58693. marker += "si32" /* TYPE_INT32ARRAY */;
  58694. }
  58695. else if (valueType === '[object Uint32Array]') {
  58696. marker += "ui32" /* TYPE_UINT32ARRAY */;
  58697. }
  58698. else if (valueType === '[object Float32Array]') {
  58699. marker += "fl32" /* TYPE_FLOAT32ARRAY */;
  58700. }
  58701. else if (valueType === '[object Float64Array]') {
  58702. marker += "fl64" /* TYPE_FLOAT64ARRAY */;
  58703. }
  58704. else {
  58705. callback(new Error('Failed to get type for BinaryArray'));
  58706. }
  58707. }
  58708. callback(marker + bufferToString(buffer));
  58709. }
  58710. else if (valueType === '[object Blob]') {
  58711. // Convert the blob to a binaryArray and then to a string.
  58712. var fileReader = new FileReader();
  58713. fileReader.onload = function () {
  58714. // Backwards-compatible prefix for the blob type.
  58715. //tslint:disable-next-line:restrict-plus-operands
  58716. var str = "~~local_forage_type~" /* BLOB_TYPE_PREFIX */ + value.type + "~" + bufferToString(this.result);
  58717. callback("__lfsc__:" /* SERIALIZED_MARKER */ + "blob" /* TYPE_BLOB */ + str);
  58718. };
  58719. fileReader.readAsArrayBuffer(value);
  58720. }
  58721. else {
  58722. try {
  58723. callback(JSON.stringify(value));
  58724. }
  58725. catch (e) {
  58726. console.error('Couldn\'t convert value into a JSON string: ', value);
  58727. callback(null, e);
  58728. }
  58729. }
  58730. }
  58731. /**
  58732. * Deserialize data we've inserted into a value column/field. We place
  58733. * special markers into our strings to mark them as encoded; this isn't
  58734. * as nice as a meta field, but it's the only sane thing we can do whilst
  58735. * keeping localStorage support intact.
  58736. *
  58737. * Oftentimes this will just deserialize JSON content, but if we have a
  58738. * special marker (SERIALIZED_MARKER, defined above), we will extract
  58739. * some kind of arraybuffer/binary data/typed array out of the string.
  58740. * @param value
  58741. */
  58742. function deserialize(value) {
  58743. // If we haven't marked this string as being specially serialized (i.e.
  58744. // something other than serialized JSON), we can just return it and be
  58745. // done with it.
  58746. if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== "__lfsc__:" /* SERIALIZED_MARKER */) {
  58747. return JSON.parse(value);
  58748. }
  58749. // The following code deals with deserializing some kind of Blob or
  58750. // TypedArray. First we separate out the type of data we're dealing
  58751. // with from the data itself.
  58752. var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
  58753. var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
  58754. var blobType;
  58755. // Backwards-compatible blob type serialization strategy.
  58756. // DBs created with older versions of localForage will simply not have the blob type.
  58757. if (type === "blob" /* TYPE_BLOB */ && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
  58758. var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
  58759. blobType = matcher[1];
  58760. serializedString = serializedString.substring(matcher[0].length);
  58761. }
  58762. var buffer = stringToBuffer(serializedString);
  58763. // Return the right type based on the code/type set during
  58764. // serialization.
  58765. switch (type) {
  58766. case "arbf" /* TYPE_ARRAYBUFFER */:
  58767. return buffer;
  58768. case "blob" /* TYPE_BLOB */:
  58769. return createBlob([buffer], { type: blobType });
  58770. case "si08" /* TYPE_INT8ARRAY */:
  58771. return new Int8Array(buffer);
  58772. case "ui08" /* TYPE_UINT8ARRAY */:
  58773. return new Uint8Array(buffer);
  58774. case "uic8" /* TYPE_UINT8CLAMPEDARRAY */:
  58775. return new Uint8ClampedArray(buffer);
  58776. case "si16" /* TYPE_INT16ARRAY */:
  58777. return new Int16Array(buffer);
  58778. case "ur16" /* TYPE_UINT16ARRAY */:
  58779. return new Uint16Array(buffer);
  58780. case "si32" /* TYPE_INT32ARRAY */:
  58781. return new Int32Array(buffer);
  58782. case "ui32" /* TYPE_UINT32ARRAY */:
  58783. return new Uint32Array(buffer);
  58784. case "fl32" /* TYPE_FLOAT32ARRAY */:
  58785. return new Float32Array(buffer);
  58786. case "fl64" /* TYPE_FLOAT64ARRAY */:
  58787. return new Float64Array(buffer);
  58788. default:
  58789. throw new Error('Unkown type: ' + type);
  58790. }
  58791. }
  58792. function clone(obj) {
  58793. var e_1, _a;
  58794. if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) {
  58795. return obj;
  58796. }
  58797. var temp = obj instanceof Date ? new Date(obj) : (obj.constructor());
  58798. try {
  58799. for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
  58800. var key = _c.value;
  58801. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  58802. obj['isActiveClone'] = null;
  58803. temp[key] = clone(obj[key]);
  58804. delete obj['isActiveClone'];
  58805. }
  58806. }
  58807. }
  58808. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  58809. finally {
  58810. try {
  58811. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  58812. }
  58813. finally { if (e_1) throw e_1.error; }
  58814. }
  58815. return temp;
  58816. }
  58817. function getKeyPrefix(options, defaultConfig) {
  58818. return (options.name || defaultConfig.name) + "/" + (options.storeName || defaultConfig.storeName) + "/";
  58819. }
  58820. function executeCallback(promise, callback) {
  58821. if (callback) {
  58822. promise.then(function (result) {
  58823. callback(null, result);
  58824. }, function (error) {
  58825. callback(error);
  58826. });
  58827. }
  58828. }
  58829. function getCallback() {
  58830. var _args = [];
  58831. for (var _i = 0; _i < arguments.length; _i++) {
  58832. _args[_i] = arguments[_i];
  58833. }
  58834. if (arguments.length && typeof arguments[arguments.length - 1] === 'function') {
  58835. return arguments[arguments.length - 1];
  58836. }
  58837. }
  58838. //tslint:disable-next-line:no-ignored-initial-value
  58839. function dropInstanceCommon(options, callback) {
  58840. var _this = this;
  58841. callback = getCallback.apply(this, arguments);
  58842. options = (typeof options !== 'function' && options) || {};
  58843. if (!options.name) {
  58844. var currentConfig = this.config();
  58845. options.name = options.name || currentConfig.name;
  58846. options.storeName = options.storeName || currentConfig.storeName;
  58847. }
  58848. var promise;
  58849. if (!options.name) {
  58850. promise = Promise.reject('Invalid arguments');
  58851. }
  58852. else {
  58853. promise = new Promise(function (resolve) {
  58854. if (!options.storeName) {
  58855. resolve(options.name + "/");
  58856. }
  58857. else {
  58858. resolve(getKeyPrefix(options, _this._defaultConfig));
  58859. }
  58860. });
  58861. }
  58862. return { promise: promise, callback: callback };
  58863. }
  58864. function normaliseKey(key) {
  58865. // Cast the key to a string, as that's all we can set as a key.
  58866. if (typeof key !== 'string') {
  58867. console.warn(key + " used as a key, but it is not a string.");
  58868. key = String(key);
  58869. }
  58870. return key;
  58871. }
  58872. var serialiser = {
  58873. bufferToString: bufferToString,
  58874. deserialize: deserialize,
  58875. serialize: serialize,
  58876. stringToBuffer: stringToBuffer
  58877. };
  58878. var stores = {};
  58879. /** @internal */
  58880. var Store = /** @class */ (function () {
  58881. function Store(kp) {
  58882. this.kp = kp;
  58883. this.data = {};
  58884. }
  58885. Store.resolve = function (kp) {
  58886. if (!stores[kp]) {
  58887. stores[kp] = new Store(kp);
  58888. }
  58889. return stores[kp];
  58890. };
  58891. Store.prototype.clear = function () {
  58892. this.data = {};
  58893. };
  58894. Store.prototype.drop = function () {
  58895. this.clear();
  58896. delete stores[this.kp];
  58897. };
  58898. Store.prototype.get = function (key) {
  58899. return this.data[key];
  58900. };
  58901. Store.prototype.key = function (idx) {
  58902. return this.keys()[idx];
  58903. };
  58904. Store.prototype.keys = function () {
  58905. return Object.keys(this.data);
  58906. };
  58907. Store.prototype.rm = function (k) {
  58908. delete this.data[k];
  58909. };
  58910. Store.prototype.set = function (k, v) {
  58911. this.data[k] = v;
  58912. };
  58913. return Store;
  58914. }());
  58915. function _initStorage(options) {
  58916. var opts = options ? clone(options) : {};
  58917. var kp = getKeyPrefix(opts, this._defaultConfig);
  58918. var store = Store.resolve(kp);
  58919. this._dbInfo = opts;
  58920. this._dbInfo.serializer = serialiser;
  58921. this._dbInfo.keyPrefix = kp;
  58922. this._dbInfo.mStore = store;
  58923. return Promise.resolve();
  58924. }
  58925. function clear(callback) {
  58926. var _this = this;
  58927. var promise = this.ready().then(function () {
  58928. _this._dbInfo.mStore.clear();
  58929. });
  58930. executeCallback(promise, callback);
  58931. return promise;
  58932. }
  58933. function dropInstance(_options, _cb) {
  58934. var _a = dropInstanceCommon.apply(this, arguments), promise = _a.promise, callback = _a.callback;
  58935. var outPromise = promise.then(function (keyPrefix) {
  58936. Store.resolve(keyPrefix).drop();
  58937. });
  58938. executeCallback(outPromise, callback);
  58939. return promise;
  58940. }
  58941. function getItem(key$, callback) {
  58942. var _this = this;
  58943. key$ = normaliseKey(key$);
  58944. var promise = this.ready().then(function () {
  58945. var result = _this._dbInfo.mStore.get(key$);
  58946. // Deserialise if the result is not null or undefined
  58947. return result == null ? null : _this._dbInfo.serializer.deserialize(result); //tslint:disable-line:triple-equals
  58948. });
  58949. executeCallback(promise, callback);
  58950. return promise;
  58951. }
  58952. function iterate(iterator, callback) {
  58953. var _this = this;
  58954. var promise = this.ready().then(function () {
  58955. var store = _this._dbInfo.mStore;
  58956. var keys = store.keys();
  58957. for (var i = 0; i < keys.length; i++) {
  58958. var value = store.get(keys[i]);
  58959. // If a result was found, parse it from the serialized
  58960. // string into a JS object. If result isn't truthy, the
  58961. // key is likely undefined and we'll pass it straight
  58962. // to the iterator.
  58963. if (value) {
  58964. value = _this._dbInfo.serializer.deserialize(value);
  58965. }
  58966. value = iterator(value, keys[i], i + 1);
  58967. if (value !== undefined) {
  58968. return value;
  58969. }
  58970. }
  58971. });
  58972. executeCallback(promise, callback);
  58973. return promise;
  58974. }
  58975. function key(idx, callback) {
  58976. var _this = this;
  58977. var promise = this.ready().then(function () {
  58978. var result;
  58979. try {
  58980. result = _this._dbInfo.mStore.key(idx);
  58981. if (result === undefined) {
  58982. result = null;
  58983. }
  58984. }
  58985. catch (_a) {
  58986. result = null;
  58987. }
  58988. return result;
  58989. });
  58990. executeCallback(promise, callback);
  58991. return promise;
  58992. }
  58993. function keys(callback) {
  58994. var _this = this;
  58995. var promise = this.ready().then(function () {
  58996. return _this._dbInfo.mStore.keys();
  58997. });
  58998. executeCallback(promise, callback);
  58999. return promise;
  59000. }
  59001. function length(callback) {
  59002. var promise = this.keys().then(function (keys$) { return keys$.length; });
  59003. executeCallback(promise, callback);
  59004. return promise;
  59005. }
  59006. function removeItem(key$, callback) {
  59007. var _this = this;
  59008. key$ = normaliseKey(key$);
  59009. var promise = this.ready().then(function () {
  59010. _this._dbInfo.mStore.rm(key$);
  59011. });
  59012. executeCallback(promise, callback);
  59013. return promise;
  59014. }
  59015. function setItem(key$, value, callback) {
  59016. var _this = this;
  59017. key$ = normaliseKey(key$);
  59018. var promise = this.ready().then(function () {
  59019. if (value === undefined) {
  59020. value = null;
  59021. }
  59022. // Save the original value to pass to the callback.
  59023. var originalValue = value;
  59024. return new Promise(function (resolve, reject) {
  59025. _this._dbInfo.serializer.serialize(value, function (value$, error) {
  59026. if (error) {
  59027. reject(error);
  59028. }
  59029. else {
  59030. try {
  59031. _this._dbInfo.mStore.set(key$, value$);
  59032. resolve(originalValue);
  59033. }
  59034. catch (e) {
  59035. reject(e);
  59036. }
  59037. }
  59038. });
  59039. });
  59040. });
  59041. executeCallback(promise, callback);
  59042. return promise;
  59043. }
  59044. var _support = true;
  59045. exports._support = _support;
  59046. exports._driver = _driver;
  59047. exports._initStorage = _initStorage;
  59048. exports.clear = clear;
  59049. exports.dropInstance = dropInstance;
  59050. exports.getItem = getItem;
  59051. exports.iterate = iterate;
  59052. exports.key = key;
  59053. exports.keys = keys;
  59054. exports.length = length;
  59055. exports.removeItem = removeItem;
  59056. exports.setItem = setItem;
  59057. Object.defineProperty(exports, '__esModule', { value: true });
  59058. }));
  59059. //# sourceMappingURL=umd.js.map
  59060. /***/ }),
  59061. /***/ 642:
  59062. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  59063. (function (global, factory) {
  59064. true ? factory(exports, __webpack_require__(9483)) :
  59065. 0;
  59066. }(this, (function (exports,localforage) { 'use strict';
  59067. localforage = 'default' in localforage ? localforage['default'] : localforage;
  59068. function getSerializerPromise(localForageInstance) {
  59069. if (getSerializerPromise.result) {
  59070. return getSerializerPromise.result;
  59071. }
  59072. if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
  59073. return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
  59074. }
  59075. getSerializerPromise.result = localForageInstance.getSerializer();
  59076. return getSerializerPromise.result;
  59077. }
  59078. function executeCallback(promise, callback) {
  59079. if (callback) {
  59080. promise.then(function (result) {
  59081. callback(null, result);
  59082. }, function (error) {
  59083. callback(error);
  59084. });
  59085. }
  59086. return promise;
  59087. }
  59088. function getItemKeyValue(key, callback) {
  59089. var localforageInstance = this;
  59090. var promise = localforageInstance.getItem(key).then(function (value) {
  59091. return {
  59092. key: key,
  59093. value: value
  59094. };
  59095. });
  59096. executeCallback(promise, callback);
  59097. return promise;
  59098. }
  59099. function getItemsGeneric(keys /*, callback*/) {
  59100. var localforageInstance = this;
  59101. var promise = new Promise(function (resolve, reject) {
  59102. var itemPromises = [];
  59103. for (var i = 0, len = keys.length; i < len; i++) {
  59104. itemPromises.push(getItemKeyValue.call(localforageInstance, keys[i]));
  59105. }
  59106. Promise.all(itemPromises).then(function (keyValuePairs) {
  59107. var result = {};
  59108. for (var i = 0, len = keyValuePairs.length; i < len; i++) {
  59109. var keyValuePair = keyValuePairs[i];
  59110. result[keyValuePair.key] = keyValuePair.value;
  59111. }
  59112. resolve(result);
  59113. }).catch(reject);
  59114. });
  59115. return promise;
  59116. }
  59117. function getAllItemsUsingIterate() {
  59118. var localforageInstance = this;
  59119. var accumulator = {};
  59120. return localforageInstance.iterate(function (value, key /*, iterationNumber*/) {
  59121. accumulator[key] = value;
  59122. }).then(function () {
  59123. return accumulator;
  59124. });
  59125. }
  59126. function getIDBKeyRange() {
  59127. /* global IDBKeyRange, webkitIDBKeyRange, mozIDBKeyRange */
  59128. if (typeof IDBKeyRange !== 'undefined') {
  59129. return IDBKeyRange;
  59130. }
  59131. if (typeof webkitIDBKeyRange !== 'undefined') {
  59132. return webkitIDBKeyRange;
  59133. }
  59134. if (typeof mozIDBKeyRange !== 'undefined') {
  59135. return mozIDBKeyRange;
  59136. }
  59137. }
  59138. var idbKeyRange = getIDBKeyRange();
  59139. function getItemsIndexedDB(keys /*, callback*/) {
  59140. keys = keys.slice();
  59141. var localforageInstance = this;
  59142. function comparer(a, b) {
  59143. return a < b ? -1 : a > b ? 1 : 0;
  59144. }
  59145. var promise = new Promise(function (resolve, reject) {
  59146. localforageInstance.ready().then(function () {
  59147. // Thanks https://hacks.mozilla.org/2014/06/breaking-the-borders-of-indexeddb/
  59148. var dbInfo = localforageInstance._dbInfo;
  59149. var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly').objectStore(dbInfo.storeName);
  59150. var set = keys.sort(comparer);
  59151. var keyRangeValue = idbKeyRange.bound(keys[0], keys[keys.length - 1], false, false);
  59152. var req;
  59153. if ('getAll' in store) {
  59154. req = store.getAll(keyRangeValue);
  59155. req.onsuccess = function () {
  59156. var value = req.result;
  59157. if (value === undefined) {
  59158. value = null;
  59159. }
  59160. resolve(value);
  59161. };
  59162. } else {
  59163. req = store.openCursor(keyRangeValue);
  59164. var result = {};
  59165. var i = 0;
  59166. req.onsuccess = function () /*event*/{
  59167. var cursor = req.result; // event.target.result;
  59168. if (!cursor) {
  59169. resolve(result);
  59170. return;
  59171. }
  59172. var key = cursor.key;
  59173. while (key > set[i]) {
  59174. i++; // The cursor has passed beyond this key. Check next.
  59175. if (i === set.length) {
  59176. // There is no next. Stop searching.
  59177. resolve(result);
  59178. return;
  59179. }
  59180. }
  59181. if (key === set[i]) {
  59182. // The current cursor value should be included and we should continue
  59183. // a single step in case next item has the same key or possibly our
  59184. // next key in set.
  59185. var value = cursor.value;
  59186. if (value === undefined) {
  59187. value = null;
  59188. }
  59189. result[key] = value;
  59190. // onfound(cursor.value);
  59191. cursor.continue();
  59192. } else {
  59193. // cursor.key not yet at set[i]. Forward cursor to the next key to hunt for.
  59194. cursor.continue(set[i]);
  59195. }
  59196. };
  59197. }
  59198. req.onerror = function () /*event*/{
  59199. reject(req.error);
  59200. };
  59201. }).catch(reject);
  59202. });
  59203. return promise;
  59204. }
  59205. function getItemsWebsql(keys /*, callback*/) {
  59206. var localforageInstance = this;
  59207. var promise = new Promise(function (resolve, reject) {
  59208. localforageInstance.ready().then(function () {
  59209. return getSerializerPromise(localforageInstance);
  59210. }).then(function (serializer) {
  59211. var dbInfo = localforageInstance._dbInfo;
  59212. dbInfo.db.transaction(function (t) {
  59213. var queryParts = new Array(keys.length);
  59214. for (var i = 0, len = keys.length; i < len; i++) {
  59215. queryParts[i] = '?';
  59216. }
  59217. t.executeSql('SELECT * FROM ' + dbInfo.storeName + ' WHERE (key IN (' + queryParts.join(',') + '))', keys, function (t, results) {
  59218. var result = {};
  59219. var rows = results.rows;
  59220. for (var i = 0, len = rows.length; i < len; i++) {
  59221. var item = rows.item(i);
  59222. var value = item.value;
  59223. // Check to see if this is serialized content we need to
  59224. // unpack.
  59225. if (value) {
  59226. value = serializer.deserialize(value);
  59227. }
  59228. result[item.key] = value;
  59229. }
  59230. resolve(result);
  59231. }, function (t, error) {
  59232. reject(error);
  59233. });
  59234. });
  59235. }).catch(reject);
  59236. });
  59237. return promise;
  59238. }
  59239. function localforageGetItems(keys, callback) {
  59240. var localforageInstance = this;
  59241. var promise;
  59242. if (!arguments.length || keys === null) {
  59243. promise = getAllItemsUsingIterate.apply(localforageInstance);
  59244. } else {
  59245. var currentDriver = localforageInstance.driver();
  59246. if (currentDriver === localforageInstance.INDEXEDDB) {
  59247. promise = getItemsIndexedDB.apply(localforageInstance, arguments);
  59248. } else if (currentDriver === localforageInstance.WEBSQL) {
  59249. promise = getItemsWebsql.apply(localforageInstance, arguments);
  59250. } else {
  59251. promise = getItemsGeneric.apply(localforageInstance, arguments);
  59252. }
  59253. }
  59254. executeCallback(promise, callback);
  59255. return promise;
  59256. }
  59257. function extendPrototype(localforage$$1) {
  59258. var localforagePrototype = Object.getPrototypeOf(localforage$$1);
  59259. if (localforagePrototype) {
  59260. localforagePrototype.getItems = localforageGetItems;
  59261. localforagePrototype.getItems.indexedDB = function () {
  59262. return getItemsIndexedDB.apply(this, arguments);
  59263. };
  59264. localforagePrototype.getItems.websql = function () {
  59265. return getItemsWebsql.apply(this, arguments);
  59266. };
  59267. localforagePrototype.getItems.generic = function () {
  59268. return getItemsGeneric.apply(this, arguments);
  59269. };
  59270. }
  59271. }
  59272. var extendPrototypeResult = extendPrototype(localforage);
  59273. exports.localforageGetItems = localforageGetItems;
  59274. exports.extendPrototype = extendPrototype;
  59275. exports.extendPrototypeResult = extendPrototypeResult;
  59276. exports.getItemsGeneric = getItemsGeneric;
  59277. Object.defineProperty(exports, '__esModule', { value: true });
  59278. })));
  59279. /***/ }),
  59280. /***/ 1459:
  59281. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  59282. (function (global, factory) {
  59283. true ? factory(exports, __webpack_require__(9483)) :
  59284. 0;
  59285. }(this, (function (exports,localforage) { 'use strict';
  59286. localforage = 'default' in localforage ? localforage['default'] : localforage;
  59287. function getSerializerPromise(localForageInstance) {
  59288. if (getSerializerPromise.result) {
  59289. return getSerializerPromise.result;
  59290. }
  59291. if (!localForageInstance || typeof localForageInstance.getSerializer !== 'function') {
  59292. return Promise.reject(new Error('localforage.getSerializer() was not available! ' + 'localforage v1.4+ is required!'));
  59293. }
  59294. getSerializerPromise.result = localForageInstance.getSerializer();
  59295. return getSerializerPromise.result;
  59296. }
  59297. function executeCallback(promise, callback) {
  59298. if (callback) {
  59299. promise.then(function (result) {
  59300. callback(null, result);
  59301. }, function (error) {
  59302. callback(error);
  59303. });
  59304. }
  59305. }
  59306. function forEachItem(items, keyFn, valueFn, loopFn) {
  59307. function ensurePropGetterMethod(propFn, defaultPropName) {
  59308. var propName = propFn || defaultPropName;
  59309. if ((!propFn || typeof propFn !== 'function') && typeof propName === 'string') {
  59310. propFn = function propFn(item) {
  59311. return item[propName];
  59312. };
  59313. }
  59314. return propFn;
  59315. }
  59316. var result = [];
  59317. // http://stackoverflow.com/questions/4775722/check-if-object-is-array
  59318. if (Object.prototype.toString.call(items) === '[object Array]') {
  59319. keyFn = ensurePropGetterMethod(keyFn, 'key');
  59320. valueFn = ensurePropGetterMethod(valueFn, 'value');
  59321. for (var i = 0, len = items.length; i < len; i++) {
  59322. var item = items[i];
  59323. result.push(loopFn(keyFn(item), valueFn(item)));
  59324. }
  59325. } else {
  59326. for (var prop in items) {
  59327. if (items.hasOwnProperty(prop)) {
  59328. result.push(loopFn(prop, items[prop]));
  59329. }
  59330. }
  59331. }
  59332. return result;
  59333. }
  59334. function setItemsIndexedDB(items, keyFn, valueFn, callback) {
  59335. var localforageInstance = this;
  59336. var promise = localforageInstance.ready().then(function () {
  59337. return new Promise(function (resolve, reject) {
  59338. // Inspired from @lu4 PR mozilla/localForage#318
  59339. var dbInfo = localforageInstance._dbInfo;
  59340. var transaction = dbInfo.db.transaction(dbInfo.storeName, 'readwrite');
  59341. var store = transaction.objectStore(dbInfo.storeName);
  59342. var lastError;
  59343. transaction.oncomplete = function () {
  59344. resolve(items);
  59345. };
  59346. transaction.onabort = transaction.onerror = function (event) {
  59347. reject(lastError || event.target);
  59348. };
  59349. function requestOnError(evt) {
  59350. var request = evt.target || this;
  59351. lastError = request.error || request.transaction.error;
  59352. reject(lastError);
  59353. }
  59354. forEachItem(items, keyFn, valueFn, function (key, value) {
  59355. // The reason we don't _save_ null is because IE 10 does
  59356. // not support saving the `null` type in IndexedDB. How
  59357. // ironic, given the bug below!
  59358. // See: https://github.com/mozilla/localForage/issues/161
  59359. if (value === null) {
  59360. value = undefined;
  59361. }
  59362. var request = store.put(value, key);
  59363. request.onerror = requestOnError;
  59364. });
  59365. });
  59366. });
  59367. executeCallback(promise, callback);
  59368. return promise;
  59369. }
  59370. function setItemsWebsql(items, keyFn, valueFn, callback) {
  59371. var localforageInstance = this;
  59372. var promise = new Promise(function (resolve, reject) {
  59373. localforageInstance.ready().then(function () {
  59374. return getSerializerPromise(localforageInstance);
  59375. }).then(function (serializer) {
  59376. // Inspired from @lu4 PR mozilla/localForage#318
  59377. var dbInfo = localforageInstance._dbInfo;
  59378. dbInfo.db.transaction(function (t) {
  59379. var query = 'INSERT OR REPLACE INTO ' + dbInfo.storeName + ' (key, value) VALUES (?, ?)';
  59380. var itemPromises = forEachItem(items, keyFn, valueFn, function (key, value) {
  59381. return new Promise(function (resolve, reject) {
  59382. serializer.serialize(value, function (value, error) {
  59383. if (error) {
  59384. reject(error);
  59385. } else {
  59386. t.executeSql(query, [key, value], function () {
  59387. resolve();
  59388. }, function (t, error) {
  59389. reject(error);
  59390. });
  59391. }
  59392. });
  59393. });
  59394. });
  59395. Promise.all(itemPromises).then(function () {
  59396. resolve(items);
  59397. }, reject);
  59398. }, function (sqlError) {
  59399. reject(sqlError);
  59400. } /*, function() {
  59401. if (resolving) {
  59402. resolve(items);
  59403. }
  59404. }*/);
  59405. }).catch(reject);
  59406. });
  59407. executeCallback(promise, callback);
  59408. return promise;
  59409. }
  59410. function setItemsGeneric(items, keyFn, valueFn, callback) {
  59411. var localforageInstance = this;
  59412. var itemPromises = forEachItem(items, keyFn, valueFn, function (key, value) {
  59413. return localforageInstance.setItem(key, value);
  59414. });
  59415. var promise = Promise.all(itemPromises);
  59416. executeCallback(promise, callback);
  59417. return promise;
  59418. }
  59419. function localforageSetItems(items, keyFn, valueFn, callback) {
  59420. var localforageInstance = this;
  59421. var currentDriver = localforageInstance.driver();
  59422. if (currentDriver === localforageInstance.INDEXEDDB) {
  59423. return setItemsIndexedDB.call(localforageInstance, items, keyFn, valueFn, callback);
  59424. } else if (currentDriver === localforageInstance.WEBSQL) {
  59425. return setItemsWebsql.call(localforageInstance, items, keyFn, valueFn, callback);
  59426. } else {
  59427. return setItemsGeneric.call(localforageInstance, items, keyFn, valueFn, callback);
  59428. }
  59429. }
  59430. function extendPrototype(localforage$$1) {
  59431. var localforagePrototype = Object.getPrototypeOf(localforage$$1);
  59432. if (localforagePrototype) {
  59433. localforagePrototype.setItems = localforageSetItems;
  59434. localforagePrototype.setItems.indexedDB = function () {
  59435. return setItemsIndexedDB.apply(this, arguments);
  59436. };
  59437. localforagePrototype.setItems.websql = function () {
  59438. return setItemsWebsql.apply(this, arguments);
  59439. };
  59440. localforagePrototype.setItems.generic = function () {
  59441. return setItemsGeneric.apply(this, arguments);
  59442. };
  59443. }
  59444. }
  59445. var extendPrototypeResult = extendPrototype(localforage);
  59446. exports.setItemsGeneric = setItemsGeneric;
  59447. exports.localforageSetItems = localforageSetItems;
  59448. exports.extendPrototype = extendPrototype;
  59449. exports.extendPrototypeResult = extendPrototypeResult;
  59450. Object.defineProperty(exports, '__esModule', { value: true });
  59451. })));
  59452. /***/ }),
  59453. /***/ 7715:
  59454. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  59455. "use strict";
  59456. var _interopRequireDefault = __webpack_require__(5318);
  59457. Object.defineProperty(exports, "__esModule", ({
  59458. value: true
  59459. }));
  59460. exports["default"] = createDriver;
  59461. var _regenerator = _interopRequireDefault(__webpack_require__(7757));
  59462. var _defineProperty2 = _interopRequireDefault(__webpack_require__(9713));
  59463. var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(8926));
  59464. var _utils = __webpack_require__(4639);
  59465. function createDriver(name, property) {
  59466. var storage = (0, _utils.getStorage)();
  59467. var support = !!(storage && storage[property]);
  59468. var driver = support ? storage[property] : {
  59469. clear: function clear() {},
  59470. get: function get() {},
  59471. remove: function remove() {},
  59472. set: function set() {}
  59473. };
  59474. var _clear = driver.clear.bind(driver);
  59475. var get = driver.get.bind(driver);
  59476. var remove = driver.remove.bind(driver);
  59477. var set = driver.set.bind(driver);
  59478. return {
  59479. _driver: name,
  59480. _support: support,
  59481. // eslint-disable-next-line no-underscore-dangle
  59482. _initStorage: function _initStorage() {
  59483. return Promise.resolve();
  59484. },
  59485. clear: function clear(callback) {
  59486. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  59487. return _regenerator["default"].wrap(function _callee$(_context) {
  59488. while (1) {
  59489. switch (_context.prev = _context.next) {
  59490. case 0:
  59491. _clear();
  59492. if (callback) callback();
  59493. case 2:
  59494. case "end":
  59495. return _context.stop();
  59496. }
  59497. }
  59498. }, _callee);
  59499. }))();
  59500. },
  59501. iterate: function iterate(iterator, callback) {
  59502. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  59503. var items, keys;
  59504. return _regenerator["default"].wrap(function _callee2$(_context2) {
  59505. while (1) {
  59506. switch (_context2.prev = _context2.next) {
  59507. case 0:
  59508. _context2.next = 2;
  59509. return (0, _utils.usePromise)(get, null);
  59510. case 2:
  59511. items = _context2.sent;
  59512. keys = Object.keys(items);
  59513. keys.forEach(function (key, i) {
  59514. return iterator(items[key], key, i);
  59515. });
  59516. if (callback) callback();
  59517. case 6:
  59518. case "end":
  59519. return _context2.stop();
  59520. }
  59521. }
  59522. }, _callee2);
  59523. }))();
  59524. },
  59525. getItem: function getItem(key, callback) {
  59526. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  59527. var result;
  59528. return _regenerator["default"].wrap(function _callee3$(_context3) {
  59529. while (1) {
  59530. switch (_context3.prev = _context3.next) {
  59531. case 0:
  59532. _context3.prev = 0;
  59533. _context3.next = 3;
  59534. return (0, _utils.usePromise)(get, key);
  59535. case 3:
  59536. result = _context3.sent;
  59537. result = typeof key === 'string' ? result[key] : result;
  59538. result = result === undefined ? null : result;
  59539. if (callback) callback(null, result);
  59540. return _context3.abrupt("return", result);
  59541. case 10:
  59542. _context3.prev = 10;
  59543. _context3.t0 = _context3["catch"](0);
  59544. if (callback) callback(_context3.t0);
  59545. throw _context3.t0;
  59546. case 14:
  59547. case "end":
  59548. return _context3.stop();
  59549. }
  59550. }
  59551. }, _callee3, null, [[0, 10]]);
  59552. }))();
  59553. },
  59554. key: function key(n, callback) {
  59555. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  59556. var results, key;
  59557. return _regenerator["default"].wrap(function _callee4$(_context4) {
  59558. while (1) {
  59559. switch (_context4.prev = _context4.next) {
  59560. case 0:
  59561. _context4.next = 2;
  59562. return (0, _utils.usePromise)(get, null);
  59563. case 2:
  59564. results = _context4.sent;
  59565. key = Object.keys(results)[n];
  59566. if (callback) callback(key);
  59567. return _context4.abrupt("return", key);
  59568. case 6:
  59569. case "end":
  59570. return _context4.stop();
  59571. }
  59572. }
  59573. }, _callee4);
  59574. }))();
  59575. },
  59576. keys: function keys(callback) {
  59577. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  59578. var results, keys;
  59579. return _regenerator["default"].wrap(function _callee5$(_context5) {
  59580. while (1) {
  59581. switch (_context5.prev = _context5.next) {
  59582. case 0:
  59583. _context5.next = 2;
  59584. return (0, _utils.usePromise)(get, null);
  59585. case 2:
  59586. results = _context5.sent;
  59587. keys = Object.keys(results);
  59588. if (callback) callback(keys);
  59589. return _context5.abrupt("return", keys);
  59590. case 6:
  59591. case "end":
  59592. return _context5.stop();
  59593. }
  59594. }
  59595. }, _callee5);
  59596. }))();
  59597. },
  59598. length: function length(callback) {
  59599. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  59600. var results, _Object$keys, length;
  59601. return _regenerator["default"].wrap(function _callee6$(_context6) {
  59602. while (1) {
  59603. switch (_context6.prev = _context6.next) {
  59604. case 0:
  59605. _context6.next = 2;
  59606. return (0, _utils.usePromise)(get, null);
  59607. case 2:
  59608. results = _context6.sent;
  59609. _Object$keys = Object.keys(results), length = _Object$keys.length;
  59610. if (callback) callback(length);
  59611. return _context6.abrupt("return", length);
  59612. case 6:
  59613. case "end":
  59614. return _context6.stop();
  59615. }
  59616. }
  59617. }, _callee6);
  59618. }))();
  59619. },
  59620. removeItem: function removeItem(key, callback) {
  59621. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  59622. return _regenerator["default"].wrap(function _callee7$(_context7) {
  59623. while (1) {
  59624. switch (_context7.prev = _context7.next) {
  59625. case 0:
  59626. _context7.next = 2;
  59627. return (0, _utils.usePromise)(remove, key);
  59628. case 2:
  59629. if (callback) callback();
  59630. case 3:
  59631. case "end":
  59632. return _context7.stop();
  59633. }
  59634. }
  59635. }, _callee7);
  59636. }))();
  59637. },
  59638. setItem: function setItem(key, value, callback) {
  59639. return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  59640. return _regenerator["default"].wrap(function _callee8$(_context8) {
  59641. while (1) {
  59642. switch (_context8.prev = _context8.next) {
  59643. case 0:
  59644. _context8.next = 2;
  59645. return (0, _utils.usePromise)(set, (0, _defineProperty2["default"])({}, key, value));
  59646. case 2:
  59647. if (callback) callback();
  59648. case 3:
  59649. case "end":
  59650. return _context8.stop();
  59651. }
  59652. }
  59653. }, _callee8);
  59654. }))();
  59655. }
  59656. };
  59657. }
  59658. /***/ }),
  59659. /***/ 7002:
  59660. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  59661. "use strict";
  59662. var __webpack_unused_export__;
  59663. var _interopRequireDefault = __webpack_require__(5318);
  59664. __webpack_unused_export__ = ({
  59665. value: true
  59666. });
  59667. exports.Z = void 0;
  59668. var _driver = _interopRequireDefault(__webpack_require__(7715));
  59669. var _default = (0, _driver["default"])('webExtensionLocalStorage', 'local');
  59670. exports.Z = _default;
  59671. /***/ }),
  59672. /***/ 1063:
  59673. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  59674. "use strict";
  59675. var __webpack_unused_export__;
  59676. var _interopRequireDefault = __webpack_require__(5318);
  59677. __webpack_unused_export__ = ({
  59678. value: true
  59679. });
  59680. exports.Z = void 0;
  59681. var _driver = _interopRequireDefault(__webpack_require__(7715));
  59682. var _default = (0, _driver["default"])('webExtensionSyncStorage', 'sync');
  59683. exports.Z = _default;
  59684. /***/ }),
  59685. /***/ 4639:
  59686. /***/ ((__unused_webpack_module, exports) => {
  59687. "use strict";
  59688. Object.defineProperty(exports, "__esModule", ({
  59689. value: true
  59690. }));
  59691. exports.getStorage = getStorage;
  59692. exports.usePromise = usePromise;
  59693. /**
  59694. * Need to invoke a function at runtime instead of import-time to make tests
  59695. * pass with mocked browser and chrome objects
  59696. */
  59697. function getStorage() {
  59698. return typeof browser !== 'undefined' && browser.storage || typeof chrome !== 'undefined' && chrome.storage;
  59699. }
  59700. /**
  59701. * Need to invoke a function at runtime instead of import-time to make tests
  59702. * pass with mocked browser and chrome objects
  59703. */
  59704. function usesPromises() {
  59705. var storage = getStorage();
  59706. try {
  59707. return storage && storage.local.get && storage.local.get() && typeof storage.local.get().then === 'function';
  59708. } catch (e) {
  59709. return false;
  59710. }
  59711. }
  59712. /**
  59713. * Converts a callback-based API to a promise based API.
  59714. * For now we assume that there is only one arg in addition to the callback
  59715. */
  59716. function usePromise(fn, arg) {
  59717. if (usesPromises()) {
  59718. return fn(arg);
  59719. }
  59720. return new Promise(function (resolve) {
  59721. fn(arg, function () {
  59722. resolve.apply(void 0, arguments);
  59723. });
  59724. });
  59725. }
  59726. /***/ }),
  59727. /***/ 9483:
  59728. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  59729. /*!
  59730. localForage -- Offline Storage, Improved
  59731. Version 1.10.0
  59732. https://localforage.github.io/localForage
  59733. (c) 2013-2017 Mozilla, Apache License 2.0
  59734. */
  59735. (function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=undefined;if(!u&&a)return require(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw (f.code="MODULE_NOT_FOUND", f)}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=undefined;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  59736. (function (global){
  59737. 'use strict';
  59738. var Mutation = global.MutationObserver || global.WebKitMutationObserver;
  59739. var scheduleDrain;
  59740. {
  59741. if (Mutation) {
  59742. var called = 0;
  59743. var observer = new Mutation(nextTick);
  59744. var element = global.document.createTextNode('');
  59745. observer.observe(element, {
  59746. characterData: true
  59747. });
  59748. scheduleDrain = function () {
  59749. element.data = (called = ++called % 2);
  59750. };
  59751. } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
  59752. var channel = new global.MessageChannel();
  59753. channel.port1.onmessage = nextTick;
  59754. scheduleDrain = function () {
  59755. channel.port2.postMessage(0);
  59756. };
  59757. } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
  59758. scheduleDrain = function () {
  59759. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  59760. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  59761. var scriptEl = global.document.createElement('script');
  59762. scriptEl.onreadystatechange = function () {
  59763. nextTick();
  59764. scriptEl.onreadystatechange = null;
  59765. scriptEl.parentNode.removeChild(scriptEl);
  59766. scriptEl = null;
  59767. };
  59768. global.document.documentElement.appendChild(scriptEl);
  59769. };
  59770. } else {
  59771. scheduleDrain = function () {
  59772. setTimeout(nextTick, 0);
  59773. };
  59774. }
  59775. }
  59776. var draining;
  59777. var queue = [];
  59778. //named nextTick for less confusing stack traces
  59779. function nextTick() {
  59780. draining = true;
  59781. var i, oldQueue;
  59782. var len = queue.length;
  59783. while (len) {
  59784. oldQueue = queue;
  59785. queue = [];
  59786. i = -1;
  59787. while (++i < len) {
  59788. oldQueue[i]();
  59789. }
  59790. len = queue.length;
  59791. }
  59792. draining = false;
  59793. }
  59794. module.exports = immediate;
  59795. function immediate(task) {
  59796. if (queue.push(task) === 1 && !draining) {
  59797. scheduleDrain();
  59798. }
  59799. }
  59800. }).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  59801. },{}],2:[function(_dereq_,module,exports){
  59802. 'use strict';
  59803. var immediate = _dereq_(1);
  59804. /* istanbul ignore next */
  59805. function INTERNAL() {}
  59806. var handlers = {};
  59807. var REJECTED = ['REJECTED'];
  59808. var FULFILLED = ['FULFILLED'];
  59809. var PENDING = ['PENDING'];
  59810. module.exports = Promise;
  59811. function Promise(resolver) {
  59812. if (typeof resolver !== 'function') {
  59813. throw new TypeError('resolver must be a function');
  59814. }
  59815. this.state = PENDING;
  59816. this.queue = [];
  59817. this.outcome = void 0;
  59818. if (resolver !== INTERNAL) {
  59819. safelyResolveThenable(this, resolver);
  59820. }
  59821. }
  59822. Promise.prototype["catch"] = function (onRejected) {
  59823. return this.then(null, onRejected);
  59824. };
  59825. Promise.prototype.then = function (onFulfilled, onRejected) {
  59826. if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||
  59827. typeof onRejected !== 'function' && this.state === REJECTED) {
  59828. return this;
  59829. }
  59830. var promise = new this.constructor(INTERNAL);
  59831. if (this.state !== PENDING) {
  59832. var resolver = this.state === FULFILLED ? onFulfilled : onRejected;
  59833. unwrap(promise, resolver, this.outcome);
  59834. } else {
  59835. this.queue.push(new QueueItem(promise, onFulfilled, onRejected));
  59836. }
  59837. return promise;
  59838. };
  59839. function QueueItem(promise, onFulfilled, onRejected) {
  59840. this.promise = promise;
  59841. if (typeof onFulfilled === 'function') {
  59842. this.onFulfilled = onFulfilled;
  59843. this.callFulfilled = this.otherCallFulfilled;
  59844. }
  59845. if (typeof onRejected === 'function') {
  59846. this.onRejected = onRejected;
  59847. this.callRejected = this.otherCallRejected;
  59848. }
  59849. }
  59850. QueueItem.prototype.callFulfilled = function (value) {
  59851. handlers.resolve(this.promise, value);
  59852. };
  59853. QueueItem.prototype.otherCallFulfilled = function (value) {
  59854. unwrap(this.promise, this.onFulfilled, value);
  59855. };
  59856. QueueItem.prototype.callRejected = function (value) {
  59857. handlers.reject(this.promise, value);
  59858. };
  59859. QueueItem.prototype.otherCallRejected = function (value) {
  59860. unwrap(this.promise, this.onRejected, value);
  59861. };
  59862. function unwrap(promise, func, value) {
  59863. immediate(function () {
  59864. var returnValue;
  59865. try {
  59866. returnValue = func(value);
  59867. } catch (e) {
  59868. return handlers.reject(promise, e);
  59869. }
  59870. if (returnValue === promise) {
  59871. handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));
  59872. } else {
  59873. handlers.resolve(promise, returnValue);
  59874. }
  59875. });
  59876. }
  59877. handlers.resolve = function (self, value) {
  59878. var result = tryCatch(getThen, value);
  59879. if (result.status === 'error') {
  59880. return handlers.reject(self, result.value);
  59881. }
  59882. var thenable = result.value;
  59883. if (thenable) {
  59884. safelyResolveThenable(self, thenable);
  59885. } else {
  59886. self.state = FULFILLED;
  59887. self.outcome = value;
  59888. var i = -1;
  59889. var len = self.queue.length;
  59890. while (++i < len) {
  59891. self.queue[i].callFulfilled(value);
  59892. }
  59893. }
  59894. return self;
  59895. };
  59896. handlers.reject = function (self, error) {
  59897. self.state = REJECTED;
  59898. self.outcome = error;
  59899. var i = -1;
  59900. var len = self.queue.length;
  59901. while (++i < len) {
  59902. self.queue[i].callRejected(error);
  59903. }
  59904. return self;
  59905. };
  59906. function getThen(obj) {
  59907. // Make sure we only access the accessor once as required by the spec
  59908. var then = obj && obj.then;
  59909. if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {
  59910. return function appyThen() {
  59911. then.apply(obj, arguments);
  59912. };
  59913. }
  59914. }
  59915. function safelyResolveThenable(self, thenable) {
  59916. // Either fulfill, reject or reject with error
  59917. var called = false;
  59918. function onError(value) {
  59919. if (called) {
  59920. return;
  59921. }
  59922. called = true;
  59923. handlers.reject(self, value);
  59924. }
  59925. function onSuccess(value) {
  59926. if (called) {
  59927. return;
  59928. }
  59929. called = true;
  59930. handlers.resolve(self, value);
  59931. }
  59932. function tryToUnwrap() {
  59933. thenable(onSuccess, onError);
  59934. }
  59935. var result = tryCatch(tryToUnwrap);
  59936. if (result.status === 'error') {
  59937. onError(result.value);
  59938. }
  59939. }
  59940. function tryCatch(func, value) {
  59941. var out = {};
  59942. try {
  59943. out.value = func(value);
  59944. out.status = 'success';
  59945. } catch (e) {
  59946. out.status = 'error';
  59947. out.value = e;
  59948. }
  59949. return out;
  59950. }
  59951. Promise.resolve = resolve;
  59952. function resolve(value) {
  59953. if (value instanceof this) {
  59954. return value;
  59955. }
  59956. return handlers.resolve(new this(INTERNAL), value);
  59957. }
  59958. Promise.reject = reject;
  59959. function reject(reason) {
  59960. var promise = new this(INTERNAL);
  59961. return handlers.reject(promise, reason);
  59962. }
  59963. Promise.all = all;
  59964. function all(iterable) {
  59965. var self = this;
  59966. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  59967. return this.reject(new TypeError('must be an array'));
  59968. }
  59969. var len = iterable.length;
  59970. var called = false;
  59971. if (!len) {
  59972. return this.resolve([]);
  59973. }
  59974. var values = new Array(len);
  59975. var resolved = 0;
  59976. var i = -1;
  59977. var promise = new this(INTERNAL);
  59978. while (++i < len) {
  59979. allResolver(iterable[i], i);
  59980. }
  59981. return promise;
  59982. function allResolver(value, i) {
  59983. self.resolve(value).then(resolveFromAll, function (error) {
  59984. if (!called) {
  59985. called = true;
  59986. handlers.reject(promise, error);
  59987. }
  59988. });
  59989. function resolveFromAll(outValue) {
  59990. values[i] = outValue;
  59991. if (++resolved === len && !called) {
  59992. called = true;
  59993. handlers.resolve(promise, values);
  59994. }
  59995. }
  59996. }
  59997. }
  59998. Promise.race = race;
  59999. function race(iterable) {
  60000. var self = this;
  60001. if (Object.prototype.toString.call(iterable) !== '[object Array]') {
  60002. return this.reject(new TypeError('must be an array'));
  60003. }
  60004. var len = iterable.length;
  60005. var called = false;
  60006. if (!len) {
  60007. return this.resolve([]);
  60008. }
  60009. var i = -1;
  60010. var promise = new this(INTERNAL);
  60011. while (++i < len) {
  60012. resolver(iterable[i]);
  60013. }
  60014. return promise;
  60015. function resolver(value) {
  60016. self.resolve(value).then(function (response) {
  60017. if (!called) {
  60018. called = true;
  60019. handlers.resolve(promise, response);
  60020. }
  60021. }, function (error) {
  60022. if (!called) {
  60023. called = true;
  60024. handlers.reject(promise, error);
  60025. }
  60026. });
  60027. }
  60028. }
  60029. },{"1":1}],3:[function(_dereq_,module,exports){
  60030. (function (global){
  60031. 'use strict';
  60032. if (typeof global.Promise !== 'function') {
  60033. global.Promise = _dereq_(2);
  60034. }
  60035. }).call(this,typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  60036. },{"2":2}],4:[function(_dereq_,module,exports){
  60037. 'use strict';
  60038. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  60039. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  60040. function getIDB() {
  60041. /* global indexedDB,webkitIndexedDB,mozIndexedDB,OIndexedDB,msIndexedDB */
  60042. try {
  60043. if (typeof indexedDB !== 'undefined') {
  60044. return indexedDB;
  60045. }
  60046. if (typeof webkitIndexedDB !== 'undefined') {
  60047. return webkitIndexedDB;
  60048. }
  60049. if (typeof mozIndexedDB !== 'undefined') {
  60050. return mozIndexedDB;
  60051. }
  60052. if (typeof OIndexedDB !== 'undefined') {
  60053. return OIndexedDB;
  60054. }
  60055. if (typeof msIndexedDB !== 'undefined') {
  60056. return msIndexedDB;
  60057. }
  60058. } catch (e) {
  60059. return;
  60060. }
  60061. }
  60062. var idb = getIDB();
  60063. function isIndexedDBValid() {
  60064. try {
  60065. // Initialize IndexedDB; fall back to vendor-prefixed versions
  60066. // if needed.
  60067. if (!idb || !idb.open) {
  60068. return false;
  60069. }
  60070. // We mimic PouchDB here;
  60071. //
  60072. // We test for openDatabase because IE Mobile identifies itself
  60073. // as Safari. Oh the lulz...
  60074. var isSafari = typeof openDatabase !== 'undefined' && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform);
  60075. var hasFetch = typeof fetch === 'function' && fetch.toString().indexOf('[native code') !== -1;
  60076. // Safari <10.1 does not meet our requirements for IDB support
  60077. // (see: https://github.com/pouchdb/pouchdb/issues/5572).
  60078. // Safari 10.1 shipped with fetch, we can use that to detect it.
  60079. // Note: this creates issues with `window.fetch` polyfills and
  60080. // overrides; see:
  60081. // https://github.com/localForage/localForage/issues/856
  60082. return (!isSafari || hasFetch) && typeof indexedDB !== 'undefined' &&
  60083. // some outdated implementations of IDB that appear on Samsung
  60084. // and HTC Android devices <4.4 are missing IDBKeyRange
  60085. // See: https://github.com/mozilla/localForage/issues/128
  60086. // See: https://github.com/mozilla/localForage/issues/272
  60087. typeof IDBKeyRange !== 'undefined';
  60088. } catch (e) {
  60089. return false;
  60090. }
  60091. }
  60092. // Abstracts constructing a Blob object, so it also works in older
  60093. // browsers that don't support the native Blob constructor. (i.e.
  60094. // old QtWebKit versions, at least).
  60095. // Abstracts constructing a Blob object, so it also works in older
  60096. // browsers that don't support the native Blob constructor. (i.e.
  60097. // old QtWebKit versions, at least).
  60098. function createBlob(parts, properties) {
  60099. /* global BlobBuilder,MSBlobBuilder,MozBlobBuilder,WebKitBlobBuilder */
  60100. parts = parts || [];
  60101. properties = properties || {};
  60102. try {
  60103. return new Blob(parts, properties);
  60104. } catch (e) {
  60105. if (e.name !== 'TypeError') {
  60106. throw e;
  60107. }
  60108. var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;
  60109. var builder = new Builder();
  60110. for (var i = 0; i < parts.length; i += 1) {
  60111. builder.append(parts[i]);
  60112. }
  60113. return builder.getBlob(properties.type);
  60114. }
  60115. }
  60116. // This is CommonJS because lie is an external dependency, so Rollup
  60117. // can just ignore it.
  60118. if (typeof Promise === 'undefined') {
  60119. // In the "nopromises" build this will just throw if you don't have
  60120. // a global promise object, but it would throw anyway later.
  60121. _dereq_(3);
  60122. }
  60123. var Promise$1 = Promise;
  60124. function executeCallback(promise, callback) {
  60125. if (callback) {
  60126. promise.then(function (result) {
  60127. callback(null, result);
  60128. }, function (error) {
  60129. callback(error);
  60130. });
  60131. }
  60132. }
  60133. function executeTwoCallbacks(promise, callback, errorCallback) {
  60134. if (typeof callback === 'function') {
  60135. promise.then(callback);
  60136. }
  60137. if (typeof errorCallback === 'function') {
  60138. promise["catch"](errorCallback);
  60139. }
  60140. }
  60141. function normalizeKey(key) {
  60142. // Cast the key to a string, as that's all we can set as a key.
  60143. if (typeof key !== 'string') {
  60144. console.warn(key + ' used as a key, but it is not a string.');
  60145. key = String(key);
  60146. }
  60147. return key;
  60148. }
  60149. function getCallback() {
  60150. if (arguments.length && typeof arguments[arguments.length - 1] === 'function') {
  60151. return arguments[arguments.length - 1];
  60152. }
  60153. }
  60154. // Some code originally from async_storage.js in
  60155. // [Gaia](https://github.com/mozilla-b2g/gaia).
  60156. var DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';
  60157. var supportsBlobs = void 0;
  60158. var dbContexts = {};
  60159. var toString = Object.prototype.toString;
  60160. // Transaction Modes
  60161. var READ_ONLY = 'readonly';
  60162. var READ_WRITE = 'readwrite';
  60163. // Transform a binary string to an array buffer, because otherwise
  60164. // weird stuff happens when you try to work with the binary string directly.
  60165. // It is known.
  60166. // From http://stackoverflow.com/questions/14967647/ (continues on next line)
  60167. // encode-decode-image-with-base64-breaks-image (2013-04-21)
  60168. function _binStringToArrayBuffer(bin) {
  60169. var length = bin.length;
  60170. var buf = new ArrayBuffer(length);
  60171. var arr = new Uint8Array(buf);
  60172. for (var i = 0; i < length; i++) {
  60173. arr[i] = bin.charCodeAt(i);
  60174. }
  60175. return buf;
  60176. }
  60177. //
  60178. // Blobs are not supported in all versions of IndexedDB, notably
  60179. // Chrome <37 and Android <5. In those versions, storing a blob will throw.
  60180. //
  60181. // Various other blob bugs exist in Chrome v37-42 (inclusive).
  60182. // Detecting them is expensive and confusing to users, and Chrome 37-42
  60183. // is at very low usage worldwide, so we do a hacky userAgent check instead.
  60184. //
  60185. // content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120
  60186. // 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916
  60187. // FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836
  60188. //
  60189. // Code borrowed from PouchDB. See:
  60190. // https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js
  60191. //
  60192. function _checkBlobSupportWithoutCaching(idb) {
  60193. return new Promise$1(function (resolve) {
  60194. var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
  60195. var blob = createBlob(['']);
  60196. txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');
  60197. txn.onabort = function (e) {
  60198. // If the transaction aborts now its due to not being able to
  60199. // write to the database, likely due to the disk being full
  60200. e.preventDefault();
  60201. e.stopPropagation();
  60202. resolve(false);
  60203. };
  60204. txn.oncomplete = function () {
  60205. var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
  60206. var matchedEdge = navigator.userAgent.match(/Edge\//);
  60207. // MS Edge pretends to be Chrome 42:
  60208. // https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
  60209. resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
  60210. };
  60211. })["catch"](function () {
  60212. return false; // error, so assume unsupported
  60213. });
  60214. }
  60215. function _checkBlobSupport(idb) {
  60216. if (typeof supportsBlobs === 'boolean') {
  60217. return Promise$1.resolve(supportsBlobs);
  60218. }
  60219. return _checkBlobSupportWithoutCaching(idb).then(function (value) {
  60220. supportsBlobs = value;
  60221. return supportsBlobs;
  60222. });
  60223. }
  60224. function _deferReadiness(dbInfo) {
  60225. var dbContext = dbContexts[dbInfo.name];
  60226. // Create a deferred object representing the current database operation.
  60227. var deferredOperation = {};
  60228. deferredOperation.promise = new Promise$1(function (resolve, reject) {
  60229. deferredOperation.resolve = resolve;
  60230. deferredOperation.reject = reject;
  60231. });
  60232. // Enqueue the deferred operation.
  60233. dbContext.deferredOperations.push(deferredOperation);
  60234. // Chain its promise to the database readiness.
  60235. if (!dbContext.dbReady) {
  60236. dbContext.dbReady = deferredOperation.promise;
  60237. } else {
  60238. dbContext.dbReady = dbContext.dbReady.then(function () {
  60239. return deferredOperation.promise;
  60240. });
  60241. }
  60242. }
  60243. function _advanceReadiness(dbInfo) {
  60244. var dbContext = dbContexts[dbInfo.name];
  60245. // Dequeue a deferred operation.
  60246. var deferredOperation = dbContext.deferredOperations.pop();
  60247. // Resolve its promise (which is part of the database readiness
  60248. // chain of promises).
  60249. if (deferredOperation) {
  60250. deferredOperation.resolve();
  60251. return deferredOperation.promise;
  60252. }
  60253. }
  60254. function _rejectReadiness(dbInfo, err) {
  60255. var dbContext = dbContexts[dbInfo.name];
  60256. // Dequeue a deferred operation.
  60257. var deferredOperation = dbContext.deferredOperations.pop();
  60258. // Reject its promise (which is part of the database readiness
  60259. // chain of promises).
  60260. if (deferredOperation) {
  60261. deferredOperation.reject(err);
  60262. return deferredOperation.promise;
  60263. }
  60264. }
  60265. function _getConnection(dbInfo, upgradeNeeded) {
  60266. return new Promise$1(function (resolve, reject) {
  60267. dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
  60268. if (dbInfo.db) {
  60269. if (upgradeNeeded) {
  60270. _deferReadiness(dbInfo);
  60271. dbInfo.db.close();
  60272. } else {
  60273. return resolve(dbInfo.db);
  60274. }
  60275. }
  60276. var dbArgs = [dbInfo.name];
  60277. if (upgradeNeeded) {
  60278. dbArgs.push(dbInfo.version);
  60279. }
  60280. var openreq = idb.open.apply(idb, dbArgs);
  60281. if (upgradeNeeded) {
  60282. openreq.onupgradeneeded = function (e) {
  60283. var db = openreq.result;
  60284. try {
  60285. db.createObjectStore(dbInfo.storeName);
  60286. if (e.oldVersion <= 1) {
  60287. // Added when support for blob shims was added
  60288. db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);
  60289. }
  60290. } catch (ex) {
  60291. if (ex.name === 'ConstraintError') {
  60292. console.warn('The database "' + dbInfo.name + '"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage "' + dbInfo.storeName + '" already exists.');
  60293. } else {
  60294. throw ex;
  60295. }
  60296. }
  60297. };
  60298. }
  60299. openreq.onerror = function (e) {
  60300. e.preventDefault();
  60301. reject(openreq.error);
  60302. };
  60303. openreq.onsuccess = function () {
  60304. var db = openreq.result;
  60305. db.onversionchange = function (e) {
  60306. // Triggered when the database is modified (e.g. adding an objectStore) or
  60307. // deleted (even when initiated by other sessions in different tabs).
  60308. // Closing the connection here prevents those operations from being blocked.
  60309. // If the database is accessed again later by this instance, the connection
  60310. // will be reopened or the database recreated as needed.
  60311. e.target.close();
  60312. };
  60313. resolve(db);
  60314. _advanceReadiness(dbInfo);
  60315. };
  60316. });
  60317. }
  60318. function _getOriginalConnection(dbInfo) {
  60319. return _getConnection(dbInfo, false);
  60320. }
  60321. function _getUpgradedConnection(dbInfo) {
  60322. return _getConnection(dbInfo, true);
  60323. }
  60324. function _isUpgradeNeeded(dbInfo, defaultVersion) {
  60325. if (!dbInfo.db) {
  60326. return true;
  60327. }
  60328. var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);
  60329. var isDowngrade = dbInfo.version < dbInfo.db.version;
  60330. var isUpgrade = dbInfo.version > dbInfo.db.version;
  60331. if (isDowngrade) {
  60332. // If the version is not the default one
  60333. // then warn for impossible downgrade.
  60334. if (dbInfo.version !== defaultVersion) {
  60335. console.warn('The database "' + dbInfo.name + '"' + " can't be downgraded from version " + dbInfo.db.version + ' to version ' + dbInfo.version + '.');
  60336. }
  60337. // Align the versions to prevent errors.
  60338. dbInfo.version = dbInfo.db.version;
  60339. }
  60340. if (isUpgrade || isNewStore) {
  60341. // If the store is new then increment the version (if needed).
  60342. // This will trigger an "upgradeneeded" event which is required
  60343. // for creating a store.
  60344. if (isNewStore) {
  60345. var incVersion = dbInfo.db.version + 1;
  60346. if (incVersion > dbInfo.version) {
  60347. dbInfo.version = incVersion;
  60348. }
  60349. }
  60350. return true;
  60351. }
  60352. return false;
  60353. }
  60354. // encode a blob for indexeddb engines that don't support blobs
  60355. function _encodeBlob(blob) {
  60356. return new Promise$1(function (resolve, reject) {
  60357. var reader = new FileReader();
  60358. reader.onerror = reject;
  60359. reader.onloadend = function (e) {
  60360. var base64 = btoa(e.target.result || '');
  60361. resolve({
  60362. __local_forage_encoded_blob: true,
  60363. data: base64,
  60364. type: blob.type
  60365. });
  60366. };
  60367. reader.readAsBinaryString(blob);
  60368. });
  60369. }
  60370. // decode an encoded blob
  60371. function _decodeBlob(encodedBlob) {
  60372. var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
  60373. return createBlob([arrayBuff], { type: encodedBlob.type });
  60374. }
  60375. // is this one of our fancy encoded blobs?
  60376. function _isEncodedBlob(value) {
  60377. return value && value.__local_forage_encoded_blob;
  60378. }
  60379. // Specialize the default `ready()` function by making it dependent
  60380. // on the current database operations. Thus, the driver will be actually
  60381. // ready when it's been initialized (default) *and* there are no pending
  60382. // operations on the database (initiated by some other instances).
  60383. function _fullyReady(callback) {
  60384. var self = this;
  60385. var promise = self._initReady().then(function () {
  60386. var dbContext = dbContexts[self._dbInfo.name];
  60387. if (dbContext && dbContext.dbReady) {
  60388. return dbContext.dbReady;
  60389. }
  60390. });
  60391. executeTwoCallbacks(promise, callback, callback);
  60392. return promise;
  60393. }
  60394. // Try to establish a new db connection to replace the
  60395. // current one which is broken (i.e. experiencing
  60396. // InvalidStateError while creating a transaction).
  60397. function _tryReconnect(dbInfo) {
  60398. _deferReadiness(dbInfo);
  60399. var dbContext = dbContexts[dbInfo.name];
  60400. var forages = dbContext.forages;
  60401. for (var i = 0; i < forages.length; i++) {
  60402. var forage = forages[i];
  60403. if (forage._dbInfo.db) {
  60404. forage._dbInfo.db.close();
  60405. forage._dbInfo.db = null;
  60406. }
  60407. }
  60408. dbInfo.db = null;
  60409. return _getOriginalConnection(dbInfo).then(function (db) {
  60410. dbInfo.db = db;
  60411. if (_isUpgradeNeeded(dbInfo)) {
  60412. // Reopen the database for upgrading.
  60413. return _getUpgradedConnection(dbInfo);
  60414. }
  60415. return db;
  60416. }).then(function (db) {
  60417. // store the latest db reference
  60418. // in case the db was upgraded
  60419. dbInfo.db = dbContext.db = db;
  60420. for (var i = 0; i < forages.length; i++) {
  60421. forages[i]._dbInfo.db = db;
  60422. }
  60423. })["catch"](function (err) {
  60424. _rejectReadiness(dbInfo, err);
  60425. throw err;
  60426. });
  60427. }
  60428. // FF doesn't like Promises (micro-tasks) and IDDB store operations,
  60429. // so we have to do it with callbacks
  60430. function createTransaction(dbInfo, mode, callback, retries) {
  60431. if (retries === undefined) {
  60432. retries = 1;
  60433. }
  60434. try {
  60435. var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
  60436. callback(null, tx);
  60437. } catch (err) {
  60438. if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
  60439. return Promise$1.resolve().then(function () {
  60440. if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
  60441. // increase the db version, to create the new ObjectStore
  60442. if (dbInfo.db) {
  60443. dbInfo.version = dbInfo.db.version + 1;
  60444. }
  60445. // Reopen the database for upgrading.
  60446. return _getUpgradedConnection(dbInfo);
  60447. }
  60448. }).then(function () {
  60449. return _tryReconnect(dbInfo).then(function () {
  60450. createTransaction(dbInfo, mode, callback, retries - 1);
  60451. });
  60452. })["catch"](callback);
  60453. }
  60454. callback(err);
  60455. }
  60456. }
  60457. function createDbContext() {
  60458. return {
  60459. // Running localForages sharing a database.
  60460. forages: [],
  60461. // Shared database.
  60462. db: null,
  60463. // Database readiness (promise).
  60464. dbReady: null,
  60465. // Deferred operations on the database.
  60466. deferredOperations: []
  60467. };
  60468. }
  60469. // Open the IndexedDB database (automatically creates one if one didn't
  60470. // previously exist), using any options set in the config.
  60471. function _initStorage(options) {
  60472. var self = this;
  60473. var dbInfo = {
  60474. db: null
  60475. };
  60476. if (options) {
  60477. for (var i in options) {
  60478. dbInfo[i] = options[i];
  60479. }
  60480. }
  60481. // Get the current context of the database;
  60482. var dbContext = dbContexts[dbInfo.name];
  60483. // ...or create a new context.
  60484. if (!dbContext) {
  60485. dbContext = createDbContext();
  60486. // Register the new context in the global container.
  60487. dbContexts[dbInfo.name] = dbContext;
  60488. }
  60489. // Register itself as a running localForage in the current context.
  60490. dbContext.forages.push(self);
  60491. // Replace the default `ready()` function with the specialized one.
  60492. if (!self._initReady) {
  60493. self._initReady = self.ready;
  60494. self.ready = _fullyReady;
  60495. }
  60496. // Create an array of initialization states of the related localForages.
  60497. var initPromises = [];
  60498. function ignoreErrors() {
  60499. // Don't handle errors here,
  60500. // just makes sure related localForages aren't pending.
  60501. return Promise$1.resolve();
  60502. }
  60503. for (var j = 0; j < dbContext.forages.length; j++) {
  60504. var forage = dbContext.forages[j];
  60505. if (forage !== self) {
  60506. // Don't wait for itself...
  60507. initPromises.push(forage._initReady()["catch"](ignoreErrors));
  60508. }
  60509. }
  60510. // Take a snapshot of the related localForages.
  60511. var forages = dbContext.forages.slice(0);
  60512. // Initialize the connection process only when
  60513. // all the related localForages aren't pending.
  60514. return Promise$1.all(initPromises).then(function () {
  60515. dbInfo.db = dbContext.db;
  60516. // Get the connection or open a new one without upgrade.
  60517. return _getOriginalConnection(dbInfo);
  60518. }).then(function (db) {
  60519. dbInfo.db = db;
  60520. if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {
  60521. // Reopen the database for upgrading.
  60522. return _getUpgradedConnection(dbInfo);
  60523. }
  60524. return db;
  60525. }).then(function (db) {
  60526. dbInfo.db = dbContext.db = db;
  60527. self._dbInfo = dbInfo;
  60528. // Share the final connection amongst related localForages.
  60529. for (var k = 0; k < forages.length; k++) {
  60530. var forage = forages[k];
  60531. if (forage !== self) {
  60532. // Self is already up-to-date.
  60533. forage._dbInfo.db = dbInfo.db;
  60534. forage._dbInfo.version = dbInfo.version;
  60535. }
  60536. }
  60537. });
  60538. }
  60539. function getItem(key, callback) {
  60540. var self = this;
  60541. key = normalizeKey(key);
  60542. var promise = new Promise$1(function (resolve, reject) {
  60543. self.ready().then(function () {
  60544. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  60545. if (err) {
  60546. return reject(err);
  60547. }
  60548. try {
  60549. var store = transaction.objectStore(self._dbInfo.storeName);
  60550. var req = store.get(key);
  60551. req.onsuccess = function () {
  60552. var value = req.result;
  60553. if (value === undefined) {
  60554. value = null;
  60555. }
  60556. if (_isEncodedBlob(value)) {
  60557. value = _decodeBlob(value);
  60558. }
  60559. resolve(value);
  60560. };
  60561. req.onerror = function () {
  60562. reject(req.error);
  60563. };
  60564. } catch (e) {
  60565. reject(e);
  60566. }
  60567. });
  60568. })["catch"](reject);
  60569. });
  60570. executeCallback(promise, callback);
  60571. return promise;
  60572. }
  60573. // Iterate over all items stored in database.
  60574. function iterate(iterator, callback) {
  60575. var self = this;
  60576. var promise = new Promise$1(function (resolve, reject) {
  60577. self.ready().then(function () {
  60578. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  60579. if (err) {
  60580. return reject(err);
  60581. }
  60582. try {
  60583. var store = transaction.objectStore(self._dbInfo.storeName);
  60584. var req = store.openCursor();
  60585. var iterationNumber = 1;
  60586. req.onsuccess = function () {
  60587. var cursor = req.result;
  60588. if (cursor) {
  60589. var value = cursor.value;
  60590. if (_isEncodedBlob(value)) {
  60591. value = _decodeBlob(value);
  60592. }
  60593. var result = iterator(value, cursor.key, iterationNumber++);
  60594. // when the iterator callback returns any
  60595. // (non-`undefined`) value, then we stop
  60596. // the iteration immediately
  60597. if (result !== void 0) {
  60598. resolve(result);
  60599. } else {
  60600. cursor["continue"]();
  60601. }
  60602. } else {
  60603. resolve();
  60604. }
  60605. };
  60606. req.onerror = function () {
  60607. reject(req.error);
  60608. };
  60609. } catch (e) {
  60610. reject(e);
  60611. }
  60612. });
  60613. })["catch"](reject);
  60614. });
  60615. executeCallback(promise, callback);
  60616. return promise;
  60617. }
  60618. function setItem(key, value, callback) {
  60619. var self = this;
  60620. key = normalizeKey(key);
  60621. var promise = new Promise$1(function (resolve, reject) {
  60622. var dbInfo;
  60623. self.ready().then(function () {
  60624. dbInfo = self._dbInfo;
  60625. if (toString.call(value) === '[object Blob]') {
  60626. return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {
  60627. if (blobSupport) {
  60628. return value;
  60629. }
  60630. return _encodeBlob(value);
  60631. });
  60632. }
  60633. return value;
  60634. }).then(function (value) {
  60635. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  60636. if (err) {
  60637. return reject(err);
  60638. }
  60639. try {
  60640. var store = transaction.objectStore(self._dbInfo.storeName);
  60641. // The reason we don't _save_ null is because IE 10 does
  60642. // not support saving the `null` type in IndexedDB. How
  60643. // ironic, given the bug below!
  60644. // See: https://github.com/mozilla/localForage/issues/161
  60645. if (value === null) {
  60646. value = undefined;
  60647. }
  60648. var req = store.put(value, key);
  60649. transaction.oncomplete = function () {
  60650. // Cast to undefined so the value passed to
  60651. // callback/promise is the same as what one would get out
  60652. // of `getItem()` later. This leads to some weirdness
  60653. // (setItem('foo', undefined) will return `null`), but
  60654. // it's not my fault localStorage is our baseline and that
  60655. // it's weird.
  60656. if (value === undefined) {
  60657. value = null;
  60658. }
  60659. resolve(value);
  60660. };
  60661. transaction.onabort = transaction.onerror = function () {
  60662. var err = req.error ? req.error : req.transaction.error;
  60663. reject(err);
  60664. };
  60665. } catch (e) {
  60666. reject(e);
  60667. }
  60668. });
  60669. })["catch"](reject);
  60670. });
  60671. executeCallback(promise, callback);
  60672. return promise;
  60673. }
  60674. function removeItem(key, callback) {
  60675. var self = this;
  60676. key = normalizeKey(key);
  60677. var promise = new Promise$1(function (resolve, reject) {
  60678. self.ready().then(function () {
  60679. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  60680. if (err) {
  60681. return reject(err);
  60682. }
  60683. try {
  60684. var store = transaction.objectStore(self._dbInfo.storeName);
  60685. // We use a Grunt task to make this safe for IE and some
  60686. // versions of Android (including those used by Cordova).
  60687. // Normally IE won't like `.delete()` and will insist on
  60688. // using `['delete']()`, but we have a build step that
  60689. // fixes this for us now.
  60690. var req = store["delete"](key);
  60691. transaction.oncomplete = function () {
  60692. resolve();
  60693. };
  60694. transaction.onerror = function () {
  60695. reject(req.error);
  60696. };
  60697. // The request will be also be aborted if we've exceeded our storage
  60698. // space.
  60699. transaction.onabort = function () {
  60700. var err = req.error ? req.error : req.transaction.error;
  60701. reject(err);
  60702. };
  60703. } catch (e) {
  60704. reject(e);
  60705. }
  60706. });
  60707. })["catch"](reject);
  60708. });
  60709. executeCallback(promise, callback);
  60710. return promise;
  60711. }
  60712. function clear(callback) {
  60713. var self = this;
  60714. var promise = new Promise$1(function (resolve, reject) {
  60715. self.ready().then(function () {
  60716. createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
  60717. if (err) {
  60718. return reject(err);
  60719. }
  60720. try {
  60721. var store = transaction.objectStore(self._dbInfo.storeName);
  60722. var req = store.clear();
  60723. transaction.oncomplete = function () {
  60724. resolve();
  60725. };
  60726. transaction.onabort = transaction.onerror = function () {
  60727. var err = req.error ? req.error : req.transaction.error;
  60728. reject(err);
  60729. };
  60730. } catch (e) {
  60731. reject(e);
  60732. }
  60733. });
  60734. })["catch"](reject);
  60735. });
  60736. executeCallback(promise, callback);
  60737. return promise;
  60738. }
  60739. function length(callback) {
  60740. var self = this;
  60741. var promise = new Promise$1(function (resolve, reject) {
  60742. self.ready().then(function () {
  60743. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  60744. if (err) {
  60745. return reject(err);
  60746. }
  60747. try {
  60748. var store = transaction.objectStore(self._dbInfo.storeName);
  60749. var req = store.count();
  60750. req.onsuccess = function () {
  60751. resolve(req.result);
  60752. };
  60753. req.onerror = function () {
  60754. reject(req.error);
  60755. };
  60756. } catch (e) {
  60757. reject(e);
  60758. }
  60759. });
  60760. })["catch"](reject);
  60761. });
  60762. executeCallback(promise, callback);
  60763. return promise;
  60764. }
  60765. function key(n, callback) {
  60766. var self = this;
  60767. var promise = new Promise$1(function (resolve, reject) {
  60768. if (n < 0) {
  60769. resolve(null);
  60770. return;
  60771. }
  60772. self.ready().then(function () {
  60773. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  60774. if (err) {
  60775. return reject(err);
  60776. }
  60777. try {
  60778. var store = transaction.objectStore(self._dbInfo.storeName);
  60779. var advanced = false;
  60780. var req = store.openKeyCursor();
  60781. req.onsuccess = function () {
  60782. var cursor = req.result;
  60783. if (!cursor) {
  60784. // this means there weren't enough keys
  60785. resolve(null);
  60786. return;
  60787. }
  60788. if (n === 0) {
  60789. // We have the first key, return it if that's what they
  60790. // wanted.
  60791. resolve(cursor.key);
  60792. } else {
  60793. if (!advanced) {
  60794. // Otherwise, ask the cursor to skip ahead n
  60795. // records.
  60796. advanced = true;
  60797. cursor.advance(n);
  60798. } else {
  60799. // When we get here, we've got the nth key.
  60800. resolve(cursor.key);
  60801. }
  60802. }
  60803. };
  60804. req.onerror = function () {
  60805. reject(req.error);
  60806. };
  60807. } catch (e) {
  60808. reject(e);
  60809. }
  60810. });
  60811. })["catch"](reject);
  60812. });
  60813. executeCallback(promise, callback);
  60814. return promise;
  60815. }
  60816. function keys(callback) {
  60817. var self = this;
  60818. var promise = new Promise$1(function (resolve, reject) {
  60819. self.ready().then(function () {
  60820. createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
  60821. if (err) {
  60822. return reject(err);
  60823. }
  60824. try {
  60825. var store = transaction.objectStore(self._dbInfo.storeName);
  60826. var req = store.openKeyCursor();
  60827. var keys = [];
  60828. req.onsuccess = function () {
  60829. var cursor = req.result;
  60830. if (!cursor) {
  60831. resolve(keys);
  60832. return;
  60833. }
  60834. keys.push(cursor.key);
  60835. cursor["continue"]();
  60836. };
  60837. req.onerror = function () {
  60838. reject(req.error);
  60839. };
  60840. } catch (e) {
  60841. reject(e);
  60842. }
  60843. });
  60844. })["catch"](reject);
  60845. });
  60846. executeCallback(promise, callback);
  60847. return promise;
  60848. }
  60849. function dropInstance(options, callback) {
  60850. callback = getCallback.apply(this, arguments);
  60851. var currentConfig = this.config();
  60852. options = typeof options !== 'function' && options || {};
  60853. if (!options.name) {
  60854. options.name = options.name || currentConfig.name;
  60855. options.storeName = options.storeName || currentConfig.storeName;
  60856. }
  60857. var self = this;
  60858. var promise;
  60859. if (!options.name) {
  60860. promise = Promise$1.reject('Invalid arguments');
  60861. } else {
  60862. var isCurrentDb = options.name === currentConfig.name && self._dbInfo.db;
  60863. var dbPromise = isCurrentDb ? Promise$1.resolve(self._dbInfo.db) : _getOriginalConnection(options).then(function (db) {
  60864. var dbContext = dbContexts[options.name];
  60865. var forages = dbContext.forages;
  60866. dbContext.db = db;
  60867. for (var i = 0; i < forages.length; i++) {
  60868. forages[i]._dbInfo.db = db;
  60869. }
  60870. return db;
  60871. });
  60872. if (!options.storeName) {
  60873. promise = dbPromise.then(function (db) {
  60874. _deferReadiness(options);
  60875. var dbContext = dbContexts[options.name];
  60876. var forages = dbContext.forages;
  60877. db.close();
  60878. for (var i = 0; i < forages.length; i++) {
  60879. var forage = forages[i];
  60880. forage._dbInfo.db = null;
  60881. }
  60882. var dropDBPromise = new Promise$1(function (resolve, reject) {
  60883. var req = idb.deleteDatabase(options.name);
  60884. req.onerror = function () {
  60885. var db = req.result;
  60886. if (db) {
  60887. db.close();
  60888. }
  60889. reject(req.error);
  60890. };
  60891. req.onblocked = function () {
  60892. // Closing all open connections in onversionchange handler should prevent this situation, but if
  60893. // we do get here, it just means the request remains pending - eventually it will succeed or error
  60894. console.warn('dropInstance blocked for database "' + options.name + '" until all open connections are closed');
  60895. };
  60896. req.onsuccess = function () {
  60897. var db = req.result;
  60898. if (db) {
  60899. db.close();
  60900. }
  60901. resolve(db);
  60902. };
  60903. });
  60904. return dropDBPromise.then(function (db) {
  60905. dbContext.db = db;
  60906. for (var i = 0; i < forages.length; i++) {
  60907. var _forage = forages[i];
  60908. _advanceReadiness(_forage._dbInfo);
  60909. }
  60910. })["catch"](function (err) {
  60911. (_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function () {});
  60912. throw err;
  60913. });
  60914. });
  60915. } else {
  60916. promise = dbPromise.then(function (db) {
  60917. if (!db.objectStoreNames.contains(options.storeName)) {
  60918. return;
  60919. }
  60920. var newVersion = db.version + 1;
  60921. _deferReadiness(options);
  60922. var dbContext = dbContexts[options.name];
  60923. var forages = dbContext.forages;
  60924. db.close();
  60925. for (var i = 0; i < forages.length; i++) {
  60926. var forage = forages[i];
  60927. forage._dbInfo.db = null;
  60928. forage._dbInfo.version = newVersion;
  60929. }
  60930. var dropObjectPromise = new Promise$1(function (resolve, reject) {
  60931. var req = idb.open(options.name, newVersion);
  60932. req.onerror = function (err) {
  60933. var db = req.result;
  60934. db.close();
  60935. reject(err);
  60936. };
  60937. req.onupgradeneeded = function () {
  60938. var db = req.result;
  60939. db.deleteObjectStore(options.storeName);
  60940. };
  60941. req.onsuccess = function () {
  60942. var db = req.result;
  60943. db.close();
  60944. resolve(db);
  60945. };
  60946. });
  60947. return dropObjectPromise.then(function (db) {
  60948. dbContext.db = db;
  60949. for (var j = 0; j < forages.length; j++) {
  60950. var _forage2 = forages[j];
  60951. _forage2._dbInfo.db = db;
  60952. _advanceReadiness(_forage2._dbInfo);
  60953. }
  60954. })["catch"](function (err) {
  60955. (_rejectReadiness(options, err) || Promise$1.resolve())["catch"](function () {});
  60956. throw err;
  60957. });
  60958. });
  60959. }
  60960. }
  60961. executeCallback(promise, callback);
  60962. return promise;
  60963. }
  60964. var asyncStorage = {
  60965. _driver: 'asyncStorage',
  60966. _initStorage: _initStorage,
  60967. _support: isIndexedDBValid(),
  60968. iterate: iterate,
  60969. getItem: getItem,
  60970. setItem: setItem,
  60971. removeItem: removeItem,
  60972. clear: clear,
  60973. length: length,
  60974. key: key,
  60975. keys: keys,
  60976. dropInstance: dropInstance
  60977. };
  60978. function isWebSQLValid() {
  60979. return typeof openDatabase === 'function';
  60980. }
  60981. // Sadly, the best way to save binary data in WebSQL/localStorage is serializing
  60982. // it to Base64, so this is how we store it to prevent very strange errors with less
  60983. // verbose ways of binary <-> string data storage.
  60984. var BASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  60985. var BLOB_TYPE_PREFIX = '~~local_forage_type~';
  60986. var BLOB_TYPE_PREFIX_REGEX = /^~~local_forage_type~([^~]+)~/;
  60987. var SERIALIZED_MARKER = '__lfsc__:';
  60988. var SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER.length;
  60989. // OMG the serializations!
  60990. var TYPE_ARRAYBUFFER = 'arbf';
  60991. var TYPE_BLOB = 'blob';
  60992. var TYPE_INT8ARRAY = 'si08';
  60993. var TYPE_UINT8ARRAY = 'ui08';
  60994. var TYPE_UINT8CLAMPEDARRAY = 'uic8';
  60995. var TYPE_INT16ARRAY = 'si16';
  60996. var TYPE_INT32ARRAY = 'si32';
  60997. var TYPE_UINT16ARRAY = 'ur16';
  60998. var TYPE_UINT32ARRAY = 'ui32';
  60999. var TYPE_FLOAT32ARRAY = 'fl32';
  61000. var TYPE_FLOAT64ARRAY = 'fl64';
  61001. var TYPE_SERIALIZED_MARKER_LENGTH = SERIALIZED_MARKER_LENGTH + TYPE_ARRAYBUFFER.length;
  61002. var toString$1 = Object.prototype.toString;
  61003. function stringToBuffer(serializedString) {
  61004. // Fill the string into a ArrayBuffer.
  61005. var bufferLength = serializedString.length * 0.75;
  61006. var len = serializedString.length;
  61007. var i;
  61008. var p = 0;
  61009. var encoded1, encoded2, encoded3, encoded4;
  61010. if (serializedString[serializedString.length - 1] === '=') {
  61011. bufferLength--;
  61012. if (serializedString[serializedString.length - 2] === '=') {
  61013. bufferLength--;
  61014. }
  61015. }
  61016. var buffer = new ArrayBuffer(bufferLength);
  61017. var bytes = new Uint8Array(buffer);
  61018. for (i = 0; i < len; i += 4) {
  61019. encoded1 = BASE_CHARS.indexOf(serializedString[i]);
  61020. encoded2 = BASE_CHARS.indexOf(serializedString[i + 1]);
  61021. encoded3 = BASE_CHARS.indexOf(serializedString[i + 2]);
  61022. encoded4 = BASE_CHARS.indexOf(serializedString[i + 3]);
  61023. /*jslint bitwise: true */
  61024. bytes[p++] = encoded1 << 2 | encoded2 >> 4;
  61025. bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  61026. bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
  61027. }
  61028. return buffer;
  61029. }
  61030. // Converts a buffer to a string to store, serialized, in the backend
  61031. // storage library.
  61032. function bufferToString(buffer) {
  61033. // base64-arraybuffer
  61034. var bytes = new Uint8Array(buffer);
  61035. var base64String = '';
  61036. var i;
  61037. for (i = 0; i < bytes.length; i += 3) {
  61038. /*jslint bitwise: true */
  61039. base64String += BASE_CHARS[bytes[i] >> 2];
  61040. base64String += BASE_CHARS[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
  61041. base64String += BASE_CHARS[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
  61042. base64String += BASE_CHARS[bytes[i + 2] & 63];
  61043. }
  61044. if (bytes.length % 3 === 2) {
  61045. base64String = base64String.substring(0, base64String.length - 1) + '=';
  61046. } else if (bytes.length % 3 === 1) {
  61047. base64String = base64String.substring(0, base64String.length - 2) + '==';
  61048. }
  61049. return base64String;
  61050. }
  61051. // Serialize a value, afterwards executing a callback (which usually
  61052. // instructs the `setItem()` callback/promise to be executed). This is how
  61053. // we store binary data with localStorage.
  61054. function serialize(value, callback) {
  61055. var valueType = '';
  61056. if (value) {
  61057. valueType = toString$1.call(value);
  61058. }
  61059. // Cannot use `value instanceof ArrayBuffer` or such here, as these
  61060. // checks fail when running the tests using casper.js...
  61061. //
  61062. // TODO: See why those tests fail and use a better solution.
  61063. if (value && (valueType === '[object ArrayBuffer]' || value.buffer && toString$1.call(value.buffer) === '[object ArrayBuffer]')) {
  61064. // Convert binary arrays to a string and prefix the string with
  61065. // a special marker.
  61066. var buffer;
  61067. var marker = SERIALIZED_MARKER;
  61068. if (value instanceof ArrayBuffer) {
  61069. buffer = value;
  61070. marker += TYPE_ARRAYBUFFER;
  61071. } else {
  61072. buffer = value.buffer;
  61073. if (valueType === '[object Int8Array]') {
  61074. marker += TYPE_INT8ARRAY;
  61075. } else if (valueType === '[object Uint8Array]') {
  61076. marker += TYPE_UINT8ARRAY;
  61077. } else if (valueType === '[object Uint8ClampedArray]') {
  61078. marker += TYPE_UINT8CLAMPEDARRAY;
  61079. } else if (valueType === '[object Int16Array]') {
  61080. marker += TYPE_INT16ARRAY;
  61081. } else if (valueType === '[object Uint16Array]') {
  61082. marker += TYPE_UINT16ARRAY;
  61083. } else if (valueType === '[object Int32Array]') {
  61084. marker += TYPE_INT32ARRAY;
  61085. } else if (valueType === '[object Uint32Array]') {
  61086. marker += TYPE_UINT32ARRAY;
  61087. } else if (valueType === '[object Float32Array]') {
  61088. marker += TYPE_FLOAT32ARRAY;
  61089. } else if (valueType === '[object Float64Array]') {
  61090. marker += TYPE_FLOAT64ARRAY;
  61091. } else {
  61092. callback(new Error('Failed to get type for BinaryArray'));
  61093. }
  61094. }
  61095. callback(marker + bufferToString(buffer));
  61096. } else if (valueType === '[object Blob]') {
  61097. // Conver the blob to a binaryArray and then to a string.
  61098. var fileReader = new FileReader();
  61099. fileReader.onload = function () {
  61100. // Backwards-compatible prefix for the blob type.
  61101. var str = BLOB_TYPE_PREFIX + value.type + '~' + bufferToString(this.result);
  61102. callback(SERIALIZED_MARKER + TYPE_BLOB + str);
  61103. };
  61104. fileReader.readAsArrayBuffer(value);
  61105. } else {
  61106. try {
  61107. callback(JSON.stringify(value));
  61108. } catch (e) {
  61109. console.error("Couldn't convert value into a JSON string: ", value);
  61110. callback(null, e);
  61111. }
  61112. }
  61113. }
  61114. // Deserialize data we've inserted into a value column/field. We place
  61115. // special markers into our strings to mark them as encoded; this isn't
  61116. // as nice as a meta field, but it's the only sane thing we can do whilst
  61117. // keeping localStorage support intact.
  61118. //
  61119. // Oftentimes this will just deserialize JSON content, but if we have a
  61120. // special marker (SERIALIZED_MARKER, defined above), we will extract
  61121. // some kind of arraybuffer/binary data/typed array out of the string.
  61122. function deserialize(value) {
  61123. // If we haven't marked this string as being specially serialized (i.e.
  61124. // something other than serialized JSON), we can just return it and be
  61125. // done with it.
  61126. if (value.substring(0, SERIALIZED_MARKER_LENGTH) !== SERIALIZED_MARKER) {
  61127. return JSON.parse(value);
  61128. }
  61129. // The following code deals with deserializing some kind of Blob or
  61130. // TypedArray. First we separate out the type of data we're dealing
  61131. // with from the data itself.
  61132. var serializedString = value.substring(TYPE_SERIALIZED_MARKER_LENGTH);
  61133. var type = value.substring(SERIALIZED_MARKER_LENGTH, TYPE_SERIALIZED_MARKER_LENGTH);
  61134. var blobType;
  61135. // Backwards-compatible blob type serialization strategy.
  61136. // DBs created with older versions of localForage will simply not have the blob type.
  61137. if (type === TYPE_BLOB && BLOB_TYPE_PREFIX_REGEX.test(serializedString)) {
  61138. var matcher = serializedString.match(BLOB_TYPE_PREFIX_REGEX);
  61139. blobType = matcher[1];
  61140. serializedString = serializedString.substring(matcher[0].length);
  61141. }
  61142. var buffer = stringToBuffer(serializedString);
  61143. // Return the right type based on the code/type set during
  61144. // serialization.
  61145. switch (type) {
  61146. case TYPE_ARRAYBUFFER:
  61147. return buffer;
  61148. case TYPE_BLOB:
  61149. return createBlob([buffer], { type: blobType });
  61150. case TYPE_INT8ARRAY:
  61151. return new Int8Array(buffer);
  61152. case TYPE_UINT8ARRAY:
  61153. return new Uint8Array(buffer);
  61154. case TYPE_UINT8CLAMPEDARRAY:
  61155. return new Uint8ClampedArray(buffer);
  61156. case TYPE_INT16ARRAY:
  61157. return new Int16Array(buffer);
  61158. case TYPE_UINT16ARRAY:
  61159. return new Uint16Array(buffer);
  61160. case TYPE_INT32ARRAY:
  61161. return new Int32Array(buffer);
  61162. case TYPE_UINT32ARRAY:
  61163. return new Uint32Array(buffer);
  61164. case TYPE_FLOAT32ARRAY:
  61165. return new Float32Array(buffer);
  61166. case TYPE_FLOAT64ARRAY:
  61167. return new Float64Array(buffer);
  61168. default:
  61169. throw new Error('Unkown type: ' + type);
  61170. }
  61171. }
  61172. var localforageSerializer = {
  61173. serialize: serialize,
  61174. deserialize: deserialize,
  61175. stringToBuffer: stringToBuffer,
  61176. bufferToString: bufferToString
  61177. };
  61178. /*
  61179. * Includes code from:
  61180. *
  61181. * base64-arraybuffer
  61182. * https://github.com/niklasvh/base64-arraybuffer
  61183. *
  61184. * Copyright (c) 2012 Niklas von Hertzen
  61185. * Licensed under the MIT license.
  61186. */
  61187. function createDbTable(t, dbInfo, callback, errorCallback) {
  61188. t.executeSql('CREATE TABLE IF NOT EXISTS ' + dbInfo.storeName + ' ' + '(id INTEGER PRIMARY KEY, key unique, value)', [], callback, errorCallback);
  61189. }
  61190. // Open the WebSQL database (automatically creates one if one didn't
  61191. // previously exist), using any options set in the config.
  61192. function _initStorage$1(options) {
  61193. var self = this;
  61194. var dbInfo = {
  61195. db: null
  61196. };
  61197. if (options) {
  61198. for (var i in options) {
  61199. dbInfo[i] = typeof options[i] !== 'string' ? options[i].toString() : options[i];
  61200. }
  61201. }
  61202. var dbInfoPromise = new Promise$1(function (resolve, reject) {
  61203. // Open the database; the openDatabase API will automatically
  61204. // create it for us if it doesn't exist.
  61205. try {
  61206. dbInfo.db = openDatabase(dbInfo.name, String(dbInfo.version), dbInfo.description, dbInfo.size);
  61207. } catch (e) {
  61208. return reject(e);
  61209. }
  61210. // Create our key/value table if it doesn't exist.
  61211. dbInfo.db.transaction(function (t) {
  61212. createDbTable(t, dbInfo, function () {
  61213. self._dbInfo = dbInfo;
  61214. resolve();
  61215. }, function (t, error) {
  61216. reject(error);
  61217. });
  61218. }, reject);
  61219. });
  61220. dbInfo.serializer = localforageSerializer;
  61221. return dbInfoPromise;
  61222. }
  61223. function tryExecuteSql(t, dbInfo, sqlStatement, args, callback, errorCallback) {
  61224. t.executeSql(sqlStatement, args, callback, function (t, error) {
  61225. if (error.code === error.SYNTAX_ERR) {
  61226. t.executeSql('SELECT name FROM sqlite_master ' + "WHERE type='table' AND name = ?", [dbInfo.storeName], function (t, results) {
  61227. if (!results.rows.length) {
  61228. // if the table is missing (was deleted)
  61229. // re-create it table and retry
  61230. createDbTable(t, dbInfo, function () {
  61231. t.executeSql(sqlStatement, args, callback, errorCallback);
  61232. }, errorCallback);
  61233. } else {
  61234. errorCallback(t, error);
  61235. }
  61236. }, errorCallback);
  61237. } else {
  61238. errorCallback(t, error);
  61239. }
  61240. }, errorCallback);
  61241. }
  61242. function getItem$1(key, callback) {
  61243. var self = this;
  61244. key = normalizeKey(key);
  61245. var promise = new Promise$1(function (resolve, reject) {
  61246. self.ready().then(function () {
  61247. var dbInfo = self._dbInfo;
  61248. dbInfo.db.transaction(function (t) {
  61249. tryExecuteSql(t, dbInfo, 'SELECT * FROM ' + dbInfo.storeName + ' WHERE key = ? LIMIT 1', [key], function (t, results) {
  61250. var result = results.rows.length ? results.rows.item(0).value : null;
  61251. // Check to see if this is serialized content we need to
  61252. // unpack.
  61253. if (result) {
  61254. result = dbInfo.serializer.deserialize(result);
  61255. }
  61256. resolve(result);
  61257. }, function (t, error) {
  61258. reject(error);
  61259. });
  61260. });
  61261. })["catch"](reject);
  61262. });
  61263. executeCallback(promise, callback);
  61264. return promise;
  61265. }
  61266. function iterate$1(iterator, callback) {
  61267. var self = this;
  61268. var promise = new Promise$1(function (resolve, reject) {
  61269. self.ready().then(function () {
  61270. var dbInfo = self._dbInfo;
  61271. dbInfo.db.transaction(function (t) {
  61272. tryExecuteSql(t, dbInfo, 'SELECT * FROM ' + dbInfo.storeName, [], function (t, results) {
  61273. var rows = results.rows;
  61274. var length = rows.length;
  61275. for (var i = 0; i < length; i++) {
  61276. var item = rows.item(i);
  61277. var result = item.value;
  61278. // Check to see if this is serialized content
  61279. // we need to unpack.
  61280. if (result) {
  61281. result = dbInfo.serializer.deserialize(result);
  61282. }
  61283. result = iterator(result, item.key, i + 1);
  61284. // void(0) prevents problems with redefinition
  61285. // of `undefined`.
  61286. if (result !== void 0) {
  61287. resolve(result);
  61288. return;
  61289. }
  61290. }
  61291. resolve();
  61292. }, function (t, error) {
  61293. reject(error);
  61294. });
  61295. });
  61296. })["catch"](reject);
  61297. });
  61298. executeCallback(promise, callback);
  61299. return promise;
  61300. }
  61301. function _setItem(key, value, callback, retriesLeft) {
  61302. var self = this;
  61303. key = normalizeKey(key);
  61304. var promise = new Promise$1(function (resolve, reject) {
  61305. self.ready().then(function () {
  61306. // The localStorage API doesn't return undefined values in an
  61307. // "expected" way, so undefined is always cast to null in all
  61308. // drivers. See: https://github.com/mozilla/localForage/pull/42
  61309. if (value === undefined) {
  61310. value = null;
  61311. }
  61312. // Save the original value to pass to the callback.
  61313. var originalValue = value;
  61314. var dbInfo = self._dbInfo;
  61315. dbInfo.serializer.serialize(value, function (value, error) {
  61316. if (error) {
  61317. reject(error);
  61318. } else {
  61319. dbInfo.db.transaction(function (t) {
  61320. tryExecuteSql(t, dbInfo, 'INSERT OR REPLACE INTO ' + dbInfo.storeName + ' ' + '(key, value) VALUES (?, ?)', [key, value], function () {
  61321. resolve(originalValue);
  61322. }, function (t, error) {
  61323. reject(error);
  61324. });
  61325. }, function (sqlError) {
  61326. // The transaction failed; check
  61327. // to see if it's a quota error.
  61328. if (sqlError.code === sqlError.QUOTA_ERR) {
  61329. // We reject the callback outright for now, but
  61330. // it's worth trying to re-run the transaction.
  61331. // Even if the user accepts the prompt to use
  61332. // more storage on Safari, this error will
  61333. // be called.
  61334. //
  61335. // Try to re-run the transaction.
  61336. if (retriesLeft > 0) {
  61337. resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));
  61338. return;
  61339. }
  61340. reject(sqlError);
  61341. }
  61342. });
  61343. }
  61344. });
  61345. })["catch"](reject);
  61346. });
  61347. executeCallback(promise, callback);
  61348. return promise;
  61349. }
  61350. function setItem$1(key, value, callback) {
  61351. return _setItem.apply(this, [key, value, callback, 1]);
  61352. }
  61353. function removeItem$1(key, callback) {
  61354. var self = this;
  61355. key = normalizeKey(key);
  61356. var promise = new Promise$1(function (resolve, reject) {
  61357. self.ready().then(function () {
  61358. var dbInfo = self._dbInfo;
  61359. dbInfo.db.transaction(function (t) {
  61360. tryExecuteSql(t, dbInfo, 'DELETE FROM ' + dbInfo.storeName + ' WHERE key = ?', [key], function () {
  61361. resolve();
  61362. }, function (t, error) {
  61363. reject(error);
  61364. });
  61365. });
  61366. })["catch"](reject);
  61367. });
  61368. executeCallback(promise, callback);
  61369. return promise;
  61370. }
  61371. // Deletes every item in the table.
  61372. // TODO: Find out if this resets the AUTO_INCREMENT number.
  61373. function clear$1(callback) {
  61374. var self = this;
  61375. var promise = new Promise$1(function (resolve, reject) {
  61376. self.ready().then(function () {
  61377. var dbInfo = self._dbInfo;
  61378. dbInfo.db.transaction(function (t) {
  61379. tryExecuteSql(t, dbInfo, 'DELETE FROM ' + dbInfo.storeName, [], function () {
  61380. resolve();
  61381. }, function (t, error) {
  61382. reject(error);
  61383. });
  61384. });
  61385. })["catch"](reject);
  61386. });
  61387. executeCallback(promise, callback);
  61388. return promise;
  61389. }
  61390. // Does a simple `COUNT(key)` to get the number of items stored in
  61391. // localForage.
  61392. function length$1(callback) {
  61393. var self = this;
  61394. var promise = new Promise$1(function (resolve, reject) {
  61395. self.ready().then(function () {
  61396. var dbInfo = self._dbInfo;
  61397. dbInfo.db.transaction(function (t) {
  61398. // Ahhh, SQL makes this one soooooo easy.
  61399. tryExecuteSql(t, dbInfo, 'SELECT COUNT(key) as c FROM ' + dbInfo.storeName, [], function (t, results) {
  61400. var result = results.rows.item(0).c;
  61401. resolve(result);
  61402. }, function (t, error) {
  61403. reject(error);
  61404. });
  61405. });
  61406. })["catch"](reject);
  61407. });
  61408. executeCallback(promise, callback);
  61409. return promise;
  61410. }
  61411. // Return the key located at key index X; essentially gets the key from a
  61412. // `WHERE id = ?`. This is the most efficient way I can think to implement
  61413. // this rarely-used (in my experience) part of the API, but it can seem
  61414. // inconsistent, because we do `INSERT OR REPLACE INTO` on `setItem()`, so
  61415. // the ID of each key will change every time it's updated. Perhaps a stored
  61416. // procedure for the `setItem()` SQL would solve this problem?
  61417. // TODO: Don't change ID on `setItem()`.
  61418. function key$1(n, callback) {
  61419. var self = this;
  61420. var promise = new Promise$1(function (resolve, reject) {
  61421. self.ready().then(function () {
  61422. var dbInfo = self._dbInfo;
  61423. dbInfo.db.transaction(function (t) {
  61424. tryExecuteSql(t, dbInfo, 'SELECT key FROM ' + dbInfo.storeName + ' WHERE id = ? LIMIT 1', [n + 1], function (t, results) {
  61425. var result = results.rows.length ? results.rows.item(0).key : null;
  61426. resolve(result);
  61427. }, function (t, error) {
  61428. reject(error);
  61429. });
  61430. });
  61431. })["catch"](reject);
  61432. });
  61433. executeCallback(promise, callback);
  61434. return promise;
  61435. }
  61436. function keys$1(callback) {
  61437. var self = this;
  61438. var promise = new Promise$1(function (resolve, reject) {
  61439. self.ready().then(function () {
  61440. var dbInfo = self._dbInfo;
  61441. dbInfo.db.transaction(function (t) {
  61442. tryExecuteSql(t, dbInfo, 'SELECT key FROM ' + dbInfo.storeName, [], function (t, results) {
  61443. var keys = [];
  61444. for (var i = 0; i < results.rows.length; i++) {
  61445. keys.push(results.rows.item(i).key);
  61446. }
  61447. resolve(keys);
  61448. }, function (t, error) {
  61449. reject(error);
  61450. });
  61451. });
  61452. })["catch"](reject);
  61453. });
  61454. executeCallback(promise, callback);
  61455. return promise;
  61456. }
  61457. // https://www.w3.org/TR/webdatabase/#databases
  61458. // > There is no way to enumerate or delete the databases available for an origin from this API.
  61459. function getAllStoreNames(db) {
  61460. return new Promise$1(function (resolve, reject) {
  61461. db.transaction(function (t) {
  61462. t.executeSql('SELECT name FROM sqlite_master ' + "WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function (t, results) {
  61463. var storeNames = [];
  61464. for (var i = 0; i < results.rows.length; i++) {
  61465. storeNames.push(results.rows.item(i).name);
  61466. }
  61467. resolve({
  61468. db: db,
  61469. storeNames: storeNames
  61470. });
  61471. }, function (t, error) {
  61472. reject(error);
  61473. });
  61474. }, function (sqlError) {
  61475. reject(sqlError);
  61476. });
  61477. });
  61478. }
  61479. function dropInstance$1(options, callback) {
  61480. callback = getCallback.apply(this, arguments);
  61481. var currentConfig = this.config();
  61482. options = typeof options !== 'function' && options || {};
  61483. if (!options.name) {
  61484. options.name = options.name || currentConfig.name;
  61485. options.storeName = options.storeName || currentConfig.storeName;
  61486. }
  61487. var self = this;
  61488. var promise;
  61489. if (!options.name) {
  61490. promise = Promise$1.reject('Invalid arguments');
  61491. } else {
  61492. promise = new Promise$1(function (resolve) {
  61493. var db;
  61494. if (options.name === currentConfig.name) {
  61495. // use the db reference of the current instance
  61496. db = self._dbInfo.db;
  61497. } else {
  61498. db = openDatabase(options.name, '', '', 0);
  61499. }
  61500. if (!options.storeName) {
  61501. // drop all database tables
  61502. resolve(getAllStoreNames(db));
  61503. } else {
  61504. resolve({
  61505. db: db,
  61506. storeNames: [options.storeName]
  61507. });
  61508. }
  61509. }).then(function (operationInfo) {
  61510. return new Promise$1(function (resolve, reject) {
  61511. operationInfo.db.transaction(function (t) {
  61512. function dropTable(storeName) {
  61513. return new Promise$1(function (resolve, reject) {
  61514. t.executeSql('DROP TABLE IF EXISTS ' + storeName, [], function () {
  61515. resolve();
  61516. }, function (t, error) {
  61517. reject(error);
  61518. });
  61519. });
  61520. }
  61521. var operations = [];
  61522. for (var i = 0, len = operationInfo.storeNames.length; i < len; i++) {
  61523. operations.push(dropTable(operationInfo.storeNames[i]));
  61524. }
  61525. Promise$1.all(operations).then(function () {
  61526. resolve();
  61527. })["catch"](function (e) {
  61528. reject(e);
  61529. });
  61530. }, function (sqlError) {
  61531. reject(sqlError);
  61532. });
  61533. });
  61534. });
  61535. }
  61536. executeCallback(promise, callback);
  61537. return promise;
  61538. }
  61539. var webSQLStorage = {
  61540. _driver: 'webSQLStorage',
  61541. _initStorage: _initStorage$1,
  61542. _support: isWebSQLValid(),
  61543. iterate: iterate$1,
  61544. getItem: getItem$1,
  61545. setItem: setItem$1,
  61546. removeItem: removeItem$1,
  61547. clear: clear$1,
  61548. length: length$1,
  61549. key: key$1,
  61550. keys: keys$1,
  61551. dropInstance: dropInstance$1
  61552. };
  61553. function isLocalStorageValid() {
  61554. try {
  61555. return typeof localStorage !== 'undefined' && 'setItem' in localStorage &&
  61556. // in IE8 typeof localStorage.setItem === 'object'
  61557. !!localStorage.setItem;
  61558. } catch (e) {
  61559. return false;
  61560. }
  61561. }
  61562. function _getKeyPrefix(options, defaultConfig) {
  61563. var keyPrefix = options.name + '/';
  61564. if (options.storeName !== defaultConfig.storeName) {
  61565. keyPrefix += options.storeName + '/';
  61566. }
  61567. return keyPrefix;
  61568. }
  61569. // Check if localStorage throws when saving an item
  61570. function checkIfLocalStorageThrows() {
  61571. var localStorageTestKey = '_localforage_support_test';
  61572. try {
  61573. localStorage.setItem(localStorageTestKey, true);
  61574. localStorage.removeItem(localStorageTestKey);
  61575. return false;
  61576. } catch (e) {
  61577. return true;
  61578. }
  61579. }
  61580. // Check if localStorage is usable and allows to save an item
  61581. // This method checks if localStorage is usable in Safari Private Browsing
  61582. // mode, or in any other case where the available quota for localStorage
  61583. // is 0 and there wasn't any saved items yet.
  61584. function _isLocalStorageUsable() {
  61585. return !checkIfLocalStorageThrows() || localStorage.length > 0;
  61586. }
  61587. // Config the localStorage backend, using options set in the config.
  61588. function _initStorage$2(options) {
  61589. var self = this;
  61590. var dbInfo = {};
  61591. if (options) {
  61592. for (var i in options) {
  61593. dbInfo[i] = options[i];
  61594. }
  61595. }
  61596. dbInfo.keyPrefix = _getKeyPrefix(options, self._defaultConfig);
  61597. if (!_isLocalStorageUsable()) {
  61598. return Promise$1.reject();
  61599. }
  61600. self._dbInfo = dbInfo;
  61601. dbInfo.serializer = localforageSerializer;
  61602. return Promise$1.resolve();
  61603. }
  61604. // Remove all keys from the datastore, effectively destroying all data in
  61605. // the app's key/value store!
  61606. function clear$2(callback) {
  61607. var self = this;
  61608. var promise = self.ready().then(function () {
  61609. var keyPrefix = self._dbInfo.keyPrefix;
  61610. for (var i = localStorage.length - 1; i >= 0; i--) {
  61611. var key = localStorage.key(i);
  61612. if (key.indexOf(keyPrefix) === 0) {
  61613. localStorage.removeItem(key);
  61614. }
  61615. }
  61616. });
  61617. executeCallback(promise, callback);
  61618. return promise;
  61619. }
  61620. // Retrieve an item from the store. Unlike the original async_storage
  61621. // library in Gaia, we don't modify return values at all. If a key's value
  61622. // is `undefined`, we pass that value to the callback function.
  61623. function getItem$2(key, callback) {
  61624. var self = this;
  61625. key = normalizeKey(key);
  61626. var promise = self.ready().then(function () {
  61627. var dbInfo = self._dbInfo;
  61628. var result = localStorage.getItem(dbInfo.keyPrefix + key);
  61629. // If a result was found, parse it from the serialized
  61630. // string into a JS object. If result isn't truthy, the key
  61631. // is likely undefined and we'll pass it straight to the
  61632. // callback.
  61633. if (result) {
  61634. result = dbInfo.serializer.deserialize(result);
  61635. }
  61636. return result;
  61637. });
  61638. executeCallback(promise, callback);
  61639. return promise;
  61640. }
  61641. // Iterate over all items in the store.
  61642. function iterate$2(iterator, callback) {
  61643. var self = this;
  61644. var promise = self.ready().then(function () {
  61645. var dbInfo = self._dbInfo;
  61646. var keyPrefix = dbInfo.keyPrefix;
  61647. var keyPrefixLength = keyPrefix.length;
  61648. var length = localStorage.length;
  61649. // We use a dedicated iterator instead of the `i` variable below
  61650. // so other keys we fetch in localStorage aren't counted in
  61651. // the `iterationNumber` argument passed to the `iterate()`
  61652. // callback.
  61653. //
  61654. // See: github.com/mozilla/localForage/pull/435#discussion_r38061530
  61655. var iterationNumber = 1;
  61656. for (var i = 0; i < length; i++) {
  61657. var key = localStorage.key(i);
  61658. if (key.indexOf(keyPrefix) !== 0) {
  61659. continue;
  61660. }
  61661. var value = localStorage.getItem(key);
  61662. // If a result was found, parse it from the serialized
  61663. // string into a JS object. If result isn't truthy, the
  61664. // key is likely undefined and we'll pass it straight
  61665. // to the iterator.
  61666. if (value) {
  61667. value = dbInfo.serializer.deserialize(value);
  61668. }
  61669. value = iterator(value, key.substring(keyPrefixLength), iterationNumber++);
  61670. if (value !== void 0) {
  61671. return value;
  61672. }
  61673. }
  61674. });
  61675. executeCallback(promise, callback);
  61676. return promise;
  61677. }
  61678. // Same as localStorage's key() method, except takes a callback.
  61679. function key$2(n, callback) {
  61680. var self = this;
  61681. var promise = self.ready().then(function () {
  61682. var dbInfo = self._dbInfo;
  61683. var result;
  61684. try {
  61685. result = localStorage.key(n);
  61686. } catch (error) {
  61687. result = null;
  61688. }
  61689. // Remove the prefix from the key, if a key is found.
  61690. if (result) {
  61691. result = result.substring(dbInfo.keyPrefix.length);
  61692. }
  61693. return result;
  61694. });
  61695. executeCallback(promise, callback);
  61696. return promise;
  61697. }
  61698. function keys$2(callback) {
  61699. var self = this;
  61700. var promise = self.ready().then(function () {
  61701. var dbInfo = self._dbInfo;
  61702. var length = localStorage.length;
  61703. var keys = [];
  61704. for (var i = 0; i < length; i++) {
  61705. var itemKey = localStorage.key(i);
  61706. if (itemKey.indexOf(dbInfo.keyPrefix) === 0) {
  61707. keys.push(itemKey.substring(dbInfo.keyPrefix.length));
  61708. }
  61709. }
  61710. return keys;
  61711. });
  61712. executeCallback(promise, callback);
  61713. return promise;
  61714. }
  61715. // Supply the number of keys in the datastore to the callback function.
  61716. function length$2(callback) {
  61717. var self = this;
  61718. var promise = self.keys().then(function (keys) {
  61719. return keys.length;
  61720. });
  61721. executeCallback(promise, callback);
  61722. return promise;
  61723. }
  61724. // Remove an item from the store, nice and simple.
  61725. function removeItem$2(key, callback) {
  61726. var self = this;
  61727. key = normalizeKey(key);
  61728. var promise = self.ready().then(function () {
  61729. var dbInfo = self._dbInfo;
  61730. localStorage.removeItem(dbInfo.keyPrefix + key);
  61731. });
  61732. executeCallback(promise, callback);
  61733. return promise;
  61734. }
  61735. // Set a key's value and run an optional callback once the value is set.
  61736. // Unlike Gaia's implementation, the callback function is passed the value,
  61737. // in case you want to operate on that value only after you're sure it
  61738. // saved, or something like that.
  61739. function setItem$2(key, value, callback) {
  61740. var self = this;
  61741. key = normalizeKey(key);
  61742. var promise = self.ready().then(function () {
  61743. // Convert undefined values to null.
  61744. // https://github.com/mozilla/localForage/pull/42
  61745. if (value === undefined) {
  61746. value = null;
  61747. }
  61748. // Save the original value to pass to the callback.
  61749. var originalValue = value;
  61750. return new Promise$1(function (resolve, reject) {
  61751. var dbInfo = self._dbInfo;
  61752. dbInfo.serializer.serialize(value, function (value, error) {
  61753. if (error) {
  61754. reject(error);
  61755. } else {
  61756. try {
  61757. localStorage.setItem(dbInfo.keyPrefix + key, value);
  61758. resolve(originalValue);
  61759. } catch (e) {
  61760. // localStorage capacity exceeded.
  61761. // TODO: Make this a specific error/event.
  61762. if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
  61763. reject(e);
  61764. }
  61765. reject(e);
  61766. }
  61767. }
  61768. });
  61769. });
  61770. });
  61771. executeCallback(promise, callback);
  61772. return promise;
  61773. }
  61774. function dropInstance$2(options, callback) {
  61775. callback = getCallback.apply(this, arguments);
  61776. options = typeof options !== 'function' && options || {};
  61777. if (!options.name) {
  61778. var currentConfig = this.config();
  61779. options.name = options.name || currentConfig.name;
  61780. options.storeName = options.storeName || currentConfig.storeName;
  61781. }
  61782. var self = this;
  61783. var promise;
  61784. if (!options.name) {
  61785. promise = Promise$1.reject('Invalid arguments');
  61786. } else {
  61787. promise = new Promise$1(function (resolve) {
  61788. if (!options.storeName) {
  61789. resolve(options.name + '/');
  61790. } else {
  61791. resolve(_getKeyPrefix(options, self._defaultConfig));
  61792. }
  61793. }).then(function (keyPrefix) {
  61794. for (var i = localStorage.length - 1; i >= 0; i--) {
  61795. var key = localStorage.key(i);
  61796. if (key.indexOf(keyPrefix) === 0) {
  61797. localStorage.removeItem(key);
  61798. }
  61799. }
  61800. });
  61801. }
  61802. executeCallback(promise, callback);
  61803. return promise;
  61804. }
  61805. var localStorageWrapper = {
  61806. _driver: 'localStorageWrapper',
  61807. _initStorage: _initStorage$2,
  61808. _support: isLocalStorageValid(),
  61809. iterate: iterate$2,
  61810. getItem: getItem$2,
  61811. setItem: setItem$2,
  61812. removeItem: removeItem$2,
  61813. clear: clear$2,
  61814. length: length$2,
  61815. key: key$2,
  61816. keys: keys$2,
  61817. dropInstance: dropInstance$2
  61818. };
  61819. var sameValue = function sameValue(x, y) {
  61820. return x === y || typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y);
  61821. };
  61822. var includes = function includes(array, searchElement) {
  61823. var len = array.length;
  61824. var i = 0;
  61825. while (i < len) {
  61826. if (sameValue(array[i], searchElement)) {
  61827. return true;
  61828. }
  61829. i++;
  61830. }
  61831. return false;
  61832. };
  61833. var isArray = Array.isArray || function (arg) {
  61834. return Object.prototype.toString.call(arg) === '[object Array]';
  61835. };
  61836. // Drivers are stored here when `defineDriver()` is called.
  61837. // They are shared across all instances of localForage.
  61838. var DefinedDrivers = {};
  61839. var DriverSupport = {};
  61840. var DefaultDrivers = {
  61841. INDEXEDDB: asyncStorage,
  61842. WEBSQL: webSQLStorage,
  61843. LOCALSTORAGE: localStorageWrapper
  61844. };
  61845. var DefaultDriverOrder = [DefaultDrivers.INDEXEDDB._driver, DefaultDrivers.WEBSQL._driver, DefaultDrivers.LOCALSTORAGE._driver];
  61846. var OptionalDriverMethods = ['dropInstance'];
  61847. var LibraryMethods = ['clear', 'getItem', 'iterate', 'key', 'keys', 'length', 'removeItem', 'setItem'].concat(OptionalDriverMethods);
  61848. var DefaultConfig = {
  61849. description: '',
  61850. driver: DefaultDriverOrder.slice(),
  61851. name: 'localforage',
  61852. // Default DB size is _JUST UNDER_ 5MB, as it's the highest size
  61853. // we can use without a prompt.
  61854. size: 4980736,
  61855. storeName: 'keyvaluepairs',
  61856. version: 1.0
  61857. };
  61858. function callWhenReady(localForageInstance, libraryMethod) {
  61859. localForageInstance[libraryMethod] = function () {
  61860. var _args = arguments;
  61861. return localForageInstance.ready().then(function () {
  61862. return localForageInstance[libraryMethod].apply(localForageInstance, _args);
  61863. });
  61864. };
  61865. }
  61866. function extend() {
  61867. for (var i = 1; i < arguments.length; i++) {
  61868. var arg = arguments[i];
  61869. if (arg) {
  61870. for (var _key in arg) {
  61871. if (arg.hasOwnProperty(_key)) {
  61872. if (isArray(arg[_key])) {
  61873. arguments[0][_key] = arg[_key].slice();
  61874. } else {
  61875. arguments[0][_key] = arg[_key];
  61876. }
  61877. }
  61878. }
  61879. }
  61880. }
  61881. return arguments[0];
  61882. }
  61883. var LocalForage = function () {
  61884. function LocalForage(options) {
  61885. _classCallCheck(this, LocalForage);
  61886. for (var driverTypeKey in DefaultDrivers) {
  61887. if (DefaultDrivers.hasOwnProperty(driverTypeKey)) {
  61888. var driver = DefaultDrivers[driverTypeKey];
  61889. var driverName = driver._driver;
  61890. this[driverTypeKey] = driverName;
  61891. if (!DefinedDrivers[driverName]) {
  61892. // we don't need to wait for the promise,
  61893. // since the default drivers can be defined
  61894. // in a blocking manner
  61895. this.defineDriver(driver);
  61896. }
  61897. }
  61898. }
  61899. this._defaultConfig = extend({}, DefaultConfig);
  61900. this._config = extend({}, this._defaultConfig, options);
  61901. this._driverSet = null;
  61902. this._initDriver = null;
  61903. this._ready = false;
  61904. this._dbInfo = null;
  61905. this._wrapLibraryMethodsWithReady();
  61906. this.setDriver(this._config.driver)["catch"](function () {});
  61907. }
  61908. // Set any config values for localForage; can be called anytime before
  61909. // the first API call (e.g. `getItem`, `setItem`).
  61910. // We loop through options so we don't overwrite existing config
  61911. // values.
  61912. LocalForage.prototype.config = function config(options) {
  61913. // If the options argument is an object, we use it to set values.
  61914. // Otherwise, we return either a specified config value or all
  61915. // config values.
  61916. if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') {
  61917. // If localforage is ready and fully initialized, we can't set
  61918. // any new configuration values. Instead, we return an error.
  61919. if (this._ready) {
  61920. return new Error("Can't call config() after localforage " + 'has been used.');
  61921. }
  61922. for (var i in options) {
  61923. if (i === 'storeName') {
  61924. options[i] = options[i].replace(/\W/g, '_');
  61925. }
  61926. if (i === 'version' && typeof options[i] !== 'number') {
  61927. return new Error('Database version must be a number.');
  61928. }
  61929. this._config[i] = options[i];
  61930. }
  61931. // after all config options are set and
  61932. // the driver option is used, try setting it
  61933. if ('driver' in options && options.driver) {
  61934. return this.setDriver(this._config.driver);
  61935. }
  61936. return true;
  61937. } else if (typeof options === 'string') {
  61938. return this._config[options];
  61939. } else {
  61940. return this._config;
  61941. }
  61942. };
  61943. // Used to define a custom driver, shared across all instances of
  61944. // localForage.
  61945. LocalForage.prototype.defineDriver = function defineDriver(driverObject, callback, errorCallback) {
  61946. var promise = new Promise$1(function (resolve, reject) {
  61947. try {
  61948. var driverName = driverObject._driver;
  61949. var complianceError = new Error('Custom driver not compliant; see ' + 'https://mozilla.github.io/localForage/#definedriver');
  61950. // A driver name should be defined and not overlap with the
  61951. // library-defined, default drivers.
  61952. if (!driverObject._driver) {
  61953. reject(complianceError);
  61954. return;
  61955. }
  61956. var driverMethods = LibraryMethods.concat('_initStorage');
  61957. for (var i = 0, len = driverMethods.length; i < len; i++) {
  61958. var driverMethodName = driverMethods[i];
  61959. // when the property is there,
  61960. // it should be a method even when optional
  61961. var isRequired = !includes(OptionalDriverMethods, driverMethodName);
  61962. if ((isRequired || driverObject[driverMethodName]) && typeof driverObject[driverMethodName] !== 'function') {
  61963. reject(complianceError);
  61964. return;
  61965. }
  61966. }
  61967. var configureMissingMethods = function configureMissingMethods() {
  61968. var methodNotImplementedFactory = function methodNotImplementedFactory(methodName) {
  61969. return function () {
  61970. var error = new Error('Method ' + methodName + ' is not implemented by the current driver');
  61971. var promise = Promise$1.reject(error);
  61972. executeCallback(promise, arguments[arguments.length - 1]);
  61973. return promise;
  61974. };
  61975. };
  61976. for (var _i = 0, _len = OptionalDriverMethods.length; _i < _len; _i++) {
  61977. var optionalDriverMethod = OptionalDriverMethods[_i];
  61978. if (!driverObject[optionalDriverMethod]) {
  61979. driverObject[optionalDriverMethod] = methodNotImplementedFactory(optionalDriverMethod);
  61980. }
  61981. }
  61982. };
  61983. configureMissingMethods();
  61984. var setDriverSupport = function setDriverSupport(support) {
  61985. if (DefinedDrivers[driverName]) {
  61986. console.info('Redefining LocalForage driver: ' + driverName);
  61987. }
  61988. DefinedDrivers[driverName] = driverObject;
  61989. DriverSupport[driverName] = support;
  61990. // don't use a then, so that we can define
  61991. // drivers that have simple _support methods
  61992. // in a blocking manner
  61993. resolve();
  61994. };
  61995. if ('_support' in driverObject) {
  61996. if (driverObject._support && typeof driverObject._support === 'function') {
  61997. driverObject._support().then(setDriverSupport, reject);
  61998. } else {
  61999. setDriverSupport(!!driverObject._support);
  62000. }
  62001. } else {
  62002. setDriverSupport(true);
  62003. }
  62004. } catch (e) {
  62005. reject(e);
  62006. }
  62007. });
  62008. executeTwoCallbacks(promise, callback, errorCallback);
  62009. return promise;
  62010. };
  62011. LocalForage.prototype.driver = function driver() {
  62012. return this._driver || null;
  62013. };
  62014. LocalForage.prototype.getDriver = function getDriver(driverName, callback, errorCallback) {
  62015. var getDriverPromise = DefinedDrivers[driverName] ? Promise$1.resolve(DefinedDrivers[driverName]) : Promise$1.reject(new Error('Driver not found.'));
  62016. executeTwoCallbacks(getDriverPromise, callback, errorCallback);
  62017. return getDriverPromise;
  62018. };
  62019. LocalForage.prototype.getSerializer = function getSerializer(callback) {
  62020. var serializerPromise = Promise$1.resolve(localforageSerializer);
  62021. executeTwoCallbacks(serializerPromise, callback);
  62022. return serializerPromise;
  62023. };
  62024. LocalForage.prototype.ready = function ready(callback) {
  62025. var self = this;
  62026. var promise = self._driverSet.then(function () {
  62027. if (self._ready === null) {
  62028. self._ready = self._initDriver();
  62029. }
  62030. return self._ready;
  62031. });
  62032. executeTwoCallbacks(promise, callback, callback);
  62033. return promise;
  62034. };
  62035. LocalForage.prototype.setDriver = function setDriver(drivers, callback, errorCallback) {
  62036. var self = this;
  62037. if (!isArray(drivers)) {
  62038. drivers = [drivers];
  62039. }
  62040. var supportedDrivers = this._getSupportedDrivers(drivers);
  62041. function setDriverToConfig() {
  62042. self._config.driver = self.driver();
  62043. }
  62044. function extendSelfWithDriver(driver) {
  62045. self._extend(driver);
  62046. setDriverToConfig();
  62047. self._ready = self._initStorage(self._config);
  62048. return self._ready;
  62049. }
  62050. function initDriver(supportedDrivers) {
  62051. return function () {
  62052. var currentDriverIndex = 0;
  62053. function driverPromiseLoop() {
  62054. while (currentDriverIndex < supportedDrivers.length) {
  62055. var driverName = supportedDrivers[currentDriverIndex];
  62056. currentDriverIndex++;
  62057. self._dbInfo = null;
  62058. self._ready = null;
  62059. return self.getDriver(driverName).then(extendSelfWithDriver)["catch"](driverPromiseLoop);
  62060. }
  62061. setDriverToConfig();
  62062. var error = new Error('No available storage method found.');
  62063. self._driverSet = Promise$1.reject(error);
  62064. return self._driverSet;
  62065. }
  62066. return driverPromiseLoop();
  62067. };
  62068. }
  62069. // There might be a driver initialization in progress
  62070. // so wait for it to finish in order to avoid a possible
  62071. // race condition to set _dbInfo
  62072. var oldDriverSetDone = this._driverSet !== null ? this._driverSet["catch"](function () {
  62073. return Promise$1.resolve();
  62074. }) : Promise$1.resolve();
  62075. this._driverSet = oldDriverSetDone.then(function () {
  62076. var driverName = supportedDrivers[0];
  62077. self._dbInfo = null;
  62078. self._ready = null;
  62079. return self.getDriver(driverName).then(function (driver) {
  62080. self._driver = driver._driver;
  62081. setDriverToConfig();
  62082. self._wrapLibraryMethodsWithReady();
  62083. self._initDriver = initDriver(supportedDrivers);
  62084. });
  62085. })["catch"](function () {
  62086. setDriverToConfig();
  62087. var error = new Error('No available storage method found.');
  62088. self._driverSet = Promise$1.reject(error);
  62089. return self._driverSet;
  62090. });
  62091. executeTwoCallbacks(this._driverSet, callback, errorCallback);
  62092. return this._driverSet;
  62093. };
  62094. LocalForage.prototype.supports = function supports(driverName) {
  62095. return !!DriverSupport[driverName];
  62096. };
  62097. LocalForage.prototype._extend = function _extend(libraryMethodsAndProperties) {
  62098. extend(this, libraryMethodsAndProperties);
  62099. };
  62100. LocalForage.prototype._getSupportedDrivers = function _getSupportedDrivers(drivers) {
  62101. var supportedDrivers = [];
  62102. for (var i = 0, len = drivers.length; i < len; i++) {
  62103. var driverName = drivers[i];
  62104. if (this.supports(driverName)) {
  62105. supportedDrivers.push(driverName);
  62106. }
  62107. }
  62108. return supportedDrivers;
  62109. };
  62110. LocalForage.prototype._wrapLibraryMethodsWithReady = function _wrapLibraryMethodsWithReady() {
  62111. // Add a stub for each driver API method that delays the call to the
  62112. // corresponding driver method until localForage is ready. These stubs
  62113. // will be replaced by the driver methods as soon as the driver is
  62114. // loaded, so there is no performance impact.
  62115. for (var i = 0, len = LibraryMethods.length; i < len; i++) {
  62116. callWhenReady(this, LibraryMethods[i]);
  62117. }
  62118. };
  62119. LocalForage.prototype.createInstance = function createInstance(options) {
  62120. return new LocalForage(options);
  62121. };
  62122. return LocalForage;
  62123. }();
  62124. // The actual localForage object that we expose as a module or via a
  62125. // global. It's extended by pulling in one of our other libraries.
  62126. var localforage_js = new LocalForage();
  62127. module.exports = localforage_js;
  62128. },{"3":3}]},{},[4])(4)
  62129. });
  62130. /***/ }),
  62131. /***/ 2705:
  62132. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62133. var root = __webpack_require__(5639);
  62134. /** Built-in value references. */
  62135. var Symbol = root.Symbol;
  62136. module.exports = Symbol;
  62137. /***/ }),
  62138. /***/ 4239:
  62139. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62140. var Symbol = __webpack_require__(2705),
  62141. getRawTag = __webpack_require__(9607),
  62142. objectToString = __webpack_require__(2333);
  62143. /** `Object#toString` result references. */
  62144. var nullTag = '[object Null]',
  62145. undefinedTag = '[object Undefined]';
  62146. /** Built-in value references. */
  62147. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  62148. /**
  62149. * The base implementation of `getTag` without fallbacks for buggy environments.
  62150. *
  62151. * @private
  62152. * @param {*} value The value to query.
  62153. * @returns {string} Returns the `toStringTag`.
  62154. */
  62155. function baseGetTag(value) {
  62156. if (value == null) {
  62157. return value === undefined ? undefinedTag : nullTag;
  62158. }
  62159. return (symToStringTag && symToStringTag in Object(value))
  62160. ? getRawTag(value)
  62161. : objectToString(value);
  62162. }
  62163. module.exports = baseGetTag;
  62164. /***/ }),
  62165. /***/ 7561:
  62166. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62167. var trimmedEndIndex = __webpack_require__(7990);
  62168. /** Used to match leading whitespace. */
  62169. var reTrimStart = /^\s+/;
  62170. /**
  62171. * The base implementation of `_.trim`.
  62172. *
  62173. * @private
  62174. * @param {string} string The string to trim.
  62175. * @returns {string} Returns the trimmed string.
  62176. */
  62177. function baseTrim(string) {
  62178. return string
  62179. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  62180. : string;
  62181. }
  62182. module.exports = baseTrim;
  62183. /***/ }),
  62184. /***/ 1957:
  62185. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62186. /** Detect free variable `global` from Node.js. */
  62187. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  62188. module.exports = freeGlobal;
  62189. /***/ }),
  62190. /***/ 9607:
  62191. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62192. var Symbol = __webpack_require__(2705);
  62193. /** Used for built-in method references. */
  62194. var objectProto = Object.prototype;
  62195. /** Used to check objects for own properties. */
  62196. var hasOwnProperty = objectProto.hasOwnProperty;
  62197. /**
  62198. * Used to resolve the
  62199. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  62200. * of values.
  62201. */
  62202. var nativeObjectToString = objectProto.toString;
  62203. /** Built-in value references. */
  62204. var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  62205. /**
  62206. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  62207. *
  62208. * @private
  62209. * @param {*} value The value to query.
  62210. * @returns {string} Returns the raw `toStringTag`.
  62211. */
  62212. function getRawTag(value) {
  62213. var isOwn = hasOwnProperty.call(value, symToStringTag),
  62214. tag = value[symToStringTag];
  62215. try {
  62216. value[symToStringTag] = undefined;
  62217. var unmasked = true;
  62218. } catch (e) {}
  62219. var result = nativeObjectToString.call(value);
  62220. if (unmasked) {
  62221. if (isOwn) {
  62222. value[symToStringTag] = tag;
  62223. } else {
  62224. delete value[symToStringTag];
  62225. }
  62226. }
  62227. return result;
  62228. }
  62229. module.exports = getRawTag;
  62230. /***/ }),
  62231. /***/ 2333:
  62232. /***/ ((module) => {
  62233. /** Used for built-in method references. */
  62234. var objectProto = Object.prototype;
  62235. /**
  62236. * Used to resolve the
  62237. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  62238. * of values.
  62239. */
  62240. var nativeObjectToString = objectProto.toString;
  62241. /**
  62242. * Converts `value` to a string using `Object.prototype.toString`.
  62243. *
  62244. * @private
  62245. * @param {*} value The value to convert.
  62246. * @returns {string} Returns the converted string.
  62247. */
  62248. function objectToString(value) {
  62249. return nativeObjectToString.call(value);
  62250. }
  62251. module.exports = objectToString;
  62252. /***/ }),
  62253. /***/ 5639:
  62254. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62255. var freeGlobal = __webpack_require__(1957);
  62256. /** Detect free variable `self`. */
  62257. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  62258. /** Used as a reference to the global object. */
  62259. var root = freeGlobal || freeSelf || Function('return this')();
  62260. module.exports = root;
  62261. /***/ }),
  62262. /***/ 7990:
  62263. /***/ ((module) => {
  62264. /** Used to match a single whitespace character. */
  62265. var reWhitespace = /\s/;
  62266. /**
  62267. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  62268. * character of `string`.
  62269. *
  62270. * @private
  62271. * @param {string} string The string to inspect.
  62272. * @returns {number} Returns the index of the last non-whitespace character.
  62273. */
  62274. function trimmedEndIndex(string) {
  62275. var index = string.length;
  62276. while (index-- && reWhitespace.test(string.charAt(index))) {}
  62277. return index;
  62278. }
  62279. module.exports = trimmedEndIndex;
  62280. /***/ }),
  62281. /***/ 3279:
  62282. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62283. var isObject = __webpack_require__(3218),
  62284. now = __webpack_require__(7771),
  62285. toNumber = __webpack_require__(4841);
  62286. /** Error message constants. */
  62287. var FUNC_ERROR_TEXT = 'Expected a function';
  62288. /* Built-in method references for those with the same name as other `lodash` methods. */
  62289. var nativeMax = Math.max,
  62290. nativeMin = Math.min;
  62291. /**
  62292. * Creates a debounced function that delays invoking `func` until after `wait`
  62293. * milliseconds have elapsed since the last time the debounced function was
  62294. * invoked. The debounced function comes with a `cancel` method to cancel
  62295. * delayed `func` invocations and a `flush` method to immediately invoke them.
  62296. * Provide `options` to indicate whether `func` should be invoked on the
  62297. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  62298. * with the last arguments provided to the debounced function. Subsequent
  62299. * calls to the debounced function return the result of the last `func`
  62300. * invocation.
  62301. *
  62302. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  62303. * invoked on the trailing edge of the timeout only if the debounced function
  62304. * is invoked more than once during the `wait` timeout.
  62305. *
  62306. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  62307. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  62308. *
  62309. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  62310. * for details over the differences between `_.debounce` and `_.throttle`.
  62311. *
  62312. * @static
  62313. * @memberOf _
  62314. * @since 0.1.0
  62315. * @category Function
  62316. * @param {Function} func The function to debounce.
  62317. * @param {number} [wait=0] The number of milliseconds to delay.
  62318. * @param {Object} [options={}] The options object.
  62319. * @param {boolean} [options.leading=false]
  62320. * Specify invoking on the leading edge of the timeout.
  62321. * @param {number} [options.maxWait]
  62322. * The maximum time `func` is allowed to be delayed before it's invoked.
  62323. * @param {boolean} [options.trailing=true]
  62324. * Specify invoking on the trailing edge of the timeout.
  62325. * @returns {Function} Returns the new debounced function.
  62326. * @example
  62327. *
  62328. * // Avoid costly calculations while the window size is in flux.
  62329. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  62330. *
  62331. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  62332. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  62333. * 'leading': true,
  62334. * 'trailing': false
  62335. * }));
  62336. *
  62337. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  62338. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  62339. * var source = new EventSource('/stream');
  62340. * jQuery(source).on('message', debounced);
  62341. *
  62342. * // Cancel the trailing debounced invocation.
  62343. * jQuery(window).on('popstate', debounced.cancel);
  62344. */
  62345. function debounce(func, wait, options) {
  62346. var lastArgs,
  62347. lastThis,
  62348. maxWait,
  62349. result,
  62350. timerId,
  62351. lastCallTime,
  62352. lastInvokeTime = 0,
  62353. leading = false,
  62354. maxing = false,
  62355. trailing = true;
  62356. if (typeof func != 'function') {
  62357. throw new TypeError(FUNC_ERROR_TEXT);
  62358. }
  62359. wait = toNumber(wait) || 0;
  62360. if (isObject(options)) {
  62361. leading = !!options.leading;
  62362. maxing = 'maxWait' in options;
  62363. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  62364. trailing = 'trailing' in options ? !!options.trailing : trailing;
  62365. }
  62366. function invokeFunc(time) {
  62367. var args = lastArgs,
  62368. thisArg = lastThis;
  62369. lastArgs = lastThis = undefined;
  62370. lastInvokeTime = time;
  62371. result = func.apply(thisArg, args);
  62372. return result;
  62373. }
  62374. function leadingEdge(time) {
  62375. // Reset any `maxWait` timer.
  62376. lastInvokeTime = time;
  62377. // Start the timer for the trailing edge.
  62378. timerId = setTimeout(timerExpired, wait);
  62379. // Invoke the leading edge.
  62380. return leading ? invokeFunc(time) : result;
  62381. }
  62382. function remainingWait(time) {
  62383. var timeSinceLastCall = time - lastCallTime,
  62384. timeSinceLastInvoke = time - lastInvokeTime,
  62385. timeWaiting = wait - timeSinceLastCall;
  62386. return maxing
  62387. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  62388. : timeWaiting;
  62389. }
  62390. function shouldInvoke(time) {
  62391. var timeSinceLastCall = time - lastCallTime,
  62392. timeSinceLastInvoke = time - lastInvokeTime;
  62393. // Either this is the first call, activity has stopped and we're at the
  62394. // trailing edge, the system time has gone backwards and we're treating
  62395. // it as the trailing edge, or we've hit the `maxWait` limit.
  62396. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  62397. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  62398. }
  62399. function timerExpired() {
  62400. var time = now();
  62401. if (shouldInvoke(time)) {
  62402. return trailingEdge(time);
  62403. }
  62404. // Restart the timer.
  62405. timerId = setTimeout(timerExpired, remainingWait(time));
  62406. }
  62407. function trailingEdge(time) {
  62408. timerId = undefined;
  62409. // Only invoke if we have `lastArgs` which means `func` has been
  62410. // debounced at least once.
  62411. if (trailing && lastArgs) {
  62412. return invokeFunc(time);
  62413. }
  62414. lastArgs = lastThis = undefined;
  62415. return result;
  62416. }
  62417. function cancel() {
  62418. if (timerId !== undefined) {
  62419. clearTimeout(timerId);
  62420. }
  62421. lastInvokeTime = 0;
  62422. lastArgs = lastCallTime = lastThis = timerId = undefined;
  62423. }
  62424. function flush() {
  62425. return timerId === undefined ? result : trailingEdge(now());
  62426. }
  62427. function debounced() {
  62428. var time = now(),
  62429. isInvoking = shouldInvoke(time);
  62430. lastArgs = arguments;
  62431. lastThis = this;
  62432. lastCallTime = time;
  62433. if (isInvoking) {
  62434. if (timerId === undefined) {
  62435. return leadingEdge(lastCallTime);
  62436. }
  62437. if (maxing) {
  62438. // Handle invocations in a tight loop.
  62439. clearTimeout(timerId);
  62440. timerId = setTimeout(timerExpired, wait);
  62441. return invokeFunc(lastCallTime);
  62442. }
  62443. }
  62444. if (timerId === undefined) {
  62445. timerId = setTimeout(timerExpired, wait);
  62446. }
  62447. return result;
  62448. }
  62449. debounced.cancel = cancel;
  62450. debounced.flush = flush;
  62451. return debounced;
  62452. }
  62453. module.exports = debounce;
  62454. /***/ }),
  62455. /***/ 3218:
  62456. /***/ ((module) => {
  62457. /**
  62458. * Checks if `value` is the
  62459. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  62460. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  62461. *
  62462. * @static
  62463. * @memberOf _
  62464. * @since 0.1.0
  62465. * @category Lang
  62466. * @param {*} value The value to check.
  62467. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  62468. * @example
  62469. *
  62470. * _.isObject({});
  62471. * // => true
  62472. *
  62473. * _.isObject([1, 2, 3]);
  62474. * // => true
  62475. *
  62476. * _.isObject(_.noop);
  62477. * // => true
  62478. *
  62479. * _.isObject(null);
  62480. * // => false
  62481. */
  62482. function isObject(value) {
  62483. var type = typeof value;
  62484. return value != null && (type == 'object' || type == 'function');
  62485. }
  62486. module.exports = isObject;
  62487. /***/ }),
  62488. /***/ 7005:
  62489. /***/ ((module) => {
  62490. /**
  62491. * Checks if `value` is object-like. A value is object-like if it's not `null`
  62492. * and has a `typeof` result of "object".
  62493. *
  62494. * @static
  62495. * @memberOf _
  62496. * @since 4.0.0
  62497. * @category Lang
  62498. * @param {*} value The value to check.
  62499. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  62500. * @example
  62501. *
  62502. * _.isObjectLike({});
  62503. * // => true
  62504. *
  62505. * _.isObjectLike([1, 2, 3]);
  62506. * // => true
  62507. *
  62508. * _.isObjectLike(_.noop);
  62509. * // => false
  62510. *
  62511. * _.isObjectLike(null);
  62512. * // => false
  62513. */
  62514. function isObjectLike(value) {
  62515. return value != null && typeof value == 'object';
  62516. }
  62517. module.exports = isObjectLike;
  62518. /***/ }),
  62519. /***/ 3448:
  62520. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62521. var baseGetTag = __webpack_require__(4239),
  62522. isObjectLike = __webpack_require__(7005);
  62523. /** `Object#toString` result references. */
  62524. var symbolTag = '[object Symbol]';
  62525. /**
  62526. * Checks if `value` is classified as a `Symbol` primitive or object.
  62527. *
  62528. * @static
  62529. * @memberOf _
  62530. * @since 4.0.0
  62531. * @category Lang
  62532. * @param {*} value The value to check.
  62533. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  62534. * @example
  62535. *
  62536. * _.isSymbol(Symbol.iterator);
  62537. * // => true
  62538. *
  62539. * _.isSymbol('abc');
  62540. * // => false
  62541. */
  62542. function isSymbol(value) {
  62543. return typeof value == 'symbol' ||
  62544. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  62545. }
  62546. module.exports = isSymbol;
  62547. /***/ }),
  62548. /***/ 7771:
  62549. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62550. var root = __webpack_require__(5639);
  62551. /**
  62552. * Gets the timestamp of the number of milliseconds that have elapsed since
  62553. * the Unix epoch (1 January 1970 00:00:00 UTC).
  62554. *
  62555. * @static
  62556. * @memberOf _
  62557. * @since 2.4.0
  62558. * @category Date
  62559. * @returns {number} Returns the timestamp.
  62560. * @example
  62561. *
  62562. * _.defer(function(stamp) {
  62563. * console.log(_.now() - stamp);
  62564. * }, _.now());
  62565. * // => Logs the number of milliseconds it took for the deferred invocation.
  62566. */
  62567. var now = function() {
  62568. return root.Date.now();
  62569. };
  62570. module.exports = now;
  62571. /***/ }),
  62572. /***/ 4841:
  62573. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  62574. var baseTrim = __webpack_require__(7561),
  62575. isObject = __webpack_require__(3218),
  62576. isSymbol = __webpack_require__(3448);
  62577. /** Used as references for various `Number` constants. */
  62578. var NAN = 0 / 0;
  62579. /** Used to detect bad signed hexadecimal string values. */
  62580. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  62581. /** Used to detect binary string values. */
  62582. var reIsBinary = /^0b[01]+$/i;
  62583. /** Used to detect octal string values. */
  62584. var reIsOctal = /^0o[0-7]+$/i;
  62585. /** Built-in method references without a dependency on `root`. */
  62586. var freeParseInt = parseInt;
  62587. /**
  62588. * Converts `value` to a number.
  62589. *
  62590. * @static
  62591. * @memberOf _
  62592. * @since 4.0.0
  62593. * @category Lang
  62594. * @param {*} value The value to process.
  62595. * @returns {number} Returns the number.
  62596. * @example
  62597. *
  62598. * _.toNumber(3.2);
  62599. * // => 3.2
  62600. *
  62601. * _.toNumber(Number.MIN_VALUE);
  62602. * // => 5e-324
  62603. *
  62604. * _.toNumber(Infinity);
  62605. * // => Infinity
  62606. *
  62607. * _.toNumber('3.2');
  62608. * // => 3.2
  62609. */
  62610. function toNumber(value) {
  62611. if (typeof value == 'number') {
  62612. return value;
  62613. }
  62614. if (isSymbol(value)) {
  62615. return NAN;
  62616. }
  62617. if (isObject(value)) {
  62618. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  62619. value = isObject(other) ? (other + '') : other;
  62620. }
  62621. if (typeof value != 'string') {
  62622. return value === 0 ? value : +value;
  62623. }
  62624. value = baseTrim(value);
  62625. var isBinary = reIsBinary.test(value);
  62626. return (isBinary || reIsOctal.test(value))
  62627. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  62628. : (reIsBadHex.test(value) ? NAN : +value);
  62629. }
  62630. module.exports = toNumber;
  62631. /***/ }),
  62632. /***/ 1271:
  62633. /***/ ((module, exports, __webpack_require__) => {
  62634. var __WEBPACK_AMD_DEFINE_RESULT__;/*!
  62635. * Sizzle CSS Selector Engine v2.3.6
  62636. * https://sizzlejs.com/
  62637. *
  62638. * Copyright JS Foundation and other contributors
  62639. * Released under the MIT license
  62640. * https://js.foundation/
  62641. *
  62642. * Date: 2021-02-16
  62643. */
  62644. ( function( window ) {
  62645. var i,
  62646. support,
  62647. Expr,
  62648. getText,
  62649. isXML,
  62650. tokenize,
  62651. compile,
  62652. select,
  62653. outermostContext,
  62654. sortInput,
  62655. hasDuplicate,
  62656. // Local document vars
  62657. setDocument,
  62658. document,
  62659. docElem,
  62660. documentIsHTML,
  62661. rbuggyQSA,
  62662. rbuggyMatches,
  62663. matches,
  62664. contains,
  62665. // Instance-specific data
  62666. expando = "sizzle" + 1 * new Date(),
  62667. preferredDoc = window.document,
  62668. dirruns = 0,
  62669. done = 0,
  62670. classCache = createCache(),
  62671. tokenCache = createCache(),
  62672. compilerCache = createCache(),
  62673. nonnativeSelectorCache = createCache(),
  62674. sortOrder = function( a, b ) {
  62675. if ( a === b ) {
  62676. hasDuplicate = true;
  62677. }
  62678. return 0;
  62679. },
  62680. // Instance methods
  62681. hasOwn = ( {} ).hasOwnProperty,
  62682. arr = [],
  62683. pop = arr.pop,
  62684. pushNative = arr.push,
  62685. push = arr.push,
  62686. slice = arr.slice,
  62687. // Use a stripped-down indexOf as it's faster than native
  62688. // https://jsperf.com/thor-indexof-vs-for/5
  62689. indexOf = function( list, elem ) {
  62690. var i = 0,
  62691. len = list.length;
  62692. for ( ; i < len; i++ ) {
  62693. if ( list[ i ] === elem ) {
  62694. return i;
  62695. }
  62696. }
  62697. return -1;
  62698. },
  62699. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
  62700. "ismap|loop|multiple|open|readonly|required|scoped",
  62701. // Regular expressions
  62702. // http://www.w3.org/TR/css3-selectors/#whitespace
  62703. whitespace = "[\\x20\\t\\r\\n\\f]",
  62704. // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
  62705. identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
  62706. "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
  62707. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  62708. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  62709. // Operator (capture 2)
  62710. "*([*^$|!~]?=)" + whitespace +
  62711. // "Attribute values must be CSS identifiers [capture 5]
  62712. // or strings [capture 3 or capture 4]"
  62713. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
  62714. whitespace + "*\\]",
  62715. pseudos = ":(" + identifier + ")(?:\\((" +
  62716. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  62717. // 1. quoted (capture 3; capture 4 or capture 5)
  62718. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  62719. // 2. simple (capture 6)
  62720. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  62721. // 3. anything else (capture 2)
  62722. ".*" +
  62723. ")\\)|)",
  62724. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  62725. rwhitespace = new RegExp( whitespace + "+", "g" ),
  62726. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
  62727. whitespace + "+$", "g" ),
  62728. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  62729. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
  62730. "*" ),
  62731. rdescend = new RegExp( whitespace + "|>" ),
  62732. rpseudo = new RegExp( pseudos ),
  62733. ridentifier = new RegExp( "^" + identifier + "$" ),
  62734. matchExpr = {
  62735. "ID": new RegExp( "^#(" + identifier + ")" ),
  62736. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  62737. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  62738. "ATTR": new RegExp( "^" + attributes ),
  62739. "PSEUDO": new RegExp( "^" + pseudos ),
  62740. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
  62741. whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
  62742. whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  62743. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  62744. // For use in libraries implementing .is()
  62745. // We use this for POS matching in `select`
  62746. "needsContext": new RegExp( "^" + whitespace +
  62747. "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  62748. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  62749. },
  62750. rhtml = /HTML$/i,
  62751. rinputs = /^(?:input|select|textarea|button)$/i,
  62752. rheader = /^h\d$/i,
  62753. rnative = /^[^{]+\{\s*\[native \w/,
  62754. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  62755. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  62756. rsibling = /[+~]/,
  62757. // CSS escapes
  62758. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  62759. runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
  62760. funescape = function( escape, nonHex ) {
  62761. var high = "0x" + escape.slice( 1 ) - 0x10000;
  62762. return nonHex ?
  62763. // Strip the backslash prefix from a non-hex escape sequence
  62764. nonHex :
  62765. // Replace a hexadecimal escape sequence with the encoded Unicode code point
  62766. // Support: IE <=11+
  62767. // For values outside the Basic Multilingual Plane (BMP), manually construct a
  62768. // surrogate pair
  62769. high < 0 ?
  62770. String.fromCharCode( high + 0x10000 ) :
  62771. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  62772. },
  62773. // CSS string/identifier serialization
  62774. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  62775. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  62776. fcssescape = function( ch, asCodePoint ) {
  62777. if ( asCodePoint ) {
  62778. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  62779. if ( ch === "\0" ) {
  62780. return "\uFFFD";
  62781. }
  62782. // Control characters and (dependent upon position) numbers get escaped as code points
  62783. return ch.slice( 0, -1 ) + "\\" +
  62784. ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  62785. }
  62786. // Other potentially-special ASCII characters get backslash-escaped
  62787. return "\\" + ch;
  62788. },
  62789. // Used for iframes
  62790. // See setDocument()
  62791. // Removing the function wrapper causes a "Permission Denied"
  62792. // error in IE
  62793. unloadHandler = function() {
  62794. setDocument();
  62795. },
  62796. inDisabledFieldset = addCombinator(
  62797. function( elem ) {
  62798. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  62799. },
  62800. { dir: "parentNode", next: "legend" }
  62801. );
  62802. // Optimize for push.apply( _, NodeList )
  62803. try {
  62804. push.apply(
  62805. ( arr = slice.call( preferredDoc.childNodes ) ),
  62806. preferredDoc.childNodes
  62807. );
  62808. // Support: Android<4.0
  62809. // Detect silently failing push.apply
  62810. // eslint-disable-next-line no-unused-expressions
  62811. arr[ preferredDoc.childNodes.length ].nodeType;
  62812. } catch ( e ) {
  62813. push = { apply: arr.length ?
  62814. // Leverage slice if possible
  62815. function( target, els ) {
  62816. pushNative.apply( target, slice.call( els ) );
  62817. } :
  62818. // Support: IE<9
  62819. // Otherwise append directly
  62820. function( target, els ) {
  62821. var j = target.length,
  62822. i = 0;
  62823. // Can't trust NodeList.length
  62824. while ( ( target[ j++ ] = els[ i++ ] ) ) {}
  62825. target.length = j - 1;
  62826. }
  62827. };
  62828. }
  62829. function Sizzle( selector, context, results, seed ) {
  62830. var m, i, elem, nid, match, groups, newSelector,
  62831. newContext = context && context.ownerDocument,
  62832. // nodeType defaults to 9, since context defaults to document
  62833. nodeType = context ? context.nodeType : 9;
  62834. results = results || [];
  62835. // Return early from calls with invalid selector or context
  62836. if ( typeof selector !== "string" || !selector ||
  62837. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  62838. return results;
  62839. }
  62840. // Try to shortcut find operations (as opposed to filters) in HTML documents
  62841. if ( !seed ) {
  62842. setDocument( context );
  62843. context = context || document;
  62844. if ( documentIsHTML ) {
  62845. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  62846. // (excepting DocumentFragment context, where the methods don't exist)
  62847. if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
  62848. // ID selector
  62849. if ( ( m = match[ 1 ] ) ) {
  62850. // Document context
  62851. if ( nodeType === 9 ) {
  62852. if ( ( elem = context.getElementById( m ) ) ) {
  62853. // Support: IE, Opera, Webkit
  62854. // TODO: identify versions
  62855. // getElementById can match elements by name instead of ID
  62856. if ( elem.id === m ) {
  62857. results.push( elem );
  62858. return results;
  62859. }
  62860. } else {
  62861. return results;
  62862. }
  62863. // Element context
  62864. } else {
  62865. // Support: IE, Opera, Webkit
  62866. // TODO: identify versions
  62867. // getElementById can match elements by name instead of ID
  62868. if ( newContext && ( elem = newContext.getElementById( m ) ) &&
  62869. contains( context, elem ) &&
  62870. elem.id === m ) {
  62871. results.push( elem );
  62872. return results;
  62873. }
  62874. }
  62875. // Type selector
  62876. } else if ( match[ 2 ] ) {
  62877. push.apply( results, context.getElementsByTagName( selector ) );
  62878. return results;
  62879. // Class selector
  62880. } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
  62881. context.getElementsByClassName ) {
  62882. push.apply( results, context.getElementsByClassName( m ) );
  62883. return results;
  62884. }
  62885. }
  62886. // Take advantage of querySelectorAll
  62887. if ( support.qsa &&
  62888. !nonnativeSelectorCache[ selector + " " ] &&
  62889. ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
  62890. // Support: IE 8 only
  62891. // Exclude object elements
  62892. ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
  62893. newSelector = selector;
  62894. newContext = context;
  62895. // qSA considers elements outside a scoping root when evaluating child or
  62896. // descendant combinators, which is not what we want.
  62897. // In such cases, we work around the behavior by prefixing every selector in the
  62898. // list with an ID selector referencing the scope context.
  62899. // The technique has to be used as well when a leading combinator is used
  62900. // as such selectors are not recognized by querySelectorAll.
  62901. // Thanks to Andrew Dupont for this technique.
  62902. if ( nodeType === 1 &&
  62903. ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
  62904. // Expand context for sibling selectors
  62905. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  62906. context;
  62907. // We can use :scope instead of the ID hack if the browser
  62908. // supports it & if we're not changing the context.
  62909. if ( newContext !== context || !support.scope ) {
  62910. // Capture the context ID, setting it first if necessary
  62911. if ( ( nid = context.getAttribute( "id" ) ) ) {
  62912. nid = nid.replace( rcssescape, fcssescape );
  62913. } else {
  62914. context.setAttribute( "id", ( nid = expando ) );
  62915. }
  62916. }
  62917. // Prefix every selector in the list
  62918. groups = tokenize( selector );
  62919. i = groups.length;
  62920. while ( i-- ) {
  62921. groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
  62922. toSelector( groups[ i ] );
  62923. }
  62924. newSelector = groups.join( "," );
  62925. }
  62926. try {
  62927. push.apply( results,
  62928. newContext.querySelectorAll( newSelector )
  62929. );
  62930. return results;
  62931. } catch ( qsaError ) {
  62932. nonnativeSelectorCache( selector, true );
  62933. } finally {
  62934. if ( nid === expando ) {
  62935. context.removeAttribute( "id" );
  62936. }
  62937. }
  62938. }
  62939. }
  62940. }
  62941. // All others
  62942. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  62943. }
  62944. /**
  62945. * Create key-value caches of limited size
  62946. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  62947. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  62948. * deleting the oldest entry
  62949. */
  62950. function createCache() {
  62951. var keys = [];
  62952. function cache( key, value ) {
  62953. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  62954. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  62955. // Only keep the most recent entries
  62956. delete cache[ keys.shift() ];
  62957. }
  62958. return ( cache[ key + " " ] = value );
  62959. }
  62960. return cache;
  62961. }
  62962. /**
  62963. * Mark a function for special use by Sizzle
  62964. * @param {Function} fn The function to mark
  62965. */
  62966. function markFunction( fn ) {
  62967. fn[ expando ] = true;
  62968. return fn;
  62969. }
  62970. /**
  62971. * Support testing using an element
  62972. * @param {Function} fn Passed the created element and returns a boolean result
  62973. */
  62974. function assert( fn ) {
  62975. var el = document.createElement( "fieldset" );
  62976. try {
  62977. return !!fn( el );
  62978. } catch ( e ) {
  62979. return false;
  62980. } finally {
  62981. // Remove from its parent by default
  62982. if ( el.parentNode ) {
  62983. el.parentNode.removeChild( el );
  62984. }
  62985. // release memory in IE
  62986. el = null;
  62987. }
  62988. }
  62989. /**
  62990. * Adds the same handler for all of the specified attrs
  62991. * @param {String} attrs Pipe-separated list of attributes
  62992. * @param {Function} handler The method that will be applied
  62993. */
  62994. function addHandle( attrs, handler ) {
  62995. var arr = attrs.split( "|" ),
  62996. i = arr.length;
  62997. while ( i-- ) {
  62998. Expr.attrHandle[ arr[ i ] ] = handler;
  62999. }
  63000. }
  63001. /**
  63002. * Checks document order of two siblings
  63003. * @param {Element} a
  63004. * @param {Element} b
  63005. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  63006. */
  63007. function siblingCheck( a, b ) {
  63008. var cur = b && a,
  63009. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  63010. a.sourceIndex - b.sourceIndex;
  63011. // Use IE sourceIndex if available on both nodes
  63012. if ( diff ) {
  63013. return diff;
  63014. }
  63015. // Check if b follows a
  63016. if ( cur ) {
  63017. while ( ( cur = cur.nextSibling ) ) {
  63018. if ( cur === b ) {
  63019. return -1;
  63020. }
  63021. }
  63022. }
  63023. return a ? 1 : -1;
  63024. }
  63025. /**
  63026. * Returns a function to use in pseudos for input types
  63027. * @param {String} type
  63028. */
  63029. function createInputPseudo( type ) {
  63030. return function( elem ) {
  63031. var name = elem.nodeName.toLowerCase();
  63032. return name === "input" && elem.type === type;
  63033. };
  63034. }
  63035. /**
  63036. * Returns a function to use in pseudos for buttons
  63037. * @param {String} type
  63038. */
  63039. function createButtonPseudo( type ) {
  63040. return function( elem ) {
  63041. var name = elem.nodeName.toLowerCase();
  63042. return ( name === "input" || name === "button" ) && elem.type === type;
  63043. };
  63044. }
  63045. /**
  63046. * Returns a function to use in pseudos for :enabled/:disabled
  63047. * @param {Boolean} disabled true for :disabled; false for :enabled
  63048. */
  63049. function createDisabledPseudo( disabled ) {
  63050. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  63051. return function( elem ) {
  63052. // Only certain elements can match :enabled or :disabled
  63053. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  63054. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  63055. if ( "form" in elem ) {
  63056. // Check for inherited disabledness on relevant non-disabled elements:
  63057. // * listed form-associated elements in a disabled fieldset
  63058. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  63059. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  63060. // * option elements in a disabled optgroup
  63061. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  63062. // All such elements have a "form" property.
  63063. if ( elem.parentNode && elem.disabled === false ) {
  63064. // Option elements defer to a parent optgroup if present
  63065. if ( "label" in elem ) {
  63066. if ( "label" in elem.parentNode ) {
  63067. return elem.parentNode.disabled === disabled;
  63068. } else {
  63069. return elem.disabled === disabled;
  63070. }
  63071. }
  63072. // Support: IE 6 - 11
  63073. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  63074. return elem.isDisabled === disabled ||
  63075. // Where there is no isDisabled, check manually
  63076. /* jshint -W018 */
  63077. elem.isDisabled !== !disabled &&
  63078. inDisabledFieldset( elem ) === disabled;
  63079. }
  63080. return elem.disabled === disabled;
  63081. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  63082. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  63083. // even exist on them, let alone have a boolean value.
  63084. } else if ( "label" in elem ) {
  63085. return elem.disabled === disabled;
  63086. }
  63087. // Remaining elements are neither :enabled nor :disabled
  63088. return false;
  63089. };
  63090. }
  63091. /**
  63092. * Returns a function to use in pseudos for positionals
  63093. * @param {Function} fn
  63094. */
  63095. function createPositionalPseudo( fn ) {
  63096. return markFunction( function( argument ) {
  63097. argument = +argument;
  63098. return markFunction( function( seed, matches ) {
  63099. var j,
  63100. matchIndexes = fn( [], seed.length, argument ),
  63101. i = matchIndexes.length;
  63102. // Match elements found at the specified indexes
  63103. while ( i-- ) {
  63104. if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
  63105. seed[ j ] = !( matches[ j ] = seed[ j ] );
  63106. }
  63107. }
  63108. } );
  63109. } );
  63110. }
  63111. /**
  63112. * Checks a node for validity as a Sizzle context
  63113. * @param {Element|Object=} context
  63114. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  63115. */
  63116. function testContext( context ) {
  63117. return context && typeof context.getElementsByTagName !== "undefined" && context;
  63118. }
  63119. // Expose support vars for convenience
  63120. support = Sizzle.support = {};
  63121. /**
  63122. * Detects XML nodes
  63123. * @param {Element|Object} elem An element or a document
  63124. * @returns {Boolean} True iff elem is a non-HTML XML node
  63125. */
  63126. isXML = Sizzle.isXML = function( elem ) {
  63127. var namespace = elem && elem.namespaceURI,
  63128. docElem = elem && ( elem.ownerDocument || elem ).documentElement;
  63129. // Support: IE <=8
  63130. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  63131. // https://bugs.jquery.com/ticket/4833
  63132. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  63133. };
  63134. /**
  63135. * Sets document-related variables once based on the current document
  63136. * @param {Element|Object} [doc] An element or document object to use to set the document
  63137. * @returns {Object} Returns the current document
  63138. */
  63139. setDocument = Sizzle.setDocument = function( node ) {
  63140. var hasCompare, subWindow,
  63141. doc = node ? node.ownerDocument || node : preferredDoc;
  63142. // Return early if doc is invalid or already selected
  63143. // Support: IE 11+, Edge 17 - 18+
  63144. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63145. // two documents; shallow comparisons work.
  63146. // eslint-disable-next-line eqeqeq
  63147. if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
  63148. return document;
  63149. }
  63150. // Update global variables
  63151. document = doc;
  63152. docElem = document.documentElement;
  63153. documentIsHTML = !isXML( document );
  63154. // Support: IE 9 - 11+, Edge 12 - 18+
  63155. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  63156. // Support: IE 11+, Edge 17 - 18+
  63157. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63158. // two documents; shallow comparisons work.
  63159. // eslint-disable-next-line eqeqeq
  63160. if ( preferredDoc != document &&
  63161. ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
  63162. // Support: IE 11, Edge
  63163. if ( subWindow.addEventListener ) {
  63164. subWindow.addEventListener( "unload", unloadHandler, false );
  63165. // Support: IE 9 - 10 only
  63166. } else if ( subWindow.attachEvent ) {
  63167. subWindow.attachEvent( "onunload", unloadHandler );
  63168. }
  63169. }
  63170. // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
  63171. // Safari 4 - 5 only, Opera <=11.6 - 12.x only
  63172. // IE/Edge & older browsers don't support the :scope pseudo-class.
  63173. // Support: Safari 6.0 only
  63174. // Safari 6.0 supports :scope but it's an alias of :root there.
  63175. support.scope = assert( function( el ) {
  63176. docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
  63177. return typeof el.querySelectorAll !== "undefined" &&
  63178. !el.querySelectorAll( ":scope fieldset div" ).length;
  63179. } );
  63180. /* Attributes
  63181. ---------------------------------------------------------------------- */
  63182. // Support: IE<8
  63183. // Verify that getAttribute really returns attributes and not properties
  63184. // (excepting IE8 booleans)
  63185. support.attributes = assert( function( el ) {
  63186. el.className = "i";
  63187. return !el.getAttribute( "className" );
  63188. } );
  63189. /* getElement(s)By*
  63190. ---------------------------------------------------------------------- */
  63191. // Check if getElementsByTagName("*") returns only elements
  63192. support.getElementsByTagName = assert( function( el ) {
  63193. el.appendChild( document.createComment( "" ) );
  63194. return !el.getElementsByTagName( "*" ).length;
  63195. } );
  63196. // Support: IE<9
  63197. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  63198. // Support: IE<10
  63199. // Check if getElementById returns elements by name
  63200. // The broken getElementById methods don't pick up programmatically-set names,
  63201. // so use a roundabout getElementsByName test
  63202. support.getById = assert( function( el ) {
  63203. docElem.appendChild( el ).id = expando;
  63204. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  63205. } );
  63206. // ID filter and find
  63207. if ( support.getById ) {
  63208. Expr.filter[ "ID" ] = function( id ) {
  63209. var attrId = id.replace( runescape, funescape );
  63210. return function( elem ) {
  63211. return elem.getAttribute( "id" ) === attrId;
  63212. };
  63213. };
  63214. Expr.find[ "ID" ] = function( id, context ) {
  63215. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  63216. var elem = context.getElementById( id );
  63217. return elem ? [ elem ] : [];
  63218. }
  63219. };
  63220. } else {
  63221. Expr.filter[ "ID" ] = function( id ) {
  63222. var attrId = id.replace( runescape, funescape );
  63223. return function( elem ) {
  63224. var node = typeof elem.getAttributeNode !== "undefined" &&
  63225. elem.getAttributeNode( "id" );
  63226. return node && node.value === attrId;
  63227. };
  63228. };
  63229. // Support: IE 6 - 7 only
  63230. // getElementById is not reliable as a find shortcut
  63231. Expr.find[ "ID" ] = function( id, context ) {
  63232. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  63233. var node, i, elems,
  63234. elem = context.getElementById( id );
  63235. if ( elem ) {
  63236. // Verify the id attribute
  63237. node = elem.getAttributeNode( "id" );
  63238. if ( node && node.value === id ) {
  63239. return [ elem ];
  63240. }
  63241. // Fall back on getElementsByName
  63242. elems = context.getElementsByName( id );
  63243. i = 0;
  63244. while ( ( elem = elems[ i++ ] ) ) {
  63245. node = elem.getAttributeNode( "id" );
  63246. if ( node && node.value === id ) {
  63247. return [ elem ];
  63248. }
  63249. }
  63250. }
  63251. return [];
  63252. }
  63253. };
  63254. }
  63255. // Tag
  63256. Expr.find[ "TAG" ] = support.getElementsByTagName ?
  63257. function( tag, context ) {
  63258. if ( typeof context.getElementsByTagName !== "undefined" ) {
  63259. return context.getElementsByTagName( tag );
  63260. // DocumentFragment nodes don't have gEBTN
  63261. } else if ( support.qsa ) {
  63262. return context.querySelectorAll( tag );
  63263. }
  63264. } :
  63265. function( tag, context ) {
  63266. var elem,
  63267. tmp = [],
  63268. i = 0,
  63269. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  63270. results = context.getElementsByTagName( tag );
  63271. // Filter out possible comments
  63272. if ( tag === "*" ) {
  63273. while ( ( elem = results[ i++ ] ) ) {
  63274. if ( elem.nodeType === 1 ) {
  63275. tmp.push( elem );
  63276. }
  63277. }
  63278. return tmp;
  63279. }
  63280. return results;
  63281. };
  63282. // Class
  63283. Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
  63284. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  63285. return context.getElementsByClassName( className );
  63286. }
  63287. };
  63288. /* QSA/matchesSelector
  63289. ---------------------------------------------------------------------- */
  63290. // QSA and matchesSelector support
  63291. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  63292. rbuggyMatches = [];
  63293. // qSa(:focus) reports false when true (Chrome 21)
  63294. // We allow this because of a bug in IE8/9 that throws an error
  63295. // whenever `document.activeElement` is accessed on an iframe
  63296. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  63297. // See https://bugs.jquery.com/ticket/13378
  63298. rbuggyQSA = [];
  63299. if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
  63300. // Build QSA regex
  63301. // Regex strategy adopted from Diego Perini
  63302. assert( function( el ) {
  63303. var input;
  63304. // Select is set to empty string on purpose
  63305. // This is to test IE's treatment of not explicitly
  63306. // setting a boolean content attribute,
  63307. // since its presence should be enough
  63308. // https://bugs.jquery.com/ticket/12359
  63309. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  63310. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  63311. "<option selected=''></option></select>";
  63312. // Support: IE8, Opera 11-12.16
  63313. // Nothing should be selected when empty strings follow ^= or $= or *=
  63314. // The test attribute must be unknown in Opera but "safe" for WinRT
  63315. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  63316. if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
  63317. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  63318. }
  63319. // Support: IE8
  63320. // Boolean attributes and "value" are not treated correctly
  63321. if ( !el.querySelectorAll( "[selected]" ).length ) {
  63322. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  63323. }
  63324. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  63325. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  63326. rbuggyQSA.push( "~=" );
  63327. }
  63328. // Support: IE 11+, Edge 15 - 18+
  63329. // IE 11/Edge don't find elements on a `[name='']` query in some cases.
  63330. // Adding a temporary attribute to the document before the selection works
  63331. // around the issue.
  63332. // Interestingly, IE 10 & older don't seem to have the issue.
  63333. input = document.createElement( "input" );
  63334. input.setAttribute( "name", "" );
  63335. el.appendChild( input );
  63336. if ( !el.querySelectorAll( "[name='']" ).length ) {
  63337. rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
  63338. whitespace + "*(?:''|\"\")" );
  63339. }
  63340. // Webkit/Opera - :checked should return selected option elements
  63341. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  63342. // IE8 throws error here and will not see later tests
  63343. if ( !el.querySelectorAll( ":checked" ).length ) {
  63344. rbuggyQSA.push( ":checked" );
  63345. }
  63346. // Support: Safari 8+, iOS 8+
  63347. // https://bugs.webkit.org/show_bug.cgi?id=136851
  63348. // In-page `selector#id sibling-combinator selector` fails
  63349. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  63350. rbuggyQSA.push( ".#.+[+~]" );
  63351. }
  63352. // Support: Firefox <=3.6 - 5 only
  63353. // Old Firefox doesn't throw on a badly-escaped identifier.
  63354. el.querySelectorAll( "\\\f" );
  63355. rbuggyQSA.push( "[\\r\\n\\f]" );
  63356. } );
  63357. assert( function( el ) {
  63358. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  63359. "<select disabled='disabled'><option/></select>";
  63360. // Support: Windows 8 Native Apps
  63361. // The type and name attributes are restricted during .innerHTML assignment
  63362. var input = document.createElement( "input" );
  63363. input.setAttribute( "type", "hidden" );
  63364. el.appendChild( input ).setAttribute( "name", "D" );
  63365. // Support: IE8
  63366. // Enforce case-sensitivity of name attribute
  63367. if ( el.querySelectorAll( "[name=d]" ).length ) {
  63368. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  63369. }
  63370. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  63371. // IE8 throws error here and will not see later tests
  63372. if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
  63373. rbuggyQSA.push( ":enabled", ":disabled" );
  63374. }
  63375. // Support: IE9-11+
  63376. // IE's :disabled selector does not pick up the children of disabled fieldsets
  63377. docElem.appendChild( el ).disabled = true;
  63378. if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
  63379. rbuggyQSA.push( ":enabled", ":disabled" );
  63380. }
  63381. // Support: Opera 10 - 11 only
  63382. // Opera 10-11 does not throw on post-comma invalid pseudos
  63383. el.querySelectorAll( "*,:x" );
  63384. rbuggyQSA.push( ",.*:" );
  63385. } );
  63386. }
  63387. if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
  63388. docElem.webkitMatchesSelector ||
  63389. docElem.mozMatchesSelector ||
  63390. docElem.oMatchesSelector ||
  63391. docElem.msMatchesSelector ) ) ) ) {
  63392. assert( function( el ) {
  63393. // Check to see if it's possible to do matchesSelector
  63394. // on a disconnected node (IE 9)
  63395. support.disconnectedMatch = matches.call( el, "*" );
  63396. // This should fail with an exception
  63397. // Gecko does not error, returns false instead
  63398. matches.call( el, "[s!='']:x" );
  63399. rbuggyMatches.push( "!=", pseudos );
  63400. } );
  63401. }
  63402. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
  63403. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
  63404. /* Contains
  63405. ---------------------------------------------------------------------- */
  63406. hasCompare = rnative.test( docElem.compareDocumentPosition );
  63407. // Element contains another
  63408. // Purposefully self-exclusive
  63409. // As in, an element does not contain itself
  63410. contains = hasCompare || rnative.test( docElem.contains ) ?
  63411. function( a, b ) {
  63412. var adown = a.nodeType === 9 ? a.documentElement : a,
  63413. bup = b && b.parentNode;
  63414. return a === bup || !!( bup && bup.nodeType === 1 && (
  63415. adown.contains ?
  63416. adown.contains( bup ) :
  63417. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  63418. ) );
  63419. } :
  63420. function( a, b ) {
  63421. if ( b ) {
  63422. while ( ( b = b.parentNode ) ) {
  63423. if ( b === a ) {
  63424. return true;
  63425. }
  63426. }
  63427. }
  63428. return false;
  63429. };
  63430. /* Sorting
  63431. ---------------------------------------------------------------------- */
  63432. // Document order sorting
  63433. sortOrder = hasCompare ?
  63434. function( a, b ) {
  63435. // Flag for duplicate removal
  63436. if ( a === b ) {
  63437. hasDuplicate = true;
  63438. return 0;
  63439. }
  63440. // Sort on method existence if only one input has compareDocumentPosition
  63441. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  63442. if ( compare ) {
  63443. return compare;
  63444. }
  63445. // Calculate position if both inputs belong to the same document
  63446. // Support: IE 11+, Edge 17 - 18+
  63447. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63448. // two documents; shallow comparisons work.
  63449. // eslint-disable-next-line eqeqeq
  63450. compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
  63451. a.compareDocumentPosition( b ) :
  63452. // Otherwise we know they are disconnected
  63453. 1;
  63454. // Disconnected nodes
  63455. if ( compare & 1 ||
  63456. ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
  63457. // Choose the first element that is related to our preferred document
  63458. // Support: IE 11+, Edge 17 - 18+
  63459. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63460. // two documents; shallow comparisons work.
  63461. // eslint-disable-next-line eqeqeq
  63462. if ( a == document || a.ownerDocument == preferredDoc &&
  63463. contains( preferredDoc, a ) ) {
  63464. return -1;
  63465. }
  63466. // Support: IE 11+, Edge 17 - 18+
  63467. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63468. // two documents; shallow comparisons work.
  63469. // eslint-disable-next-line eqeqeq
  63470. if ( b == document || b.ownerDocument == preferredDoc &&
  63471. contains( preferredDoc, b ) ) {
  63472. return 1;
  63473. }
  63474. // Maintain original order
  63475. return sortInput ?
  63476. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  63477. 0;
  63478. }
  63479. return compare & 4 ? -1 : 1;
  63480. } :
  63481. function( a, b ) {
  63482. // Exit early if the nodes are identical
  63483. if ( a === b ) {
  63484. hasDuplicate = true;
  63485. return 0;
  63486. }
  63487. var cur,
  63488. i = 0,
  63489. aup = a.parentNode,
  63490. bup = b.parentNode,
  63491. ap = [ a ],
  63492. bp = [ b ];
  63493. // Parentless nodes are either documents or disconnected
  63494. if ( !aup || !bup ) {
  63495. // Support: IE 11+, Edge 17 - 18+
  63496. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63497. // two documents; shallow comparisons work.
  63498. /* eslint-disable eqeqeq */
  63499. return a == document ? -1 :
  63500. b == document ? 1 :
  63501. /* eslint-enable eqeqeq */
  63502. aup ? -1 :
  63503. bup ? 1 :
  63504. sortInput ?
  63505. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  63506. 0;
  63507. // If the nodes are siblings, we can do a quick check
  63508. } else if ( aup === bup ) {
  63509. return siblingCheck( a, b );
  63510. }
  63511. // Otherwise we need full lists of their ancestors for comparison
  63512. cur = a;
  63513. while ( ( cur = cur.parentNode ) ) {
  63514. ap.unshift( cur );
  63515. }
  63516. cur = b;
  63517. while ( ( cur = cur.parentNode ) ) {
  63518. bp.unshift( cur );
  63519. }
  63520. // Walk down the tree looking for a discrepancy
  63521. while ( ap[ i ] === bp[ i ] ) {
  63522. i++;
  63523. }
  63524. return i ?
  63525. // Do a sibling check if the nodes have a common ancestor
  63526. siblingCheck( ap[ i ], bp[ i ] ) :
  63527. // Otherwise nodes in our document sort first
  63528. // Support: IE 11+, Edge 17 - 18+
  63529. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63530. // two documents; shallow comparisons work.
  63531. /* eslint-disable eqeqeq */
  63532. ap[ i ] == preferredDoc ? -1 :
  63533. bp[ i ] == preferredDoc ? 1 :
  63534. /* eslint-enable eqeqeq */
  63535. 0;
  63536. };
  63537. return document;
  63538. };
  63539. Sizzle.matches = function( expr, elements ) {
  63540. return Sizzle( expr, null, null, elements );
  63541. };
  63542. Sizzle.matchesSelector = function( elem, expr ) {
  63543. setDocument( elem );
  63544. if ( support.matchesSelector && documentIsHTML &&
  63545. !nonnativeSelectorCache[ expr + " " ] &&
  63546. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  63547. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  63548. try {
  63549. var ret = matches.call( elem, expr );
  63550. // IE 9's matchesSelector returns false on disconnected nodes
  63551. if ( ret || support.disconnectedMatch ||
  63552. // As well, disconnected nodes are said to be in a document
  63553. // fragment in IE 9
  63554. elem.document && elem.document.nodeType !== 11 ) {
  63555. return ret;
  63556. }
  63557. } catch ( e ) {
  63558. nonnativeSelectorCache( expr, true );
  63559. }
  63560. }
  63561. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  63562. };
  63563. Sizzle.contains = function( context, elem ) {
  63564. // Set document vars if needed
  63565. // Support: IE 11+, Edge 17 - 18+
  63566. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63567. // two documents; shallow comparisons work.
  63568. // eslint-disable-next-line eqeqeq
  63569. if ( ( context.ownerDocument || context ) != document ) {
  63570. setDocument( context );
  63571. }
  63572. return contains( context, elem );
  63573. };
  63574. Sizzle.attr = function( elem, name ) {
  63575. // Set document vars if needed
  63576. // Support: IE 11+, Edge 17 - 18+
  63577. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  63578. // two documents; shallow comparisons work.
  63579. // eslint-disable-next-line eqeqeq
  63580. if ( ( elem.ownerDocument || elem ) != document ) {
  63581. setDocument( elem );
  63582. }
  63583. var fn = Expr.attrHandle[ name.toLowerCase() ],
  63584. // Don't get fooled by Object.prototype properties (jQuery #13807)
  63585. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  63586. fn( elem, name, !documentIsHTML ) :
  63587. undefined;
  63588. return val !== undefined ?
  63589. val :
  63590. support.attributes || !documentIsHTML ?
  63591. elem.getAttribute( name ) :
  63592. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  63593. val.value :
  63594. null;
  63595. };
  63596. Sizzle.escape = function( sel ) {
  63597. return ( sel + "" ).replace( rcssescape, fcssescape );
  63598. };
  63599. Sizzle.error = function( msg ) {
  63600. throw new Error( "Syntax error, unrecognized expression: " + msg );
  63601. };
  63602. /**
  63603. * Document sorting and removing duplicates
  63604. * @param {ArrayLike} results
  63605. */
  63606. Sizzle.uniqueSort = function( results ) {
  63607. var elem,
  63608. duplicates = [],
  63609. j = 0,
  63610. i = 0;
  63611. // Unless we *know* we can detect duplicates, assume their presence
  63612. hasDuplicate = !support.detectDuplicates;
  63613. sortInput = !support.sortStable && results.slice( 0 );
  63614. results.sort( sortOrder );
  63615. if ( hasDuplicate ) {
  63616. while ( ( elem = results[ i++ ] ) ) {
  63617. if ( elem === results[ i ] ) {
  63618. j = duplicates.push( i );
  63619. }
  63620. }
  63621. while ( j-- ) {
  63622. results.splice( duplicates[ j ], 1 );
  63623. }
  63624. }
  63625. // Clear input after sorting to release objects
  63626. // See https://github.com/jquery/sizzle/pull/225
  63627. sortInput = null;
  63628. return results;
  63629. };
  63630. /**
  63631. * Utility function for retrieving the text value of an array of DOM nodes
  63632. * @param {Array|Element} elem
  63633. */
  63634. getText = Sizzle.getText = function( elem ) {
  63635. var node,
  63636. ret = "",
  63637. i = 0,
  63638. nodeType = elem.nodeType;
  63639. if ( !nodeType ) {
  63640. // If no nodeType, this is expected to be an array
  63641. while ( ( node = elem[ i++ ] ) ) {
  63642. // Do not traverse comment nodes
  63643. ret += getText( node );
  63644. }
  63645. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  63646. // Use textContent for elements
  63647. // innerText usage removed for consistency of new lines (jQuery #11153)
  63648. if ( typeof elem.textContent === "string" ) {
  63649. return elem.textContent;
  63650. } else {
  63651. // Traverse its children
  63652. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  63653. ret += getText( elem );
  63654. }
  63655. }
  63656. } else if ( nodeType === 3 || nodeType === 4 ) {
  63657. return elem.nodeValue;
  63658. }
  63659. // Do not include comment or processing instruction nodes
  63660. return ret;
  63661. };
  63662. Expr = Sizzle.selectors = {
  63663. // Can be adjusted by the user
  63664. cacheLength: 50,
  63665. createPseudo: markFunction,
  63666. match: matchExpr,
  63667. attrHandle: {},
  63668. find: {},
  63669. relative: {
  63670. ">": { dir: "parentNode", first: true },
  63671. " ": { dir: "parentNode" },
  63672. "+": { dir: "previousSibling", first: true },
  63673. "~": { dir: "previousSibling" }
  63674. },
  63675. preFilter: {
  63676. "ATTR": function( match ) {
  63677. match[ 1 ] = match[ 1 ].replace( runescape, funescape );
  63678. // Move the given value to match[3] whether quoted or unquoted
  63679. match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
  63680. match[ 5 ] || "" ).replace( runescape, funescape );
  63681. if ( match[ 2 ] === "~=" ) {
  63682. match[ 3 ] = " " + match[ 3 ] + " ";
  63683. }
  63684. return match.slice( 0, 4 );
  63685. },
  63686. "CHILD": function( match ) {
  63687. /* matches from matchExpr["CHILD"]
  63688. 1 type (only|nth|...)
  63689. 2 what (child|of-type)
  63690. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  63691. 4 xn-component of xn+y argument ([+-]?\d*n|)
  63692. 5 sign of xn-component
  63693. 6 x of xn-component
  63694. 7 sign of y-component
  63695. 8 y of y-component
  63696. */
  63697. match[ 1 ] = match[ 1 ].toLowerCase();
  63698. if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
  63699. // nth-* requires argument
  63700. if ( !match[ 3 ] ) {
  63701. Sizzle.error( match[ 0 ] );
  63702. }
  63703. // numeric x and y parameters for Expr.filter.CHILD
  63704. // remember that false/true cast respectively to 0/1
  63705. match[ 4 ] = +( match[ 4 ] ?
  63706. match[ 5 ] + ( match[ 6 ] || 1 ) :
  63707. 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
  63708. match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
  63709. // other types prohibit arguments
  63710. } else if ( match[ 3 ] ) {
  63711. Sizzle.error( match[ 0 ] );
  63712. }
  63713. return match;
  63714. },
  63715. "PSEUDO": function( match ) {
  63716. var excess,
  63717. unquoted = !match[ 6 ] && match[ 2 ];
  63718. if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
  63719. return null;
  63720. }
  63721. // Accept quoted arguments as-is
  63722. if ( match[ 3 ] ) {
  63723. match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
  63724. // Strip excess characters from unquoted arguments
  63725. } else if ( unquoted && rpseudo.test( unquoted ) &&
  63726. // Get excess from tokenize (recursively)
  63727. ( excess = tokenize( unquoted, true ) ) &&
  63728. // advance to the next closing parenthesis
  63729. ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
  63730. // excess is a negative index
  63731. match[ 0 ] = match[ 0 ].slice( 0, excess );
  63732. match[ 2 ] = unquoted.slice( 0, excess );
  63733. }
  63734. // Return only captures needed by the pseudo filter method (type and argument)
  63735. return match.slice( 0, 3 );
  63736. }
  63737. },
  63738. filter: {
  63739. "TAG": function( nodeNameSelector ) {
  63740. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  63741. return nodeNameSelector === "*" ?
  63742. function() {
  63743. return true;
  63744. } :
  63745. function( elem ) {
  63746. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  63747. };
  63748. },
  63749. "CLASS": function( className ) {
  63750. var pattern = classCache[ className + " " ];
  63751. return pattern ||
  63752. ( pattern = new RegExp( "(^|" + whitespace +
  63753. ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
  63754. className, function( elem ) {
  63755. return pattern.test(
  63756. typeof elem.className === "string" && elem.className ||
  63757. typeof elem.getAttribute !== "undefined" &&
  63758. elem.getAttribute( "class" ) ||
  63759. ""
  63760. );
  63761. } );
  63762. },
  63763. "ATTR": function( name, operator, check ) {
  63764. return function( elem ) {
  63765. var result = Sizzle.attr( elem, name );
  63766. if ( result == null ) {
  63767. return operator === "!=";
  63768. }
  63769. if ( !operator ) {
  63770. return true;
  63771. }
  63772. result += "";
  63773. /* eslint-disable max-len */
  63774. return operator === "=" ? result === check :
  63775. operator === "!=" ? result !== check :
  63776. operator === "^=" ? check && result.indexOf( check ) === 0 :
  63777. operator === "*=" ? check && result.indexOf( check ) > -1 :
  63778. operator === "$=" ? check && result.slice( -check.length ) === check :
  63779. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  63780. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  63781. false;
  63782. /* eslint-enable max-len */
  63783. };
  63784. },
  63785. "CHILD": function( type, what, _argument, first, last ) {
  63786. var simple = type.slice( 0, 3 ) !== "nth",
  63787. forward = type.slice( -4 ) !== "last",
  63788. ofType = what === "of-type";
  63789. return first === 1 && last === 0 ?
  63790. // Shortcut for :nth-*(n)
  63791. function( elem ) {
  63792. return !!elem.parentNode;
  63793. } :
  63794. function( elem, _context, xml ) {
  63795. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  63796. dir = simple !== forward ? "nextSibling" : "previousSibling",
  63797. parent = elem.parentNode,
  63798. name = ofType && elem.nodeName.toLowerCase(),
  63799. useCache = !xml && !ofType,
  63800. diff = false;
  63801. if ( parent ) {
  63802. // :(first|last|only)-(child|of-type)
  63803. if ( simple ) {
  63804. while ( dir ) {
  63805. node = elem;
  63806. while ( ( node = node[ dir ] ) ) {
  63807. if ( ofType ?
  63808. node.nodeName.toLowerCase() === name :
  63809. node.nodeType === 1 ) {
  63810. return false;
  63811. }
  63812. }
  63813. // Reverse direction for :only-* (if we haven't yet done so)
  63814. start = dir = type === "only" && !start && "nextSibling";
  63815. }
  63816. return true;
  63817. }
  63818. start = [ forward ? parent.firstChild : parent.lastChild ];
  63819. // non-xml :nth-child(...) stores cache data on `parent`
  63820. if ( forward && useCache ) {
  63821. // Seek `elem` from a previously-cached index
  63822. // ...in a gzip-friendly way
  63823. node = parent;
  63824. outerCache = node[ expando ] || ( node[ expando ] = {} );
  63825. // Support: IE <9 only
  63826. // Defend against cloned attroperties (jQuery gh-1709)
  63827. uniqueCache = outerCache[ node.uniqueID ] ||
  63828. ( outerCache[ node.uniqueID ] = {} );
  63829. cache = uniqueCache[ type ] || [];
  63830. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  63831. diff = nodeIndex && cache[ 2 ];
  63832. node = nodeIndex && parent.childNodes[ nodeIndex ];
  63833. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  63834. // Fallback to seeking `elem` from the start
  63835. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  63836. // When found, cache indexes on `parent` and break
  63837. if ( node.nodeType === 1 && ++diff && node === elem ) {
  63838. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  63839. break;
  63840. }
  63841. }
  63842. } else {
  63843. // Use previously-cached element index if available
  63844. if ( useCache ) {
  63845. // ...in a gzip-friendly way
  63846. node = elem;
  63847. outerCache = node[ expando ] || ( node[ expando ] = {} );
  63848. // Support: IE <9 only
  63849. // Defend against cloned attroperties (jQuery gh-1709)
  63850. uniqueCache = outerCache[ node.uniqueID ] ||
  63851. ( outerCache[ node.uniqueID ] = {} );
  63852. cache = uniqueCache[ type ] || [];
  63853. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  63854. diff = nodeIndex;
  63855. }
  63856. // xml :nth-child(...)
  63857. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  63858. if ( diff === false ) {
  63859. // Use the same loop as above to seek `elem` from the start
  63860. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  63861. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  63862. if ( ( ofType ?
  63863. node.nodeName.toLowerCase() === name :
  63864. node.nodeType === 1 ) &&
  63865. ++diff ) {
  63866. // Cache the index of each encountered element
  63867. if ( useCache ) {
  63868. outerCache = node[ expando ] ||
  63869. ( node[ expando ] = {} );
  63870. // Support: IE <9 only
  63871. // Defend against cloned attroperties (jQuery gh-1709)
  63872. uniqueCache = outerCache[ node.uniqueID ] ||
  63873. ( outerCache[ node.uniqueID ] = {} );
  63874. uniqueCache[ type ] = [ dirruns, diff ];
  63875. }
  63876. if ( node === elem ) {
  63877. break;
  63878. }
  63879. }
  63880. }
  63881. }
  63882. }
  63883. // Incorporate the offset, then check against cycle size
  63884. diff -= last;
  63885. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  63886. }
  63887. };
  63888. },
  63889. "PSEUDO": function( pseudo, argument ) {
  63890. // pseudo-class names are case-insensitive
  63891. // http://www.w3.org/TR/selectors/#pseudo-classes
  63892. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  63893. // Remember that setFilters inherits from pseudos
  63894. var args,
  63895. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  63896. Sizzle.error( "unsupported pseudo: " + pseudo );
  63897. // The user may use createPseudo to indicate that
  63898. // arguments are needed to create the filter function
  63899. // just as Sizzle does
  63900. if ( fn[ expando ] ) {
  63901. return fn( argument );
  63902. }
  63903. // But maintain support for old signatures
  63904. if ( fn.length > 1 ) {
  63905. args = [ pseudo, pseudo, "", argument ];
  63906. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  63907. markFunction( function( seed, matches ) {
  63908. var idx,
  63909. matched = fn( seed, argument ),
  63910. i = matched.length;
  63911. while ( i-- ) {
  63912. idx = indexOf( seed, matched[ i ] );
  63913. seed[ idx ] = !( matches[ idx ] = matched[ i ] );
  63914. }
  63915. } ) :
  63916. function( elem ) {
  63917. return fn( elem, 0, args );
  63918. };
  63919. }
  63920. return fn;
  63921. }
  63922. },
  63923. pseudos: {
  63924. // Potentially complex pseudos
  63925. "not": markFunction( function( selector ) {
  63926. // Trim the selector passed to compile
  63927. // to avoid treating leading and trailing
  63928. // spaces as combinators
  63929. var input = [],
  63930. results = [],
  63931. matcher = compile( selector.replace( rtrim, "$1" ) );
  63932. return matcher[ expando ] ?
  63933. markFunction( function( seed, matches, _context, xml ) {
  63934. var elem,
  63935. unmatched = matcher( seed, null, xml, [] ),
  63936. i = seed.length;
  63937. // Match elements unmatched by `matcher`
  63938. while ( i-- ) {
  63939. if ( ( elem = unmatched[ i ] ) ) {
  63940. seed[ i ] = !( matches[ i ] = elem );
  63941. }
  63942. }
  63943. } ) :
  63944. function( elem, _context, xml ) {
  63945. input[ 0 ] = elem;
  63946. matcher( input, null, xml, results );
  63947. // Don't keep the element (issue #299)
  63948. input[ 0 ] = null;
  63949. return !results.pop();
  63950. };
  63951. } ),
  63952. "has": markFunction( function( selector ) {
  63953. return function( elem ) {
  63954. return Sizzle( selector, elem ).length > 0;
  63955. };
  63956. } ),
  63957. "contains": markFunction( function( text ) {
  63958. text = text.replace( runescape, funescape );
  63959. return function( elem ) {
  63960. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  63961. };
  63962. } ),
  63963. // "Whether an element is represented by a :lang() selector
  63964. // is based solely on the element's language value
  63965. // being equal to the identifier C,
  63966. // or beginning with the identifier C immediately followed by "-".
  63967. // The matching of C against the element's language value is performed case-insensitively.
  63968. // The identifier C does not have to be a valid language name."
  63969. // http://www.w3.org/TR/selectors/#lang-pseudo
  63970. "lang": markFunction( function( lang ) {
  63971. // lang value must be a valid identifier
  63972. if ( !ridentifier.test( lang || "" ) ) {
  63973. Sizzle.error( "unsupported lang: " + lang );
  63974. }
  63975. lang = lang.replace( runescape, funescape ).toLowerCase();
  63976. return function( elem ) {
  63977. var elemLang;
  63978. do {
  63979. if ( ( elemLang = documentIsHTML ?
  63980. elem.lang :
  63981. elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
  63982. elemLang = elemLang.toLowerCase();
  63983. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  63984. }
  63985. } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
  63986. return false;
  63987. };
  63988. } ),
  63989. // Miscellaneous
  63990. "target": function( elem ) {
  63991. var hash = window.location && window.location.hash;
  63992. return hash && hash.slice( 1 ) === elem.id;
  63993. },
  63994. "root": function( elem ) {
  63995. return elem === docElem;
  63996. },
  63997. "focus": function( elem ) {
  63998. return elem === document.activeElement &&
  63999. ( !document.hasFocus || document.hasFocus() ) &&
  64000. !!( elem.type || elem.href || ~elem.tabIndex );
  64001. },
  64002. // Boolean properties
  64003. "enabled": createDisabledPseudo( false ),
  64004. "disabled": createDisabledPseudo( true ),
  64005. "checked": function( elem ) {
  64006. // In CSS3, :checked should return both checked and selected elements
  64007. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  64008. var nodeName = elem.nodeName.toLowerCase();
  64009. return ( nodeName === "input" && !!elem.checked ) ||
  64010. ( nodeName === "option" && !!elem.selected );
  64011. },
  64012. "selected": function( elem ) {
  64013. // Accessing this property makes selected-by-default
  64014. // options in Safari work properly
  64015. if ( elem.parentNode ) {
  64016. // eslint-disable-next-line no-unused-expressions
  64017. elem.parentNode.selectedIndex;
  64018. }
  64019. return elem.selected === true;
  64020. },
  64021. // Contents
  64022. "empty": function( elem ) {
  64023. // http://www.w3.org/TR/selectors/#empty-pseudo
  64024. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  64025. // but not by others (comment: 8; processing instruction: 7; etc.)
  64026. // nodeType < 6 works because attributes (2) do not appear as children
  64027. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  64028. if ( elem.nodeType < 6 ) {
  64029. return false;
  64030. }
  64031. }
  64032. return true;
  64033. },
  64034. "parent": function( elem ) {
  64035. return !Expr.pseudos[ "empty" ]( elem );
  64036. },
  64037. // Element/input types
  64038. "header": function( elem ) {
  64039. return rheader.test( elem.nodeName );
  64040. },
  64041. "input": function( elem ) {
  64042. return rinputs.test( elem.nodeName );
  64043. },
  64044. "button": function( elem ) {
  64045. var name = elem.nodeName.toLowerCase();
  64046. return name === "input" && elem.type === "button" || name === "button";
  64047. },
  64048. "text": function( elem ) {
  64049. var attr;
  64050. return elem.nodeName.toLowerCase() === "input" &&
  64051. elem.type === "text" &&
  64052. // Support: IE<8
  64053. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  64054. ( ( attr = elem.getAttribute( "type" ) ) == null ||
  64055. attr.toLowerCase() === "text" );
  64056. },
  64057. // Position-in-collection
  64058. "first": createPositionalPseudo( function() {
  64059. return [ 0 ];
  64060. } ),
  64061. "last": createPositionalPseudo( function( _matchIndexes, length ) {
  64062. return [ length - 1 ];
  64063. } ),
  64064. "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
  64065. return [ argument < 0 ? argument + length : argument ];
  64066. } ),
  64067. "even": createPositionalPseudo( function( matchIndexes, length ) {
  64068. var i = 0;
  64069. for ( ; i < length; i += 2 ) {
  64070. matchIndexes.push( i );
  64071. }
  64072. return matchIndexes;
  64073. } ),
  64074. "odd": createPositionalPseudo( function( matchIndexes, length ) {
  64075. var i = 1;
  64076. for ( ; i < length; i += 2 ) {
  64077. matchIndexes.push( i );
  64078. }
  64079. return matchIndexes;
  64080. } ),
  64081. "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  64082. var i = argument < 0 ?
  64083. argument + length :
  64084. argument > length ?
  64085. length :
  64086. argument;
  64087. for ( ; --i >= 0; ) {
  64088. matchIndexes.push( i );
  64089. }
  64090. return matchIndexes;
  64091. } ),
  64092. "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  64093. var i = argument < 0 ? argument + length : argument;
  64094. for ( ; ++i < length; ) {
  64095. matchIndexes.push( i );
  64096. }
  64097. return matchIndexes;
  64098. } )
  64099. }
  64100. };
  64101. Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
  64102. // Add button/input type pseudos
  64103. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  64104. Expr.pseudos[ i ] = createInputPseudo( i );
  64105. }
  64106. for ( i in { submit: true, reset: true } ) {
  64107. Expr.pseudos[ i ] = createButtonPseudo( i );
  64108. }
  64109. // Easy API for creating new setFilters
  64110. function setFilters() {}
  64111. setFilters.prototype = Expr.filters = Expr.pseudos;
  64112. Expr.setFilters = new setFilters();
  64113. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  64114. var matched, match, tokens, type,
  64115. soFar, groups, preFilters,
  64116. cached = tokenCache[ selector + " " ];
  64117. if ( cached ) {
  64118. return parseOnly ? 0 : cached.slice( 0 );
  64119. }
  64120. soFar = selector;
  64121. groups = [];
  64122. preFilters = Expr.preFilter;
  64123. while ( soFar ) {
  64124. // Comma and first run
  64125. if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
  64126. if ( match ) {
  64127. // Don't consume trailing commas as valid
  64128. soFar = soFar.slice( match[ 0 ].length ) || soFar;
  64129. }
  64130. groups.push( ( tokens = [] ) );
  64131. }
  64132. matched = false;
  64133. // Combinators
  64134. if ( ( match = rcombinators.exec( soFar ) ) ) {
  64135. matched = match.shift();
  64136. tokens.push( {
  64137. value: matched,
  64138. // Cast descendant combinators to space
  64139. type: match[ 0 ].replace( rtrim, " " )
  64140. } );
  64141. soFar = soFar.slice( matched.length );
  64142. }
  64143. // Filters
  64144. for ( type in Expr.filter ) {
  64145. if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
  64146. ( match = preFilters[ type ]( match ) ) ) ) {
  64147. matched = match.shift();
  64148. tokens.push( {
  64149. value: matched,
  64150. type: type,
  64151. matches: match
  64152. } );
  64153. soFar = soFar.slice( matched.length );
  64154. }
  64155. }
  64156. if ( !matched ) {
  64157. break;
  64158. }
  64159. }
  64160. // Return the length of the invalid excess
  64161. // if we're just parsing
  64162. // Otherwise, throw an error or return tokens
  64163. return parseOnly ?
  64164. soFar.length :
  64165. soFar ?
  64166. Sizzle.error( selector ) :
  64167. // Cache the tokens
  64168. tokenCache( selector, groups ).slice( 0 );
  64169. };
  64170. function toSelector( tokens ) {
  64171. var i = 0,
  64172. len = tokens.length,
  64173. selector = "";
  64174. for ( ; i < len; i++ ) {
  64175. selector += tokens[ i ].value;
  64176. }
  64177. return selector;
  64178. }
  64179. function addCombinator( matcher, combinator, base ) {
  64180. var dir = combinator.dir,
  64181. skip = combinator.next,
  64182. key = skip || dir,
  64183. checkNonElements = base && key === "parentNode",
  64184. doneName = done++;
  64185. return combinator.first ?
  64186. // Check against closest ancestor/preceding element
  64187. function( elem, context, xml ) {
  64188. while ( ( elem = elem[ dir ] ) ) {
  64189. if ( elem.nodeType === 1 || checkNonElements ) {
  64190. return matcher( elem, context, xml );
  64191. }
  64192. }
  64193. return false;
  64194. } :
  64195. // Check against all ancestor/preceding elements
  64196. function( elem, context, xml ) {
  64197. var oldCache, uniqueCache, outerCache,
  64198. newCache = [ dirruns, doneName ];
  64199. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  64200. if ( xml ) {
  64201. while ( ( elem = elem[ dir ] ) ) {
  64202. if ( elem.nodeType === 1 || checkNonElements ) {
  64203. if ( matcher( elem, context, xml ) ) {
  64204. return true;
  64205. }
  64206. }
  64207. }
  64208. } else {
  64209. while ( ( elem = elem[ dir ] ) ) {
  64210. if ( elem.nodeType === 1 || checkNonElements ) {
  64211. outerCache = elem[ expando ] || ( elem[ expando ] = {} );
  64212. // Support: IE <9 only
  64213. // Defend against cloned attroperties (jQuery gh-1709)
  64214. uniqueCache = outerCache[ elem.uniqueID ] ||
  64215. ( outerCache[ elem.uniqueID ] = {} );
  64216. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  64217. elem = elem[ dir ] || elem;
  64218. } else if ( ( oldCache = uniqueCache[ key ] ) &&
  64219. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  64220. // Assign to newCache so results back-propagate to previous elements
  64221. return ( newCache[ 2 ] = oldCache[ 2 ] );
  64222. } else {
  64223. // Reuse newcache so results back-propagate to previous elements
  64224. uniqueCache[ key ] = newCache;
  64225. // A match means we're done; a fail means we have to keep checking
  64226. if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
  64227. return true;
  64228. }
  64229. }
  64230. }
  64231. }
  64232. }
  64233. return false;
  64234. };
  64235. }
  64236. function elementMatcher( matchers ) {
  64237. return matchers.length > 1 ?
  64238. function( elem, context, xml ) {
  64239. var i = matchers.length;
  64240. while ( i-- ) {
  64241. if ( !matchers[ i ]( elem, context, xml ) ) {
  64242. return false;
  64243. }
  64244. }
  64245. return true;
  64246. } :
  64247. matchers[ 0 ];
  64248. }
  64249. function multipleContexts( selector, contexts, results ) {
  64250. var i = 0,
  64251. len = contexts.length;
  64252. for ( ; i < len; i++ ) {
  64253. Sizzle( selector, contexts[ i ], results );
  64254. }
  64255. return results;
  64256. }
  64257. function condense( unmatched, map, filter, context, xml ) {
  64258. var elem,
  64259. newUnmatched = [],
  64260. i = 0,
  64261. len = unmatched.length,
  64262. mapped = map != null;
  64263. for ( ; i < len; i++ ) {
  64264. if ( ( elem = unmatched[ i ] ) ) {
  64265. if ( !filter || filter( elem, context, xml ) ) {
  64266. newUnmatched.push( elem );
  64267. if ( mapped ) {
  64268. map.push( i );
  64269. }
  64270. }
  64271. }
  64272. }
  64273. return newUnmatched;
  64274. }
  64275. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  64276. if ( postFilter && !postFilter[ expando ] ) {
  64277. postFilter = setMatcher( postFilter );
  64278. }
  64279. if ( postFinder && !postFinder[ expando ] ) {
  64280. postFinder = setMatcher( postFinder, postSelector );
  64281. }
  64282. return markFunction( function( seed, results, context, xml ) {
  64283. var temp, i, elem,
  64284. preMap = [],
  64285. postMap = [],
  64286. preexisting = results.length,
  64287. // Get initial elements from seed or context
  64288. elems = seed || multipleContexts(
  64289. selector || "*",
  64290. context.nodeType ? [ context ] : context,
  64291. []
  64292. ),
  64293. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  64294. matcherIn = preFilter && ( seed || !selector ) ?
  64295. condense( elems, preMap, preFilter, context, xml ) :
  64296. elems,
  64297. matcherOut = matcher ?
  64298. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  64299. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  64300. // ...intermediate processing is necessary
  64301. [] :
  64302. // ...otherwise use results directly
  64303. results :
  64304. matcherIn;
  64305. // Find primary matches
  64306. if ( matcher ) {
  64307. matcher( matcherIn, matcherOut, context, xml );
  64308. }
  64309. // Apply postFilter
  64310. if ( postFilter ) {
  64311. temp = condense( matcherOut, postMap );
  64312. postFilter( temp, [], context, xml );
  64313. // Un-match failing elements by moving them back to matcherIn
  64314. i = temp.length;
  64315. while ( i-- ) {
  64316. if ( ( elem = temp[ i ] ) ) {
  64317. matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
  64318. }
  64319. }
  64320. }
  64321. if ( seed ) {
  64322. if ( postFinder || preFilter ) {
  64323. if ( postFinder ) {
  64324. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  64325. temp = [];
  64326. i = matcherOut.length;
  64327. while ( i-- ) {
  64328. if ( ( elem = matcherOut[ i ] ) ) {
  64329. // Restore matcherIn since elem is not yet a final match
  64330. temp.push( ( matcherIn[ i ] = elem ) );
  64331. }
  64332. }
  64333. postFinder( null, ( matcherOut = [] ), temp, xml );
  64334. }
  64335. // Move matched elements from seed to results to keep them synchronized
  64336. i = matcherOut.length;
  64337. while ( i-- ) {
  64338. if ( ( elem = matcherOut[ i ] ) &&
  64339. ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
  64340. seed[ temp ] = !( results[ temp ] = elem );
  64341. }
  64342. }
  64343. }
  64344. // Add elements to results, through postFinder if defined
  64345. } else {
  64346. matcherOut = condense(
  64347. matcherOut === results ?
  64348. matcherOut.splice( preexisting, matcherOut.length ) :
  64349. matcherOut
  64350. );
  64351. if ( postFinder ) {
  64352. postFinder( null, results, matcherOut, xml );
  64353. } else {
  64354. push.apply( results, matcherOut );
  64355. }
  64356. }
  64357. } );
  64358. }
  64359. function matcherFromTokens( tokens ) {
  64360. var checkContext, matcher, j,
  64361. len = tokens.length,
  64362. leadingRelative = Expr.relative[ tokens[ 0 ].type ],
  64363. implicitRelative = leadingRelative || Expr.relative[ " " ],
  64364. i = leadingRelative ? 1 : 0,
  64365. // The foundational matcher ensures that elements are reachable from top-level context(s)
  64366. matchContext = addCombinator( function( elem ) {
  64367. return elem === checkContext;
  64368. }, implicitRelative, true ),
  64369. matchAnyContext = addCombinator( function( elem ) {
  64370. return indexOf( checkContext, elem ) > -1;
  64371. }, implicitRelative, true ),
  64372. matchers = [ function( elem, context, xml ) {
  64373. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  64374. ( checkContext = context ).nodeType ?
  64375. matchContext( elem, context, xml ) :
  64376. matchAnyContext( elem, context, xml ) );
  64377. // Avoid hanging onto element (issue #299)
  64378. checkContext = null;
  64379. return ret;
  64380. } ];
  64381. for ( ; i < len; i++ ) {
  64382. if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
  64383. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  64384. } else {
  64385. matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
  64386. // Return special upon seeing a positional matcher
  64387. if ( matcher[ expando ] ) {
  64388. // Find the next relative operator (if any) for proper handling
  64389. j = ++i;
  64390. for ( ; j < len; j++ ) {
  64391. if ( Expr.relative[ tokens[ j ].type ] ) {
  64392. break;
  64393. }
  64394. }
  64395. return setMatcher(
  64396. i > 1 && elementMatcher( matchers ),
  64397. i > 1 && toSelector(
  64398. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  64399. tokens
  64400. .slice( 0, i - 1 )
  64401. .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
  64402. ).replace( rtrim, "$1" ),
  64403. matcher,
  64404. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  64405. j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
  64406. j < len && toSelector( tokens )
  64407. );
  64408. }
  64409. matchers.push( matcher );
  64410. }
  64411. }
  64412. return elementMatcher( matchers );
  64413. }
  64414. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  64415. var bySet = setMatchers.length > 0,
  64416. byElement = elementMatchers.length > 0,
  64417. superMatcher = function( seed, context, xml, results, outermost ) {
  64418. var elem, j, matcher,
  64419. matchedCount = 0,
  64420. i = "0",
  64421. unmatched = seed && [],
  64422. setMatched = [],
  64423. contextBackup = outermostContext,
  64424. // We must always have either seed elements or outermost context
  64425. elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
  64426. // Use integer dirruns iff this is the outermost matcher
  64427. dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
  64428. len = elems.length;
  64429. if ( outermost ) {
  64430. // Support: IE 11+, Edge 17 - 18+
  64431. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  64432. // two documents; shallow comparisons work.
  64433. // eslint-disable-next-line eqeqeq
  64434. outermostContext = context == document || context || outermost;
  64435. }
  64436. // Add elements passing elementMatchers directly to results
  64437. // Support: IE<9, Safari
  64438. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  64439. for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
  64440. if ( byElement && elem ) {
  64441. j = 0;
  64442. // Support: IE 11+, Edge 17 - 18+
  64443. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  64444. // two documents; shallow comparisons work.
  64445. // eslint-disable-next-line eqeqeq
  64446. if ( !context && elem.ownerDocument != document ) {
  64447. setDocument( elem );
  64448. xml = !documentIsHTML;
  64449. }
  64450. while ( ( matcher = elementMatchers[ j++ ] ) ) {
  64451. if ( matcher( elem, context || document, xml ) ) {
  64452. results.push( elem );
  64453. break;
  64454. }
  64455. }
  64456. if ( outermost ) {
  64457. dirruns = dirrunsUnique;
  64458. }
  64459. }
  64460. // Track unmatched elements for set filters
  64461. if ( bySet ) {
  64462. // They will have gone through all possible matchers
  64463. if ( ( elem = !matcher && elem ) ) {
  64464. matchedCount--;
  64465. }
  64466. // Lengthen the array for every element, matched or not
  64467. if ( seed ) {
  64468. unmatched.push( elem );
  64469. }
  64470. }
  64471. }
  64472. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  64473. // makes the latter nonnegative.
  64474. matchedCount += i;
  64475. // Apply set filters to unmatched elements
  64476. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  64477. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  64478. // no element matchers and no seed.
  64479. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  64480. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  64481. // numerically zero.
  64482. if ( bySet && i !== matchedCount ) {
  64483. j = 0;
  64484. while ( ( matcher = setMatchers[ j++ ] ) ) {
  64485. matcher( unmatched, setMatched, context, xml );
  64486. }
  64487. if ( seed ) {
  64488. // Reintegrate element matches to eliminate the need for sorting
  64489. if ( matchedCount > 0 ) {
  64490. while ( i-- ) {
  64491. if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
  64492. setMatched[ i ] = pop.call( results );
  64493. }
  64494. }
  64495. }
  64496. // Discard index placeholder values to get only actual matches
  64497. setMatched = condense( setMatched );
  64498. }
  64499. // Add matches to results
  64500. push.apply( results, setMatched );
  64501. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  64502. if ( outermost && !seed && setMatched.length > 0 &&
  64503. ( matchedCount + setMatchers.length ) > 1 ) {
  64504. Sizzle.uniqueSort( results );
  64505. }
  64506. }
  64507. // Override manipulation of globals by nested matchers
  64508. if ( outermost ) {
  64509. dirruns = dirrunsUnique;
  64510. outermostContext = contextBackup;
  64511. }
  64512. return unmatched;
  64513. };
  64514. return bySet ?
  64515. markFunction( superMatcher ) :
  64516. superMatcher;
  64517. }
  64518. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  64519. var i,
  64520. setMatchers = [],
  64521. elementMatchers = [],
  64522. cached = compilerCache[ selector + " " ];
  64523. if ( !cached ) {
  64524. // Generate a function of recursive functions that can be used to check each element
  64525. if ( !match ) {
  64526. match = tokenize( selector );
  64527. }
  64528. i = match.length;
  64529. while ( i-- ) {
  64530. cached = matcherFromTokens( match[ i ] );
  64531. if ( cached[ expando ] ) {
  64532. setMatchers.push( cached );
  64533. } else {
  64534. elementMatchers.push( cached );
  64535. }
  64536. }
  64537. // Cache the compiled function
  64538. cached = compilerCache(
  64539. selector,
  64540. matcherFromGroupMatchers( elementMatchers, setMatchers )
  64541. );
  64542. // Save selector and tokenization
  64543. cached.selector = selector;
  64544. }
  64545. return cached;
  64546. };
  64547. /**
  64548. * A low-level selection function that works with Sizzle's compiled
  64549. * selector functions
  64550. * @param {String|Function} selector A selector or a pre-compiled
  64551. * selector function built with Sizzle.compile
  64552. * @param {Element} context
  64553. * @param {Array} [results]
  64554. * @param {Array} [seed] A set of elements to match against
  64555. */
  64556. select = Sizzle.select = function( selector, context, results, seed ) {
  64557. var i, tokens, token, type, find,
  64558. compiled = typeof selector === "function" && selector,
  64559. match = !seed && tokenize( ( selector = compiled.selector || selector ) );
  64560. results = results || [];
  64561. // Try to minimize operations if there is only one selector in the list and no seed
  64562. // (the latter of which guarantees us context)
  64563. if ( match.length === 1 ) {
  64564. // Reduce context if the leading compound selector is an ID
  64565. tokens = match[ 0 ] = match[ 0 ].slice( 0 );
  64566. if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
  64567. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
  64568. context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
  64569. .replace( runescape, funescape ), context ) || [] )[ 0 ];
  64570. if ( !context ) {
  64571. return results;
  64572. // Precompiled matchers will still verify ancestry, so step up a level
  64573. } else if ( compiled ) {
  64574. context = context.parentNode;
  64575. }
  64576. selector = selector.slice( tokens.shift().value.length );
  64577. }
  64578. // Fetch a seed set for right-to-left matching
  64579. i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
  64580. while ( i-- ) {
  64581. token = tokens[ i ];
  64582. // Abort if we hit a combinator
  64583. if ( Expr.relative[ ( type = token.type ) ] ) {
  64584. break;
  64585. }
  64586. if ( ( find = Expr.find[ type ] ) ) {
  64587. // Search, expanding context for leading sibling combinators
  64588. if ( ( seed = find(
  64589. token.matches[ 0 ].replace( runescape, funescape ),
  64590. rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
  64591. context
  64592. ) ) ) {
  64593. // If seed is empty or no tokens remain, we can return early
  64594. tokens.splice( i, 1 );
  64595. selector = seed.length && toSelector( tokens );
  64596. if ( !selector ) {
  64597. push.apply( results, seed );
  64598. return results;
  64599. }
  64600. break;
  64601. }
  64602. }
  64603. }
  64604. }
  64605. // Compile and execute a filtering function if one is not provided
  64606. // Provide `match` to avoid retokenization if we modified the selector above
  64607. ( compiled || compile( selector, match ) )(
  64608. seed,
  64609. context,
  64610. !documentIsHTML,
  64611. results,
  64612. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  64613. );
  64614. return results;
  64615. };
  64616. // One-time assignments
  64617. // Sort stability
  64618. support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
  64619. // Support: Chrome 14-35+
  64620. // Always assume duplicates if they aren't passed to the comparison function
  64621. support.detectDuplicates = !!hasDuplicate;
  64622. // Initialize against the default document
  64623. setDocument();
  64624. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  64625. // Detached nodes confoundingly follow *each other*
  64626. support.sortDetached = assert( function( el ) {
  64627. // Should return 1, but returns 4 (following)
  64628. return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
  64629. } );
  64630. // Support: IE<8
  64631. // Prevent attribute/property "interpolation"
  64632. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  64633. if ( !assert( function( el ) {
  64634. el.innerHTML = "<a href='#'></a>";
  64635. return el.firstChild.getAttribute( "href" ) === "#";
  64636. } ) ) {
  64637. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  64638. if ( !isXML ) {
  64639. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  64640. }
  64641. } );
  64642. }
  64643. // Support: IE<9
  64644. // Use defaultValue in place of getAttribute("value")
  64645. if ( !support.attributes || !assert( function( el ) {
  64646. el.innerHTML = "<input/>";
  64647. el.firstChild.setAttribute( "value", "" );
  64648. return el.firstChild.getAttribute( "value" ) === "";
  64649. } ) ) {
  64650. addHandle( "value", function( elem, _name, isXML ) {
  64651. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  64652. return elem.defaultValue;
  64653. }
  64654. } );
  64655. }
  64656. // Support: IE<9
  64657. // Use getAttributeNode to fetch booleans when getAttribute lies
  64658. if ( !assert( function( el ) {
  64659. return el.getAttribute( "disabled" ) == null;
  64660. } ) ) {
  64661. addHandle( booleans, function( elem, name, isXML ) {
  64662. var val;
  64663. if ( !isXML ) {
  64664. return elem[ name ] === true ? name.toLowerCase() :
  64665. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  64666. val.value :
  64667. null;
  64668. }
  64669. } );
  64670. }
  64671. // EXPOSE
  64672. var _sizzle = window.Sizzle;
  64673. Sizzle.noConflict = function() {
  64674. if ( window.Sizzle === Sizzle ) {
  64675. window.Sizzle = _sizzle;
  64676. }
  64677. return Sizzle;
  64678. };
  64679. if ( true ) {
  64680. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  64681. return Sizzle;
  64682. }).call(exports, __webpack_require__, exports, module),
  64683. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  64684. // Sizzle requires that there be a global window in Common-JS like environments
  64685. } else {}
  64686. // EXPOSE
  64687. } )( window );
  64688. /***/ }),
  64689. /***/ 3379:
  64690. /***/ ((module) => {
  64691. "use strict";
  64692. var stylesInDOM = [];
  64693. function getIndexByIdentifier(identifier) {
  64694. var result = -1;
  64695. for (var i = 0; i < stylesInDOM.length; i++) {
  64696. if (stylesInDOM[i].identifier === identifier) {
  64697. result = i;
  64698. break;
  64699. }
  64700. }
  64701. return result;
  64702. }
  64703. function modulesToDom(list, options) {
  64704. var idCountMap = {};
  64705. var identifiers = [];
  64706. for (var i = 0; i < list.length; i++) {
  64707. var item = list[i];
  64708. var id = options.base ? item[0] + options.base : item[0];
  64709. var count = idCountMap[id] || 0;
  64710. var identifier = "".concat(id, " ").concat(count);
  64711. idCountMap[id] = count + 1;
  64712. var indexByIdentifier = getIndexByIdentifier(identifier);
  64713. var obj = {
  64714. css: item[1],
  64715. media: item[2],
  64716. sourceMap: item[3],
  64717. supports: item[4],
  64718. layer: item[5]
  64719. };
  64720. if (indexByIdentifier !== -1) {
  64721. stylesInDOM[indexByIdentifier].references++;
  64722. stylesInDOM[indexByIdentifier].updater(obj);
  64723. } else {
  64724. var updater = addElementStyle(obj, options);
  64725. options.byIndex = i;
  64726. stylesInDOM.splice(i, 0, {
  64727. identifier: identifier,
  64728. updater: updater,
  64729. references: 1
  64730. });
  64731. }
  64732. identifiers.push(identifier);
  64733. }
  64734. return identifiers;
  64735. }
  64736. function addElementStyle(obj, options) {
  64737. var api = options.domAPI(options);
  64738. api.update(obj);
  64739. var updater = function updater(newObj) {
  64740. if (newObj) {
  64741. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
  64742. return;
  64743. }
  64744. api.update(obj = newObj);
  64745. } else {
  64746. api.remove();
  64747. }
  64748. };
  64749. return updater;
  64750. }
  64751. module.exports = function (list, options) {
  64752. options = options || {};
  64753. list = list || [];
  64754. var lastIdentifiers = modulesToDom(list, options);
  64755. return function update(newList) {
  64756. newList = newList || [];
  64757. for (var i = 0; i < lastIdentifiers.length; i++) {
  64758. var identifier = lastIdentifiers[i];
  64759. var index = getIndexByIdentifier(identifier);
  64760. stylesInDOM[index].references--;
  64761. }
  64762. var newLastIdentifiers = modulesToDom(newList, options);
  64763. for (var _i = 0; _i < lastIdentifiers.length; _i++) {
  64764. var _identifier = lastIdentifiers[_i];
  64765. var _index = getIndexByIdentifier(_identifier);
  64766. if (stylesInDOM[_index].references === 0) {
  64767. stylesInDOM[_index].updater();
  64768. stylesInDOM.splice(_index, 1);
  64769. }
  64770. }
  64771. lastIdentifiers = newLastIdentifiers;
  64772. };
  64773. };
  64774. /***/ }),
  64775. /***/ 569:
  64776. /***/ ((module) => {
  64777. "use strict";
  64778. var memo = {};
  64779. /* istanbul ignore next */
  64780. function getTarget(target) {
  64781. if (typeof memo[target] === "undefined") {
  64782. var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
  64783. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  64784. try {
  64785. // This will throw an exception if access to iframe is blocked
  64786. // due to cross-origin restrictions
  64787. styleTarget = styleTarget.contentDocument.head;
  64788. } catch (e) {
  64789. // istanbul ignore next
  64790. styleTarget = null;
  64791. }
  64792. }
  64793. memo[target] = styleTarget;
  64794. }
  64795. return memo[target];
  64796. }
  64797. /* istanbul ignore next */
  64798. function insertBySelector(insert, style) {
  64799. var target = getTarget(insert);
  64800. if (!target) {
  64801. throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  64802. }
  64803. target.appendChild(style);
  64804. }
  64805. module.exports = insertBySelector;
  64806. /***/ }),
  64807. /***/ 9216:
  64808. /***/ ((module) => {
  64809. "use strict";
  64810. /* istanbul ignore next */
  64811. function insertStyleElement(options) {
  64812. var element = document.createElement("style");
  64813. options.setAttributes(element, options.attributes);
  64814. options.insert(element, options.options);
  64815. return element;
  64816. }
  64817. module.exports = insertStyleElement;
  64818. /***/ }),
  64819. /***/ 3565:
  64820. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  64821. "use strict";
  64822. /* istanbul ignore next */
  64823. function setAttributesWithoutAttributes(styleElement) {
  64824. var nonce = true ? __webpack_require__.nc : 0;
  64825. if (nonce) {
  64826. styleElement.setAttribute("nonce", nonce);
  64827. }
  64828. }
  64829. module.exports = setAttributesWithoutAttributes;
  64830. /***/ }),
  64831. /***/ 7795:
  64832. /***/ ((module) => {
  64833. "use strict";
  64834. /* istanbul ignore next */
  64835. function apply(styleElement, options, obj) {
  64836. var css = "";
  64837. if (obj.supports) {
  64838. css += "@supports (".concat(obj.supports, ") {");
  64839. }
  64840. if (obj.media) {
  64841. css += "@media ".concat(obj.media, " {");
  64842. }
  64843. var needLayer = typeof obj.layer !== "undefined";
  64844. if (needLayer) {
  64845. css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
  64846. }
  64847. css += obj.css;
  64848. if (needLayer) {
  64849. css += "}";
  64850. }
  64851. if (obj.media) {
  64852. css += "}";
  64853. }
  64854. if (obj.supports) {
  64855. css += "}";
  64856. }
  64857. var sourceMap = obj.sourceMap;
  64858. if (sourceMap && typeof btoa !== "undefined") {
  64859. css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
  64860. } // For old IE
  64861. /* istanbul ignore if */
  64862. options.styleTagTransform(css, styleElement, options.options);
  64863. }
  64864. function removeStyleElement(styleElement) {
  64865. // istanbul ignore if
  64866. if (styleElement.parentNode === null) {
  64867. return false;
  64868. }
  64869. styleElement.parentNode.removeChild(styleElement);
  64870. }
  64871. /* istanbul ignore next */
  64872. function domAPI(options) {
  64873. var styleElement = options.insertStyleElement(options);
  64874. return {
  64875. update: function update(obj) {
  64876. apply(styleElement, options, obj);
  64877. },
  64878. remove: function remove() {
  64879. removeStyleElement(styleElement);
  64880. }
  64881. };
  64882. }
  64883. module.exports = domAPI;
  64884. /***/ }),
  64885. /***/ 4589:
  64886. /***/ ((module) => {
  64887. "use strict";
  64888. /* istanbul ignore next */
  64889. function styleTagTransform(css, styleElement) {
  64890. if (styleElement.styleSheet) {
  64891. styleElement.styleSheet.cssText = css;
  64892. } else {
  64893. while (styleElement.firstChild) {
  64894. styleElement.removeChild(styleElement.firstChild);
  64895. }
  64896. styleElement.appendChild(document.createTextNode(css));
  64897. }
  64898. }
  64899. module.exports = styleTagTransform;
  64900. /***/ }),
  64901. /***/ 7521:
  64902. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  64903. var map = {
  64904. "./af/LC_MESSAGES/converse.po": [
  64905. 4534,
  64906. 5830
  64907. ],
  64908. "./ar/LC_MESSAGES/converse.po": [
  64909. 4201,
  64910. 4469
  64911. ],
  64912. "./bg/LC_MESSAGES/converse.po": [
  64913. 5384,
  64914. 2551
  64915. ],
  64916. "./ca/LC_MESSAGES/converse.po": [
  64917. 122,
  64918. 1553
  64919. ],
  64920. "./cs/LC_MESSAGES/converse.po": [
  64921. 3893,
  64922. 5301
  64923. ],
  64924. "./da/LC_MESSAGES/converse.po": [
  64925. 7889,
  64926. 1163
  64927. ],
  64928. "./de/LC_MESSAGES/converse.po": [
  64929. 1658,
  64930. 2895
  64931. ],
  64932. "./el/LC_MESSAGES/converse.po": [
  64933. 7530,
  64934. 5524
  64935. ],
  64936. "./eo/LC_MESSAGES/converse.po": [
  64937. 1758,
  64938. 2433
  64939. ],
  64940. "./es/LC_MESSAGES/converse.po": [
  64941. 7790,
  64942. 8269
  64943. ],
  64944. "./eu/LC_MESSAGES/converse.po": [
  64945. 9398,
  64946. 3103
  64947. ],
  64948. "./fa/LC_MESSAGES/converse.po": [
  64949. 2897,
  64950. 321
  64951. ],
  64952. "./fi/LC_MESSAGES/converse.po": [
  64953. 9583,
  64954. 7618
  64955. ],
  64956. "./fr/LC_MESSAGES/converse.po": [
  64957. 5011,
  64958. 5129
  64959. ],
  64960. "./gl/LC_MESSAGES/converse.po": [
  64961. 8816,
  64962. 777
  64963. ],
  64964. "./he/LC_MESSAGES/converse.po": [
  64965. 6725,
  64966. 4363
  64967. ],
  64968. "./hi/LC_MESSAGES/converse.po": [
  64969. 411,
  64970. 4468
  64971. ],
  64972. "./hu/LC_MESSAGES/converse.po": [
  64973. 2825,
  64974. 6239
  64975. ],
  64976. "./id/LC_MESSAGES/converse.po": [
  64977. 6042,
  64978. 6678
  64979. ],
  64980. "./it/LC_MESSAGES/converse.po": [
  64981. 3741,
  64982. 3719
  64983. ],
  64984. "./ja/LC_MESSAGES/converse.po": [
  64985. 6893,
  64986. 6249
  64987. ],
  64988. "./lt/LC_MESSAGES/converse.po": [
  64989. 5176,
  64990. 513
  64991. ],
  64992. "./mr/LC_MESSAGES/converse.po": [
  64993. 6292,
  64994. 1784
  64995. ],
  64996. "./nb/LC_MESSAGES/converse.po": [
  64997. 8467,
  64998. 473
  64999. ],
  65000. "./nl/LC_MESSAGES/converse.po": [
  65001. 8544,
  65002. 2473
  65003. ],
  65004. "./nl_BE/LC_MESSAGES/converse.po": [
  65005. 8133,
  65006. 8131
  65007. ],
  65008. "./oc/LC_MESSAGES/converse.po": [
  65009. 8857,
  65010. 5500
  65011. ],
  65012. "./pl/LC_MESSAGES/converse.po": [
  65013. 2503,
  65014. 3606
  65015. ],
  65016. "./pt/LC_MESSAGES/converse.po": [
  65017. 1132,
  65018. 6227
  65019. ],
  65020. "./pt_BR/LC_MESSAGES/converse.po": [
  65021. 6380,
  65022. 1455
  65023. ],
  65024. "./ro/LC_MESSAGES/converse.po": [
  65025. 9740,
  65026. 3539
  65027. ],
  65028. "./ru/LC_MESSAGES/converse.po": [
  65029. 2276,
  65030. 7917
  65031. ],
  65032. "./sv/LC_MESSAGES/converse.po": [
  65033. 1025,
  65034. 8859
  65035. ],
  65036. "./th/LC_MESSAGES/converse.po": [
  65037. 4297,
  65038. 457
  65039. ],
  65040. "./tr/LC_MESSAGES/converse.po": [
  65041. 2266,
  65042. 4195
  65043. ],
  65044. "./uk/LC_MESSAGES/converse.po": [
  65045. 9642,
  65046. 7979
  65047. ],
  65048. "./vi/LC_MESSAGES/converse.po": [
  65049. 1298,
  65050. 2110
  65051. ],
  65052. "./zh_CN/LC_MESSAGES/converse.po": [
  65053. 9771,
  65054. 3325
  65055. ],
  65056. "./zh_TW/LC_MESSAGES/converse.po": [
  65057. 4133,
  65058. 1458
  65059. ]
  65060. };
  65061. function webpackAsyncContext(req) {
  65062. if(!__webpack_require__.o(map, req)) {
  65063. return Promise.resolve().then(() => {
  65064. var e = new Error("Cannot find module '" + req + "'");
  65065. e.code = 'MODULE_NOT_FOUND';
  65066. throw e;
  65067. });
  65068. }
  65069. var ids = map[req], id = ids[0];
  65070. return __webpack_require__.e(ids[1]).then(() => {
  65071. return __webpack_require__.t(id, 3 | 16);
  65072. });
  65073. }
  65074. webpackAsyncContext.keys = () => (Object.keys(map));
  65075. webpackAsyncContext.id = 7521;
  65076. module.exports = webpackAsyncContext;
  65077. /***/ })
  65078. /******/ });
  65079. /************************************************************************/
  65080. /******/ // The module cache
  65081. /******/ var __webpack_module_cache__ = {};
  65082. /******/
  65083. /******/ // The require function
  65084. /******/ function __webpack_require__(moduleId) {
  65085. /******/ // Check if module is in cache
  65086. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  65087. /******/ if (cachedModule !== undefined) {
  65088. /******/ return cachedModule.exports;
  65089. /******/ }
  65090. /******/ // Create a new module (and put it into the cache)
  65091. /******/ var module = __webpack_module_cache__[moduleId] = {
  65092. /******/ id: moduleId,
  65093. /******/ loaded: false,
  65094. /******/ exports: {}
  65095. /******/ };
  65096. /******/
  65097. /******/ // Execute the module function
  65098. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  65099. /******/
  65100. /******/ // Flag the module as loaded
  65101. /******/ module.loaded = true;
  65102. /******/
  65103. /******/ // Return the exports of the module
  65104. /******/ return module.exports;
  65105. /******/ }
  65106. /******/
  65107. /******/ // expose the modules object (__webpack_modules__)
  65108. /******/ __webpack_require__.m = __webpack_modules__;
  65109. /******/
  65110. /************************************************************************/
  65111. /******/ /* webpack/runtime/compat get default export */
  65112. /******/ (() => {
  65113. /******/ // getDefaultExport function for compatibility with non-harmony modules
  65114. /******/ __webpack_require__.n = (module) => {
  65115. /******/ var getter = module && module.__esModule ?
  65116. /******/ () => (module['default']) :
  65117. /******/ () => (module);
  65118. /******/ __webpack_require__.d(getter, { a: getter });
  65119. /******/ return getter;
  65120. /******/ };
  65121. /******/ })();
  65122. /******/
  65123. /******/ /* webpack/runtime/create fake namespace object */
  65124. /******/ (() => {
  65125. /******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
  65126. /******/ var leafPrototypes;
  65127. /******/ // create a fake namespace object
  65128. /******/ // mode & 1: value is a module id, require it
  65129. /******/ // mode & 2: merge all properties of value into the ns
  65130. /******/ // mode & 4: return value when already ns object
  65131. /******/ // mode & 16: return value when it's Promise-like
  65132. /******/ // mode & 8|1: behave like require
  65133. /******/ __webpack_require__.t = function(value, mode) {
  65134. /******/ if(mode & 1) value = this(value);
  65135. /******/ if(mode & 8) return value;
  65136. /******/ if(typeof value === 'object' && value) {
  65137. /******/ if((mode & 4) && value.__esModule) return value;
  65138. /******/ if((mode & 16) && typeof value.then === 'function') return value;
  65139. /******/ }
  65140. /******/ var ns = Object.create(null);
  65141. /******/ __webpack_require__.r(ns);
  65142. /******/ var def = {};
  65143. /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
  65144. /******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {
  65145. /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
  65146. /******/ }
  65147. /******/ def['default'] = () => (value);
  65148. /******/ __webpack_require__.d(ns, def);
  65149. /******/ return ns;
  65150. /******/ };
  65151. /******/ })();
  65152. /******/
  65153. /******/ /* webpack/runtime/define property getters */
  65154. /******/ (() => {
  65155. /******/ // define getter functions for harmony exports
  65156. /******/ __webpack_require__.d = (exports, definition) => {
  65157. /******/ for(var key in definition) {
  65158. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  65159. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  65160. /******/ }
  65161. /******/ }
  65162. /******/ };
  65163. /******/ })();
  65164. /******/
  65165. /******/ /* webpack/runtime/ensure chunk */
  65166. /******/ (() => {
  65167. /******/ __webpack_require__.f = {};
  65168. /******/ // This file contains only the entry chunk.
  65169. /******/ // The chunk loading function for additional chunks
  65170. /******/ __webpack_require__.e = (chunkId) => {
  65171. /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
  65172. /******/ __webpack_require__.f[key](chunkId, promises);
  65173. /******/ return promises;
  65174. /******/ }, []));
  65175. /******/ };
  65176. /******/ })();
  65177. /******/
  65178. /******/ /* webpack/runtime/get javascript chunk filename */
  65179. /******/ (() => {
  65180. /******/ // This function allow to reference async chunks
  65181. /******/ __webpack_require__.u = (chunkId) => {
  65182. /******/ // return url for filenames based on template
  65183. /******/ return "" + {"52":"locales/dayjs/de-js","102":"locales/dayjs/ca-js","145":"locales/dayjs/me-js","265":"locales/dayjs/pt-js","280":"locales/dayjs/bn-js","321":"locales/fa-LC_MESSAGES-converse-po","457":"locales/th-LC_MESSAGES-converse-po","473":"locales/nb-LC_MESSAGES-converse-po","485":"locales/dayjs/ar-sa-js","513":"locales/lt-LC_MESSAGES-converse-po","535":"locales/dayjs/en-js","555":"locales/dayjs/tet-js","559":"locales/dayjs/ru-js","578":"locales/dayjs/bg-js","631":"locales/dayjs/lv-js","646":"locales/dayjs/nb-js","688":"locales/dayjs/ga-js","760":"locales/dayjs/br-js","777":"locales/gl-LC_MESSAGES-converse-po","825":"locales/dayjs/gom-latn-js","882":"locales/dayjs/ms-my-js","911":"locales/dayjs/es-pr-js","1107":"locales/dayjs/ja-js","1110":"locales/dayjs/uz-latn-js","1163":"locales/da-LC_MESSAGES-converse-po","1194":"locales/dayjs/is-js","1204":"locales/dayjs/lo-js","1211":"locales/dayjs/pl-js","1298":"locales/dayjs/sd-js","1351":"locales/dayjs/bn-bd-js","1396":"locales/dayjs/eu-js","1455":"locales/pt_BR-LC_MESSAGES-converse-po","1458":"locales/zh_TW-LC_MESSAGES-converse-po","1520":"locales/dayjs/nl-js","1553":"locales/ca-LC_MESSAGES-converse-po","1606":"locales/dayjs/el-js","1619":"locales/dayjs/uk-js","1679":"locales/dayjs/de-ch-js","1729":"locales/dayjs/th-js","1735":"locales/dayjs/en-sg-js","1784":"locales/mr-LC_MESSAGES-converse-po","1880":"locales/dayjs/it-js","1910":"locales/dayjs/fr-js","1942":"locales/dayjs/se-js","2110":"locales/vi-LC_MESSAGES-converse-po","2130":"locales/dayjs/fi-js","2263":"locales/dayjs/bm-js","2433":"locales/eo-LC_MESSAGES-converse-po","2446":"locales/dayjs/tg-js","2473":"locales/nl-LC_MESSAGES-converse-po","2475":"locales/dayjs/km-js","2548":"locales/dayjs/da-js","2551":"locales/bg-LC_MESSAGES-converse-po","2814":"locales/dayjs/tlh-js","2843":"locales/dayjs/tzl-js","2895":"locales/de-LC_MESSAGES-converse-po","2984":"locales/dayjs/bi-js","2990":"locales/dayjs/ar-iq-js","3103":"locales/eu-LC_MESSAGES-converse-po","3153":"locales/dayjs/uz-js","3155":"locales/dayjs/nl-be-js","3208":"locales/dayjs/es-us-js","3221":"locales/dayjs/rw-js","3325":"locales/zh_CN-LC_MESSAGES-converse-po","3411":"locales/dayjs/es-js","3435":"locales/dayjs/sr-cyrl-js","3446":"locales/dayjs/ko-js","3463":"locales/dayjs/en-il-js","3521":"locales/dayjs/ar-ly-js","3539":"locales/ro-LC_MESSAGES-converse-po","3606":"locales/pl-LC_MESSAGES-converse-po","3623":"locales/dayjs/gu-js","3719":"locales/it-LC_MESSAGES-converse-po","3755":"locales/dayjs/zh-hk-js","3933":"locales/dayjs/tzm-latn-js","4035":"locales/dayjs/en-ca-js","4153":"locales/dayjs/et-js","4195":"locales/tr-LC_MESSAGES-converse-po","4305":"locales/dayjs/jv-js","4342":"locales/dayjs/tzm-js","4363":"locales/he-LC_MESSAGES-converse-po","4423":"locales/dayjs/x-pseudo-js","4468":"locales/hi-LC_MESSAGES-converse-po","4469":"locales/ar-LC_MESSAGES-converse-po","4481":"locales/dayjs/cv-js","4610":"emojis","4678":"locales/dayjs/rn-js","4951":"locales/dayjs/mk-js","4963":"locales/dayjs/az-js","5050":"locales/dayjs/gd-js","5055":"locales/dayjs/ky-js","5073":"locales/dayjs/am-js","5121":"locales/dayjs/eo-js","5129":"locales/fr-LC_MESSAGES-converse-po","5166":"locales/dayjs/my-js","5186":"locales/dayjs/ka-js","5206":"locales/dayjs/kk-js","5215":"locales/dayjs/lb-js","5256":"locales/dayjs/tk-js","5274":"locales/dayjs/pt-br-js","5301":"locales/cs-LC_MESSAGES-converse-po","5313":"locales/dayjs/ar-ma-js","5407":"locales/dayjs/hy-am-js","5485":"locales/dayjs/en-au-js","5500":"locales/oc-LC_MESSAGES-converse-po","5524":"locales/el-LC_MESSAGES-converse-po","5544":"locales/dayjs/fa-js","5569":"locales/dayjs/dv-js","5600":"locales/dayjs/mr-js","5818":"locales/dayjs/gl-js","5822":"locales/dayjs/ht-js","5830":"locales/af-LC_MESSAGES-converse-po","5850":"locales/dayjs/pa-in-js","6010":"locales/dayjs/it-ch-js","6031":"locales/dayjs/en-gb-js","6105":"locales/dayjs/en-tt-js","6227":"locales/pt-LC_MESSAGES-converse-po","6239":"locales/hu-LC_MESSAGES-converse-po","6249":"locales/ja-LC_MESSAGES-converse-po","6376":"locales/dayjs/fy-js","6678":"locales/id-LC_MESSAGES-converse-po","6740":"locales/dayjs/cy-js","6755":"locales/dayjs/ar-js","6776":"locales/dayjs/zh-tw-js","6783":"locales/dayjs/sk-js","6890":"locales/dayjs/ug-cn-js","6898":"locales/dayjs/en-in-js","7024":"locales/dayjs/ku-js","7050":"locales/dayjs/nn-js","7175":"locales/dayjs/de-at-js","7203":"locales/dayjs/oc-lnc-js","7363":"locales/dayjs/fr-ca-js","7390":"locales/dayjs/sr-js","7400":"locales/dayjs/cs-js","7416":"locales/dayjs/es-mx-js","7419":"locales/dayjs/hr-js","7454":"locales/dayjs/mi-js","7523":"locales/dayjs/kn-js","7618":"locales/fi-LC_MESSAGES-converse-po","7645":"locales/dayjs/ta-js","7679":"locales/dayjs/ml-js","7714":"locales/dayjs/te-js","7899":"locales/dayjs/lt-js","7917":"locales/ru-LC_MESSAGES-converse-po","7952":"locales/dayjs/fr-ch-js","7979":"locales/uk-LC_MESSAGES-converse-po","8010":"locales/dayjs/hi-js","8022":"locales/dayjs/ro-js","8040":"locales/dayjs/ar-tn-js","8073":"locales/dayjs/vi-js","8129":"locales/dayjs/en-ie-js","8131":"locales/nl_BE-LC_MESSAGES-converse-po","8214":"locales/dayjs/hu-js","8269":"locales/es-LC_MESSAGES-converse-po","8458":"locales/dayjs/zh-js","8547":"locales/dayjs/en-nz-js","8603":"locales/dayjs/sq-js","8618":"locales/dayjs/mn-js","8665":"locales/dayjs/tr-js","8692":"locales/dayjs/yo-js","8745":"locales/dayjs/fo-js","8758":"locales/dayjs/es-do-js","8859":"locales/sv-LC_MESSAGES-converse-po","9030":"locales/dayjs/ne-js","9095":"locales/dayjs/ms-js","9210":"locales/dayjs/af-js","9238":"locales/dayjs/ss-js","9333":"locales/dayjs/si-js","9372":"locales/dayjs/he-js","9406":"locales/dayjs/ar-dz-js","9443":"locales/dayjs/tl-ph-js","9478":"locales/dayjs/be-js","9513":"locales/dayjs/id-js","9568":"locales/dayjs/ur-js","9625":"locales/dayjs/sl-js","9630":"locales/dayjs/zh-cn-js","9652":"locales/dayjs/sv-js","9665":"locales/dayjs/mt-js","9733":"locales/dayjs/sw-js","9833":"locales/dayjs/bs-js","9897":"locales/dayjs/ar-kw-js","9950":"locales/dayjs/bo-js","9997":"locales/dayjs/sv-fi-js"}[chunkId] + ".js";
  65184. /******/ };
  65185. /******/ })();
  65186. /******/
  65187. /******/ /* webpack/runtime/get mini-css chunk filename */
  65188. /******/ (() => {
  65189. /******/ // This function allow to reference async chunks
  65190. /******/ __webpack_require__.miniCssF = (chunkId) => {
  65191. /******/ // return url for filenames based on template
  65192. /******/ return undefined;
  65193. /******/ };
  65194. /******/ })();
  65195. /******/
  65196. /******/ /* webpack/runtime/get mini-css chunk filename */
  65197. /******/ (() => {
  65198. /******/ // This function allow to reference async chunks
  65199. /******/ __webpack_require__.miniCssF = (chunkId) => {
  65200. /******/ // return url for filenames based on template
  65201. /******/ return undefined;
  65202. /******/ };
  65203. /******/ })();
  65204. /******/
  65205. /******/ /* webpack/runtime/global */
  65206. /******/ (() => {
  65207. /******/ __webpack_require__.g = (function() {
  65208. /******/ if (typeof globalThis === 'object') return globalThis;
  65209. /******/ try {
  65210. /******/ return this || new Function('return this')();
  65211. /******/ } catch (e) {
  65212. /******/ if (typeof window === 'object') return window;
  65213. /******/ }
  65214. /******/ })();
  65215. /******/ })();
  65216. /******/
  65217. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  65218. /******/ (() => {
  65219. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  65220. /******/ })();
  65221. /******/
  65222. /******/ /* webpack/runtime/load script */
  65223. /******/ (() => {
  65224. /******/ var inProgress = {};
  65225. /******/ var dataWebpackPrefix = "converse.js:";
  65226. /******/ // loadScript function to load a script via script tag
  65227. /******/ __webpack_require__.l = (url, done, key, chunkId) => {
  65228. /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
  65229. /******/ var script, needAttach;
  65230. /******/ if(key !== undefined) {
  65231. /******/ var scripts = document.getElementsByTagName("script");
  65232. /******/ for(var i = 0; i < scripts.length; i++) {
  65233. /******/ var s = scripts[i];
  65234. /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
  65235. /******/ }
  65236. /******/ }
  65237. /******/ if(!script) {
  65238. /******/ needAttach = true;
  65239. /******/ script = document.createElement('script');
  65240. /******/
  65241. /******/ script.charset = 'utf-8';
  65242. /******/ script.timeout = 120;
  65243. /******/ if (__webpack_require__.nc) {
  65244. /******/ script.setAttribute("nonce", __webpack_require__.nc);
  65245. /******/ }
  65246. /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
  65247. /******/ script.src = url;
  65248. /******/ }
  65249. /******/ inProgress[url] = [done];
  65250. /******/ var onScriptComplete = (prev, event) => {
  65251. /******/ // avoid mem leaks in IE.
  65252. /******/ script.onerror = script.onload = null;
  65253. /******/ clearTimeout(timeout);
  65254. /******/ var doneFns = inProgress[url];
  65255. /******/ delete inProgress[url];
  65256. /******/ script.parentNode && script.parentNode.removeChild(script);
  65257. /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
  65258. /******/ if(prev) return prev(event);
  65259. /******/ }
  65260. /******/ ;
  65261. /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
  65262. /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
  65263. /******/ script.onload = onScriptComplete.bind(null, script.onload);
  65264. /******/ needAttach && document.head.appendChild(script);
  65265. /******/ };
  65266. /******/ })();
  65267. /******/
  65268. /******/ /* webpack/runtime/make namespace object */
  65269. /******/ (() => {
  65270. /******/ // define __esModule on exports
  65271. /******/ __webpack_require__.r = (exports) => {
  65272. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  65273. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  65274. /******/ }
  65275. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  65276. /******/ };
  65277. /******/ })();
  65278. /******/
  65279. /******/ /* webpack/runtime/node module decorator */
  65280. /******/ (() => {
  65281. /******/ __webpack_require__.nmd = (module) => {
  65282. /******/ module.paths = [];
  65283. /******/ if (!module.children) module.children = [];
  65284. /******/ return module;
  65285. /******/ };
  65286. /******/ })();
  65287. /******/
  65288. /******/ /* webpack/runtime/publicPath */
  65289. /******/ (() => {
  65290. /******/ __webpack_require__.p = "/dist/";
  65291. /******/ })();
  65292. /******/
  65293. /******/ /* webpack/runtime/jsonp chunk loading */
  65294. /******/ (() => {
  65295. /******/ // no baseURI
  65296. /******/
  65297. /******/ // object to store loaded and loading chunks
  65298. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  65299. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  65300. /******/ var installedChunks = {
  65301. /******/ 5040: 0,
  65302. /******/ 1189: 0
  65303. /******/ };
  65304. /******/
  65305. /******/ __webpack_require__.f.j = (chunkId, promises) => {
  65306. /******/ // JSONP chunk loading for javascript
  65307. /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
  65308. /******/ if(installedChunkData !== 0) { // 0 means "already installed".
  65309. /******/
  65310. /******/ // a Promise means "currently loading".
  65311. /******/ if(installedChunkData) {
  65312. /******/ promises.push(installedChunkData[2]);
  65313. /******/ } else {
  65314. /******/ if(true) { // all chunks have JS
  65315. /******/ // setup Promise in chunk cache
  65316. /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
  65317. /******/ promises.push(installedChunkData[2] = promise);
  65318. /******/
  65319. /******/ // start chunk loading
  65320. /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
  65321. /******/ // create error before stack unwound to get useful stacktrace later
  65322. /******/ var error = new Error();
  65323. /******/ var loadingEnded = (event) => {
  65324. /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
  65325. /******/ installedChunkData = installedChunks[chunkId];
  65326. /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
  65327. /******/ if(installedChunkData) {
  65328. /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
  65329. /******/ var realSrc = event && event.target && event.target.src;
  65330. /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
  65331. /******/ error.name = 'ChunkLoadError';
  65332. /******/ error.type = errorType;
  65333. /******/ error.request = realSrc;
  65334. /******/ installedChunkData[1](error);
  65335. /******/ }
  65336. /******/ }
  65337. /******/ };
  65338. /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
  65339. /******/ } else installedChunks[chunkId] = 0;
  65340. /******/ }
  65341. /******/ }
  65342. /******/ };
  65343. /******/
  65344. /******/ // no prefetching
  65345. /******/
  65346. /******/ // no preloaded
  65347. /******/
  65348. /******/ // no HMR
  65349. /******/
  65350. /******/ // no HMR manifest
  65351. /******/
  65352. /******/ // no on chunks loaded
  65353. /******/
  65354. /******/ // install a JSONP callback for chunk loading
  65355. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  65356. /******/ var [chunkIds, moreModules, runtime] = data;
  65357. /******/ // add "moreModules" to the modules object,
  65358. /******/ // then flag all "chunkIds" as loaded and fire callback
  65359. /******/ var moduleId, chunkId, i = 0;
  65360. /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
  65361. /******/ for(moduleId in moreModules) {
  65362. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  65363. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  65364. /******/ }
  65365. /******/ }
  65366. /******/ if(runtime) var result = runtime(__webpack_require__);
  65367. /******/ }
  65368. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  65369. /******/ for(;i < chunkIds.length; i++) {
  65370. /******/ chunkId = chunkIds[i];
  65371. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  65372. /******/ installedChunks[chunkId][0]();
  65373. /******/ }
  65374. /******/ installedChunks[chunkId] = 0;
  65375. /******/ }
  65376. /******/
  65377. /******/ }
  65378. /******/
  65379. /******/ var chunkLoadingGlobal = self["webpackChunkconverse_js"] = self["webpackChunkconverse_js"] || [];
  65380. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  65381. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  65382. /******/ })();
  65383. /******/
  65384. /************************************************************************/
  65385. var __webpack_exports__ = {};
  65386. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  65387. (() => {
  65388. "use strict";
  65389. // Converse.js
  65390. // https://conversejs.org
  65391. //
  65392. // Copyright (c) 2020, the Converse.js contributors
  65393. // Licensed under the Mozilla Public License (MPLv2)
  65394. //
  65395. // Webpack entry file
  65396. //
  65397. // The purpose of this file is to provide an initial temporary public API
  65398. // (window.converse) for **before** the rest of converse.js is loaded so
  65399. // that we can set the __webpack_public_path__ global variable.
  65400. //
  65401. // Once the rest converse.js has been loaded, window.converse will be replaced
  65402. // with the full-fledged public API.
  65403. const plugins = {};
  65404. const converse = {
  65405. plugins: {
  65406. add(name, plugin) {
  65407. if (plugins[name] !== undefined) {
  65408. throw new TypeError(`Error: plugin with name "${name}" has already been ` + 'registered!');
  65409. }
  65410. plugins[name] = plugin;
  65411. }
  65412. },
  65413. initialize() {
  65414. let settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  65415. return converse.load(settings).initialize(settings);
  65416. },
  65417. /**
  65418. * Public API method which explicitly loads Converse and allows you the
  65419. * possibility to pass in configuration settings which need to be defined
  65420. * before loading. Currently this is only the [assets_path](https://conversejs.org/docs/html/configuration.html#assets_path)
  65421. * setting.
  65422. *
  65423. * If not called explicitly, this method will be called implicitly once
  65424. * {@link converse.initialize} is called.
  65425. *
  65426. * In most cases, you probably don't need to explicitly call this method,
  65427. * however, until converse.js has been loaded you won't have access to the
  65428. * utility methods and globals exposed via {@link converse.env}. So if you
  65429. * need to access `converse.env` outside of any plugins and before
  65430. * `converse.initialize` has been called, then you need to call
  65431. * `converse.load` first.
  65432. *
  65433. * @memberOf converse
  65434. * @method load
  65435. * @param {object} settings A map of configuration-settings that are needed at load time.
  65436. * @example
  65437. * converse.load({assets_path: '/path/to/assets/'});
  65438. */
  65439. load() {
  65440. let settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  65441. if (settings.assets_path) {
  65442. __webpack_require__.p = settings.assets_path; // eslint-disable-line no-undef
  65443. }
  65444. __webpack_require__(517);
  65445. Object.keys(plugins).forEach(name => converse.plugins.add(name, plugins[name]));
  65446. return converse;
  65447. }
  65448. };
  65449. window.converse = converse;
  65450. /**
  65451. * Once Converse.js has loaded, it'll dispatch a custom event with the name `converse-loaded`.
  65452. * You can listen for this event in order to be informed as soon as converse.js has been
  65453. * loaded and parsed, which would mean it's safe to call `converse.initialize`.
  65454. * @event converse-loaded
  65455. * @example window.addEventListener('converse-loaded', () => converse.initialize());
  65456. */
  65457. const ev = new CustomEvent('converse-loaded', {
  65458. 'detail': {
  65459. converse
  65460. }
  65461. });
  65462. window.dispatchEvent(ev);
  65463. /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (converse)));
  65464. })();
  65465. /******/ })()
  65466. ;
  65467. //# sourceMappingURL=converse.js.map